Index: channel.c =================================================================== RCS file: /usr/cvsroot/asterisk/channel.c,v retrieving revision 1.139 diff -u -3 -r1.139 channel.c --- channel.c 15 Sep 2004 14:12:45 -0000 1.139 +++ channel.c 12 Nov 2004 22:09:24 -0000 @@ -874,6 +874,7 @@ int x, y; int winner = -1; int spoint; + long passed; struct pollfd *pfds; pfds = alloca(sizeof(struct pollfd) * n); @@ -891,13 +892,23 @@ y++; } } - res = poll(pfds, y, *ms); + /* Retry the poll() call if we were interrupted. */ + do { + res = poll(pfds, y, *ms); + + if (*ms > 0) { + gettimeofday(&now, NULL); + passed = (now.tv_sec - start.tv_sec) * 1000; + passed += (now.tv_usec - start.tv_usec) / 1000; + if (passed <= *ms) + *ms -= passed; + else + *ms = 0; + } + } while (res < 0 && errno == EINTR); + if (res < 0) { - /* Simulate a timeout if we were interrupted */ - if (errno != EINTR) - *ms = -1; - else - *ms = 0; + *ms = -1; return -1; } spoint = 0; @@ -914,16 +925,6 @@ } } } - if (*ms > 0) { - long passed; - gettimeofday(&now, NULL); - passed = (now.tv_sec - start.tv_sec) * 1000; - passed += (now.tv_usec - start.tv_usec) / 1000; - if (passed <= *ms) - *ms -= passed; - else - *ms = 0; - } return winner; } @@ -1003,21 +1004,30 @@ } if (*ms > 0) gettimeofday(&start, NULL); - res = poll(pfds, max, rms); + + do { + res = poll(pfds, max, rms); + + if (rms > 0) { + gettimeofday(&end, NULL); + diff = (end.tv_sec - start.tv_sec) * 1000; + diff += (end.tv_usec - start.tv_usec) / 1000; + if (diff < rms) + rms -= diff; + else + rms = 0; + } + } while (res < 0 && errno == EINTR); + if (res < 0) { for (x=0;xblocking = 0; /* Simulate a timeout if we were interrupted */ - if (errno != EINTR) - *ms = -1; - else { - /* Just an interrupt */ -#if 0 - *ms = 0; -#endif - } + *ms = -1; return NULL; } + else + *ms = rms; if (havewhen) time(&now); @@ -1056,16 +1066,6 @@ winner = NULL; } } - } - if (*ms > 0) { - long diff; - gettimeofday(&end, NULL); - diff = (end.tv_sec - start.tv_sec) * 1000; - diff += (end.tv_usec - start.tv_usec) / 1000; - if (diff < *ms) - *ms -= diff; - else - *ms = 0; } return winner; }