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

Fix a crash issue that happened when #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 13 additions & 1 deletion src/sio_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ namespace sio

void ack(int msgId,string const& name,message::list const& ack_message);

void timeout_close(const boost::system::error_code& error);
void timeout_connection(const boost::system::error_code &ec);

void send_connect();
Expand Down Expand Up @@ -293,7 +294,7 @@ namespace sio
}
boost::system::error_code ec;
m_connection_timer->expires_from_now(boost::posix_time::milliseconds(3000), ec);
m_connection_timer->async_wait(lib::bind(&socket::impl::on_close, this));
m_connection_timer->async_wait(std::bind(&socket::impl::timeout_close, this, std::placeholders::_1));
}
}

Expand Down Expand Up @@ -324,6 +325,17 @@ namespace sio
}
}

void socket::impl::timeout_close(const boost::system::error_code& error) {
NULL_GUARD(m_client);
if(error)
{
return;
}
m_connection_timer.reset();
LOG("Close timeout,close socket."<<std::endl);
this->on_close();
}

void socket::impl::on_close()
{
NULL_GUARD(m_client);
Expand Down