Unverified Commit f575911f authored by kladko's avatar kladko

SKALE-4586 Added Thread Pool

parent 150b2cda
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "SGXException.h" #include "SGXException.h"
#include "ExitRequestedException.h" #include "ExitRequestedException.h"
#include "ReqMessage.h"
#include "ZMQMessage.h" #include "ZMQMessage.h"
#include "ZMQServer.h" #include "ZMQServer.h"
#include "sgxwallet_common.h" #include "sgxwallet_common.h"
...@@ -199,6 +200,7 @@ void ZMQServer::doOneServerLoop() { ...@@ -199,6 +200,7 @@ void ZMQServer::doOneServerLoop() {
} while (pollResult == 0); } while (pollResult == 0);
if (!socket->recv(&identity)) { if (!socket->recv(&identity)) {
checkForExit();
// something terrible happened // something terrible happened
spdlog::error("Fatal error: socket->recv(&identity) returned false. Exiting."); spdlog::error("Fatal error: socket->recv(&identity) returned false. Exiting.");
exit(-11); exit(-11);
...@@ -213,6 +215,7 @@ void ZMQServer::doOneServerLoop() { ...@@ -213,6 +215,7 @@ void ZMQServer::doOneServerLoop() {
zmq::message_t reqMsg; zmq::message_t reqMsg;
if (!socket->recv(&reqMsg, 0)) { if (!socket->recv(&reqMsg, 0)) {
checkForExit();
// something terrible happened // something terrible happened
spdlog::error("Fatal error: socket.recv(&reqMsg, 0) returned false. Exiting"); spdlog::error("Fatal error: socket.recv(&reqMsg, 0) returned false. Exiting");
exit(-13); exit(-13);
...@@ -226,6 +229,16 @@ void ZMQServer::doOneServerLoop() { ...@@ -226,6 +229,16 @@ void ZMQServer::doOneServerLoop() {
auto parsedMsg = ZMQMessage::parse( auto parsedMsg = ZMQMessage::parse(
stringToParse.c_str(), stringToParse.size(), true, checkSignature, checkKeyOwnership); stringToParse.c_str(), stringToParse.size(), true, checkSignature, checkKeyOwnership);
if ((dynamic_pointer_cast<BLSSignReqMessage>(parsedMsg)!= nullptr) ||
dynamic_pointer_cast<ECDSASignReqMessage>(parsedMsg)) {
spdlog::info("FUFUFUFUF");
} else {
spdlog::info("HAHAHA");
}
CHECK_STATE2(parsedMsg, ZMQ_COULD_NOT_PARSE); CHECK_STATE2(parsedMsg, ZMQ_COULD_NOT_PARSE);
...@@ -233,11 +246,13 @@ void ZMQServer::doOneServerLoop() { ...@@ -233,11 +246,13 @@ void ZMQServer::doOneServerLoop() {
} catch (ExitRequestedException) { } catch (ExitRequestedException) {
throw; throw;
} catch (std::exception &e) { } catch (std::exception &e) {
checkForExit();
result["errorMessage"] = string(e.what()); result["errorMessage"] = string(e.what());
spdlog::error("Exception in zmq server :{}", e.what()); spdlog::error("Exception in zmq server :{}", e.what());
spdlog::error("ID:" + string((char *) identity.data(), identity.size())); spdlog::error("ID:" + string((char *) identity.data(), identity.size()));
spdlog::error("Client request :" + stringToParse); spdlog::error("Client request :" + stringToParse);
} catch (...) { } catch (...) {
checkForExit();
spdlog::error("Error in zmq server "); spdlog::error("Error in zmq server ");
result["errorMessage"] = "Error in zmq server "; result["errorMessage"] = "Error in zmq server ";
spdlog::error("ID:" + string((char *) identity.data(), identity.size())); spdlog::error("ID:" + string((char *) identity.data(), identity.size()));
...@@ -255,23 +270,20 @@ void ZMQServer::doOneServerLoop() { ...@@ -255,23 +270,20 @@ void ZMQServer::doOneServerLoop() {
CHECK_STATE(replyStr.back() == '}'); CHECK_STATE(replyStr.back() == '}');
if (!socket->send(identity, ZMQ_SNDMORE)) { if (!socket->send(identity, ZMQ_SNDMORE)) {
if (isExitRequested) {
return;
}
exit(-15); exit(-15);
} }
if (!s_send(*socket, replyStr)) { if (!s_send(*socket, replyStr)) {
if (isExitRequested) {
return;
}
exit(-16); exit(-16);
} }
} catch (ExitRequestedException) { } catch (ExitRequestedException) {
throw; throw;
} catch (std::exception &e) { } catch (std::exception &e) {
checkForExit();
spdlog::error("Exception in zmq server worker send :{}", e.what()); spdlog::error("Exception in zmq server worker send :{}", e.what());
exit(-17); exit(-17);
} catch (...) { } catch (...) {
checkForExit();
spdlog::error("Unklnown exception in zmq server worker send"); spdlog::error("Unklnown exception in zmq server worker send");
exit(-18); exit(-18);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment