Skip to content

Commit

Permalink
check return value of epmd server listen() call
Browse files Browse the repository at this point in the history
The listen() call can fail due to a variety of conditions, so check
its return value and if it fails, print a suitable debug message if
appropriate and then exit. The exit values used are the same for those
already used for bind() failures: 0 if the error is EADDRINUSE, 1
otherwise.
  • Loading branch information
vinoski committed Jul 14, 2010
1 parent c4b4eda commit c5c8baa
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions erts/epmd/src/epmd_srv.c
Expand Up @@ -188,8 +188,20 @@ void run(EpmdVars *g)

dbg_printf(g,2,"starting");

listen(listensock, SOMAXCONN);

if(listen(listensock, SOMAXCONN) < 0)
{
if (errno == EADDRINUSE)
{
dbg_tty_printf(g,1,"there is already a epmd running at port %d",
g->port);
epmd_cleanup_exit(g,0);
}
else
{
dbg_perror(g,"failed to listen on socket");
epmd_cleanup_exit(g,1);
}
}

FD_ZERO(&g->orig_read_mask);
FD_SET(listensock,&g->orig_read_mask);
Expand Down

0 comments on commit c5c8baa

Please sign in to comment.