diff options
| author | Garrett D'Amore <garrett@damore.org> | 2020-11-08 21:17:40 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2020-11-08 21:17:40 -0800 |
| commit | a06a4b45ef111908c1cb7138990ae36bd2c5d0c3 (patch) | |
| tree | 9c93557efe6f784b0f2810515b2fd35afda08014 | |
| parent | 6cf8b299a4658a235033f77c2645b76043ff801e (diff) | |
| download | nng-a06a4b45ef111908c1cb7138990ae36bd2c5d0c3.tar.gz nng-a06a4b45ef111908c1cb7138990ae36bd2c5d0c3.tar.bz2 nng-a06a4b45ef111908c1cb7138990ae36bd2c5d0c3.zip | |
Clean up warnings, and panic if epoll fd expectations fail.
| -rw-r--r-- | src/platform/posix/posix_pipe.c | 5 | ||||
| -rw-r--r-- | src/platform/posix/posix_pollq_epoll.c | 18 |
2 files changed, 18 insertions, 5 deletions
diff --git a/src/platform/posix/posix_pipe.c b/src/platform/posix/posix_pipe.c index fcca0aba..8132aff9 100644 --- a/src/platform/posix/posix_pipe.c +++ b/src/platform/posix/posix_pipe.c @@ -1,5 +1,5 @@ // -// Copyright 2017 Garrett D'Amore <garrett@damore.org> +// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -103,7 +103,10 @@ nni_plat_pipe_raise(int wfd) { char c = 1; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" (void) write(wfd, &c, 1); +#pragma GCC diagnostic pop } void diff --git a/src/platform/posix/posix_pollq_epoll.c b/src/platform/posix/posix_pollq_epoll.c index bbfa9f6e..fc55f76f 100644 --- a/src/platform/posix/posix_pollq_epoll.c +++ b/src/platform/posix/posix_pollq_epoll.c @@ -61,7 +61,7 @@ struct nni_posix_pollq { }; struct nni_posix_pfd { - nni_list_node node; + nni_list_node node; nni_posix_pollq *pq; int fd; nni_posix_pfd_cb cb; @@ -205,7 +205,9 @@ nni_posix_pfd_fini(nni_posix_pfd *pfd) // a hang waiting for the poller to reap the pfd in fini, // if it were possible for them to occur. (Barring other // bugs, it isn't.) - (void) write(pq->evfd, &one, sizeof(one)); + if (write(pq->evfd, &one, sizeof(one)) != sizeof(one)) { + nni_panic("BUG! write to epoll fd incorrect!"); + } while (!pfd->closed) { nni_cv_wait(&pfd->cv); @@ -261,7 +263,10 @@ nni_posix_poll_thr(void *arg) if ((ev->data.ptr == NULL) && (ev->events & (unsigned) POLLIN)) { uint64_t clear; - (void) read(pq->evfd, &clear, sizeof(clear)); + if (read(pq->evfd, &clear, sizeof(clear)) != + sizeof(clear)) { + nni_panic("read from evfd incorrect!"); + } reap = true; } else { nni_posix_pfd * pfd = ev->data.ptr; @@ -305,7 +310,12 @@ nni_posix_pollq_destroy(nni_posix_pollq *pq) nni_mtx_lock(&pq->mtx); pq->close = true; - (void) write(pq->evfd, &one, sizeof(one)); + + if (write(pq->evfd, &one, sizeof(one)) != sizeof(one)) { + // This should never occur, and if it does it could + // lead to a hang. + nni_panic("BUG! unable to write to evfd!"); + } nni_mtx_unlock(&pq->mtx); nni_thr_fini(&pq->thr); |
