aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/dialer.c61
-rw-r--r--src/core/listener.c57
-rw-r--r--src/core/pipe.c44
-rw-r--r--src/core/socket.c30
-rw-r--r--src/core/sockimpl.h2
5 files changed, 10 insertions, 184 deletions
diff --git a/src/core/dialer.c b/src/core/dialer.c
index 4b0ad615..78122646 100644
--- a/src/core/dialer.c
+++ b/src/core/dialer.c
@@ -19,7 +19,6 @@
// Functionality related to dialing.
static void dialer_connect_start(nni_dialer *);
static void dialer_connect_cb(void *);
-static void dialer_connect_cb_old(void *);
static void dialer_timer_cb(void *);
static nni_id_map dialers = NNI_ID_MAP_INITIALIZER(1, 0x7fffffff, 0);
@@ -235,20 +234,10 @@ nni_dialer_init(nni_dialer *d, nni_sock *s, nni_sp_tran *tran)
nni_mtx_init(&d->d_mtx);
- if (d->d_ops.d_size != 0) {
- d->d_data = ((uint8_t *) d) + NNI_ALIGN_UP(sizeof(*d));
- dp = d->d_data;
- } else {
- // legacy: remove me when transports converted
- dp = &d->d_data;
- }
+ d->d_data = ((uint8_t *) d) + NNI_ALIGN_UP(sizeof(*d));
+ dp = d->d_data;
- if (tran->tran_pipe->p_size) {
- nni_aio_init(&d->d_con_aio, dialer_connect_cb, d);
- } else {
- // legacy: remove me
- nni_aio_init(&d->d_con_aio, dialer_connect_cb_old, d);
- }
+ nni_aio_init(&d->d_con_aio, dialer_connect_cb, d);
nni_aio_init(&d->d_tmo_aio, dialer_timer_cb, d);
dialer_stats_init(d);
@@ -452,50 +441,6 @@ dialer_connect_cb(void *arg)
}
static void
-dialer_connect_cb_old(void *arg)
-{
- nni_dialer *d = arg;
- nni_aio *aio = &d->d_con_aio;
- nni_aio *user_aio;
- int rv;
-
- nni_mtx_lock(&d->d_mtx);
- user_aio = d->d_user_aio;
- d->d_user_aio = NULL;
- nni_mtx_unlock(&d->d_mtx);
-
- switch ((rv = nni_aio_result(aio))) {
- case 0:
-#ifdef NNG_ENABLE_STATS
- nni_stat_inc(&d->st_connect, 1);
-#endif
- nni_dialer_add_pipe(d, nni_aio_get_output(aio, 0));
- break;
- case NNG_ECLOSED: // No further action.
- case NNG_ECANCELED: // No further action.
- nni_dialer_bump_error(d, rv);
- break;
- case NNG_ECONNREFUSED:
- case NNG_ETIMEDOUT:
- default:
- nng_log_warn("NNG-CONN-FAIL",
- "Failed connecting socket<%u>: %s", nni_sock_id(d->d_sock),
- nng_strerror(rv));
-
- nni_dialer_bump_error(d, rv);
- if (user_aio == NULL) {
- nni_dialer_timer_start(d);
- } else {
- nni_atomic_flag_reset(&d->d_started);
- }
- break;
- }
- if (user_aio != NULL) {
- nni_aio_finish(user_aio, rv, 0);
- }
-}
-
-static void
dialer_connect_start(nni_dialer *d)
{
d->d_ops.d_connect(d->d_data, &d->d_con_aio);
diff --git a/src/core/listener.c b/src/core/listener.c
index 28b7bc6f..c212ce91 100644
--- a/src/core/listener.c
+++ b/src/core/listener.c
@@ -22,7 +22,6 @@
static void listener_accept_start(nni_listener *);
static void listener_accept_cb(void *);
-static void listener_accept_cb_old(void *);
static void listener_timer_cb(void *);
static nni_id_map listeners = NNI_ID_MAP_INITIALIZER(1, 0x7fffffff, 0);
@@ -230,22 +229,13 @@ nni_listener_init(nni_listener *l, nni_sock *s, nni_sp_tran *tran)
NNI_LIST_NODE_INIT(&l->l_node);
NNI_LIST_INIT(&l->l_pipes, nni_pipe, p_ep_node);
- if (tran->tran_pipe->p_size) {
- nni_aio_init(&l->l_acc_aio, listener_accept_cb, l);
- } else {
- nni_aio_init(&l->l_acc_aio, listener_accept_cb_old, l);
- }
+ nni_aio_init(&l->l_acc_aio, listener_accept_cb, l);
nni_aio_init(&l->l_tmo_aio, listener_timer_cb, l);
listener_stats_init(l);
- if (l->l_ops.l_size != 0) {
- l->l_data = ((uint8_t *) l) + NNI_ALIGN_UP(sizeof(*l));
- lp = l->l_data;
- } else {
- // legacy: remove me when transports converted
- lp = &l->l_data;
- }
+ l->l_data = ((uint8_t *) l) + NNI_ALIGN_UP(sizeof(*l));
+ lp = l->l_data;
rv = l->l_ops.l_init(lp, &l->l_url, l);
@@ -444,47 +434,6 @@ listener_accept_cb(void *arg)
}
static void
-listener_accept_cb_old(void *arg)
-{
- nni_listener *l = arg;
- nni_aio *aio = &l->l_acc_aio;
- int rv;
-
- switch ((rv = nni_aio_result(aio))) {
- case 0:
-#ifdef NNG_ENABLE_STATS
- nni_stat_inc(&l->st_accept, 1);
-#endif
- nni_listener_add_pipe(l, nni_aio_get_output(aio, 0));
- listener_accept_start(l);
- break;
- case NNG_ECONNABORTED: // remote condition, no cool down
- case NNG_ECONNRESET: // remote condition, no cool down
- case NNG_ETIMEDOUT: // No need to sleep, we timed out already.
- case NNG_EPEERAUTH: // peer validation failure
- nng_log_warn("NNG-ACCEPT-FAIL",
- "Failed accepting for socket<%u>: %s",
- nni_sock_id(l->l_sock), nng_strerror(rv));
- nni_listener_bump_error(l, rv);
- listener_accept_start(l);
- break;
- case NNG_ECLOSED: // no further action
- case NNG_ECANCELED: // no further action
- nni_listener_bump_error(l, rv);
- break;
- default:
- // We don't really know why we failed, but we back off
- // here. This is because errors here are probably due
- // to system failures (resource exhaustion) and we hope
- // by not thrashing we give the system a chance to
- // recover. 100 ms is enough to cool down.
- nni_listener_bump_error(l, rv);
- nni_sleep_aio(100, &l->l_tmo_aio);
- break;
- }
-}
-
-static void
listener_accept_start(nni_listener *l)
{
// Call with the listener lock held.
diff --git a/src/core/pipe.c b/src/core/pipe.c
index eaf49af9..dac24140 100644
--- a/src/core/pipe.c
+++ b/src/core/pipe.c
@@ -240,7 +240,7 @@ pipe_stats_init(nni_pipe *p)
static int
pipe_create(nni_pipe **pp, nni_sock *sock, nni_sp_tran *tran, nni_dialer *d,
- nni_listener *l, void *tran_data)
+ nni_listener *l)
{
nni_pipe *p;
int rv1, rv2, rv3;
@@ -253,11 +253,6 @@ pipe_create(nni_pipe **pp, nni_sock *sock, nni_sp_tran *tran, nni_dialer *d,
NNI_ALIGN_UP(tops->p_size);
if ((p = nni_zalloc(sz)) == NULL) {
- // TODO: remove when all transports converted
- // to use p_size.
- if (tran_data != NULL) {
- tops->p_fini(tran_data);
- }
return (NNG_ENOMEM);
}
@@ -279,10 +274,7 @@ pipe_create(nni_pipe **pp, nni_sock *sock, nni_sp_tran *tran, nni_dialer *d,
NNI_LIST_NODE_INIT(&p->p_ep_node);
uint8_t *proto_data = (uint8_t *) p + NNI_ALIGN_UP(sizeof(*p));
-
- if (tran_data == NULL) {
- tran_data = proto_data + NNI_ALIGN_UP(pops->pipe_size);
- }
+ uint8_t *tran_data = proto_data + NNI_ALIGN_UP(pops->pipe_size);
nni_pipe_add(p);
p->p_tran_data = tran_data;
@@ -309,34 +301,6 @@ pipe_create(nni_pipe **pp, nni_sock *sock, nni_sp_tran *tran, nni_dialer *d,
}
int
-nni_pipe_create_dialer(nni_pipe **pp, nni_dialer *d, void *tran_data)
-{
- int rv;
- nni_sp_tran *tran = d->d_tran;
- nni_pipe *p;
-
- if ((rv = pipe_create(&p, d->d_sock, tran, d, NULL, tran_data)) != 0) {
- return (rv);
- }
- *pp = p;
- return (0);
-}
-
-int
-nni_pipe_create_listener(nni_pipe **pp, nni_listener *l, void *tran_data)
-{
- int rv;
- nni_sp_tran *tran = l->l_tran;
- nni_pipe *p;
-
- if ((rv = pipe_create(&p, l->l_sock, tran, NULL, l, tran_data)) != 0) {
- return (rv);
- }
- *pp = p;
- return (0);
-}
-
-int
nni_pipe_alloc_dialer(void **datap, nni_dialer *d)
{
int rv;
@@ -344,7 +308,7 @@ nni_pipe_alloc_dialer(void **datap, nni_dialer *d)
nni_sock *s = d->d_sock;
nni_pipe *p;
- if ((rv = pipe_create(&p, s, tran, d, NULL, NULL)) != 0) {
+ if ((rv = pipe_create(&p, s, tran, d, NULL)) != 0) {
return (rv);
}
*datap = p->p_tran_data;
@@ -359,7 +323,7 @@ nni_pipe_alloc_listener(void **datap, nni_listener *l)
nni_sock *s = l->l_sock;
nni_pipe *p;
- if ((rv = pipe_create(&p, s, tran, NULL, l, NULL)) != 0) {
+ if ((rv = pipe_create(&p, s, tran, NULL, l)) != 0) {
return (rv);
}
*datap = p->p_tran_data;
diff --git a/src/core/socket.c b/src/core/socket.c
index ec2691a3..6ba5d54e 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1326,24 +1326,6 @@ dialer_start_pipe(nni_dialer *d, nni_pipe *p)
}
void
-nni_dialer_add_pipe(nni_dialer *d, void *tpipe)
-{
- nni_sock *s = d->d_sock;
- nni_pipe *p;
-
- if (nni_pipe_create_dialer(&p, d, tpipe) != 0) {
- return;
- }
-
- nni_mtx_lock(&s->s_mx);
- d->d_pipe = p;
- d->d_currtime = d->d_inirtime;
- nni_mtx_unlock(&s->s_mx);
-
- dialer_start_pipe(d, p);
-}
-
-void
nni_dialer_shutdown(nni_dialer *d)
{
nni_sock *s = d->d_sock;
@@ -1453,18 +1435,6 @@ listener_start_pipe(nni_listener *l, nni_pipe *p)
}
void
-nni_listener_add_pipe(nni_listener *l, void *tpipe)
-{
- nni_pipe *p;
-
- if (nni_pipe_create_listener(&p, l, tpipe) != 0) {
- return;
- }
-
- listener_start_pipe(l, p);
-}
-
-void
nni_listener_shutdown(nni_listener *l)
{
nni_sock *s = l->l_sock;
diff --git a/src/core/sockimpl.h b/src/core/sockimpl.h
index aeaa369b..3140b97b 100644
--- a/src/core/sockimpl.h
+++ b/src/core/sockimpl.h
@@ -143,8 +143,6 @@ extern void nni_pipe_add(nni_pipe *);
extern void nni_pipe_remove(nni_pipe *);
extern bool nni_pipe_is_closed(nni_pipe *);
extern void nni_pipe_run_cb(nni_pipe *, nng_pipe_ev);
-extern int nni_pipe_create_dialer(nni_pipe **, nni_dialer *, void *);
-extern int nni_pipe_create_listener(nni_pipe **, nni_listener *, void *);
extern void nni_pipe_start(nni_pipe *);