|  | @@ -1221,6 +1221,7 @@ static int poll(struct pollfd *pfd, int n, int milliseconds) {
 | 
											
												
													
														|  |    struct timeval tv;
 |  |    struct timeval tv;
 | 
											
												
													
														|  |    fd_set set;
 |  |    fd_set set;
 | 
											
												
													
														|  |    int i, result;
 |  |    int i, result;
 | 
											
												
													
														|  | 
 |  | +  int maxfd = 0;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    tv.tv_sec = milliseconds / 1000;
 |  |    tv.tv_sec = milliseconds / 1000;
 | 
											
												
													
														|  |    tv.tv_usec = (milliseconds % 1000) * 1000;
 |  |    tv.tv_usec = (milliseconds % 1000) * 1000;
 | 
											
										
											
												
													
														|  | @@ -1229,9 +1230,13 @@ static int poll(struct pollfd *pfd, int n, int milliseconds) {
 | 
											
												
													
														|  |    for (i = 0; i < n; i++) {
 |  |    for (i = 0; i < n; i++) {
 | 
											
												
													
														|  |      FD_SET((SOCKET) pfd[i].fd, &set);
 |  |      FD_SET((SOCKET) pfd[i].fd, &set);
 | 
											
												
													
														|  |      pfd[i].revents = 0;
 |  |      pfd[i].revents = 0;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    if (pfd[i].fd > maxfd) {
 | 
											
												
													
														|  | 
 |  | +        maxfd = pfd[i].fd;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -  if ((result = select(0, &set, NULL, NULL, &tv)) > 0) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +  if ((result = select(maxfd+1, &set, NULL, NULL, &tv)) > 0) {
 | 
											
												
													
														|  |      for (i = 0; i < n; i++) {
 |  |      for (i = 0; i < n; i++) {
 | 
											
												
													
														|  |        if (FD_ISSET(pfd[i].fd, &set)) {
 |  |        if (FD_ISSET(pfd[i].fd, &set)) {
 | 
											
												
													
														|  |          pfd[i].revents = POLLIN;
 |  |          pfd[i].revents = POLLIN;
 |