diff options
Diffstat (limited to 'src/core/iomgr')
-rw-r--r-- | src/core/iomgr/fd_posix.c | 23 | ||||
-rw-r--r-- | src/core/iomgr/fd_posix.h | 5 | ||||
-rw-r--r-- | src/core/iomgr/pollset_multipoller_with_poll_posix.c | 2 | ||||
-rw-r--r-- | src/core/iomgr/pollset_posix.c | 13 | ||||
-rw-r--r-- | src/core/iomgr/pollset_posix.h | 3 |
5 files changed, 27 insertions, 19 deletions
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index 567e1ff02e..e086a71e12 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -46,8 +46,8 @@ #include <grpc/support/useful.h> #include <sys/syscall.h> -#define CLOSURE_NOT_READY ((grpc_closure*)0) -#define CLOSURE_READY ((grpc_closure*)1) +#define CLOSURE_NOT_READY ((grpc_closure *)0) +#define CLOSURE_READY ((grpc_closure *)1) /* We need to keep a freelist not because of any concerns of malloc performance * but instead so that implementations with multiple threads in (for example) @@ -175,13 +175,16 @@ grpc_fd *grpc_fd_create(int fd, const char *name) { static int count_inactive(grpc_fd *fd) { int n = 0; grpc_fd_watcher *w; - for (w = fd->inactive_watcher_root.next; w != &fd->inactive_watcher_root; w = w->next) { + for (w = fd->inactive_watcher_root.next; w != &fd->inactive_watcher_root; + w = w->next) { n++; } return n; } -static void fdev_add(fd_event_type type, grpc_fd *fd, grpc_pollset *pollset, grpc_pollset_worker *pollset_worker, grpc_fd_watcher *fd_watcher) { +static void fdev_add(fd_event_type type, grpc_fd *fd, grpc_pollset *pollset, + grpc_pollset_worker *pollset_worker, + grpc_fd_watcher *fd_watcher) { fd_event *ev; if (fd->num_ev == fd->cap_ev) { fd->cap_ev = GPR_MAX(2 * fd->cap_ev, 32); @@ -210,7 +213,8 @@ static void pollset_kick_locked(grpc_fd_watcher *watcher, fd_event_type type) { fdev_add(type, watcher->fd, watcher->pollset, watcher->worker, watcher); gpr_mu_lock(GRPC_POLLSET_MU(watcher->pollset)); GPR_ASSERT(watcher->worker); - grpc_pollset_kick_ex(watcher->pollset, watcher->worker, GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP); + grpc_pollset_kick_ex(watcher->pollset, watcher->worker, + GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP); gpr_mu_unlock(GRPC_POLLSET_MU(watcher->pollset)); fdev_add(type + 1, watcher->fd, watcher->pollset, watcher->worker, watcher); } @@ -277,8 +281,8 @@ void grpc_fd_ref(grpc_fd *fd) { ref_by(fd, 2); } void grpc_fd_unref(grpc_fd *fd) { unref_by(fd, 2); } #endif -static void notify_on_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure **st, - grpc_closure *closure) { +static void notify_on_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd, + grpc_closure **st, grpc_closure *closure) { if (*st == CLOSURE_NOT_READY) { *st = closure; } else if (*st == CLOSURE_READY) { @@ -296,7 +300,7 @@ static void notify_on_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure /* returns 1 if state becomes not ready */ static int set_ready_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd, - grpc_closure **st) { + grpc_closure **st) { if (*st == CLOSURE_READY) { /* duplicate ready, ignore */ return 0; @@ -407,7 +411,8 @@ void grpc_fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher, gpr_mu_lock(&fd->mu); - fdev_add(FDEV_END_POLL, watcher->fd, watcher->pollset, watcher->worker, watcher); + fdev_add(FDEV_END_POLL, watcher->fd, watcher->pollset, watcher->worker, + watcher); if (watcher == fd->read_watcher) { /* remove read watcher, kick if we still need a read */ diff --git a/src/core/iomgr/fd_posix.h b/src/core/iomgr/fd_posix.h index b56931cb2b..8e6f2cfb52 100644 --- a/src/core/iomgr/fd_posix.h +++ b/src/core/iomgr/fd_posix.h @@ -129,9 +129,8 @@ void grpc_fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure *on_done, fd's current interest (such as epoll) do not need to call this function. MUST NOT be called with a pollset lock taken */ gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset, - grpc_pollset_worker *worker, - gpr_uint32 read_mask, gpr_uint32 write_mask, - grpc_fd_watcher *rec); + grpc_pollset_worker *worker, gpr_uint32 read_mask, + gpr_uint32 write_mask, grpc_fd_watcher *rec); /* Complete polling previously started with grpc_fd_begin_poll MUST NOT be called with a pollset lock taken */ void grpc_fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *rec, diff --git a/src/core/iomgr/pollset_multipoller_with_poll_posix.c b/src/core/iomgr/pollset_multipoller_with_poll_posix.c index ba0ba72816..faa6c14491 100644 --- a/src/core/iomgr/pollset_multipoller_with_poll_posix.c +++ b/src/core/iomgr/pollset_multipoller_with_poll_posix.c @@ -103,7 +103,7 @@ static void multipoll_with_poll_pollset_maybe_work_and_unlock( grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker *worker, gpr_timespec deadline, gpr_timespec now) { #define POLLOUT_CHECK (POLLOUT | POLLHUP | POLLERR) -#define POLLIN_CHECK (POLLIN | POLLHUP | POLLERR) +#define POLLIN_CHECK (POLLIN | POLLHUP | POLLERR) int timeout; int r; diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index 5b7f7cce9a..574ebc7c60 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -98,7 +98,8 @@ static void push_front_worker(grpc_pollset *p, grpc_pollset_worker *worker) { worker->prev->next = worker->next->prev = worker; } -void grpc_pollset_kick_ex(grpc_pollset *p, grpc_pollset_worker *specific_worker, gpr_uint32 flags) { +void grpc_pollset_kick_ex(grpc_pollset *p, grpc_pollset_worker *specific_worker, + gpr_uint32 flags) { /* pollset->mu already held */ if (specific_worker != NULL) { if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) { @@ -128,11 +129,13 @@ void grpc_pollset_kick_ex(grpc_pollset *p, grpc_pollset_worker *specific_worker, GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0); specific_worker = pop_front_worker(p); if (specific_worker != NULL) { - if (gpr_tls_get(&g_current_thread_worker) == (gpr_intptr)specific_worker) { + if (gpr_tls_get(&g_current_thread_worker) == + (gpr_intptr)specific_worker) { push_back_worker(p, specific_worker); specific_worker = pop_front_worker(p); - if ((flags & GRPC_POLLSET_CAN_KICK_SELF) == 0 && - gpr_tls_get(&g_current_thread_worker) == (gpr_intptr)specific_worker) { + if ((flags & GRPC_POLLSET_CAN_KICK_SELF) == 0 && + gpr_tls_get(&g_current_thread_worker) == + (gpr_intptr)specific_worker) { push_back_worker(p, specific_worker); return; } @@ -497,7 +500,7 @@ static void basic_pollset_maybe_work_and_unlock(grpc_exec_ctx *exec_ctx, gpr_timespec deadline, gpr_timespec now) { #define POLLOUT_CHECK (POLLOUT | POLLHUP | POLLERR) -#define POLLIN_CHECK (POLLIN | POLLHUP | POLLERR) +#define POLLIN_CHECK (POLLIN | POLLHUP | POLLERR) struct pollfd pfd[3]; grpc_fd *fd; diff --git a/src/core/iomgr/pollset_posix.h b/src/core/iomgr/pollset_posix.h index 762582c79d..d375207643 100644 --- a/src/core/iomgr/pollset_posix.h +++ b/src/core/iomgr/pollset_posix.h @@ -114,7 +114,8 @@ int grpc_poll_deadline_to_millis_timeout(gpr_timespec deadline, #define GRPC_POLLSET_CAN_KICK_SELF 1 #define GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP 2 -void grpc_pollset_kick_ex(grpc_pollset *p, grpc_pollset_worker *specific_worker, gpr_uint32 flags); +void grpc_pollset_kick_ex(grpc_pollset *p, grpc_pollset_worker *specific_worker, + gpr_uint32 flags); /* turn a pollset into a multipoller: platform specific */ typedef void (*grpc_platform_become_multipoller_type)(grpc_exec_ctx *exec_ctx, |