Skip to content

Commit

Permalink
transports: fix the tests a bit for closed, to be clearer
Browse files Browse the repository at this point in the history
Also increase the backoff times to 1/2 seconds, if we are out of
files or memory.  If someone is up against this, they want to let
the system calm down.
  • Loading branch information
gdamore committed Dec 16, 2024
1 parent 570347b commit d50cf36
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/sp/transport/ipc/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ ipc_ep_accept_cb(void *arg)
break;
case NNG_ENOMEM:
case NNG_ENOFILES:
nng_sleep_aio(10, &ep->time_aio);
nng_sleep_aio(500, &ep->time_aio);

Check warning on line 731 in src/sp/transport/ipc/ipc.c

View check run for this annotation

Codecov / codecov/patch

src/sp/transport/ipc/ipc.c#L731

Added line #L731 was not covered by tests
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion src/sp/transport/socket/sockfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ sfd_tran_accept_cb(void *arg)
ep->useraio = NULL;
nni_aio_finish_error(aio, rv);
}
if (!ep->closed) {
if (rv != NNG_ECLOSED) {
nng_stream_listener_accept(ep->listener, &ep->connaio);
}
nni_mtx_unlock(&ep->mtx);
Expand Down
8 changes: 4 additions & 4 deletions src/sp/transport/tcp/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,15 +716,15 @@ tcptran_accept_cb(void *arg)
}
switch (rv) {

case NNG_ECLOSED:
break;
case NNG_ENOMEM:
case NNG_ENOFILES:
nng_sleep_aio(10, &ep->timeaio);
nng_sleep_aio(500, &ep->timeaio);

Check warning on line 723 in src/sp/transport/tcp/tcp.c

View check run for this annotation

Codecov / codecov/patch

src/sp/transport/tcp/tcp.c#L723

Added line #L723 was not covered by tests
break;

default:
if (!ep->closed) {
nng_stream_listener_accept(ep->listener, &ep->connaio);
}
nng_stream_listener_accept(ep->listener, &ep->connaio);

Check warning on line 727 in src/sp/transport/tcp/tcp.c

View check run for this annotation

Codecov / codecov/patch

src/sp/transport/tcp/tcp.c#L727

Added line #L727 was not covered by tests
break;
}
nni_mtx_unlock(&ep->mtx);
Expand Down
8 changes: 4 additions & 4 deletions src/sp/transport/tls/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,19 +682,19 @@ tlstran_accept_cb(void *arg)
}
switch (rv) {

case NNG_ECLOSED:
break;
case NNG_ENOMEM:
case NNG_ENOFILES:
// We need to cool down here, to avoid spinning.
nng_sleep_aio(10, &ep->timeaio);
nng_sleep_aio(500, &ep->timeaio);

Check warning on line 690 in src/sp/transport/tls/tls.c

View check run for this annotation

Codecov / codecov/patch

src/sp/transport/tls/tls.c#L690

Added line #L690 was not covered by tests
break;

default:
// Start another accept. This is done because we want to
// ensure that TLS negotiations are disconnected from
// the upper layer accept logic.
if (!ep->closed) {
nng_stream_listener_accept(ep->listener, &ep->connaio);
}
nng_stream_listener_accept(ep->listener, &ep->connaio);

Check warning on line 697 in src/sp/transport/tls/tls.c

View check run for this annotation

Codecov / codecov/patch

src/sp/transport/tls/tls.c#L697

Added line #L697 was not covered by tests
break;
}
nni_mtx_unlock(&ep->mtx);
Expand Down

0 comments on commit d50cf36

Please sign in to comment.