when a streamdev server is not accepting connections (eg isn't running) the client leaks fds. Spotted this after it leaked ~1000 fds and prevented vdr from opening any files... fix below.
artur
diff -urNp /pub/cvs/vdr/streamdev/streamdev/tools/socket.c streamdev/tools/socket.c --- /pub/cvs/vdr/streamdev/streamdev/tools/socket.c 2005-02-08 17:22:35.000000000 +0000 +++ streamdev/tools/socket.c 2006-02-24 01:43:29.000000000 +0000 @@ -30,24 +31,27 @@ bool cTBSocket::Connect(const std::strin m_LocalAddr.sin_addr.s_addr = INADDR_ANY; if (::bind(socket, (struct sockaddr*)&m_LocalAddr, sizeof(m_LocalAddr)) == -1) - return false; + goto closefd;
m_RemoteAddr.sin_family = AF_INET; m_RemoteAddr.sin_port = htons(Port); m_RemoteAddr.sin_addr.s_addr = inet_addr(Host.c_str()); if (::connect(socket, (struct sockaddr*)&m_RemoteAddr, sizeof(m_RemoteAddr)) == -1) - return false; + goto closefd;
len = sizeof(struct sockaddr_in); if (::getpeername(socket, (struct sockaddr*)&m_RemoteAddr, &len) == -1) - return false; + goto closefd; len = sizeof(struct sockaddr_in); if (::getsockname(socket, (struct sockaddr*)&m_LocalAddr, &len) == -1) - return false; + goto closefd;
return cTBSource::Open(socket); +closefd: + ::close(socket); + return false; }
bool cTBSocket::Listen(const std::string &Ip, unsigned int Port, int BackLog) {
On Fri, May 05, 2006 at 09:21:43PM +0200, Artur Skawina wrote:
when a streamdev server is not accepting connections (eg isn't running) the client leaks fds. Spotted this after it leaked ~1000 fds and prevented vdr from opening any files... fix below.
artur
Exactly the same piece of code is used by the ffnetdev plugin, too.
Frank
Artur Skawina wrote:
when a streamdev server is not accepting connections (eg isn't running) the client leaks fds. Spotted this after it leaked ~1000 fds and prevented vdr from opening any files... fix below.
This fix was just commited to streamdev's CVS. Thanks for providing it!
Thomas