server_test: don't fail with EADDRINUSE

RESOLVED FIXED in 4.12

Status

P2
normal
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: agx, Assigned: agx)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Assignee)

Description

3 years ago
Created attachment 8703355 [details] [diff] [review]
0001-server_test-reuse-address.patch

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.
(Assignee)

Updated

3 years ago
OS: Unspecified → Linux
Hardware: Unspecified → x86_64

Comment 1

3 years ago
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)
(Assignee)

Comment 2

3 years ago
Created attachment 8704659 [details] [diff] [review]
0001-Bug-1236244-server_test-reuse-address.patch

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)

Comment 3

3 years ago
Created attachment 8706004 [details] [diff] [review]
0001-Bug-1236244-server_test-reuse-address.patch by Guido Günther

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+

Updated

3 years ago
Attachment #8704659 - Attachment is obsolete: true

Updated

3 years ago
Assignee: wtc → agx
Status: UNCONFIRMED → RESOLVED
Last Resolved: 3 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.