commit
68272312fa
|
|
@ -64,7 +64,25 @@ public:
|
||||||
Monitor(const Monitor &monitor) : _watchable(monitor._watchable)
|
Monitor(const Monitor &monitor) : _watchable(monitor._watchable)
|
||||||
{
|
{
|
||||||
// register with the watchable
|
// register with the watchable
|
||||||
_watchable->add(this);
|
if (_watchable) _watchable->add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assignment operator
|
||||||
|
* @param monitor
|
||||||
|
*/
|
||||||
|
Monitor& operator= (const Monitor &monitor)
|
||||||
|
{
|
||||||
|
// remove from watchable
|
||||||
|
if (_watchable) _watchable->remove(this);
|
||||||
|
|
||||||
|
// replace watchable
|
||||||
|
_watchable = monitor._watchable;
|
||||||
|
|
||||||
|
// register with the watchable
|
||||||
|
if (_watchable) _watchable->add(this);
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ public:
|
||||||
* Proceed to the next state
|
* Proceed to the next state
|
||||||
* @return TcpState *
|
* @return TcpState *
|
||||||
*/
|
*/
|
||||||
TcpState *proceed()
|
TcpState *proceed(const Monitor &monitor)
|
||||||
{
|
{
|
||||||
// do we have a valid socket?
|
// do we have a valid socket?
|
||||||
if (_socket >= 0)
|
if (_socket >= 0)
|
||||||
|
|
@ -211,6 +211,9 @@ public:
|
||||||
// report error
|
// report error
|
||||||
_handler->onError(_connection, _error.data());
|
_handler->onError(_connection, _error.data());
|
||||||
|
|
||||||
|
// handler callback might have destroyed connection
|
||||||
|
if (!monitor.valid()) return nullptr;
|
||||||
|
|
||||||
// create dummy implementation
|
// create dummy implementation
|
||||||
return new TcpClosed(_connection, _handler);
|
return new TcpClosed(_connection, _handler);
|
||||||
}
|
}
|
||||||
|
|
@ -229,7 +232,7 @@ public:
|
||||||
if (fd != _pipe.in() || !(flags & readable)) return this;
|
if (fd != _pipe.in() || !(flags & readable)) return this;
|
||||||
|
|
||||||
// proceed to the next state
|
// proceed to the next state
|
||||||
return proceed();
|
return proceed(monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -243,7 +246,7 @@ public:
|
||||||
_thread.join();
|
_thread.join();
|
||||||
|
|
||||||
// proceed to the next state
|
// proceed to the next state
|
||||||
return proceed();
|
return proceed(monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -262,4 +265,3 @@ public:
|
||||||
* End of namespace
|
* End of namespace
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue