1 | /* |
1 | /* |
2 | * libev select fd activity backend |
2 | * libev select fd activity backend |
3 | * |
3 | * |
4 | * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de> |
4 | * Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de> |
5 | * All rights reserved. |
5 | * All rights reserved. |
6 | * |
6 | * |
7 | * Redistribution and use in source and binary forms, with or without modifica- |
7 | * Redistribution and use in source and binary forms, with or without modifica- |
8 | * tion, are permitted provided that the following conditions are met: |
8 | * tion, are permitted provided that the following conditions are met: |
9 | * |
9 | * |
… | |
… | |
132 | #endif |
132 | #endif |
133 | |
133 | |
134 | tv.tv_sec = (long)timeout; |
134 | tv.tv_sec = (long)timeout; |
135 | tv.tv_usec = (long)((timeout - (ev_tstamp)tv.tv_sec) * 1e6); |
135 | tv.tv_usec = (long)((timeout - (ev_tstamp)tv.tv_sec) * 1e6); |
136 | |
136 | |
|
|
137 | #ifdef _WIN32 |
|
|
138 | /* pass in the write set as except set. |
|
|
139 | * the idea behind this is to work around a windows bug that causes |
|
|
140 | * errors to be reported as an exception and not by setting |
|
|
141 | * the writable bit. this is so uncontrollably lame. |
|
|
142 | */ |
|
|
143 | res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, (fd_set *)vec_wo, &tv); |
|
|
144 | #else |
137 | res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv); |
145 | res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv); |
|
|
146 | #endif |
138 | |
147 | |
139 | if (expect_false (res < 0)) |
148 | if (expect_false (res < 0)) |
140 | { |
149 | { |
141 | #if EV_SELECT_IS_WINSOCKET |
150 | #if EV_SELECT_IS_WINSOCKET |
142 | errno = WSAGetLastError (); |
151 | errno = WSAGetLastError (); |