diff options
author | sin <sin@2f30.org> | 2014-09-24 14:29:06 +0100 |
---|---|---|
committer | sin <sin@2f30.org> | 2014-09-24 14:29:06 +0100 |
commit | ee6c055b69a608e46f23a8d3daae0527d0817e3e (patch) | |
tree | ca8c1d02908bbfc005ececfb55855d30ac465e25 /ratox.c | |
parent | 1a58298f14b9fa3c85b65d09398603e86ad7ec6b (diff) |
Only poll the file descriptors we added to the set
Diffstat (limited to 'ratox.c')
-rw-r--r-- | ratox.c | 44 |
1 files changed, 17 insertions, 27 deletions
@@ -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); } } } |