Skip to content

Commit

Permalink
Fix sentinel position in sample u2u server
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
greghudson committed Jun 13, 2013
1 parent e51c089 commit 0903006
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/appl/user_user/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0903006

Please sign in to comment.