Skip to content

Commit

Permalink
socket transport: No need for a cool down for this transport.
Browse files Browse the repository at this point in the history
If an error occurs, the application gets to know about it.  There
cannot be external factors that cause us to spin for memory, since
this is not accessible via the network.
  • Loading branch information
gdamore committed Dec 8, 2024
1 parent 3ca7bcc commit 465bd08
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions src/sp/transport/socket/sockfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ struct sfd_tran_ep {
int refcnt; // active pipes
nni_aio *useraio;
nni_aio connaio;
nni_aio timeaio;
nni_list busypipes; // busy pipes -- ones passed to socket
nni_list waitpipes; // pipes waiting to match to socket
nni_list negopipes; // pipes busy negotiating
Expand Down Expand Up @@ -666,10 +665,8 @@ sfd_tran_ep_fini(void *arg)
return;
}
nni_mtx_unlock(&ep->mtx);
nni_aio_stop(&ep->timeaio);
nni_aio_stop(&ep->connaio);
nng_stream_listener_free(ep->listener);
nni_aio_fini(&ep->timeaio);
nni_aio_fini(&ep->connaio);

nni_mtx_fini(&ep->mtx);
Expand All @@ -685,7 +682,6 @@ sfd_tran_ep_close(void *arg)
nni_mtx_lock(&ep->mtx);

ep->closed = true;
nni_aio_close(&ep->timeaio);
if (ep->listener != NULL) {
nng_stream_listener_close(ep->listener);
}
Expand All @@ -706,15 +702,6 @@ sfd_tran_ep_close(void *arg)
nni_mtx_unlock(&ep->mtx);
}

static void
sfd_tran_timer_cb(void *arg)
{
sfd_tran_ep *ep = arg;
if (nni_aio_result(&ep->timeaio) == 0) {
nng_stream_listener_accept(ep->listener, &ep->connaio);
}
}

static void
sfd_tran_accept_cb(void *arg)
{
Expand Down Expand Up @@ -754,18 +741,8 @@ sfd_tran_accept_cb(void *arg)
ep->useraio = NULL;
nni_aio_finish_error(aio, rv);
}
switch (rv) {

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

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

Check warning on line 745 in src/sp/transport/socket/sockfd.c

View check run for this annotation

Codecov / codecov/patch

src/sp/transport/socket/sockfd.c#L745

Added line #L745 was not covered by tests
}
nni_mtx_unlock(&ep->mtx);
}
Expand Down Expand Up @@ -820,7 +797,6 @@ sfd_tran_listener_init(void **lp, nng_url *url, nni_listener *nlistener)
}

nni_aio_init(&ep->connaio, sfd_tran_accept_cb, ep);
nni_aio_init(&ep->timeaio, sfd_tran_timer_cb, ep);

if ((rv = nng_stream_listener_alloc_url(&ep->listener, url)) != 0) {
sfd_tran_ep_fini(ep);
Expand Down

0 comments on commit 465bd08

Please sign in to comment.