aboutsummaryrefslogtreecommitdiffstats
path: root/erts/epmd
diff options
context:
space:
mode:
authorSteve Vinoski <[email protected]>2010-07-14 10:10:10 -0400
committerPatrik Nyblom <[email protected]>2011-01-11 17:10:32 +0100
commit2b021d21d7d084196560f50f392b1c4962094d99 (patch)
tree768a811d78782b722af6e42b33dde86e5a4d6360 /erts/epmd
parentc6abed0fa0cbda3247bfd935bdc325f8983320cc (diff)
downloadotp-2b021d21d7d084196560f50f392b1c4962094d99.tar.gz
otp-2b021d21d7d084196560f50f392b1c4962094d99.tar.bz2
otp-2b021d21d7d084196560f50f392b1c4962094d99.zip
check return value of epmd server listen() call
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.
Diffstat (limited to 'erts/epmd')
-rw-r--r--erts/epmd/src/epmd_srv.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/erts/epmd/src/epmd_srv.c b/erts/epmd/src/epmd_srv.c
index ef471a473a..6b3900fae2 100644
--- a/erts/epmd/src/epmd_srv.c
+++ b/erts/epmd/src/epmd_srv.c
@@ -157,8 +157,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);