@@ -172,7 +172,7 @@ static void php_mrloop_readv_cb(void *data, int res)
172172 cb = (php_mrloop_cb_t * )data ;
173173 iov = (php_iovec_t * )cb -> data ;
174174
175- char next [iov -> iov_len ];
175+ char next [( size_t ) iov -> iov_len ];
176176 sprintf (next , "%.*s" , (int )iov -> iov_len , (char * )iov -> iov_base );
177177
178178 ZVAL_STRING (& args [0 ], next );
@@ -434,23 +434,32 @@ static void php_mrloop_parse_http_response(INTERNAL_FUNCTION_PARAMETERS)
434434
435435static void php_mrloop_signal_cb (int sig )
436436{
437- zval result ;
438- int fsignal ;
439-
440- MRLOOP_G (sig_cb )-> fci .retval = & result ;
441- MRLOOP_G (sig_cb )-> fci .param_count = 0 ;
442- MRLOOP_G (sig_cb )-> fci .params = NULL ;
443-
444- fsignal = MRLOOP_G (sig_cb )-> signal ;
445-
446- if (fsignal == sig )
437+ for (size_t idx = 0 ; idx < MRLOOP_G (sigc ); idx ++ )
447438 {
448- if (zend_call_function ( & MRLOOP_G (sig_cb )-> fci , & MRLOOP_G ( sig_cb ) -> fci_cache ) == FAILURE )
439+ if (MRLOOP_G (sig_cb )[ idx ] == NULL )
449440 {
450- PHP_MRLOOP_THROW ( "There is an error in your callback" ) ;
441+ break ;
451442 }
452443
453- zval_ptr_dtor (& result );
444+ php_mrloop_cb_t * cb = MRLOOP_G (sig_cb )[idx ];
445+
446+ if (cb -> signal == sig )
447+ {
448+ zval result ;
449+
450+ cb -> fci .retval = & result ;
451+ cb -> fci .param_count = 0 ;
452+ cb -> fci .params = NULL ;
453+
454+ if (zend_call_function (& cb -> fci , & cb -> fci_cache ) == FAILURE )
455+ {
456+ PHP_MRLOOP_THROW ("There is an error in your callback" );
457+ }
458+
459+ zval_ptr_dtor (& result );
460+
461+ break ;
462+ }
454463 }
455464
456465 exit (EXIT_SUCCESS );
@@ -466,9 +475,12 @@ static void php_mrloop_add_signal(INTERNAL_FUNCTION_PARAMETERS)
466475 Z_PARAM_FUNC (fci , fci_cache )
467476 ZEND_PARSE_PARAMETERS_END ();
468477
469- MRLOOP_G (sig_cb ) = emalloc (sizeof (php_mrloop_cb_t ));
470- PHP_CB_TO_MRLOOP_CB (MRLOOP_G (sig_cb ), fci , fci_cache );
471- MRLOOP_G (sig_cb )-> signal = (int )php_signal ;
478+ MRLOOP_G (sigc )++ ;
479+ size_t next = MRLOOP_G (sigc ) - 1 ;
480+
481+ MRLOOP_G (sig_cb )[next ] = emalloc (sizeof (php_mrloop_cb_t ));
482+ PHP_CB_TO_MRLOOP_CB (MRLOOP_G (sig_cb )[next ], fci , fci_cache );
483+ MRLOOP_G (sig_cb )[next ]-> signal = (int )php_signal ;
472484
473485 signal (SIGINT , php_mrloop_signal_cb );
474486 signal (SIGHUP , php_mrloop_signal_cb );
@@ -533,7 +545,7 @@ static void php_mrloop_add_read_stream(INTERNAL_FUNCTION_PARAMETERS)
533545 return ;
534546 }
535547
536- fnbytes = (size_t )(nbytes_null == true ? DEFAULT_STREAM_BUFF_LEN : fnbytes );
548+ fnbytes = (size_t )(nbytes_null == true ? DEFAULT_STREAM_BUFF_LEN : nbytes );
537549
538550 iov = emalloc (sizeof (php_iovec_t ));
539551 iov -> iov_base = emalloc (fnbytes );
0 commit comments