aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2015-05-30 13:08:37 -0700
committerGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2015-05-30 13:08:37 -0700
commit2e378c89f89820941d1b30ad8c8b501fefa213b0 (patch)
treea6fc49ed5ce72b408a3487b89de47e3f00a04714 /src
parent0461e07ab8d939f77fafa12e142fd2c69a8800f5 (diff)
parenta2779c122ec3b2c3b6a475afa2ed18145d1f1b61 (diff)
Merge pull request #1824 from ctiller/but-maybe-i-want-to-poll
Make it possible to run with poll() instead of epoll()
Diffstat (limited to 'src')
-rw-r--r--src/core/iomgr/pollset_multipoller_with_epoll.c9
-rw-r--r--src/core/iomgr/pollset_multipoller_with_poll_posix.c14
-rw-r--r--src/core/iomgr/pollset_posix.h11
3 files changed, 24 insertions, 10 deletions
diff --git a/src/core/iomgr/pollset_multipoller_with_epoll.c b/src/core/iomgr/pollset_multipoller_with_epoll.c
index a1c3938a33..40b7935a57 100644
--- a/src/core/iomgr/pollset_multipoller_with_epoll.c
+++ b/src/core/iomgr/pollset_multipoller_with_epoll.c
@@ -164,8 +164,8 @@ static const grpc_pollset_vtable multipoll_with_epoll_pollset = {
multipoll_with_epoll_pollset_maybe_work, epoll_kick,
multipoll_with_epoll_pollset_destroy};
-void grpc_platform_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
- size_t nfds) {
+static void epoll_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
+ size_t nfds) {
size_t i;
pollset_hdr *h = gpr_malloc(sizeof(pollset_hdr));
struct epoll_event ev;
@@ -194,4 +194,7 @@ void grpc_platform_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
}
}
-#endif /* GPR_LINUX_MULTIPOLL_WITH_EPOLL */
+grpc_platform_become_multipoller_type grpc_platform_become_multipoller =
+ epoll_become_multipoller;
+
+#endif /* GPR_LINUX_MULTIPOLL_WITH_EPOLL */
diff --git a/src/core/iomgr/pollset_multipoller_with_poll_posix.c b/src/core/iomgr/pollset_multipoller_with_poll_posix.c
index 4d36107ab0..d781c9b4bb 100644
--- a/src/core/iomgr/pollset_multipoller_with_poll_posix.c
+++ b/src/core/iomgr/pollset_multipoller_with_poll_posix.c
@@ -33,7 +33,7 @@
#include <grpc/support/port_platform.h>
-#ifdef GPR_POSIX_MULTIPOLL_WITH_POLL
+#ifdef GPR_POSIX_SOCKET
#include "src/core/iomgr/pollset_posix.h"
@@ -98,7 +98,8 @@ static void end_polling(grpc_pollset *pollset) {
pollset_hdr *h;
h = pollset->data.ptr;
for (i = 1; i < h->pfd_count; i++) {
- grpc_fd_end_poll(&h->watchers[i], h->pfds[i].revents & POLLIN, h->pfds[i].revents & POLLOUT);
+ grpc_fd_end_poll(&h->watchers[i], h->pfds[i].revents & POLLIN,
+ h->pfds[i].revents & POLLOUT);
}
}
@@ -228,8 +229,8 @@ static const grpc_pollset_vtable multipoll_with_poll_pollset = {
multipoll_with_poll_pollset_maybe_work, multipoll_with_poll_pollset_kick,
multipoll_with_poll_pollset_destroy};
-void grpc_platform_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
- size_t nfds) {
+void grpc_poll_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
+ size_t nfds) {
size_t i;
pollset_hdr *h = gpr_malloc(sizeof(pollset_hdr));
pollset->vtable = &multipoll_with_poll_pollset;
@@ -250,4 +251,9 @@ void grpc_platform_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
}
}
+#endif /* GPR_POSIX_SOCKET */
+
+#ifdef GPR_POSIX_MULTIPOLL_WITH_POLL
+grpc_platform_become_multipoller_type grpc_platform_become_multipoller =
+ grpc_poll_become_multipoller;
#endif
diff --git a/src/core/iomgr/pollset_posix.h b/src/core/iomgr/pollset_posix.h
index da843f7381..088ec910c2 100644
--- a/src/core/iomgr/pollset_posix.h
+++ b/src/core/iomgr/pollset_posix.h
@@ -101,7 +101,12 @@ void grpc_kick_drain(grpc_pollset *p);
grpc_pollset *grpc_backup_pollset(void);
/* turn a pollset into a multipoller: platform specific */
-void grpc_platform_become_multipoller(grpc_pollset *pollset,
- struct grpc_fd **fds, size_t fd_count);
+typedef void (*grpc_platform_become_multipoller_type)(grpc_pollset *pollset,
+ struct grpc_fd **fds,
+ size_t fd_count);
+extern grpc_platform_become_multipoller_type grpc_platform_become_multipoller;
-#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_POSIX_H */
+void grpc_poll_become_multipoller(grpc_pollset *pollset, struct grpc_fd **fds,
+ size_t fd_count);
+
+#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_POSIX_H */