Commit 693d165b authored by Pavel Vainerman's avatar Pavel Vainerman Committed by Pavel Vainerman

[uwebsocket]: fixed libev error (double attach to signals)

parent a8c6f301
......@@ -76,8 +76,6 @@ UWebSocketGate::UWebSocketGate( uniset::ObjectId id
wsactivate.set<UWebSocketGate, &UWebSocketGate::onActivate>(this);
wscmd->set<UWebSocketGate, &UWebSocketGate::onCommand>(this);
sigTERM.set<UWebSocketGate, &UWebSocketGate::onTerminate>(this);
sigQUIT.set<UWebSocketGate, &UWebSocketGate::onTerminate>(this);
sigINT.set<UWebSocketGate, &UWebSocketGate::onTerminate>(this);
iocheck.set<UWebSocketGate, &UWebSocketGate::checkMessages>(this);
maxMessagesProcessing = conf->getArgPInt("--" + prefix + "max-messages-processing", conf->getField("maxMessagesProcessing"), maxMessagesProcessing);
......@@ -180,7 +178,7 @@ UWebSocketGate::~UWebSocketGate()
runlock->unlock();
}
//--------------------------------------------------------------------------------------------
void UWebSocketGate::onTerminate( ev::sig& evsig, int revents )
void UWebSocketGate::onTerminate( ev::async& watcher, int revents )
{
if( EV_ERROR & revents )
{
......@@ -190,7 +188,7 @@ void UWebSocketGate::onTerminate( ev::sig& evsig, int revents )
myinfo << myname << "(onTerminate): terminate..." << endl;
evsig.stop();
watcher.stop();
//evsig.loop.break_loop();
try
......@@ -383,11 +381,7 @@ void UWebSocketGate::evprepare()
wscmd->start();
sigTERM.set(loop);
sigTERM.start(SIGTERM);
sigQUIT.set(loop);
sigQUIT.start(SIGQUIT);
sigINT.set(loop);
sigINT.start(SIGINT);
sigTERM.start();
iocheck.set(loop);
iocheck.start(0, check_sec);
......@@ -618,6 +612,12 @@ void UWebSocketGate::onWebSocketSession( Poco::Net::HTTPServerRequest& req, Poco
myinfoV(3) << myname << "(onWebSocketSession): finish session for " << req.clientAddress().toString() << endl;
}
// -----------------------------------------------------------------------------
bool UWebSocketGate::deactivateObject()
{
sigTERM.send();
return UniSetObject::deactivateObject();
}
// -----------------------------------------------------------------------------
bool UWebSocketGate::activateObject()
{
bool ret = UniSetObject::activateObject();
......
......@@ -223,6 +223,7 @@ namespace uniset
class UWebSocket;
virtual bool activateObject() override;
virtual bool deactivateObject() override;
void run( bool async );
virtual void evfinish() override;
virtual void evprepare() override;
......@@ -241,10 +242,8 @@ namespace uniset
Poco::JSON::Object::Ptr respError( Poco::Net::HTTPServerResponse& resp, Poco::Net::HTTPResponse::HTTPStatus s, const std::string& message );
void makeResponseAccessHeader( Poco::Net::HTTPServerResponse& resp );
#endif
ev::sig sigTERM;
ev::sig sigQUIT;
ev::sig sigINT;
void onTerminate( ev::sig& evsig, int revents );
ev::async sigTERM;
void onTerminate( ev::async& watcher, int revents );
ev::async wsactivate; // активация WebSocket-ов
std::shared_ptr<ev::async> wscmd;
......
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