Make socket reactor more easy to use
I use SocketReactor in Poco. And I found that user must do resource management in UDF Handler which can be improved by handling it in SocketReactor.
Resource management means:
- remove all events in
NObserver - delete
UDF Handler
In my case there is a uncaught error in my UDF Handler and it lead to 100% CPU usage.
Possible fix:
- Clear events
SocketReactor::dispatchreveive error. - Create a new
NObserverwhose_pObjectis aRefCountedObject
This change may lead to compatibility issue.
Please make a SSCCE as a demonstration of the problem, and make a pull request as a fix proposal.
SSCCE :
Use Net/samples/EchoServer/src/EchoServer.cpp just modify onSocketWritable which throw something.
void onSocketWritable(const AutoPtr<WritableNotification>& pNf)
{
try
{
_socket.sendBytes(_fifoOut);
throw 1;
}
catch (Poco::Exception& exc)
{
Application& app = Application::instance();
app.logger().log(exc);
delete this;
}
}
@aleks-f How about the idea Make socket reactor more easy to use? Expecting for reply.
It's quite a big diff, did not have time to look at it yet. There are conflicts in the pull now, fix and I'll review as soon as I get a chance.
@aleks-f Conflicts are fixed. Pls review when you have a chance.