@@ -387,6 +387,10 @@ static PHP_METHOD(Manager, executeCommand)
387387 goto cleanup ;
388388 }
389389
390+ /* If the Manager was created in a different process, reset the client so
391+ * that cursors created by this process can be differentiated. */
392+ PHONGO_RESET_CLIENT_IF_PID_DIFFERS (intern );
393+
390394 phongo_execute_command (intern -> client , PHONGO_COMMAND_RAW , db , command , options , server_id , return_value , return_value_used TSRMLS_CC );
391395
392396cleanup :
@@ -430,6 +434,10 @@ static PHP_METHOD(Manager, executeReadCommand)
430434 return ;
431435 }
432436
437+ /* If the Manager was created in a different process, reset the client so
438+ * that cursors created by this process can be differentiated. */
439+ PHONGO_RESET_CLIENT_IF_PID_DIFFERS (intern );
440+
433441 phongo_execute_command (intern -> client , PHONGO_COMMAND_READ , db , command , options , server_id , return_value , return_value_used TSRMLS_CC );
434442} /* }}} */
435443
@@ -462,6 +470,10 @@ static PHP_METHOD(Manager, executeWriteCommand)
462470 return ;
463471 }
464472
473+ /* If the Manager was created in a different process, reset the client so
474+ * that cursors created by this process can be differentiated. */
475+ PHONGO_RESET_CLIENT_IF_PID_DIFFERS (intern );
476+
465477 phongo_execute_command (intern -> client , PHONGO_COMMAND_WRITE , db , command , options , server_id , return_value , return_value_used TSRMLS_CC );
466478} /* }}} */
467479
@@ -494,6 +506,10 @@ static PHP_METHOD(Manager, executeReadWriteCommand)
494506 return ;
495507 }
496508
509+ /* If the Manager was created in a different process, reset the client so
510+ * that cursors created by this process can be differentiated. */
511+ PHONGO_RESET_CLIENT_IF_PID_DIFFERS (intern );
512+
497513 phongo_execute_command (intern -> client , PHONGO_COMMAND_READ_WRITE , db , command , options , server_id , return_value , return_value_used TSRMLS_CC );
498514} /* }}} */
499515
@@ -535,6 +551,10 @@ static PHP_METHOD(Manager, executeQuery)
535551 goto cleanup ;
536552 }
537553
554+ /* If the Manager was created in a different process, reset the client so
555+ * that cursors created by this process can be differentiated. */
556+ PHONGO_RESET_CLIENT_IF_PID_DIFFERS (intern );
557+
538558 phongo_execute_query (intern -> client , namespace , query , options , server_id , return_value , return_value_used TSRMLS_CC );
539559
540560cleanup :
@@ -750,6 +770,11 @@ static PHP_METHOD(Manager, startSession)
750770 }
751771 }
752772
773+ /* If the Manager was created in a different process, reset the client so
774+ * that its session pool is cleared. This will ensure that we do not re-use
775+ * a server session (i.e. LSID) created by a parent process. */
776+ PHONGO_RESET_CLIENT_IF_PID_DIFFERS (intern );
777+
753778 cs = mongoc_client_start_session (intern -> client , cs_opts , & error );
754779
755780 if (cs ) {
@@ -855,6 +880,8 @@ static phongo_create_object_retval php_phongo_manager_create_object(zend_class_e
855880 zend_object_std_init (& intern -> std , class_type TSRMLS_CC );
856881 object_properties_init (& intern -> std , class_type );
857882
883+ PHONGO_SET_CREATED_BY_PID (intern );
884+
858885#if PHP_VERSION_ID >= 70000
859886 intern -> std .handlers = & php_phongo_handler_manager ;
860887
0 commit comments