Fix QTcpServer::listen() returning true when the port is in use on OS X.
authorRobin Burchell <robin+qt@viroteck.net>
Fri, 30 Mar 2012 19:21:40 +0000 (21:21 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 2 Apr 2012 12:52:48 +0000 (14:52 +0200)
commita84b42e6194be0f40bd8f961effef9947c07c832
treefc661873602e5fe90f81abbc058d5849bcfd820d
parent97282527ae7f1c97d6ca3cfeee61c4bacb30832f
Fix QTcpServer::listen() returning true when the port is in use on OS X.

Way back in the mists of time, someone added SO_REUSEPORT to socket binding,
which was great, because otherwise it meant that multiple UDP sockets couldn't
share the same port on OS X (as platforms with SO_REUSEPORT apparently don't
support rebinding with SO_REUSEADDR).

However: SO_REUSEPORT also means that *any* bind on a port will succeed, which
is most definitely not wanted in the case of TCP sockets, so check the socket
type before performing the actual bind.

Also test that multiple listens don't take effect.

Change-Id: I2f8d450bcfb8a7f3abd8918a4e789a850281dd13
Done-with: Thiago Macieira
Done-with: Shane Kearns
Task-number: QTBUG-6305
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
src/network/socket/qnativesocketengine_unix.cpp
tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp