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:
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user