|
Lines 832-834
ms_to_timeval(struct timeval *tv, int ms
Link Here
|
| 832 |
tv->tv_usec = (ms % 1000) * 1000; |
832 |
tv->tv_usec = (ms % 1000) * 1000; |
| 833 |
} |
833 |
} |
| 834 |
|
834 |
|
|
|
835 |
int |
| 836 |
debug_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, |
| 837 |
struct timeval *timeout) |
| 838 |
{ |
| 839 |
int i, ret; |
| 840 |
|
| 841 |
debug3("%s: nfds = %d", __func__, nfds); |
| 842 |
debug3("%s: readfds = %p, writefds = %p, exceptfds = %p", __func__, |
| 843 |
readfds, writefds, exceptfds); |
| 844 |
if (timeout == NULL) |
| 845 |
debug3("%s: timeout = NULL", __func__); |
| 846 |
else |
| 847 |
debug3("%s: timeout = %p { %ld, %ld }", __func__, timeout, |
| 848 |
timeout->tv_sec, timeout->tv_usec); |
| 849 |
for (i = 0; readfds && i < nfds; i++) { |
| 850 |
if (FD_ISSET(i, readfds)) |
| 851 |
debug3("%s: before rfd %d%s", __func__, i, |
| 852 |
fcntl(i, F_GETFL, 0) < 0 ? " INVALID" : ""); |
| 853 |
} |
| 854 |
for (i = 0; writefds && i < nfds; i++) { |
| 855 |
if (FD_ISSET(i, writefds)) |
| 856 |
debug3("%s: before wfd %d%s", __func__, i, |
| 857 |
fcntl(i, F_GETFL, 0) < 0 ? " INVALID" : ""); |
| 858 |
} |
| 859 |
for (i = 0; exceptfds && i < nfds; i++) { |
| 860 |
if (FD_ISSET(i, exceptfds)) |
| 861 |
debug3("%s: before efd %d%s", __func__, i, |
| 862 |
fcntl(i, F_GETFL, 0) < 0 ? " INVALID" : ""); |
| 863 |
} |
| 864 |
errno = 0; |
| 865 |
ret = select(nfds, readfds, writefds, exceptfds, timeout); |
| 866 |
debug3("%s: select() = %d", __func__, ret); |
| 867 |
if (ret < 0) |
| 868 |
debug3("%s: errno = %d: %s", __func__, errno, strerror(errno)); |
| 869 |
|
| 870 |
for (i = 0; readfds && ret > 0 && i < nfds; i++) { |
| 871 |
if (FD_ISSET(i, readfds)) |
| 872 |
debug3("%s: after rfd %d", __func__, i); |
| 873 |
} |
| 874 |
for (i = 0; writefds && ret > 0 && i < nfds; i++) { |
| 875 |
if (FD_ISSET(i, writefds)) |
| 876 |
debug3("%s: after wfd %d", __func__, i); |
| 877 |
} |
| 878 |
for (i = 0; exceptfds && ret > 0 && i < nfds; i++) { |
| 879 |
if (FD_ISSET(i, exceptfds)) |
| 880 |
debug3("%s: after efd %d", __func__, i); |
| 881 |
} |
| 882 |
return ret; |
| 883 |
} |
| 884 |
|