poco icon indicating copy to clipboard operation
poco copied to clipboard

Make socket reactor more easy to use

Open JackyWoo opened this issue 2 years ago • 5 comments

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:

  1. remove all events in NObserver
  2. delete UDF Handler

In my case there is a uncaught error in my UDF Handler and it lead to 100% CPU usage.

Possible fix:

  1. Clear events SocketReactor::dispatch reveive error.
  2. Create a new NObserver whose _pObject is a RefCountedObject

This change may lead to compatibility issue.

JackyWoo avatar Jul 11 '22 08:07 JackyWoo

Please make a SSCCE as a demonstration of the problem, and make a pull request as a fix proposal.

aleks-f avatar Jul 11 '22 13:07 aleks-f

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;
		}
	}

JackyWoo avatar Jul 14 '22 09:07 JackyWoo

@aleks-f How about the idea Make socket reactor more easy to use? Expecting for reply.

JackyWoo avatar Aug 01 '22 02:08 JackyWoo

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 avatar Aug 01 '22 07:08 aleks-f

@aleks-f Conflicts are fixed. Pls review when you have a chance.

JackyWoo avatar Aug 07 '22 06:08 JackyWoo