From 5e90c03acd2d20e2b307e2ed03383eed2d3a85b8 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 10 May 2017 16:36:10 -0700 Subject: [PATCH 1/2] Don't crate GRPC_OS_ERROR with a non-static string --- src/core/lib/iomgr/ev_epoll_linux.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/lib/iomgr/ev_epoll_linux.c b/src/core/lib/iomgr/ev_epoll_linux.c index e603a755937..fac4b112cb3 100644 --- a/src/core/lib/iomgr/ev_epoll_linux.c +++ b/src/core/lib/iomgr/ev_epoll_linux.c @@ -418,7 +418,7 @@ static void polling_island_add_fds_locked(polling_island *pi, grpc_fd **fds, &err_msg, "epoll_ctl (epoll_fd: %d) add fd: %d failed with error: %d (%s)", pi->epoll_fd, fds[i]->fd, errno, strerror(errno)); - append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc); + append_error(error, GRPC_OS_ERROR(errno, err_desc), err_msg); gpr_free(err_msg); } @@ -456,7 +456,7 @@ static void polling_island_add_wakeup_fd_locked(polling_island *pi, "error: %d (%s)", pi->epoll_fd, GRPC_WAKEUP_FD_GET_READ_FD(&global_wakeup_fd), errno, strerror(errno)); - append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc); + append_error(error, GRPC_OS_ERROR(errno, err_desc), err_msg); gpr_free(err_msg); } } @@ -477,7 +477,7 @@ static void polling_island_remove_all_fds_locked(polling_island *pi, "epoll_ctl (epoll_fd: %d) delete fds[%zu]: %d failed with " "error: %d (%s)", pi->epoll_fd, i, pi->fds[i]->fd, errno, strerror(errno)); - append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc); + append_error(error, GRPC_OS_ERROR(errno, err_desc), err_msg); gpr_free(err_msg); } @@ -507,7 +507,7 @@ static void polling_island_remove_fd_locked(polling_island *pi, grpc_fd *fd, &err_msg, "epoll_ctl (epoll_fd: %d) del fd: %d failed with error: %d (%s)", pi->epoll_fd, fd->fd, errno, strerror(errno)); - append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc); + append_error(error, GRPC_OS_ERROR(errno, err_desc), err_msg); gpr_free(err_msg); } } @@ -1435,7 +1435,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx, gpr_asprintf(&err_msg, "epoll_wait() epoll fd: %d failed with error: %d (%s)", epoll_fd, errno, strerror(errno)); - append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc); + append_error(error, GRPC_OS_ERROR(errno, err_desc), err_msg); } else { /* We were interrupted. Save an interation by doing a zero timeout epoll_wait to see if there are any other events of interest */ From b920d103de1c653c1c26791b2d71ef94c664dca3 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 10 May 2017 17:49:18 -0700 Subject: [PATCH 2/2] Copy error string in GRPC_OS_ERROR --- src/core/lib/iomgr/error.c | 2 +- src/core/lib/iomgr/ev_epoll_linux.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/lib/iomgr/error.c b/src/core/lib/iomgr/error.c index 5f2c989aad0..685581b5cb4 100644 --- a/src/core/lib/iomgr/error.c +++ b/src/core/lib/iomgr/error.c @@ -769,7 +769,7 @@ grpc_error *grpc_os_error(const char *file, int line, int err, GRPC_ERROR_INT_ERRNO, err), GRPC_ERROR_STR_OS_ERROR, grpc_slice_from_static_string(strerror(err))), - GRPC_ERROR_STR_SYSCALL, grpc_slice_from_static_string(call_name)); + GRPC_ERROR_STR_SYSCALL, grpc_slice_from_copied_string(call_name)); } #ifdef GPR_WINDOWS diff --git a/src/core/lib/iomgr/ev_epoll_linux.c b/src/core/lib/iomgr/ev_epoll_linux.c index fac4b112cb3..e603a755937 100644 --- a/src/core/lib/iomgr/ev_epoll_linux.c +++ b/src/core/lib/iomgr/ev_epoll_linux.c @@ -418,7 +418,7 @@ static void polling_island_add_fds_locked(polling_island *pi, grpc_fd **fds, &err_msg, "epoll_ctl (epoll_fd: %d) add fd: %d failed with error: %d (%s)", pi->epoll_fd, fds[i]->fd, errno, strerror(errno)); - append_error(error, GRPC_OS_ERROR(errno, err_desc), err_msg); + append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc); gpr_free(err_msg); } @@ -456,7 +456,7 @@ static void polling_island_add_wakeup_fd_locked(polling_island *pi, "error: %d (%s)", pi->epoll_fd, GRPC_WAKEUP_FD_GET_READ_FD(&global_wakeup_fd), errno, strerror(errno)); - append_error(error, GRPC_OS_ERROR(errno, err_desc), err_msg); + append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc); gpr_free(err_msg); } } @@ -477,7 +477,7 @@ static void polling_island_remove_all_fds_locked(polling_island *pi, "epoll_ctl (epoll_fd: %d) delete fds[%zu]: %d failed with " "error: %d (%s)", pi->epoll_fd, i, pi->fds[i]->fd, errno, strerror(errno)); - append_error(error, GRPC_OS_ERROR(errno, err_desc), err_msg); + append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc); gpr_free(err_msg); } @@ -507,7 +507,7 @@ static void polling_island_remove_fd_locked(polling_island *pi, grpc_fd *fd, &err_msg, "epoll_ctl (epoll_fd: %d) del fd: %d failed with error: %d (%s)", pi->epoll_fd, fd->fd, errno, strerror(errno)); - append_error(error, GRPC_OS_ERROR(errno, err_desc), err_msg); + append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc); gpr_free(err_msg); } } @@ -1435,7 +1435,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx, gpr_asprintf(&err_msg, "epoll_wait() epoll fd: %d failed with error: %d (%s)", epoll_fd, errno, strerror(errno)); - append_error(error, GRPC_OS_ERROR(errno, err_desc), err_msg); + append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc); } else { /* We were interrupted. Save an interation by doing a zero timeout epoll_wait to see if there are any other events of interest */