diff options
author | brian <brian@FreeBSD.org> | 1999-03-08 22:35:19 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-03-08 22:35:19 +0000 |
commit | e4123152162992340d7f201722952d74f139b145 (patch) | |
tree | d29d0357a207badba1ec5d6947299a5701316c8c /usr.sbin/ppp/server.c | |
parent | c269952e177a5b66ae3bc2306ada5ecc1dc39515 (diff) | |
download | FreeBSD-src-e4123152162992340d7f201722952d74f139b145.zip FreeBSD-src-e4123152162992340d7f201722952d74f139b145.tar.gz |
Don't destroy the old server socket another ``set server''
call fails.
Diffstat (limited to 'usr.sbin/ppp/server.c')
-rw-r--r-- | usr.sbin/ppp/server.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.sbin/ppp/server.c b/usr.sbin/ppp/server.c index 5ae15f5..bb5b96a 100644 --- a/usr.sbin/ppp/server.c +++ b/usr.sbin/ppp/server.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: server.c,v 1.23 1998/08/02 13:01:16 brian Exp $ + * $Id: server.c,v 1.24 1999/03/07 11:54:43 brian Exp $ */ #include <sys/types.h> @@ -191,7 +191,6 @@ server_LocalOpen(struct bundle *bundle, const char *name, mode_t mask) return 0; } - server_Close(bundle); memset(&server.ifsun, '\0', sizeof server.ifsun); server.ifsun.sun_len = strlen(name); if (server.ifsun.sun_len > sizeof server.ifsun.sun_path - 1) { @@ -224,6 +223,7 @@ server_LocalOpen(struct bundle *bundle, const char *name, mode_t mask) ID0unlink(name); return 5; } + server_Close(bundle); server.fd = s; server.rm = server.ifsun.sun_path; log_Printf(LogPHASE, "Listening at local socket %s.\n", name); @@ -255,7 +255,8 @@ server_TcpOpen(struct bundle *bundle, int port) return 8; } if (listen(s, 5) != 0) { - log_Printf(LogERROR, "Tcp: Unable to listen to socket - BUNDLE overload?\n"); + log_Printf(LogERROR, "Tcp: Unable to listen to socket: %s\n", + strerror(errno)); close(s); return 9; } @@ -270,11 +271,16 @@ int server_Close(struct bundle *bundle) { if (server.fd >= 0) { - close(server.fd); if (server.rm) { - ID0unlink(server.rm); + struct sockaddr_un un; + int sz = sizeof un; + + if (getsockname(server.fd, (struct sockaddr *)&un, &sz) == 0 && + un.sun_family == AF_LOCAL && sz == sizeof un) + ID0unlink(un.sun_path); server.rm = NULL; } + close(server.fd); server.fd = -1; server.port = 0; /* Drop associated prompts */ |