Skip to content

Commit ddc558e

Browse files
committed
Fix null pointer exception
1 parent b6b6e96 commit ddc558e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

php_phongo.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -669,19 +669,15 @@ int phongo_stream_close(mongoc_stream_t *stream) /* {{{ */
669669
void php_phongo_set_timeout(php_phongo_stream_socket *base_stream, int32_t timeout_msec) /* {{{ */
670670
{
671671
TSRMLS_FETCH_FROM_CTX(base_stream->tsrm_ls);
672+
struct timeval rtimeout = {0, 0};
672673

673674
if (timeout_msec > 0) {
674-
struct timeval rtimeout = {0, 0};
675-
676675
rtimeout.tv_sec = timeout_msec / 1000;
677676
rtimeout.tv_usec = (timeout_msec % 1000) * 1000;
678-
679-
php_stream_set_option(base_stream->stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &rtimeout);
680-
mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, "Setting timeout to: %d", timeout_msec);
681-
} else if (timeout_msec == 0) {
682-
mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, "Setting timeout to 0");
683-
php_stream_set_option(base_stream->stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, NULL);
684677
}
678+
679+
php_stream_set_option(base_stream->stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &rtimeout);
680+
mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, "Setting timeout to: %d", timeout_msec);
685681
} /* }}} */
686682

687683
ssize_t phongo_stream_writev(mongoc_stream_t *stream, mongoc_iovec_t *iov, size_t iovcnt, int32_t timeout_msec) /* {{{ */

0 commit comments

Comments
 (0)