diff options
author | brian <brian@FreeBSD.org> | 1999-11-30 23:52:37 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-11-30 23:52:37 +0000 |
commit | e483373e23122f0a1d3c0568ec6bedec3e5c1430 (patch) | |
tree | 76c1aa752df58118e7a6165e3ec5f29405020d34 /usr.sbin/ppp/mp.c | |
parent | 047f08a518948b2395b1d36dd09e2d25c66e4d3d (diff) | |
download | FreeBSD-src-e483373e23122f0a1d3c0568ec6bedec3e5c1430.zip FreeBSD-src-e483373e23122f0a1d3c0568ec6bedec3e5c1430.tar.gz |
Change the way we transfer links (again). The previous
method avoided all race conditions, but suffered from
sometimes running out of buffer space if enough clients
were piled up at the same time.
Now, the client pushes the link descriptor, one end of a
socketpair() and the ppp version via sendmsg() at the
server. The server replies with a pid. The client then
transfers any link lock with uu_lock_txfr() and writev()s
the actual link contents. The socketpair is now the only
place we need to have large socket buffers and the bind()ed
socket can keep the default 4k buffer while still handling
around 90 racing clients.
Diffstat (limited to 'usr.sbin/ppp/mp.c')
-rw-r--r-- | usr.sbin/ppp/mp.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c index e030e35..516255c 100644 --- a/usr.sbin/ppp/mp.c +++ b/usr.sbin/ppp/mp.c @@ -1046,7 +1046,7 @@ mpserver_Init(struct mpserver *s) int mpserver_Open(struct mpserver *s, struct peerid *peer) { - int f, l, bufsz; + int f, l; mode_t mask; if (s->fd != -1) { @@ -1076,17 +1076,10 @@ mpserver_Open(struct mpserver *s, struct peerid *peer) mask = umask(0177); /* - * Calculate how big a link is. It's vital that we set our receive - * buffer size before binding the socket, otherwise we'll end up with - * a sendmsg() failing with ENOBUFS. + * Try to bind the socket. If we succeed we play server, if we fail + * we connect() and hand the link off. */ - bufsz = bundle_LinkSize() + SOCKET_OVERHEAD; - log_Printf(LogDEBUG, "Setting MP socket buffer size to %d\n", bufsz); - if (setsockopt(s->fd, SOL_SOCKET, SO_RCVBUF, &bufsz, sizeof bufsz) == -1) - log_Printf(LogERROR, "setsockopt(SO_RCVBUF, %d): %s\n", bufsz, - strerror(errno)); - if (ID0bind_un(s->fd, &s->socket) < 0) { if (errno != EADDRINUSE) { log_Printf(LogPHASE, "mpserver: can't create bundle socket %s (%s)\n", @@ -1097,10 +1090,7 @@ mpserver_Open(struct mpserver *s, struct peerid *peer) return MPSERVER_FAILED; } - /* Ok, so we'll play sender... set the send buffer size */ - if (setsockopt(s->fd, SOL_SOCKET, SO_SNDBUF, &bufsz, sizeof bufsz) == -1) - log_Printf(LogERROR, "setsockopt(SO_SNDBUF, %d): %s\n", bufsz, - strerror(errno)); + /* So we're the sender */ umask(mask); if (ID0connect_un(s->fd, &s->socket) < 0) { log_Printf(LogPHASE, "mpserver: can't connect to bundle socket %s (%s)\n", |