possible problem when stream sockets are closed by the remote peer ?
Philippe Torrelli
philippe.torrelli at alcatel-lucent.fr
Mon Apr 16 11:11:49 CEST 2007
Hello,
I noticed a difference in the stl version shipped with VS2005 and the one
minisip binaries are built with, that makes VS2005 builds crash when a TCP
socket is closed by the remote peer.
It is true for tcp and tls socket:
When the remote peer closes the connection ( for example, the proxy minisip
is connected to crashes ), here minisip crashes in SocketServer::run because
inputready noticed the closed, removed the socket from the ' sockets ' map,
and then the ++ operator of the iterator pops an error.
This doesn't seem to cause troubles with the binaries downloadable from the
autobuild directory.
for( i = sockets.begin(); i != sockets.end(); i++ ){
MRef<Socket*> socket = i->first;
MRef<InputReadyHandler*> handler = i->second;
if( FD_ISSET( socket->getFd(), &set ) ){
if( !handler.isNull() ){
handler->inputReady( socket );
break;
}
}
}
Incrementing the iterator before inputReady is called solves the problem
here:
for( i = sockets.begin(); i != sockets.end(); ){ // CHANGED
MRef<Socket*> socket = i->first;
MRef<InputReadyHandler*> handler = i->second;
i++; // CHANGED
if( FD_ISSET( socket->getFd(), &set ) ){
if( !handler.isNull() ){
handler->inputReady( socket );
break;
}
}
}
I don't know which compiler conforms to the standard, thought it might be of
interest.
Philippe Torrelli
More information about the Minisip-devel
mailing list