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