always use pss_obj_init

pull/10507/head
Craig Tiller 8 years ago
parent bcf8db50b9
commit bd412f9d3d
  1. 20
      src/core/lib/iomgr/ev_epollex_linux.c

@ -91,6 +91,14 @@ typedef struct pss_obj {
grpc_pollset_set *pss_master; grpc_pollset_set *pss_master;
} pss_obj; } pss_obj;
static void pss_obj_init(pss_obj *obj) {
gpr_mu_init(&obj->mu);
obj->pss_refs = 0;
obj->pss_next = NULL;
obj->pss_prev = NULL;
obj->pss_master = NULL;
}
/******************************************************************************* /*******************************************************************************
* Fd Declarations * Fd Declarations
*/ */
@ -288,13 +296,9 @@ static grpc_fd *fd_create(int fd, const char *name) {
if (new_fd == NULL) { if (new_fd == NULL) {
new_fd = gpr_malloc(sizeof(grpc_fd)); new_fd = gpr_malloc(sizeof(grpc_fd));
gpr_mu_init(&new_fd->po.mu);
} }
/* Note: It is not really needed to get the new_fd->po.mu lock here. If this pss_obj_init(&new_fd->po);
* is a newly created fd (or an fd we got from the freelist), no one else
* would be holding a lock to it anyway. */
gpr_mu_lock(&new_fd->po.mu);
gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1); gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1);
new_fd->fd = fd; new_fd->fd = fd;
@ -313,8 +317,6 @@ static grpc_fd *fd_create(int fd, const char *name) {
new_fd->freelist_next = NULL; new_fd->freelist_next = NULL;
new_fd->on_done_closure = NULL; new_fd->on_done_closure = NULL;
gpr_mu_unlock(&new_fd->po.mu);
char *fd_name; char *fd_name;
gpr_asprintf(&fd_name, "%s fd=%d", name, fd); gpr_asprintf(&fd_name, "%s fd=%d", name, fd);
grpc_iomgr_register_object(&new_fd->iomgr_object, fd_name); grpc_iomgr_register_object(&new_fd->iomgr_object, fd_name);
@ -525,7 +527,7 @@ static grpc_error *kick_poller(void) {
} }
static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) { static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
gpr_mu_init(&pollset->po.mu); pss_obj_init(&pollset->po);
pollset->epfd = epoll_create1(EPOLL_CLOEXEC); pollset->epfd = epoll_create1(EPOLL_CLOEXEC);
if (pollset->epfd < 0) { if (pollset->epfd < 0) {
GRPC_LOG_IF_ERROR("pollset_init", GRPC_OS_ERROR(errno, "epoll_create1")); GRPC_LOG_IF_ERROR("pollset_init", GRPC_OS_ERROR(errno, "epoll_create1"));
@ -787,7 +789,7 @@ static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
static grpc_pollset_set *pollset_set_create(void) { static grpc_pollset_set *pollset_set_create(void) {
grpc_pollset_set *pss = gpr_zalloc(sizeof(*pss)); grpc_pollset_set *pss = gpr_zalloc(sizeof(*pss));
gpr_mu_init(&pss->po.mu); pss_obj_init(&pss->po);
gpr_ref_init(&pss->refs, 1); gpr_ref_init(&pss->refs, 1);
pss->roots[PSS_POLLSET_SET] = &pss->po; pss->roots[PSS_POLLSET_SET] = &pss->po;
pss->po.pss_master = pss; pss->po.pss_master = pss;

Loading…
Cancel
Save