Closed Bug 1236244 Opened 9 years ago Closed 9 years ago

server_test: don't fail with EADDRINUSE

Categories

(NSPR :: NSPR, defect, P2)

4.11
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: agx, Assigned: agx)

Details

Attachments

(1 file, 2 obsolete files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.5.0 Build ID: 20151216011944 Steps to reproduce: * Build nspr * cd nspr/pr/tests * make && ./server_test && ./server_test Actual results: Second serer_test run fails with Sending 2 bytes of client data and 2 bytes of server data Main changed state to 0 Main waiting for state 5 Server error binding to server address: OS error 98 Server changed state to 4 Main resuming from wait for state 5; state now 4 server loop user/user: 500.00 usec Expected results: The test should pass as well.
OS: Unspecified → Linux
Hardware: Unspecified → x86_64
Comment on attachment 8703355 [details] [diff] [review] 0001-server_test-reuse-address.patch Review of attachment 8703355 [details] [diff] [review]: ----------------------------------------------------------------- Guido: thanks for the patch. I think the patch is correct. I suggest two small changes. ::: nspr/pr/tests/server_test.c @@ +259,5 @@ > } > > + sockOpt.option = PR_SockOpt_Reuseaddr; > + sockOpt.value.reuse_addr = PR_TRUE; > + if ( PR_SetSocketOption(listenSocket, &sockOpt) == PR_FAILURE) { Nit: remove the space after the opening parenthesis in "if ( ". Nit: check for failure by the != PR_SUCCESS test. The reason is that PR_SUCCESS has the value 0 and it is usually faster to compare with 0.
Attachment #8703355 - Flags: review?(ted)
Comments addressed. Note that the line: if ( PR_SetSocketOption(listenSocket, &sockOpt) == PR_FAILURE) { was a straight c'n'p from pr/tests/servr_*.c so these should probably be fixed too in a follow up patch.
Attachment #8703355 - Attachment is obsolete: true
Attachment #8703355 - Flags: review?(ted)
Guido: thanks for the updated patch. You're right. The formatting of code in server_test.c is pretty bad. I edited your patch slightly and checked it in: https://hg.mozilla.org/projects/nspr/rev/c0d797ad940c
Attachment #8706004 - Flags: review+
Attachment #8706004 - Flags: checked-in+
Attachment #8704659 - Attachment is obsolete: true
Assignee: wtc → agx
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
OS: Linux → All
Priority: -- → P2
Hardware: x86_64 → All
Resolution: --- → FIXED
Target Milestone: --- → 4.12
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: