From 90308d8a3651d163c08d4fae3cfda90c5292e812 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 11 Dec 2024 07:46:27 -0800 Subject: [PATCH] transports: all transports implement stop functions Add test cases ensuring that the transports implement all required functionality (entry points are not null). --- src/core/dialer.c | 4 +--- src/core/listener.c | 4 +--- src/sp/transport.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/core/dialer.c b/src/core/dialer.c index 6224ce9bb..4b0ad615f 100644 --- a/src/core/dialer.c +++ b/src/core/dialer.c @@ -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 * diff --git a/src/core/listener.c b/src/core/listener.c index 1eeaa3cde..28b7bc6f7 100644 --- a/src/core/listener.c +++ b/src/core/listener.c @@ -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 * diff --git a/src/sp/transport.c b/src/sp/transport.c index 919a0f374..178cc7489 100644 --- a/src/sp/transport.c +++ b/src/sp/transport.c @@ -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();