Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed CurlEpollFdTracker completely #896

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions runtime/curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,38 +1021,10 @@ void clear_contexts(array<CTX *> &contexts) {
hard_reset_var(contexts);
}

class CurlEpollFdTracker : vk::not_copyable {
public:
void add_fd(int fd) noexcept {
int64_t dummy{};
used_fds_.emplace_value(fd, dummy);
}

void remove_fd(int fd) noexcept {
used_fds_.unset(fd);
}

void dispose_all_fds_from_epoll() noexcept {
for (auto it : used_fds_) {
int fd = it.get_int_key();
epoll_remove(fd);
remove_fd(fd);
}
hard_reset_var(used_fds_);
}

private:
CurlEpollFdTracker() = default;
friend class vk::singleton<CurlEpollFdTracker>;

array<int64_t> used_fds_;
};

void free_curl_lib() noexcept {
dl::CriticalSectionGuard critical_section;
clear_contexts(vk::singleton<CurlContexts>::get().easy_contexts);
clear_contexts(vk::singleton<CurlContexts>::get().multi_contexts);
vk::singleton<CurlEpollFdTracker>::get().dispose_all_fds_from_epoll();
vk::singleton<CurlMemoryUsage>::get().total_allocated = 0;
}

Expand Down Expand Up @@ -1168,8 +1140,7 @@ static int curl_epoll_cb(int fd, void *data, event_t *ev) {
}

static int curl_socketfunction_cb(CURL */*easy*/, curl_socket_t fd, int action, void *userp, void */*socketp*/) {
dl::CriticalSectionGuard critical_section;

dl::CriticalSectionGuard guard;
auto *curl_request = static_cast<CurlRequest *>(userp);
php_assert(curl_request);

Expand All @@ -1186,12 +1157,10 @@ static int curl_socketfunction_cb(CURL */*easy*/, curl_socket_t fd, int action,
}
epoll_insert(fd, events);
epoll_sethandler(fd, 0, curl_epoll_cb, curl_request);
vk::singleton<CurlEpollFdTracker>::get().add_fd(fd);
break;
}
case CURL_POLL_REMOVE: {
epoll_remove(fd);
vk::singleton<CurlEpollFdTracker>::get().remove_fd(fd);
break;
}
default:
Expand Down