From cb09e7009ecbccf772b1dd0cdd023181a8288840 Mon Sep 17 00:00:00 2001 From: Paul Marks Date: Wed, 23 Nov 2016 16:23:18 -0800 Subject: Fix a memory leak in grpc_udp_server_add_port() This occurred when running a QUIC test in an IPv6-only environment: E1123 16:04:20.282041 159850 heap-profile-table.cc:489] RAW: Leak of 1360 bytes in 17 objects allocated from: @ 0x7f160b8923ab gpr_malloc @ 0x7f160b8cff27 copy_error_and_unref @ 0x7f160b8d0151 grpc_error_set_str @ 0x7f160b8e3ff8 error_for_fd @ 0x7f160b8e3edd grpc_create_dualstack_socket @ 0x7f160b8ea5c3 grpc_udp_server_add_port @ 0x7f1627a65d20 grpc_server_add_quic_port @ 0x7f1627a6bea4 grpc::(anonymous namespace)::QuicServerCredentialsImpl::AddPortToServer() ... --- src/core/lib/iomgr/udp_server.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/core/lib/iomgr/udp_server.c') diff --git a/src/core/lib/iomgr/udp_server.c b/src/core/lib/iomgr/udp_server.c index fd0c7a0f9d..dd82563127 100644 --- a/src/core/lib/iomgr/udp_server.c +++ b/src/core/lib/iomgr/udp_server.c @@ -388,7 +388,9 @@ int grpc_udp_server_add_port(grpc_udp_server *s, /* Try listening on IPv6 first. */ addr = &wild6; // TODO(rjshade): Test and propagate the returned grpc_error*: - grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP, &dsmode, &fd); + GRPC_ERROR_UNREF( + grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP, + &dsmode, &fd)); allocated_port1 = add_socket_to_server(s, fd, addr, read_cb, orphan_cb); if (fd >= 0 && dsmode == GRPC_DSMODE_DUALSTACK) { goto done; @@ -402,7 +404,9 @@ int grpc_udp_server_add_port(grpc_udp_server *s, } // TODO(rjshade): Test and propagate the returned grpc_error*: - grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP, &dsmode, &fd); + GRPC_ERROR_UNREF( + grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP, + &dsmode, &fd)); if (fd < 0) { gpr_log(GPR_ERROR, "Unable to create socket: %s", strerror(errno)); } -- cgit v1.2.3 From 83b6e8e6152dd04e35d3221ecaa108f48c7e07a5 Mon Sep 17 00:00:00 2001 From: Paul Marks Date: Mon, 28 Nov 2016 16:10:27 -0800 Subject: Run clang-format on udp_server.c --- src/core/lib/iomgr/udp_server.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/core/lib/iomgr/udp_server.c') diff --git a/src/core/lib/iomgr/udp_server.c b/src/core/lib/iomgr/udp_server.c index dd82563127..3c24ea9afa 100644 --- a/src/core/lib/iomgr/udp_server.c +++ b/src/core/lib/iomgr/udp_server.c @@ -388,9 +388,8 @@ int grpc_udp_server_add_port(grpc_udp_server *s, /* Try listening on IPv6 first. */ addr = &wild6; // TODO(rjshade): Test and propagate the returned grpc_error*: - GRPC_ERROR_UNREF( - grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP, - &dsmode, &fd)); + GRPC_ERROR_UNREF(grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP, + &dsmode, &fd)); allocated_port1 = add_socket_to_server(s, fd, addr, read_cb, orphan_cb); if (fd >= 0 && dsmode == GRPC_DSMODE_DUALSTACK) { goto done; @@ -404,9 +403,8 @@ int grpc_udp_server_add_port(grpc_udp_server *s, } // TODO(rjshade): Test and propagate the returned grpc_error*: - GRPC_ERROR_UNREF( - grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP, - &dsmode, &fd)); + GRPC_ERROR_UNREF(grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP, + &dsmode, &fd)); if (fd < 0) { gpr_log(GPR_ERROR, "Unable to create socket: %s", strerror(errno)); } -- cgit v1.2.3