From 3c820445c6e599832fc22b76ab4c4d5deb5f34b6 Mon Sep 17 00:00:00 2001 From: lotodore Date: Sun, 25 Jan 2009 21:12:33 +0000 Subject: [PATCH] Fixed missing completion call issue. However, boost::asio now automatically closes the socket. This cannot be disabled. So the next step is to use the boost::asio socket class for the session and everywhere else. --- src/net/common/senderthread.cpp | 20 ++++++++++---------- src/net/common/serverlobbythread.cpp | 1 - src/net/senderthread.h | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/net/common/senderthread.cpp b/src/net/common/senderthread.cpp index 7a297787..f2dd3a7a 100644 --- a/src/net/common/senderthread.cpp +++ b/src/net/common/senderthread.cpp @@ -26,10 +26,10 @@ #include #include -#include +#include using namespace std; -using boost::asio::ip::tcp; +using boost::asio::ip::tcp; #define SEND_ERROR_TIMEOUT_MSEC 20000 @@ -46,7 +46,6 @@ SenderThread::SendDataManager::HandleWrite(const boost::system::error_code& erro SetCompleted(true); } - SenderThread::SenderThread(SenderCallback &cb) : m_callback(cb) { @@ -135,18 +134,19 @@ SenderThread::Main() else { boost::shared_ptr tmpPacket = tmpManager->list.front(); - boost::asio::async_write( - *tmpManager->socket, - boost::asio::buffer(tmpPacket->GetRawData(), - tmpPacket->GetLen()), - boost::bind(&SendDataManager::HandleWrite, tmpManager, - boost::asio::placeholders::error)); - tmpManager->SetWriteInProgress(true); + boost::asio::async_write( + *tmpManager->socket, + boost::asio::buffer(tmpPacket->GetRawData(), + tmpPacket->GetLen()), + boost::bind(&SendDataManager::HandleWrite, tmpManager, + boost::asio::placeholders::error)); + tmpManager->SetWriteInProgress(true); } } } i = next; } + m_ioService.run_one(); Msleep(SEND_TIMEOUT_MSEC); } } diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 534c6475..2f395121 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -71,7 +71,6 @@ public: } virtual void SignalSessionTerminated(unsigned /*session*/) { - // Nothing to do, since we only have one sender thread. } private: diff --git a/src/net/senderthread.h b/src/net/senderthread.h index f6e91dfd..ce592c95 100644 --- a/src/net/senderthread.h +++ b/src/net/senderthread.h @@ -28,7 +28,7 @@ #include #include -#include +#include class SessionData; #define SENDER_THREAD_TERMINATE_TIMEOUT THREAD_WAIT_INFINITE