I'd like someone to review main rev. 18615, described below.  It contains a 
number of minor changes, but the significant part is to update 
OsServerSocket::close and ::accept.

It seems to be common that one thread calls OsServerSocket::close() on an 
OsServerSocket object while another thread is blocked inside 
OsServerSocket::accept().  The execution of the kernel close() inside ::close() 
causes the ::accept() to continue executing, but there is a race between the 
two threads at that point:  They both want to call kernel close() on the socket 
and then set the member variable socketDescriptor to -1 (to indicate that there 
is no open socket associated with the OsServerSocket).  Once one thread sets 
socketDescriptor to -1, the other thread may try to execute 
close(socketDescriptor), causing the invalid kernel call close(-1), which 
Valgrind object to.  The fix is, within each of these methods, to save the 
value of socketDescriptor to a local variable before the potentially blocking 
kernel calls.  Both threads will call kernel close() on the descriptor, but 
both will use the former value of socketDescriptor and not be confused if the 
other thread sets so
 cketDescriptor to -1.

Dale

________________________________________
From: [email protected] 
[[email protected]] On Behalf Of 
[email protected] [[email protected]]

Project sipXecs
New Revision    18615<http://code.sipfoundry.org//changelog/sipXecs/?cs=18615>
Committer       dworley
Date    2010-04-17 23:04:31 -0500 (Sat, 17 Apr 2010)

Fix OsServerSocket::close() and OsServerSocket::accept() to stop
attempting to close fd -1.

Modified:

 *   main/sipXmediaLib/src/mp/dmaTaskPosix.cpp 
<http://code.sipfoundry.org//browse/sipXecs/main/sipXmediaLib/src/mp/dmaTaskPosix.cpp?r1=18614&r2=18615>
 *   main/sipXportLib/include/os/OsProcess.h 
<http://code.sipfoundry.org//browse/sipXecs/main/sipXportLib/include/os/OsProcess.h?r1=18614&r2=18615>
 *   main/sipXportLib/src/os/OsProcessBase.cpp 
<http://code.sipfoundry.org//browse/sipXecs/main/sipXportLib/src/os/OsProcessBase.cpp?r1=18614&r2=18615>
 *   main/sipXportLib/src/os/OsServerSocket.cpp 
<http://code.sipfoundry.org//browse/sipXecs/main/sipXportLib/src/os/OsServerSocket.cpp?r1=18614&r2=18615>
 *   main/sipXportLib/src/os/linux/OsProcessLinux.cpp 
<http://code.sipfoundry.org//browse/sipXecs/main/sipXportLib/src/os/linux/OsProcessLinux.cpp?r1=18614&r2=18615>
 *   main/sipXtackLib/include/net/SipRefreshMgr.h 
<http://code.sipfoundry.org//browse/sipXecs/main/sipXtackLib/include/net/SipRefreshMgr.h?r1=18614&r2=18615>
_______________________________________
_______________________________________________
sipx-dev mailing list [email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev
Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev
sipXecs IP PBX -- http://www.sipfoundry.org/

Reply via email to