mhlkmn0108 / junixsocket

Automatically exported from code.google.com/p/junixsocket
1 stars 0 forks source link

connection errors can leak sockets (file handles) #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Attempt to connect to a non existing unix socket
2. let the java application running
3.

What is the expected output? What do you see instead?

run 'lsof -U' as root. This should not list any unix socket (file handle)
allocated by the java process however it does. All new failed connect
attempt allocates a new socket which will only be released when the java
application terminates. This may result in 'too many open files' error
messages in any applications running on the same computer

check lsof -U output as root - there is a socket/file handle allocated for
the java process thought the connection fails 

What version of the product are you using? On what operating system?

junixsocket 1.1 - linux (Debian, RedHat, several gcc versions)

Please provide any additional information below.

The fix is easy: if connect() returns error release the socket before
throwing the exception. See the patch file below.

*** org_newsclub_net_unix_NativeUnixSocket.c  2009-08-28 20:24:29.000000000
+0200
--- org_newsclub_net_unix_NativeUnixSocket.c    2010-02-09
09:54:02.000000000 +0100
***************
*** 227,232 ****
--- 227,233 ----

                int ret = connect(socketHandle, (struct sockaddr *)&su,
suLength);
                if(ret == -1) {
+                       close( socketHandle );

org_newsclub_net_unix_NativeUnixSocket_throwException(env, strerror(errno),
file);
                        return;
                }

Original issue reported on code.google.com by nttnem...@freemail.hu on 9 Feb 2010 at 9:55

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Will be nice to see a package with the fix on this one too.

Original comment by Stas.Os...@gmail.com on 11 Feb 2010 at 6:51

GoogleCodeExporter commented 9 years ago
Hello, we are experiencing this issue too.  Any chance of pushing a new release?

Original comment by Geoffrey...@gmail.com on 4 Mar 2010 at 5:57

GoogleCodeExporter commented 9 years ago

Original comment by ckkohl79 on 4 Mar 2010 at 6:20

GoogleCodeExporter commented 9 years ago
Committed to SVN. Thanks!

Christian

Original comment by ckkohl79 on 7 Apr 2010 at 9:06

GoogleCodeExporter commented 9 years ago
Issue 8 has been merged into this issue.

Original comment by ckkohl79 on 7 Apr 2010 at 9:06