Skip to content

Commit 3a91948

Browse files
bjorijmikola
authored andcommitted
PHPC-415: SSL/TLS already set-up for this stream
When closing a stream we can't free the base_stream, only our stream. Which also means, when destroying a stream we may not always have a wrapping stream
1 parent 4d6157f commit 3a91948

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

php_phongo.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,11 @@ void phongo_stream_destroy(mongoc_stream_t *stream_wrap) /* {{{ */
825825
{
826826
php_phongo_stream_socket *base_stream = (php_phongo_stream_socket *)stream_wrap;
827827

828-
MONGOC_DEBUG("Not destroying RSRC#%d", base_stream->stream->rsrc_id);
828+
if (base_stream->stream) {
829+
MONGOC_DEBUG("Not destroying RSRC#%d", base_stream->stream->rsrc_id);
830+
} else {
831+
MONGOC_DEBUG("Wrapped stream already destroyed");
832+
}
829833
/*
830834
* DON'T DO ANYTHING TO THE INTERNAL base_stream->stream
831835
* The stream should not be closed during normal dtor -- as we want it to
@@ -855,7 +859,14 @@ int phongo_stream_close(mongoc_stream_t *stream_wrap) /* {{{ */
855859
php_phongo_stream_socket *base_stream = (php_phongo_stream_socket *)stream_wrap;
856860

857861
MONGOC_DEBUG("Closing RSRC#%d", base_stream->stream->rsrc_id);
858-
phongo_stream_destroy(stream_wrap);
862+
if (base_stream->stream) {
863+
TSRMLS_FETCH_FROM_CTX(base_stream->tsrm_ls);
864+
865+
MONGOC_DEBUG("Destroying RSRC#%d", base_stream->stream->rsrc_id);
866+
php_stream_free(base_stream->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
867+
base_stream->stream = NULL;
868+
}
869+
859870
return 0;
860871
} /* }}} */
861872

0 commit comments

Comments
 (0)