From: Raghuram D. <dra...@gm...> - 2007-07-30 16:56:54
Attachments:
socket.txt.gz
|
With the latest code from the trunk, I see one failure as follows: Ran 77 tests in 6.696s FAILED (errors=1) test test_socket failed -- Traceback (most recent call last): File "/localhome/raghu/localwork/jython/jython/dist/Lib/unittest.py", line 204, in __call__ self.setUp() File "/localhome/raghu/localwork/jython/jython/dist/Lib/test/test_socket.py", line 39, in setUp self.serv.listen(1) File "/localhome/raghu/localwork/jython/jython/dist/Lib/socket.py", line 489, in listen raise _map_exception(jlx) error: (98, 'Address already in use') 1 test failed: test_socket 1 fail unexpected on java1.5.0_04: test_socket I ran the tests several times and got this error most of the times. The remaining runs failed with some other errors which I will post separately if I can confirm that they happen consistently. netstat output just before this particular test ran is as follows: ######## tcp 0 0 127.0.0.1:50007 :::* LISTEN tcp 0 0 127.0.0.1:37911 127.0.0.1:50007 TIME_WAIT tcp 0 0 127.0.0.1:37912 127.0.0.1:50007 TIME_WAIT tcp 0 0 127.0.0.1:37913 127.0.0.1:50007 TIME_WAIT tcp 0 0 127.0.0.1:37914 127.0.0.1:50007 TIME_WAIT tcp 0 0 127.0.0.1:37916 127.0.0.1:50007 TIME_WAIT tcp 0 0 127.0.0.1:37917 127.0.0.1:50007 TIME_WAIT ######## It can be seen that the socket is in listen state and the listen in setUp fails. My tests are run on SuSe 10. The full output from the tests is attached. I will investigate further but I want to know if any one else is seeing this kind of failure. Thanks, Raghu |
From: Pekka L. <pe...@ik...> - 2007-07-30 17:45:40
|
2007/7/30, Raghuram Devarakonda <dra...@gm...>: > With the latest code from the trunk, I see one failure as follows: > > Ran 77 tests in 6.696s > > FAILED (errors=1) > test test_socket failed -- Traceback (most recent call last): > File "/localhome/raghu/localwork/jython/jython/dist/Lib/unittest.py", > line 204, in __call__ > self.setUp() > File "/localhome/raghu/localwork/jython/jython/dist/Lib/test/test_socket.py", > line 39, in setUp > self.serv.listen(1) > File "/localhome/raghu/localwork/jython/jython/dist/Lib/socket.py", > line 489, in listen > raise _map_exception(jlx) > error: (98, 'Address already in use') > > 1 test failed: > test_socket > 1 fail unexpected on java1.5.0_04: > test_socket > > I ran the tests several times and got this error most of the times. > The remaining runs failed with some other errors which I will post > separately if I can confirm that they happen consistently. [snip] > I will investigate further but I want to know if > any one else is seeing this kind of failure. Can't confirm this on my Ubuntu 7.04 but I got another problem when trying to run socket tests repeatedly. All tests pass the first time but on the second round they hung on "testConnectWithLocalBind (__main__.NonBlockingTCPTests)". This happens if I have half a minute pause between test runs but if the pause is one minute everything goes ok and all tests pass. Cheers, .peke |
From: Raghuram D. <dra...@gm...> - 2007-07-30 18:29:05
|
On 7/30/07, Pekka Laukkanen <pe...@ik...> wrote: > Can't confirm this on my Ubuntu 7.04 but I got another problem when > trying to run socket tests repeatedly. All tests pass the first time > but on the second round they hung on "testConnectWithLocalBind > (__main__.NonBlockingTCPTests)". This happens if I have half a minute > pause between test runs but if the pause is one minute everything goes > ok and all tests pass. I see the hang too when the tests are run with in a small interval. This particular test tries to bind to 50006 and then connect to 50007. The first time when the test is run, it will be fine but once the connection is closed, it ends up in TIME_WAIT state (typically for a small time). tcp 0 0 127.0.0.1:50006 127.0.0.1:50007 TIME_WAIT During this time if the test is run again, connect() hangs. The problem is with the usage of hard coded port number 50006. If I change the code to use a dynamic port number for client-side (in place of PORT-1), there is no hang. The way I obtain dynamic port number is as follows: def find_free_tcp_port(self): s = socket.socket() s.bind(("localhost", 0)) s.listen(1) port = s.getsockname()[1] s.close() # There is a window here when the port can be taken by some one else. return port |
From: Alan K. <jyt...@xh...> - 2007-07-30 19:02:49
|
[Pekka] >> ... I got another problem when >>trying to run socket tests repeatedly. All tests pass the first time >>but on the second round they hung on "testConnectWithLocalBind >>(__main__.NonBlockingTCPTests)". This happens if I have half a minute >>pause between test runs but if the pause is one minute everything goes >>ok and all tests pass. Pekka, I think this is the same Linux binding problem again. Please can you try this definition of the client method for that test, which should resolve the issue. def _testConnectWithLocalBind(self): # Testing blocking connect with local bind self.cli.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.cli.bind( (HOST, PORT-1) ) self.cli.connect((HOST, PORT)) bound_host, bound_port = self.cli.getsockname() self.failUnlessEqual(bound_port, PORT-1) [Raghuram] > The problem is with the usage of hard coded port number 50006. If I > change the code to use a dynamic port number for client-side (in place > of PORT-1), there is no hang. Indeed, while that will make the test pass, I'd prefer not to opt for that solution just yet. If we had taken this option to make the server bind problems on Linux go away, then we'd never have found the bug that Charlie fixed, relating to SO_REUSEADDR on 'accept'ed client sockets. Regards, Alan. |
From: Raghuram D. <dra...@gm...> - 2007-07-30 19:08:44
|
On 7/30/07, Alan Kennedy <jyt...@xh...> wrote: > [Raghuram] > > The problem is with the usage of hard coded port number 50006. If I > > change the code to use a dynamic port number for client-side (in place > > of PORT-1), there is no hang. > > Indeed, while that will make the test pass, I'd prefer not to opt for > that solution just yet. > > If we had taken this option to make the server bind problems on Linux go > away, then we'd never have found the bug that Charlie fixed, relating to > SO_REUSEADDR on 'accept'ed client sockets. Agreed. If SO_REUSEADDR on the client socket fixes the issue, I will prefer that solution to using a dynamic port. Also, as I said, it will be nice to have a separate test for SO_REUSEADDR. Some thing similar to what Bob posted as an independent script. |
From: Raghuram D. <dra...@gm...> - 2007-07-30 21:19:18
|
On 7/30/07, Alan Kennedy <jyt...@xh...> wrote: > def _testConnectWithLocalBind(self): > # Testing blocking connect with local bind > self.cli.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > self.cli.bind( (HOST, PORT-1) ) > self.cli.connect((HOST, PORT)) > bound_host, bound_port = self.cli.getsockname() > self.failUnlessEqual(bound_port, PORT-1) I get the hang with this code too. But let us wait for Pekka to confirm. |
From: Pekka L. <pe...@ik...> - 2007-07-30 21:59:59
|
2007/7/31, Raghuram Devarakonda <dra...@gm...>: > On 7/30/07, Alan Kennedy <jyt...@xh...> wrote: > > def _testConnectWithLocalBind(self): > > # Testing blocking connect with local bind > > self.cli.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > > self.cli.bind( (HOST, PORT-1) ) > > self.cli.connect((HOST, PORT)) > > bound_host, bound_port = self.cli.getsockname() > > self.failUnlessEqual(bound_port, PORT-1) > > I get the hang with this code too. But let us wait for Pekka to confirm. Hanging confirmed. Cheers, .peke |
From: Charlie G. <cha...@gm...> - 2007-07-31 08:45:00
|
On 7/30/07, Pekka Laukkanen <pe...@ik...> wrote: > 2007/7/31, Raghuram Devarakonda <dra...@gm...>: > > On 7/30/07, Alan Kennedy <jyt...@xh...> wrote: > > > def _testConnectWithLocalBind(self): > > > # Testing blocking connect with local bind > > > self.cli.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > > > self.cli.bind( (HOST, PORT-1) ) > > > self.cli.connect((HOST, PORT)) > > > bound_host, bound_port = self.cli.getsockname() > > > self.failUnlessEqual(bound_port, PORT-1) > > > > I get the hang with this code too. But let us wait for Pekka to confirm. > > Hanging confirmed. I believe this is fixed as of r3372. Alan's fix got half of the problem; there was another little change necessary in socket.py to set SO_REUSEADDR on the Java socket before it was bound. Does this fix it for you two? Charlie |
From: Alan K. <jyt...@xh...> - 2007-07-31 22:18:09
|
[Charlie] > I believe this is fixed as of r3372. Alan's fix got half of the > problem; there was another little change necessary in socket.py to set > SO_REUSEADDR on the Java socket before it was bound. Charlie, Again I am in your debt; thanks for getting to the bottom of this one. Regards, Alan. |
From: Pekka L. <pe...@ik...> - 2007-07-31 10:25:03
|
2007/7/31, Charlie Groves <cha...@gm...>: > On 7/30/07, Pekka Laukkanen <pe...@ik...> wrote: > > 2007/7/31, Raghuram Devarakonda <dra...@gm...>: > > > On 7/30/07, Alan Kennedy <jyt...@xh...> wrote: > > > > def _testConnectWithLocalBind(self): > > > > # Testing blocking connect with local bind > > > > self.cli.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > > > > self.cli.bind( (HOST, PORT-1) ) > > > > self.cli.connect((HOST, PORT)) > > > > bound_host, bound_port = self.cli.getsockname() > > > > self.failUnlessEqual(bound_port, PORT-1) > > > > > > I get the hang with this code too. But let us wait for Pekka to confirm. > > > > Hanging confirmed. > > I believe this is fixed as of r3372. Alan's fix got half of the > problem; there was another little change necessary in socket.py to set > SO_REUSEADDR on the Java socket before it was bound. Does this fix it > for you two? I'll test this later today when I'm back at home. Should I use the latest version from trunk with or without the modified test Alan asked to use above? Can of course test both too. Cheers, .peke |
From: Charlie G. <cha...@gm...> - 2007-07-31 15:38:34
|
On 7/31/07, Pekka Laukkanen <pe...@ik...> wrote: > I'll test this later today when I'm back at home. Should I use the > latest version from trunk with or without the modified test Alan asked > to use above? Can of course test both too. Just the latest from trunk without the modified test should be fine. It incorporates Alan's change. Charlie |
From: Raghuram D. <dra...@gm...> - 2007-07-31 14:20:18
|
On 7/31/07, Charlie Groves <cha...@gm...> wrote: > > > I get the hang with this code too. But let us wait for Pekka to confirm. > > > > Hanging confirmed. > > I believe this is fixed as of r3372. Alan's fix got half of the > problem; there was another little change necessary in socket.py to set > SO_REUSEADDR on the Java socket before it was bound. Does this fix it > for you two? Yes. Tests with latest trunk do not get hangs any more. Thanks. |
From: Pekka L. <pe...@ik...> - 2007-07-31 18:52:12
|
2007/7/31, Raghuram Devarakonda <dra...@gm...>: > On 7/31/07, Charlie Groves <cha...@gm...> wrote: > > > > I get the hang with this code too. But let us wait for Pekka to confirm. > > > > > > Hanging confirmed. > > > > I believe this is fixed as of r3372. Alan's fix got half of the > > problem; there was another little change necessary in socket.py to set > > SO_REUSEADDR on the Java socket before it was bound. Does this fix it > > for you two? > > Yes. Tests with latest trunk do not get hangs any more. Thanks. No hanging here either! Cheers, .peke |
From: Raghuram D. <dra...@gm...> - 2007-08-01 14:18:27
|
On 7/30/07, Raghuram Devarakonda <dra...@gm...> wrote: > With the latest code from the trunk, I see one failure as follows: > > Ran 77 tests in 6.696s > > FAILED (errors=1) > test test_socket failed -- Traceback (most recent call last): > File "/localhome/raghu/localwork/jython/jython/dist/Lib/unittest.py", > line 204, in __call__ > self.setUp() > File "/localhome/raghu/localwork/jython/jython/dist/Lib/test/test_socket.py", > line 39, in setUp > self.serv.listen(1) > File "/localhome/raghu/localwork/jython/jython/dist/Lib/socket.py", > line 489, in listen > raise _map_exception(jlx) > error: (98, 'Address already in use') > > 1 test failed: > test_socket > 1 fail unexpected on java1.5.0_04: > test_socket > This problem turned out to be due to JVM. Amazingly, even after socket was closed in TCPTimeoutTest's tearDown(), I could see that localhost:50007 was in LISTEN state, thus failing next tests. My tests with 1.6.0_02, however, pass every time. Thanks, Raghu |