diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-22 02:32:32 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-22 02:32:32 -0800 |
| commit | b93d5759c9b39ff153a14d474d800cd981f7dc97 (patch) | |
| tree | 1a98b7ac74cd91003c38f53ae3eb01fb8027deef /src/core/socket.c | |
| parent | 769f9a2b66aca629eb4dd240a072849a48aa300f (diff) | |
| download | nng-b93d5759c9b39ff153a14d474d800cd981f7dc97.tar.gz nng-b93d5759c9b39ff153a14d474d800cd981f7dc97.tar.bz2 nng-b93d5759c9b39ff153a14d474d800cd981f7dc97.zip | |
Event notification via pollable FDs verified working.
Diffstat (limited to 'src/core/socket.c')
| -rw-r--r-- | src/core/socket.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/core/socket.c b/src/core/socket.c index c0cf20b7..f451ba45 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -321,11 +321,11 @@ nni_sock_open(nni_sock **sockp, uint16_t pnum) goto fail; } - rv = nni_ev_init(&sock->s_recv_ev, NNG_EV_CAN_RECV, sock); + rv = nni_ev_init(&sock->s_recv_ev, NNG_EV_CAN_RCV, sock); if (rv != 0) { goto fail; } - rv = nni_ev_init(&sock->s_send_ev, NNG_EV_CAN_SEND, sock); + rv = nni_ev_init(&sock->s_send_ev, NNG_EV_CAN_SND, sock); if (rv != 0) { goto fail; } @@ -364,12 +364,22 @@ nni_sock_open(nni_sock **sockp, uint16_t pnum) } } + // XXX: This kills performance. Look at moving this to + // be conditional - if nobody has callbacks because their code is + // also threaded, then we don't need to jump through these hoops. + rv = nni_msgq_notify(sock->s_urq, nni_sock_urq_notify, sock); + if (rv != 0) { + goto fail; + } + rv = nni_msgq_notify(sock->s_uwq, nni_sock_uwq_notify, sock); + if (rv != 0) { + goto fail; + } + for (i = 0; i < NNI_MAXWORKERS; i++) { nni_thr_run(&sock->s_worker_thr[i]); } - nni_msgq_notify(sock->s_urq, nni_sock_urq_notify, sock); - nni_msgq_notify(sock->s_uwq, nni_sock_uwq_notify, sock); nni_thr_run(&sock->s_reaper); nni_thr_run(&sock->s_notifier); @@ -808,12 +818,12 @@ nni_sock_getopt(nni_sock *sock, int opt, void *val, size_t *sizep) case NNG_OPT_RCVBUF: rv = nni_getopt_buf(sock->s_urq, val, sizep); break; - case NNG_OPT_SENDFD: - rv = nni_getopt_fd(sock, &sock->s_send_fd, NNG_EV_CAN_SEND, + case NNG_OPT_SNDFD: + rv = nni_getopt_fd(sock, &sock->s_send_fd, NNG_EV_CAN_SND, val, sizep); break; - case NNG_OPT_RECVFD: - rv = nni_getopt_fd(sock, &sock->s_recv_fd, NNG_EV_CAN_RECV, + case NNG_OPT_RCVFD: + rv = nni_getopt_fd(sock, &sock->s_recv_fd, NNG_EV_CAN_RCV, val, sizep); break; } |
