Skip to content
Snippets Groups Projects
Commit 24f0f57e authored by Sree Kuchibhotla's avatar Sree Kuchibhotla
Browse files

Moving the creation of epoll_fd to pollset_init() instead of

pollset_add_fd() [Verified stable. All tests pass]
parent f6a2adf0
No related branches found
No related tags found
No related merge requests found
...@@ -787,6 +787,9 @@ static void pollset_global_shutdown(void) { ...@@ -787,6 +787,9 @@ static void pollset_global_shutdown(void) {
static void kick_poller(void) { grpc_wakeup_fd_wakeup(&grpc_global_wakeup_fd); } static void kick_poller(void) { grpc_wakeup_fd_wakeup(&grpc_global_wakeup_fd); }
/* TODO: sreek. Try to Remove this forward declaration*/
static void multipoll_with_epoll_pollset_create_efd(grpc_pollset *pollset);
/* main interface */ /* main interface */
static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) { static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
...@@ -800,7 +803,9 @@ static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) { ...@@ -800,7 +803,9 @@ static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
pollset->idle_jobs.head = pollset->idle_jobs.tail = NULL; pollset->idle_jobs.head = pollset->idle_jobs.tail = NULL;
pollset->local_wakeup_cache = NULL; pollset->local_wakeup_cache = NULL;
pollset->kicked_without_pollers = 0; pollset->kicked_without_pollers = 0;
pollset->data.ptr = NULL; pollset->data.ptr = NULL;
multipoll_with_epoll_pollset_create_efd(pollset);
} }
/* TODO(sreek): Maybe merge multipoll_*_destroy() with pollset_destroy() /* TODO(sreek): Maybe merge multipoll_*_destroy() with pollset_destroy()
...@@ -1153,13 +1158,15 @@ static void finally_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, ...@@ -1153,13 +1158,15 @@ static void finally_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
} }
/* Creates an epoll fd and initializes the pollset */ /* Creates an epoll fd and initializes the pollset */
static void multipoll_with_epoll_pollset_create_efd(grpc_exec_ctx *exec_ctx, /* TODO: This has to be called ONLY from pollset_init function. and hence it
grpc_pollset *pollset) { * does not acquire any lock */
static void multipoll_with_epoll_pollset_create_efd(grpc_pollset *pollset) {
epoll_hdr *h = gpr_malloc(sizeof(epoll_hdr)); epoll_hdr *h = gpr_malloc(sizeof(epoll_hdr));
struct epoll_event ev; struct epoll_event ev;
int err; int err;
/* Ensuring that the pollset is infact empty (with no epoll fd either) */ /* TODO (sreek). remove this assert. Currently added this just to ensure that
* we do not overwrite h->epoll_fd without freeing the older one*/
GPR_ASSERT(pollset->data.ptr == NULL); GPR_ASSERT(pollset->data.ptr == NULL);
pollset->data.ptr = h; pollset->data.ptr = h;
...@@ -1188,10 +1195,10 @@ static void multipoll_with_epoll_pollset_create_efd(grpc_exec_ctx *exec_ctx, ...@@ -1188,10 +1195,10 @@ static void multipoll_with_epoll_pollset_create_efd(grpc_exec_ctx *exec_ctx,
static void multipoll_with_epoll_pollset_add_fd(grpc_exec_ctx *exec_ctx, static void multipoll_with_epoll_pollset_add_fd(grpc_exec_ctx *exec_ctx,
grpc_pollset *pollset, grpc_pollset *pollset,
grpc_fd *fd) { grpc_fd *fd) {
/* If there is no epoll fd on the pollset, create one */ GPR_ASSERT(pollset->data.ptr != NULL);
if (pollset->data.ptr == NULL) {
multipoll_with_epoll_pollset_create_efd(exec_ctx, pollset); /* TODO(sreek). Remove this unlock code (and also the code that acquires the
} * lock before calling multipoll_with_epoll_add_fd() function */
gpr_mu_unlock(&pollset->mu); gpr_mu_unlock(&pollset->mu);
finally_add_fd(exec_ctx, pollset, fd); finally_add_fd(exec_ctx, pollset, fd);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment