This is an automated email from the ASF dual-hosted git repository.

shinrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 9b3a8a2  Fix post_error test by initializating the address length of 
the accept call.
9b3a8a2 is described below

commit 9b3a8a2d1faf291cdfa3ad1cea46c0a75d7fd7b6
Author: [email protected] <[email protected]>
AuthorDate: Tue Apr 17 14:09:43 2018 -0500

    Fix post_error test by initializating the address length of the accept call.
---
 tests/gold_tests/post_error/post_server.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tests/gold_tests/post_error/post_server.c 
b/tests/gold_tests/post_error/post_server.c
index bff4889..cb4976f 100644
--- a/tests/gold_tests/post_error/post_server.c
+++ b/tests/gold_tests/post_error/post_server.c
@@ -41,18 +41,27 @@ main(int argc, char *argv[])
   printf("Starting...\n");
 
   int listenfd = socket(AF_INET, SOCK_STREAM, 0);
+
+  int optval = 1;
+  setsockopt(listenfd, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval));
+
   struct sockaddr_in serv_addr, peer_addr;
   socklen_t peer_len;
-
   serv_addr.sin_family      = AF_INET;
   serv_addr.sin_addr.s_addr = INADDR_ANY;
   int port                  = atoi(argv[1]);
   serv_addr.sin_port        = htons(port);
-  bind(listenfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
-  listen(listenfd, 10);
+  if (bind(listenfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
+    perror("bind failed");
+    exit(1);
+  }
+  if (listen(listenfd, 10) < 0) {
+    perror("listen failed");
+    exit(1);
+  }
 
   for (;;) {
-    socklen_t client_len;
+    socklen_t client_len = sizeof(struct sockaddr_in);
     struct sockaddr_in client;
     int client_sock = accept(listenfd, reinterpret_cast<struct sockaddr 
*>(&client), &client_len);
     if (client_sock < 0) {

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to