Overview
Features
Download
Documentation
Community
Add-Ons & Services

TCPServerDispatcher doesn't duplicate() _pParams

Please post support and help requests here.

TCPServerDispatcher doesn't duplicate() _pParams

Postby NickG » 23 Dec 2008, 04:59

Hello,
The documentation for HTTPServer states that the server takes ownership of the HTTPServerParams pointer passed in - however, HTTPServerParams is a RefCountedObject, and unlike other uses of those in /Net, the constructor for TCPServerDispatcher, where ownership of the params object is transferred, doesn't duplicate() it. So, for the sake of exception safety in between when the HTTPServerParams object is created and when it's passed to the constructor of an HTTPServer, it would make sense to store it in an AutoPtr, however, that would require duplicating it before passing it to the constructor, which seems silly - so I'm wondering, is this a design choice or a bug, and if the former, what's the recommended way of dealing with exception safety for HTTPServerParams instances?

Thanks,
-Nick
NickG
 
Posts: 2
Joined: 23 Dec 2008, 03:26
Location: San Francisco, California, USA

Re: TCPServerDispatcher doesn't duplicate() _pParams

Postby guenter » 23 Dec 2008, 18:27

This is in fact one of the few places in POCO suffering from a not well thought out API. Fix is to change the argument to be an AutoPtr. This will retain backward compatibility while fixing exception safety.
guenter
 
Posts: 1138
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: TCPServerDispatcher doesn't duplicate() _pParams

Postby NickG » 24 Dec 2008, 01:05

I agree, and thanks for the response. I should also note that the workaround I had been using of duplicate()-ing the HTTPServerParams instance isn't really safe either, as it wouldn't be released if an exception were thrown in the constructor for HTTPServer, TCPServer, or TCPServerDispatcher.
NickG
 
Posts: 2
Joined: 23 Dec 2008, 03:26
Location: San Francisco, California, USA


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest