From: Greg Hudson Date: Thu, 13 Jun 2013 15:06:23 +0000 (-0400) Subject: Fix sentinel position in sample u2u server X-Git-Tag: krb5-1.12-alpha1~131 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0903006d9aef36b58d6ee7dfa5b10771add92279;p=thirdparty%2Fkrb5.git Fix sentinel position in sample u2u server Print "Server started" after calling listen(), or there wil be a race where the client tries to connect before there is a listen queue and gets ECONNREFUSED. --- diff --git a/src/appl/user_user/server.c b/src/appl/user_user/server.c index 3c844d82d5..dbff68e64a 100644 --- a/src/appl/user_user/server.c +++ b/src/appl/user_user/server.c @@ -95,14 +95,14 @@ int main(argc, argv) com_err("uu-server", errno, "binding socket"); exit(3); } - - printf("Server started\n"); - fflush(stdout); - if (listen(sock, 1) == -1) { com_err("uu-server", errno, "listening"); exit(3); } + + printf("Server started\n"); + fflush(stdout); + if ((acc = accept(sock, (struct sockaddr *)&f_inaddr, &namelen)) == -1) { com_err("uu-server", errno, "accepting"); exit(3);