Skip to content

Commit

Permalink
fix curl resumable epoll related crash (#893)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrDet authored Sep 11, 2023
1 parent cb214e2 commit 89c1c44
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions runtime/curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,15 @@ void CurlRequest::detach_multi_and_easy_handles() const noexcept {
}

static int curl_epoll_cb(int fd, void *data, event_t *ev) {
// Sometimes epoll callbacks can be invoked AFTER the related 'fd' is removed from epoll.
// It happens because our net_reactor at first stores epoll events from epoll_wait, and only then runs related callbacks (see epoll_fetch_events())
// Usually this situation is handled via some additional connection flags (conn_expect_query, C_WANTRD etc.)
// in callbacks like `server_read_write_gateway` and related.
// But here we try to keep it simple and not to do all of this stuff.
// So we need to check explicitly that this fd is still present in epoll reactor:
if (!(ev->state & EVT_IN_EPOLL)) {
return 0;
}
auto *curl_request = static_cast<CurlRequest *>(data);
php_assert(curl_request);

Expand Down

0 comments on commit 89c1c44

Please sign in to comment.