Skip to content

Commit

Permalink
transports: all transports implement stop functions
Browse files Browse the repository at this point in the history
Add test cases ensuring that the transports implement all
required functionality (entry points are not null).
  • Loading branch information
gdamore committed Dec 11, 2024
1 parent 7155676 commit 90308d8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/core/dialer.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,7 @@ nni_dialer_stop(nni_dialer *d)
d->d_ops.d_close(d->d_data);
nni_aio_stop(&d->d_tmo_aio);
nni_aio_stop(&d->d_con_aio);
if (d->d_ops.d_stop) {
d->d_ops.d_stop(d->d_data);
}
d->d_ops.d_stop(d->d_data);
}

nni_sock *
Expand Down
4 changes: 1 addition & 3 deletions src/core/listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,7 @@ nni_listener_stop(nni_listener *l)
l->l_ops.l_close(l->l_data);
nni_aio_stop(&l->l_tmo_aio);
nni_aio_stop(&l->l_acc_aio);
if (l->l_ops.l_stop) {
l->l_ops.l_stop(l->l_data);
}
l->l_ops.l_stop(l->l_data);
}

nni_sock *
Expand Down
31 changes: 31 additions & 0 deletions src/sp/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,37 @@ static nni_rwlock sp_tran_lk = NNI_RWLOCK_INITIALIZER;
void
nni_sp_tran_register(nni_sp_tran *tran)
{
#ifndef NDEBUG
NNI_ASSERT(tran->tran_pipe->p_init != NULL);
NNI_ASSERT(tran->tran_pipe->p_fini != NULL);
NNI_ASSERT(tran->tran_pipe->p_stop != NULL);
NNI_ASSERT(tran->tran_pipe->p_close != NULL);
NNI_ASSERT(tran->tran_pipe->p_send != NULL);
NNI_ASSERT(tran->tran_pipe->p_recv != NULL);
NNI_ASSERT(tran->tran_pipe->p_peer != NULL);

if (tran->tran_dialer != NULL) {
NNI_ASSERT(tran->tran_dialer->d_init != NULL);
NNI_ASSERT(tran->tran_dialer->d_fini != NULL);
NNI_ASSERT(tran->tran_dialer->d_close != NULL);
NNI_ASSERT(tran->tran_dialer->d_stop != NULL);
NNI_ASSERT(tran->tran_dialer->d_connect != NULL);
NNI_ASSERT(tran->tran_dialer->d_getopt != NULL);
NNI_ASSERT(tran->tran_dialer->d_setopt != NULL);
}

if (tran->tran_listener != NULL) {
NNI_ASSERT(tran->tran_listener->l_init != NULL);
NNI_ASSERT(tran->tran_listener->l_fini != NULL);
NNI_ASSERT(tran->tran_listener->l_bind != NULL);
NNI_ASSERT(tran->tran_listener->l_accept != NULL);
NNI_ASSERT(tran->tran_listener->l_close != NULL);
NNI_ASSERT(tran->tran_listener->l_stop != NULL);
NNI_ASSERT(tran->tran_listener->l_getopt != NULL);
NNI_ASSERT(tran->tran_listener->l_setopt != NULL);
}
#endif

nni_rwlock_wrlock(&sp_tran_lk);
if (!nni_list_node_active(&tran->tran_link)) {
tran->tran_init();
Expand Down

0 comments on commit 90308d8

Please sign in to comment.