Skip to content

Commit d280b7f

Browse files
committed
Merge branch 'true-async' into true-async-stable
2 parents f48a91c + 2d23685 commit d280b7f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ext/curl/curl_async.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ void curl_async_shutdown(void)
143143
}
144144

145145
if (curl_multi_handle != NULL) {
146+
// Pre-cleanup. Bug in CURL prior to 8.14.
147+
curl_multi_setopt(curl_multi_handle, CURLMOPT_SOCKETFUNCTION, NULL);
148+
curl_multi_setopt(curl_multi_handle, CURLMOPT_TIMERFUNCTION, NULL);
149+
curl_multi_setopt(curl_multi_handle, CURLMOPT_SOCKETDATA, NULL);
150+
curl_multi_setopt(curl_multi_handle, CURLMOPT_TIMERDATA, NULL);
151+
146152
curl_multi_cleanup(curl_multi_handle);
147153
curl_multi_handle = NULL;
148154
}
@@ -278,6 +284,10 @@ static void curl_poll_callback(
278284

279285
static int curl_socket_cb(CURL *curl, const curl_socket_t socket_fd, const int what, void *user_p, void *socket_poll)
280286
{
287+
if (UNEXPECTED(curl_multi_handle == NULL)) {
288+
return CURLM_OK;
289+
}
290+
281291
if (what == CURL_POLL_REMOVE) {
282292
if (socket_poll != NULL) {
283293
zend_async_poll_event_t *socket_event = socket_poll;
@@ -353,6 +363,10 @@ static void timer_callback(
353363

354364
static int curl_timer_cb(CURLM *multi, const long timeout_ms, void *user_p)
355365
{
366+
if (UNEXPECTED(curl_multi_handle == NULL)) {
367+
return CURLM_OK;
368+
}
369+
356370
if (timeout_ms < 0) {
357371
// Cancel timer - in new API this is handled automatically by waker cleanup
358372
if (timer != NULL) {

0 commit comments

Comments
 (0)