|
@@ -472,16 +472,20 @@ void NetIO::send_client_mailbox()
|
|
|
size_t mailboxes_queued = 0;
|
|
|
#endif
|
|
|
|
|
|
- // Send each client their tokens for the next epoch
|
|
|
+ // Send each client their tokens and mailboxes for the next epoch
|
|
|
for(uint32_t lcid = 0; lcid < num_clients_per_stg; lcid++)
|
|
|
{
|
|
|
unsigned char *tkn_ptr = epoch_tokens + lcid * token_bundle_size;
|
|
|
unsigned char *buf_ptr = epoch_mailboxes + lcid * mailbox_size;
|
|
|
|
|
|
if(client_sockets[lcid]!=nullptr) {
|
|
|
- boost::asio::async_write(*(client_sockets[lcid]),
|
|
|
+ std::vector<boost::asio::const_buffer> tosend = {
|
|
|
boost::asio::buffer(tkn_ptr, token_bundle_size),
|
|
|
- [this, lcid, buf_ptr](boost::system::error_code ec, std::size_t){
|
|
|
+ boost::asio::buffer(buf_ptr, mailbox_size)
|
|
|
+ };
|
|
|
+
|
|
|
+ boost::asio::async_write(*(client_sockets[lcid]), tosend,
|
|
|
+ [this, lcid](boost::system::error_code ec, std::size_t){
|
|
|
|
|
|
if (ec) {
|
|
|
if(ec == boost::asio::error::eof) {
|
|
@@ -489,28 +493,11 @@ void NetIO::send_client_mailbox()
|
|
|
delete(client_sockets[lcid]);
|
|
|
printf("Client socket terminated!\n");
|
|
|
} else {
|
|
|
- printf("Error send_client_mailbox tokens: %s\n", ec.message().c_str());
|
|
|
+ printf("Error send_client_mailbox tokens: %s\n",
|
|
|
+ ec.message().c_str());
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- boost::asio::async_write(*(client_sockets[lcid]),
|
|
|
- boost::asio::buffer(buf_ptr, mailbox_size),
|
|
|
- [this, lcid](boost::system::error_code ecc, std::size_t){
|
|
|
-
|
|
|
- //printf("NetIO::send_client_mailbox, Client %d messages was sent\n", lcid);
|
|
|
- if (ecc) {
|
|
|
- if(ecc == boost::asio::error::eof) {
|
|
|
- // Client connection terminated so we delete this socket
|
|
|
- delete(client_sockets[lcid]);
|
|
|
- printf("Client socket terminated!\n");
|
|
|
- } else {
|
|
|
- printf("Error send_client_mailbox mailbox (lcid = %d): %s\n",
|
|
|
- lcid, ecc.message().c_str());
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- });
|
|
|
});
|
|
|
#ifdef TRACE_SOCKIO
|
|
|
++mailboxes_queued;
|