Mercurial > dovecot > core-2.2
comparison src/lib/network.c @ 14387:cd7e15b2d575
net_listen(): If bind(ip=any) fails with non-EADDRINUSE, don't crash.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 26 Mar 2012 17:01:21 +0300 |
parents | 98fd46f8d1ab |
children | fbb1ecb9b888 e4cc3f2b66e3 |
comparison
equal
deleted
inserted
replaced
14386:3980c025805c | 14387:cd7e15b2d575 |
---|---|
406 /* specify the address/port we want to listen in */ | 406 /* specify the address/port we want to listen in */ |
407 ret = bind(fd, &so.sa, SIZEOF_SOCKADDR(so)); | 407 ret = bind(fd, &so.sa, SIZEOF_SOCKADDR(so)); |
408 if (ret < 0) { | 408 if (ret < 0) { |
409 if (errno != EADDRINUSE) { | 409 if (errno != EADDRINUSE) { |
410 i_error("bind(%s, %u) failed: %m", | 410 i_error("bind(%s, %u) failed: %m", |
411 net_ip2addr(my_ip), *port); | 411 my_ip == NULL ? "" : net_ip2addr(my_ip), *port); |
412 } | 412 } |
413 } else { | 413 } else { |
414 /* get the actual port we started listen */ | 414 /* get the actual port we started listen */ |
415 len = SIZEOF_SOCKADDR(so); | 415 len = SIZEOF_SOCKADDR(so); |
416 ret = getsockname(fd, &so.sa, &len); | 416 ret = getsockname(fd, &so.sa, &len); |