Archived

This forum has been archived. Please start a new discussion on GitHub.

handle leak ?句柄泄漏?

在下面的函数中

SOCKET
IceInternal::createSocket(bool udp)
{
SOCKET fd;

if(udp)
{
fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
}
else
{
fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
}

if(fd == INVALID_SOCKET)
{
SocketException ex(__FILE__, __LINE__);
ex.error = getSocketErrno();
throw ex;
}

#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400)
//
// Temporary work-around!
// Make this socket non-inheritable, so that IcePack-launched servers
// do not inherit it.
//
if(!SetHandleInformation(reinterpret_cast<HANDLE>(fd), HANDLE_FLAG_INHERIT, 0))
{



////////////////////////////////////////////
handle leak?

SyscallException ex(__FILE__, __LINE__);
ex.error = getSystemErrno();
throw ex;
}
#endif

if(!udp)
{
setTcpNoDelay(fd);
setKeepAlive(fd);
}

return fd;
}

Comments

  • benoit
    benoit Rennes, France
    Thanks for the bug report! We should indeed close the socket here before to throw the Ice::SyscallException. This will be fixed in the next release!

    Benoit.