| 
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,23 @@ 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 (GetFileType(handles[i]) != FILE_TYPE_PIPE  | 
 | 140 | +								|| !PeekNamedPipe(handles[i], NULL, 0, NULL, &avail_read, NULL)  | 
 | 141 | +								|| avail_read > 0  | 
 | 142 | +							) {  | 
 | 143 | +								FD_SET((uint32_t)handle_slot_to_fd[i], &aread);  | 
 | 144 | +								retcode++;  | 
 | 145 | +							}  | 
139 | 146 | 						}  | 
140 | 147 | 						if (SAFE_FD_ISSET(handle_slot_to_fd[i], wfds)) {  | 
141 | 148 | 							FD_SET((uint32_t)handle_slot_to_fd[i], &awrite);  | 
 | 149 | +							retcode++;  | 
142 | 150 | 						}  | 
143 | 151 | 						if (SAFE_FD_ISSET(handle_slot_to_fd[i], efds)) {  | 
144 | 152 | 							FD_SET((uint32_t)handle_slot_to_fd[i], &aexcept);  | 
 | 153 | +							retcode++;  | 
145 | 154 | 						}  | 
146 |  | -						retcode++;  | 
147 | 155 | 					}  | 
148 | 156 | 				}  | 
149 | 157 | 			}  | 
 | 
0 commit comments