Skip to content
This repository has been archived by the owner on Apr 6, 2019. It is now read-only.

Commit

Permalink
[2.4.1] fix behavior when trying to reconnect from disconnection_hand…
Browse files Browse the repository at this point in the history
…ler callback.
  • Loading branch information
Cylix committed Apr 30, 2017
1 parent bba37f2 commit c49c2ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 8 additions & 2 deletions sources/network/tcp_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ void
tcp_client::connect(const std::string& host, std::uint32_t port) {
if (is_connected()) { __TACOPIE_THROW(warn, "tcp_client is already connected"); }

m_socket.connect(host, port);
m_io_service->track(m_socket);
try {
m_socket.connect(host, port);
m_io_service->track(m_socket);
}
catch (const tacopie_error& e) {
m_socket.close();
throw e;
}

m_is_connected = true;

Expand Down
7 changes: 4 additions & 3 deletions sources/network/unix/io_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ io_service::track(const tcp_socket& socket, const event_callback_t& rd_callback,

__TACOPIE_LOG(debug, "track new socket");

auto& track_info = m_tracked_sockets[socket.get_fd()];
track_info.rd_callback = rd_callback;
track_info.wr_callback = wr_callback;
auto& track_info = m_tracked_sockets[socket.get_fd()];
track_info.rd_callback = rd_callback;
track_info.wr_callback = wr_callback;
track_info.marked_for_untrack = false;

m_notifier.notify();
}
Expand Down

0 comments on commit c49c2ba

Please sign in to comment.