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.

This commit is contained in:
lotodore
2009-01-25 21:12:33 +00:00
parent 17377f5a6b
commit 3c820445c6
3 changed files with 11 additions and 12 deletions
+10 -10
View File
@@ -26,10 +26,10 @@
#include <cassert> #include <cassert>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/asio.hpp> #include <boost/asio.hpp>
using namespace std; using namespace std;
using boost::asio::ip::tcp; using boost::asio::ip::tcp;
#define SEND_ERROR_TIMEOUT_MSEC 20000 #define SEND_ERROR_TIMEOUT_MSEC 20000
@@ -46,7 +46,6 @@ SenderThread::SendDataManager::HandleWrite(const boost::system::error_code& erro
SetCompleted(true); SetCompleted(true);
} }
SenderThread::SenderThread(SenderCallback &cb) SenderThread::SenderThread(SenderCallback &cb)
: m_callback(cb) : m_callback(cb)
{ {
@@ -135,18 +134,19 @@ SenderThread::Main()
else else
{ {
boost::shared_ptr<NetPacket> tmpPacket = tmpManager->list.front(); boost::shared_ptr<NetPacket> tmpPacket = tmpManager->list.front();
boost::asio::async_write( boost::asio::async_write(
*tmpManager->socket, *tmpManager->socket,
boost::asio::buffer(tmpPacket->GetRawData(), boost::asio::buffer(tmpPacket->GetRawData(),
tmpPacket->GetLen()), tmpPacket->GetLen()),
boost::bind(&SendDataManager::HandleWrite, tmpManager, boost::bind(&SendDataManager::HandleWrite, tmpManager,
boost::asio::placeholders::error)); boost::asio::placeholders::error));
tmpManager->SetWriteInProgress(true); tmpManager->SetWriteInProgress(true);
} }
} }
} }
i = next; i = next;
} }
m_ioService.run_one();
Msleep(SEND_TIMEOUT_MSEC); Msleep(SEND_TIMEOUT_MSEC);
} }
} }
-1
View File
@@ -71,7 +71,6 @@ public:
} }
virtual void SignalSessionTerminated(unsigned /*session*/) virtual void SignalSessionTerminated(unsigned /*session*/)
{ {
// Nothing to do, since we only have one sender thread.
} }
private: private:
+1 -1
View File
@@ -28,7 +28,7 @@
#include <list> #include <list>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/asio.hpp> #include <boost/asio.hpp>
class SessionData; class SessionData;
#define SENDER_THREAD_TERMINATE_TIMEOUT THREAD_WAIT_INFINITE #define SENDER_THREAD_TERMINATE_TIMEOUT THREAD_WAIT_INFINITE