ratox

FIFO based tox client
git clone git://git.2f30.org/ratox
Log | Files | Refs | README | LICENSE

commit ee6c055b69a608e46f23a8d3daae0527d0817e3e
parent 1a58298f14b9fa3c85b65d09398603e86ad7ec6b
Author: sin <sin@2f30.org>
Date:   Wed, 24 Sep 2014 14:29:06 +0100

Only poll the file descriptors we added to the set

Diffstat:
Mratox.c | 44+++++++++++++++++---------------------------
1 file changed, 17 insertions(+), 27 deletions(-)

diff --git a/ratox.c b/ratox.c @@ -1289,37 +1289,27 @@ loop(void) for (f = TAILQ_FIRST(&friendhead); f; f = ftmp) { ftmp = TAILQ_NEXT(f, entry); - for (i = 0; i < LEN(ffiles); i++) { - if (FD_ISSET(f->fd[i], &rfds) == 0) - continue; - switch (i) { - case FTEXT_IN: - sendfriendtext(f); - break; - case FFILE_IN: - switch (f->t.state) { - case TRANSFER_NONE: - /* Prepare a new transfer */ - f->t.state = TRANSFER_INITIATED; - now = time(NULL); - snprintf(tstamp, sizeof(tstamp), "%lu", (unsigned long)now); - tox_new_file_sender(tox, f->fid, - 0, (uint8_t *)tstamp, strlen(tstamp)); - printout("Initiated transfer to %s\n", - f->namestr[0] == '\0' ? "Anonymous" : f->namestr); - break; - case TRANSFER_INPROGRESS: - sendfriendfile(f); - break; - } + if (FD_ISSET(f->fd[FTEXT_IN], &rfds)) + sendfriendtext(f); + if (FD_ISSET(f->fd[FFILE_IN], &rfds)) { + switch (f->t.state) { + case TRANSFER_NONE: + /* Prepare a new transfer */ + f->t.state = TRANSFER_INITIATED; + now = time(NULL); + snprintf(tstamp, sizeof(tstamp), "%lu", (unsigned long)now); + tox_new_file_sender(tox, f->fid, + 0, (uint8_t *)tstamp, strlen(tstamp)); + printout("Initiated transfer to %s\n", + f->namestr[0] == '\0' ? "Anonymous" : f->namestr); break; - case FREMOVE: - removefriend(f); + case TRANSFER_INPROGRESS: + sendfriendfile(f); break; - default: - fprintf(stderr, "Unhandled FIFO read\n"); } } + if (FD_ISSET(f->fd[FREMOVE], &rfds)) + removefriend(f); } } }