Changeset 2363 in /cluster/svnroot


Ignore:
Timestamp:
Apr 20, 2010 2:43:34 PM (11 years ago)
Author:
fitz
Message:

Add delays to pkbcast's socket binding (#498)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bccd-ng/trunk/trees/bin/pkbcast

    r2207 r2363  
    2020        }
    2121
    22         syslog('err', "Could not create broadcast socket: %m")
    23         until $sock = new IO::Socket::INET (
    24                 PeerPort => $BCAST_PORT,
    25                 PeerAddr => inet_ntoa(INADDR_BROADCAST),
    26                 LocalHost => $ip,
    27                 Proto => 'udp',
    28                 Broadcast => 1);
     22        until ( $sock = new IO::Socket::INET (
     23                        PeerPort => $BCAST_PORT,
     24                        PeerAddr => inet_ntoa(INADDR_BROADCAST),
     25                        LocalHost => $ip,
     26                        Proto => 'udp',
     27                        Broadcast => 1) ) {
     28                syslog('err', "Could not create broadcast socket: %m");
     29                sleep $BCAST_INTERVAL;
     30        }
    2931
    3032        $hostname .= "\r\n";
     
    5658
    5759### Main ###
    58 $SIG{ALRM} = \&send_bcast;
    59 alarm $BCAST_INTERVAL;
    60 
    6160openlog("pkbcast", 'pid', 'user') or die "Could not establish connection to syslog";
    6261
     
    7069        my $list_sock;
    7170
    72         syslog('err', "Could not create listen socket: %m")
    73         until $list_sock = new IO::Socket::INET (
    74                 LocalPort => $BCAST_PORT,
    75                 LocalHost => inet_ntoa(INADDR_ANY),
    76                 Proto => 'udp');
     71        until ( $list_sock = new IO::Socket::INET (
     72                        LocalPort => $BCAST_PORT,
     73                        LocalHost => inet_ntoa(INADDR_ANY),
     74                        Proto => 'udp') ) {
     75                syslog('err', "Could not create listen socket: %m");
     76                sleep $BCAST_INTERVAL;
     77        }
     78
     79        # Set alarm for broadcasting
     80        $SIG{ALRM} = \&send_bcast;
     81        alarm $BCAST_INTERVAL;
    7782
    7883        # Won't return unless $list_sock unexpectedly closes,
Note: See TracChangeset for help on using the changeset viewer.