Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Oct 1999 20:18:01 -0400
From:      Christopher Masto <chris@netmonger.net>
To:        Brian Somers <brian@Awfulhak.org>, Ernie Elu <ernie@spooky.eis.net.au>
Cc:        freebsd-net@FreeBSD.ORG
Subject:   Re: Modem race with Multilink PPP
Message-ID:  <19991011201800.A11154@netmonger.net>
In-Reply-To: <199910110046.BAA01324@hak.lan.Awfulhak.org>; from Brian Somers on Mon, Oct 11, 1999 at 01:46:16AM %2B0100
References:  <199910092323.JAA18223@spooky.eis.net.au> <199910110046.BAA01324@hak.lan.Awfulhak.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--envbJBWh7q8WU6mo
Content-Type: text/plain; charset=us-ascii

On Mon, Oct 11, 1999 at 01:46:16AM +0100, Brian Somers wrote:
> This is a known problem (well, to me anyway).
> 
> Ppp will attempt to bind() a local domain socket when MP is 
> established.  If bind() fails, it'll try to connect(), otherwise 
> it'll try to listen().  If two processes are doing this at the same 
> time, one bind() succeeds, but the connect() of the failed process 
> happens before the servers listen() and fails :-(

IDKWITA, but from experimentation, the connect() should block for a
while and succeed shortly after the other process calls listen().
-- 
Christopher Masto         Senior Network Monkey      NetMonger Communications
chris@netmonger.net        info@netmonger.net        http://www.netmonger.net

Free yourself, free your machine, free the daemon -- http://www.freebsd.org/

--envbJBWh7q8WU6mo
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="sock_race.pl"

#!/usr/local/bin/perl -w

use IO::Socket;
use strict;

fork ? &parent : &child;

sub parent {
  print "P $$: parent\n";
  my $proto = getprotobyname('tcp');
  my $s = new IO::Socket;
  $s->socket(AF_INET, SOCK_STREAM, $proto) or die "P $$: socket: $!";
  $s->bind(pack_sockaddr_in(7890, INADDR_ANY)) or die "P $$: bind: $!";
  print "P $$: waiting..\n";
  sleep 5;
  print "P $$: listening.\n";
  $s->listen(5);
  print "P $$: waiting..\n";
  sleep 30;
  print "P $$: done\n";
}

sub child {
  print "C $$: child\n";
  sleep 1;
  print "C $$: connecting..\n";
  my $c = new IO::Socket::INET(Proto => "tcp", PeerAddr => "localhost:7890")
    or die "C $$: connect: $!";
  print "C $$: done.\n";
}

--envbJBWh7q8WU6mo--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991011201800.A11154>