@@ -595,17 +595,13 @@ PHP_FUNCTION(stream_get_wrappers)
595
595
/* }}} */
596
596
597
597
/* {{{ stream_select related functions */
598
- static int stream_array_to_fd_set (zval * stream_array , fd_set * fds , php_socket_t * max_fd )
598
+ static int stream_array_to_fd_set (const HashTable * stream_array , fd_set * fds , php_socket_t * max_fd )
599
599
{
600
600
zval * elem ;
601
601
php_stream * stream ;
602
602
int cnt = 0 ;
603
603
604
- if (Z_TYPE_P (stream_array ) != IS_ARRAY ) {
605
- return 0 ;
606
- }
607
-
608
- ZEND_HASH_FOREACH_VAL (Z_ARRVAL_P (stream_array ), elem ) {
604
+ ZEND_HASH_FOREACH_VAL (stream_array , elem ) {
609
605
/* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast()
610
606
would eventually bring a wrong result on x64. php_stream_cast() casts to int internally, and this will leave
611
607
the higher bits of a SOCKET variable uninitialized on systems with little endian. */
@@ -634,7 +630,7 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t
634
630
return cnt ? 1 : 0 ;
635
631
}
636
632
637
- static int stream_array_from_fd_set (zval * stream_array , fd_set * fds )
633
+ static int stream_array_from_fd_set (zval * stream_array , const fd_set * fds )
638
634
{
639
635
zval * elem , * dest_elem ;
640
636
HashTable * ht ;
@@ -643,9 +639,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds)
643
639
zend_string * key ;
644
640
zend_ulong num_ind ;
645
641
646
- if (Z_TYPE_P (stream_array ) != IS_ARRAY ) {
647
- return 0 ;
648
- }
642
+ ZEND_ASSERT (Z_TYPE_P (stream_array ) == IS_ARRAY );
649
643
ht = zend_new_array (zend_hash_num_elements (Z_ARRVAL_P (stream_array )));
650
644
651
645
ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (stream_array ), num_ind , key , elem ) {
@@ -671,7 +665,6 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds)
671
665
672
666
zval_add_ref (dest_elem );
673
667
ret ++ ;
674
- continue ;
675
668
}
676
669
}
677
670
} ZEND_HASH_FOREACH_END ();
@@ -692,9 +685,7 @@ static int stream_array_emulate_read_fd_set(zval *stream_array)
692
685
zend_ulong num_ind ;
693
686
zend_string * key ;
694
687
695
- if (Z_TYPE_P (stream_array ) != IS_ARRAY ) {
696
- return 0 ;
697
- }
688
+ ZEND_ASSERT (Z_TYPE_P (stream_array ) == IS_ARRAY );
698
689
ht = zend_new_array (zend_hash_num_elements (Z_ARRVAL_P (stream_array )));
699
690
700
691
ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (stream_array ), num_ind , key , elem ) {
@@ -717,7 +708,6 @@ static int stream_array_emulate_read_fd_set(zval *stream_array)
717
708
}
718
709
zval_add_ref (dest_elem );
719
710
ret ++ ;
720
- continue ;
721
711
}
722
712
} ZEND_HASH_FOREACH_END ();
723
713
@@ -760,21 +750,21 @@ PHP_FUNCTION(stream_select)
760
750
FD_ZERO (& efds );
761
751
762
752
if (r_array != NULL ) {
763
- set_count = stream_array_to_fd_set (r_array , & rfds , & max_fd );
753
+ set_count = stream_array_to_fd_set (Z_ARR_P ( r_array ) , & rfds , & max_fd );
764
754
if (set_count > max_set_count )
765
755
max_set_count = set_count ;
766
756
sets += set_count ;
767
757
}
768
758
769
759
if (w_array != NULL ) {
770
- set_count = stream_array_to_fd_set (w_array , & wfds , & max_fd );
760
+ set_count = stream_array_to_fd_set (Z_ARR_P ( w_array ) , & wfds , & max_fd );
771
761
if (set_count > max_set_count )
772
762
max_set_count = set_count ;
773
763
sets += set_count ;
774
764
}
775
765
776
766
if (e_array != NULL ) {
777
- set_count = stream_array_to_fd_set (e_array , & efds , & max_fd );
767
+ set_count = stream_array_to_fd_set (Z_ARR_P ( e_array ) , & efds , & max_fd );
778
768
if (set_count > max_set_count )
779
769
max_set_count = set_count ;
780
770
sets += set_count ;
0 commit comments