Skip to content

Commit

Permalink
Fixed accept() behaviour.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Mar 29, 2003
1 parent a9b1c68 commit 8c02123
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion IcculusNews_daemon.pl
Expand Up @@ -1667,6 +1667,7 @@ sub reap_kids {

syslog_and_die("couldn't create listen socket: $!") if (not $listensock);

my $selection = new IO::Select( $listensock );
drop_privileges();

do_log(syslogDaemon, "Now accepting connections (max $max_connects" .
Expand All @@ -1677,8 +1678,15 @@ sub reap_kids {
# prevent connection floods.
sleep(1) while (scalar(@kids) >= $max_connects);

# if timed out, do upkeep and try again.
1 while not $selection->can_read(999999);

# we've got a connection!
my $client = $listensock->accept();
syslog_and_die("accept() failed: $!") if (not $client);
if (not $client) {
syslog("info", "accept() failed: $!") if ($use_syslog);
next;
}

my $ip = $client->peerhost();
syslog("info", "connection from $ip") if ($use_syslog);
Expand Down

0 comments on commit 8c02123

Please sign in to comment.