@@ -351,25 +351,29 @@ PHPAPI int php_network_connect_socket(php_socket_t sockfd,
351351 * expected when a connection is actively refused. This way,
352352 * php_pollfd_for will return a mask with POLLOUT if the connection
353353 * is successful and with POLLPRI otherwise. */
354- if (( n = php_pollfd_for ( sockfd , POLLOUT |POLLPRI , timeout )) == 0 ) {
354+ int events = POLLOUT |POLLPRI ;
355355#else
356- if (( n = php_pollfd_for ( sockfd , PHP_POLLREADABLE |POLLOUT , timeout )) == 0 ) {
356+ int events = PHP_POLLREADABLE |POLLOUT ;
357357#endif
358- error = PHP_TIMEOUT_ERROR_VALUE ;
359- }
360358
361- if (n > 0 ) {
362- len = sizeof (error );
363- /*
364- BSD-derived systems set errno correctly
365- Solaris returns -1 from getsockopt in case of error
366- */
367- if (getsockopt (sockfd , SOL_SOCKET , SO_ERROR , (char * )& error , & len ) != 0 ) {
359+ while (true) {
360+ n = php_pollfd_for (sockfd , events , timeout );
361+ if (n < 0 ) {
362+ if (errno == EINTR ) {
363+ continue ;
364+ }
368365 ret = -1 ;
366+ } else if (n == 0 ) {
367+ error = PHP_TIMEOUT_ERROR_VALUE ;
368+ } else {
369+ len = sizeof (error );
370+ /* BSD-derived systems set errno correctly.
371+ * Solaris returns -1 from getsockopt in case of error. */
372+ if (getsockopt (sockfd , SOL_SOCKET , SO_ERROR , (char * )& error , & len ) != 0 ) {
373+ ret = -1 ;
374+ }
369375 }
370- } else {
371- /* whoops: sockfd has disappeared */
372- ret = -1 ;
376+ break ;
373377 }
374378
375379ok :
0 commit comments