On 16.02.2011 12:46, Dean Michael Berris wrote:
> On Wed, Feb 16, 2011 at 10:38 AM, Oleg Malashenko
> <[email protected]> wrote:
>> On 16.02.2011 03:38, Gregory Symons wrote:
>>> The following tests FAILED:
>>>        14 - cpp-netlib-hello_world (Failed)
>>>        15 - cpp-netlib-http_async_server (Failed)
>>>        16 - cpp-netlib-http_server_async_less_copy (Failed)
>>>        17 - mime-roundtrip (Failed)
>>>
>>> Looking closely at the verbose test output, it looks like they all
>>> failed because the address they were trying to bring up the server on
>>> was still in use.
>>>
>>
>> Will you please try it with the following patch?
>>
> 
> Why isn't this a pull request Oleg? :D
> 

Because I don't know if it is going to work. In fact, terminating test
applications is not the best way to close network sockets (see
http_server_async_less_copy). If test suite doesn't actually try to run
several tests simultaneously and they all try bind to the same port,
than I think we hit TIME_WAIT problem here.
http://hea-www.harvard.edu/~fine/Tech/addrinuse.html

Oh, and Gregory, I almost forgot about sync server. Here is the new
patch, that sets SO_REUSEADDR in sync_server as well as in async_server.

-- 
Best regards,
Oleg Malashenko.
diff --git a/boost/network/protocol/http/server/async_server.hpp b/boost/network/protocol/http/server/async_server.hpp
index abc05d6..7dd5fcb 100644
--- a/boost/network/protocol/http/server/async_server.hpp
+++ b/boost/network/protocol/http/server/async_server.hpp
@@ -37,6 +37,8 @@ namespace boost { namespace network { namespace http {
             tcp::endpoint endpoint = *resolver.resolve(query);
             acceptor.open(endpoint.protocol());
             acceptor.bind(endpoint);
+            tcp::socket::reuse_address opt(true);
+            acceptor.set_option(opt);
             acceptor.listen();
             new_connection.reset(new connection(io_service, handler, thread_pool));
             acceptor.async_accept(new_connection->socket(),
diff --git a/boost/network/protocol/http/server/sync_server.hpp b/boost/network/protocol/http/server/sync_server.hpp
index bd231ba..603165e 100644
--- a/boost/network/protocol/http/server/sync_server.hpp
+++ b/boost/network/protocol/http/server/sync_server.hpp
@@ -40,6 +40,8 @@ namespace boost { namespace network { namespace http {
             tcp::endpoint endpoint = *resolver.resolve(query);
             acceptor_.open(endpoint.protocol());
             acceptor_.bind(endpoint);
+            tcp::socket::reuse_address opt(true);
+            acceptor_.set_option(opt);
             acceptor_.listen();
             acceptor_.async_accept(new_connection->socket(),
                 boost::bind(&sync_server_base<Tag,Handler>::handle_accept,
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Cpp-netlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel

Reply via email to