diff mbox

[perftest,21/23] perftest_communication: check for error calling setsockopt()

Message ID 1471541538-20270-22-git-send-email-jarod@redhat.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Jarod Wilson Aug. 18, 2016, 5:32 p.m. UTC
CC: Gil Rockah <gilr@mellanox.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
---
 src/perftest_communication.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/src/perftest_communication.c b/src/perftest_communication.c
index b66801c..6b3b1d9 100755
--- a/src/perftest_communication.c
+++ b/src/perftest_communication.c
@@ -686,7 +686,11 @@  static int ethernet_server_connect(struct perftest_comm *comm)
 
 		if (sockfd >= 0) {
 			n = 1;
-			setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n);
+			if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n)) {
+				freeaddrinfo(res);
+				close(sockfd);
+				return 1;
+			}
 			if (!bind(sockfd, t->ai_addr, t->ai_addrlen))
 				break;
 			close(sockfd);