|
21 | 21 | * - If you supply only sockets, this simply passes through to winsock select().
|
22 | 22 | * - If you supply file handles, there is no way to distinguish between
|
23 | 23 | * ready for read/write or OOB, so any set in which the handle is found will
|
24 |
| - * be marked as ready. |
| 24 | + * be marked as ready. Pipes will be checked if they are ready for read, though. |
25 | 25 | * - If you supply a mixture of handles and sockets, the system will interleave
|
26 | 26 | * calls between select() and WaitForMultipleObjects(). The time slicing may
|
27 | 27 | * cause this function call to take up to 100 ms longer than you specified.
|
@@ -135,15 +135,20 @@ PHPAPI int php_select(php_socket_t max_fd, fd_set *rfds, fd_set *wfds, fd_set *e
|
135 | 135 | for (i = 0; i < n_handles; i++) {
|
136 | 136 | if (WAIT_OBJECT_0 == WaitForSingleObject(handles[i], 0)) {
|
137 | 137 | if (SAFE_FD_ISSET(handle_slot_to_fd[i], rfds)) {
|
138 |
| - FD_SET((uint32_t)handle_slot_to_fd[i], &aread); |
| 138 | + DWORD avail_read = 0; |
| 139 | + if (!PeekNamedPipe(handles[i], NULL, 0, NULL, &avail_read, NULL) || avail_read > 0) { |
| 140 | + FD_SET((uint32_t)handle_slot_to_fd[i], &aread); |
| 141 | + retcode++; |
| 142 | + } |
139 | 143 | }
|
140 | 144 | if (SAFE_FD_ISSET(handle_slot_to_fd[i], wfds)) {
|
141 | 145 | FD_SET((uint32_t)handle_slot_to_fd[i], &awrite);
|
| 146 | + retcode++; |
142 | 147 | }
|
143 | 148 | if (SAFE_FD_ISSET(handle_slot_to_fd[i], efds)) {
|
144 | 149 | FD_SET((uint32_t)handle_slot_to_fd[i], &aexcept);
|
| 150 | + retcode++; |
145 | 151 | }
|
146 |
| - retcode++; |
147 | 152 | }
|
148 | 153 | }
|
149 | 154 | }
|
|
0 commit comments