commit b967a87de8358d35b37a4a524c95ae549ee40460
parent 889af18831aba0673a2456f05a1987b972d22df6
Author: libredev <libredev@ircforever.org>
Date: Wed, 23 Nov 2022 18:52:32 +0530
fixed event_frequency
Diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/main.c b/main.c
@@ -133,17 +133,21 @@ fifo_event_cb(picoev_loop *loop, int fd, int revents, void *cb_arg)
char *cmd;
ssize_t n;
- int i, count = 0;
+ int i, count = 0, *ids;
Htiter it = {0};
if ((revents & PICOEV_TIMEOUT) != 0) {
printf("TIME to add %d more connections\n", EVENT_FREQUENCY);
while (htiterate(users, &it)) {
for (i = 0; i < netlen; i++) {
- if (((int *)it.node->val)[i] == 0) {
- ((int *)it.node->val)[i] = clone_add(loop, it.node->key, i);
+ ids = (int *)it.node->val;
+ buf = (char *)it.node->key;
+ if (ids[i] == 0) {
+ fd = clone_add(loop, buf, i);
+ ids[i] = fd;
+ printf("%d. %d: %s\n", count, fd, buf);
count++;
- if (count >= 10)
+ if (count >= EVENT_FREQUENCY)
goto return_time;
}
}