Skip to content

Commit

Permalink
STIPServer.cpp disabled error log
Browse files Browse the repository at this point in the history
RabbitWorker.cpp Expanded buffer size
RabbitServer.cpp Expanded buffer size
Connection.cpp Fixed critical error))
  • Loading branch information
Sergeydigl3 committed May 24, 2024
1 parent 9f6a123 commit 26d20ea
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
31 changes: 17 additions & 14 deletions src/protocol/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,31 +223,34 @@ namespace STIP {
sessionManager->addSession(tempMsgSession);
tempMsgSession->processIncomingPacket(packet);
session_id = packet.header.session_id;
sessionKiller.registerSessionTimeout(
packet.header.session_id,
20000,
[this, session_id] {
auto *temp = dynamic_cast<ReceiveMessageSession *>(sessionManager->getSession(
session_id));
sessionManager->deleteSessionById(session_id);
delete temp;
}
);
// sessionKiller.registerSessionTimeout(
// packet.header.session_id,
// 20000,
// [this, session_id] {
// auto *temp = dynamic_cast<ReceiveMessageSession *>(sessionManager->getSession(
// session_id));
// std::cout << "Deleting session " << session_id << std::endl;
// // sleep 5 seconds
// std::this_thread::sleep_for(std::chrono::seconds(5));
// sessionManager->deleteSessionById(session_id);
// delete temp;
// }
// ); TODO: BUG Это вызывает странные ошибки во время работы. Временно без клинера CRITICAL
break;

case Command::MSG_SEND_DATA_PART:
tempReceiveSession = dynamic_cast<ReceiveMessageSession *>(sessionManager->getSession(
packet.header.session_id));
if (tempReceiveSession != nullptr) {
tempReceiveSession->processIncomingPacket(packet);
sessionKiller.resetSessionTimeout(packet.header.session_id);
if (tempReceiveSession == nullptr) break;

}
tempReceiveSession->processIncomingPacket(packet);
sessionKiller.resetSessionTimeout(packet.header.session_id);

if (tempReceiveSession->getStatus() == 5) {
if (tempReceiveSession->dispatched) break;
tempReceiveSession->dispatched = true;
std::lock_guard<std::mutex> lock(messageMtx);

messageQueue.push(tempReceiveSession);
#ifdef STIP_PROTOCOL_DEBUG
std::cout << "Message received, should be notified" << std::endl;
Expand Down
2 changes: 2 additions & 0 deletions src/rabbitCore/server/RabbitServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ RabbitServer::RabbitServer(int port) {

void RabbitServer::init() {
server_socket = new udp::socket(io_context, udp::endpoint(udp::v4(), port));
udp::socket::receive_buffer_size bigbufsize(INT_MAX);
server_socket->set_option(bigbufsize);
}

void RabbitServer::startPolling() {
Expand Down
2 changes: 2 additions & 0 deletions src/rabbitCore/worker/RabbitWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ void RabbitWorker::init() {

server_socket = new udp::socket(io_context);
server_socket->open(udp::v4());
udp::socket::receive_buffer_size bigbufsize(INT_MAX);
server_socket->set_option(bigbufsize);

client = new STIP::STIPClient(*server_socket);
client->startListen();
Expand Down
2 changes: 1 addition & 1 deletion src/server/STIPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace STIP {
udp::endpoint remote_endpoint;
size_t length = this->socket->receive_from(boost::asio::buffer(packet), remote_endpoint, 0, error);
if (error && error != boost::asio::error::message_size || length == 0) {
std::cerr << "Receive failed in acceptConnection: " << error.message() << std::endl;
// std::cerr << "Receive failed in acceptConnection: " << error.message() << std::endl;
return nullptr;
// throw boost::system::system_error(error);
}
Expand Down

0 comments on commit 26d20ea

Please sign in to comment.