Overview
Features
Download
Documentation
Community
Add-Ons & Services

TCPServer

Please post support and help requests here.

TCPServer

Postby LokiAstari » 03 Jan 2010, 10:18

I was reading the documentation about TCPServer and have two small questions:

Question 1:
===========
The first parameter is:
TCPServerConnectionFactory::Ptr pFactory

The documentation parameter for this parameter is:
The server takes ownership of the TCPServerConnectionFactory and deletes it when it's no longer needed.



My question is:
TCPServerConnectionFactory::Ptr is actually Poco::SharedPtr. This takes ownership of the pointer. So when we pass it to the constructor of TCPServer is it actually taking ownership away from the SharedPtr (if so this implies that the parameter should only have a reference count of one (otherwise we are going to get a double delete)) or is it accepting shared ownership (In which case I think the documentation should be made clearer).

Also why not use the equivalent of the std::auto_ptr<> as this would imply transfer of ownership.

Question 2:
==========
When the stop() method is called, the queued ones are just dropped, but does the calling thread suspend until all currently executing connections finish? Or is there another technique to make sure that all executing connections (TCPServerConnection) finish? Otherwise I can see problems with the timing of the destruction of the TCPServerConnectionFactory and the TCPServerConnection(s) that it has created.
LokiAstari
 
Posts: 2
Joined: 03 Jan 2010, 09:06

Re: TCPServer

Postby LokiAstari » 03 Jan 2010, 23:00

I spent some time reading the code last night:

Question 1:
===========

The TCPServer passes the 'TCPServerConnectionFactory::Ptr pFactory' to TCPServerDispatcher internally.
This stores the factory in another 'TCPServerConnectionFactory::Ptr' (which is a shared pointer).

So the TCPServer does NOT take ownership of the object.
It accepts shared ownership.

Question 2:
===========
This now becomes moot (because of the shared ownership in question 1).
Because we can maintain the lifespan of the factory until all threads have exited all constructed connections.


So is there anyway to clean up the documentation to more clearly reflect the ownership semantics of the TCPServer over the pFactory parameter.
LokiAstari
 
Posts: 2
Joined: 03 Jan 2010, 09:06

Re: TCPServer

Postby guenter » 04 Jan 2010, 15:34

The shared pointer for TCPServerConnectionFactory has been introduced in a recent release (previously, a plain pointer has been used - hence hte membership issues), and the documentation has not been updated. I'll fix that for the next release (1.3.6p2).
guenter
 
Posts: 1157
Joined: 11 Jul 2006, 16:27
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron