diff options
author | sin <sin@2f30.org> | 2014-09-18 12:00:20 +0100 |
---|---|---|
committer | sin <sin@2f30.org> | 2014-09-18 12:00:40 +0100 |
commit | cd9b66d3f7bb293418615c7943a186265ca30c6f (patch) | |
tree | 7045c0809d4b23361c9aeb0e6b7d7f7afdac9c7e /ratox.c | |
parent | 99b652c0c07c6acf81b6a8cf36a107be76fbe98d (diff) |
We can't use TAILQ_REMOVE inside TAILQ_FOREACH
Diffstat (limited to 'ratox.c')
-rw-r--r-- | ratox.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -911,7 +911,7 @@ static void loop(void) { struct friend *f; - struct request *r; + struct request *r, *rtmp; time_t t0, t1, now; int connected = 0; int i, n; @@ -1053,17 +1053,17 @@ loop(void) (*gslots[i].cb)(NULL); } - TAILQ_FOREACH(r, &reqhead, entry) { + for (r = TAILQ_FIRST(&reqhead); r; r = rtmp) { + rtmp = TAILQ_NEXT(r, entry); if (FD_ISSET(r->fd, &rfds) == 0) continue; - if (read(r->fd, &c, 1) != 1 || c != '1') { + if (read(r->fd, &c, 1) != 1 || c != '1') continue; - } tox_add_friend_norequest(tox, r->id); printout("Accepted friend request for %s\n", r->idstr); datasave(); - close(r->fd); unlinkat(gslots[REQUEST].fd[OUT], r->idstr, 0); + close(r->fd); TAILQ_REMOVE(&reqhead, r, entry); free(r->msgstr); free(r); @@ -1104,7 +1104,6 @@ int main(int argc, char *argv[]) { printrat(); - printf("Type h for help\n"); toxinit(); localinit(); friendload(); |