@@ -762,6 +762,37 @@ mongoc_stream_t* phongo_stream_get_base_stream(mongoc_stream_t *stream) /* {{{ *
762
762
return (mongoc_stream_t * ) stream ;
763
763
} /* }}} */
764
764
765
+ ssize_t
766
+ phongo_stream_poll (mongoc_stream_poll_t * streams , size_t nstreams , int32_t timeout )
767
+ {
768
+ php_pollfd * fds = NULL ;
769
+ size_t i ;
770
+ ssize_t rval = -1 ;
771
+
772
+ fds = emalloc (sizeof (* fds ) * nstreams );
773
+ for (i = 0 ; i < nstreams ; i ++ ) {
774
+ php_socket_t this_fd ;
775
+
776
+ if (php_stream_cast (((php_phongo_stream_socket * )streams [i ].stream )-> stream , PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL , (void * )& this_fd , 0 ) == SUCCESS && this_fd >= 0 ) {
777
+ fds [i ].fd = this_fd ;
778
+ fds [i ].events = streams [i ].events ;
779
+ fds [i ].revents = 0 ;
780
+ }
781
+ }
782
+
783
+ rval = php_poll2 (fds , nstreams , timeout );
784
+
785
+ if (rval > 0 ) {
786
+ for (i = 0 ; i < nstreams ; i ++ ) {
787
+ streams [i ].revents = fds [i ].revents ;
788
+ }
789
+ }
790
+
791
+ efree (fds );
792
+
793
+ return rval ;
794
+ }
795
+
765
796
mongoc_stream_t * phongo_stream_initiator (const mongoc_uri_t * uri , const mongoc_host_list_t * host , void * user_data , bson_error_t * error ) /* {{{ */
766
797
{
767
798
php_phongo_stream_socket * base_stream = NULL ;
@@ -883,6 +914,7 @@ mongoc_stream_t* phongo_stream_initiator(const mongoc_uri_t *uri, const mongoc_h
883
914
base_stream -> vtable .setsockopt = phongo_stream_setsockopt ;
884
915
base_stream -> vtable .check_closed = phongo_stream_socket_check_closed ;
885
916
base_stream -> vtable .get_base_stream = phongo_stream_get_base_stream ;
917
+ base_stream -> vtable .poll = phongo_stream_poll ;
886
918
887
919
if (host -> family != AF_UNIX ) {
888
920
int flag = 1 ;
0 commit comments