diff options
author | David Klempner <klempner@google.com> | 2016-11-15 17:51:45 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-15 17:51:45 -0800 |
commit | d9190bd53b69b1f16c501d3a8f348d9598940ec8 (patch) | |
tree | f42e38c721080335f9ca12b10fd5ba2004071c22 /test/core | |
parent | c80fa2f673d92fdbcb30b86336c7f98a7de02ec6 (diff) | |
parent | c4151554d66f1f5213563b1b40781d7be47d6c22 (diff) |
Merge pull request #8654 from dklempner/low_level_ping_pong
Fix error checking in low_level_ping_pong_benchmark
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/network_benchmarks/low_level_ping_pong.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/test/core/network_benchmarks/low_level_ping_pong.c b/test/core/network_benchmarks/low_level_ping_pong.c index 9038d07675..0b2a920873 100644 --- a/test/core/network_benchmarks/low_level_ping_pong.c +++ b/test/core/network_benchmarks/low_level_ping_pong.c @@ -56,6 +56,7 @@ #include <grpc/support/thd.h> #include <grpc/support/time.h> #include <grpc/support/useful.h> +#include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/socket_utils_posix.h" typedef struct fd_pair { @@ -229,12 +230,12 @@ static int blocking_write_bytes(struct thread_args *args, char *buf) { on the scenario we're using. */ static int set_socket_nonblocking(thread_args *args) { - if (!grpc_set_socket_nonblocking(args->fds.read_fd, 1)) { - gpr_log(GPR_ERROR, "Unable to set socket nonblocking: %s", strerror(errno)); + if (!GRPC_LOG_IF_ERROR("Unable to set read socket nonblocking", + grpc_set_socket_nonblocking(args->fds.read_fd, 1))) { return -1; } - if (!grpc_set_socket_nonblocking(args->fds.write_fd, 1)) { - gpr_log(GPR_ERROR, "Unable to set socket nonblocking: %s", strerror(errno)); + if (!GRPC_LOG_IF_ERROR("Unable to set write socket nonblocking", + grpc_set_socket_nonblocking(args->fds.write_fd, 1))) { return -1; } return 0; @@ -347,10 +348,16 @@ static int create_listening_socket(struct sockaddr *port, socklen_t len) { goto error; } - if (!grpc_set_socket_cloexec(fd, 1) || !grpc_set_socket_low_latency(fd, 1) || - !grpc_set_socket_reuse_addr(fd, 1)) { - gpr_log(GPR_ERROR, "Unable to configure socket %d: %s", fd, - strerror(errno)); + if (!GRPC_LOG_IF_ERROR("Failed to set listening socket cloexec", + grpc_set_socket_cloexec(fd, 1))) { + goto error; + } + if (!GRPC_LOG_IF_ERROR("Failed to set listening socket low latency", + grpc_set_socket_low_latency(fd, 1))) { + goto error; + } + if (!GRPC_LOG_IF_ERROR("Failed to set listening socket reuse addr", + grpc_set_socket_reuse_addr(fd, 1))) { goto error; } @@ -386,8 +393,12 @@ static int connect_client(struct sockaddr *addr, socklen_t len) { goto error; } - if (!grpc_set_socket_cloexec(fd, 1) || !grpc_set_socket_low_latency(fd, 1)) { - gpr_log(GPR_ERROR, "Failed to configure socket"); + if (!GRPC_LOG_IF_ERROR("Failed to set connecting socket cloexec", + grpc_set_socket_cloexec(fd, 1))) { + goto error; + } + if (!GRPC_LOG_IF_ERROR("Failed to set connecting socket low latency", + grpc_set_socket_low_latency(fd, 1))) { goto error; } |