Skip to content

Commit

Permalink
fix/sslclient-spinlock (#1339)
Browse files Browse the repository at this point in the history
  • Loading branch information
Neko-Life authored Dec 1, 2024
1 parent feee595 commit 4d9fbbf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/dpp/sslclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,6 @@ void ssl_client::on_read(socket fd, const struct socket_events& ev) {
}

void ssl_client::on_write(socket fd, const struct socket_events& e) {
/* We wanted to write before so keep it */
socket_events new_se{e};
new_se.flags |= WANT_WRITE;
owner->socketengine->update_socket(new_se);

if (!tcp_connect_done) {
tcp_connect_done = true;
}
Expand Down
17 changes: 17 additions & 0 deletions src/dpp/wsclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,23 @@ void websocket_client::write(const std::string_view data, ws_opcode _opcode)
ssl_client::socket_write(header);
ssl_client::socket_write(data);
}

bool should_append_want_write = false;
socket_events *new_se = nullptr;
{
std::lock_guard lk(owner->socketengine->fds_mutex);
auto i = owner->socketengine->fds.find(sfd);

should_append_want_write = i != owner->socketengine->fds.end() && (i->second->flags & WANT_WRITE) != WANT_WRITE;
if (should_append_want_write) {
new_se = i->second.get();
new_se->flags |= WANT_WRITE;
}
}

if (should_append_want_write) {
owner->socketengine->update_socket(*new_se);
}
}

bool websocket_client::handle_buffer(std::string& buffer)
Expand Down

0 comments on commit 4d9fbbf

Please sign in to comment.