From 4250fc119057eb6a6b534e9c0758488cc5fb034e Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 24 Oct 2017 15:26:14 -0700 Subject: fixes #132 Implement saner notification for file descriptors This eliminates the "quasi-functional" notify API altogether. The aio framework will be coming soon to replace it. As a bonus, apps (legacy apps) that use the notification FDs will see improved performance, since we don't have to context switch to give them a notification. --- src/core/options.c | 61 +----------------------------------------------------- 1 file changed, 1 insertion(+), 60 deletions(-) (limited to 'src/core/options.c') diff --git a/src/core/options.c b/src/core/options.c index 3b787b82..1417d0b3 100644 --- a/src/core/options.c +++ b/src/core/options.c @@ -220,63 +220,4 @@ nni_getopt_buf(nni_msgq *mq, void *val, size_t *sizep) memcpy(val, &len, sz); *sizep = sizeof(len); return (0); -} - -static void -nni_notifyfd_push(struct nng_event *ev, void *arg) -{ - nni_notifyfd *fd = arg; - - NNI_ARG_UNUSED(ev); - - nni_plat_pipe_raise(fd->sn_wfd); -} - -int -nni_getopt_fd(nni_sock *s, nni_notifyfd *fd, int mask, void *val, size_t *szp) -{ - int rv; - uint32_t flags; - - if ((*szp < sizeof(int))) { - return (NNG_EINVAL); - } - - flags = nni_sock_flags(s); - - switch (mask) { - case NNG_EV_CAN_SND: - if ((flags & NNI_PROTO_FLAG_SND) == 0) { - return (NNG_ENOTSUP); - } - break; - case NNG_EV_CAN_RCV: - if ((flags & NNI_PROTO_FLAG_RCV) == 0) { - return (NNG_ENOTSUP); - } - break; - default: - return (NNG_ENOTSUP); - } - - // If we already inited this, just give back the same file descriptor. - if (fd->sn_init) { - memcpy(val, &fd->sn_rfd, sizeof(int)); - *szp = sizeof(int); - return (0); - } - - if ((rv = nni_plat_pipe_open(&fd->sn_wfd, &fd->sn_rfd)) != 0) { - return (rv); - } - - if (nni_sock_notify(s, mask, nni_notifyfd_push, fd) == NULL) { - nni_plat_pipe_close(fd->sn_wfd, fd->sn_rfd); - return (NNG_ENOMEM); - } - - fd->sn_init = 1; - *szp = sizeof(int); - memcpy(val, &fd->sn_rfd, sizeof(int)); - return (0); -} +} \ No newline at end of file -- cgit v1.2.3-70-g09d2