Showing posts sorted by relevance for query server.pl. Sort by date Show all posts
Showing posts sorted by relevance for query server.pl. Sort by date Show all posts

Friday, August 28, 2009

ぱぱネット(仮)さんのperlrtmp改造

perlrtmpに複数から使用していて、一方が無線LANで通信が滞りがちになると、他方の接続にも影響する。
なので、perlrtmpをinetd対応に改造しようかと思っていたところ、ぱぱネット(仮)様が、接続ごとに子プロセスに分ける改造をされていたので、いただいた。多謝。
その他にもいろいろ改造されたようだが、とりあえず子プロセスの部分だけ頂くことに。必要なのはperlrtmp.pl のみ。これを少々書き換えてserver.plとして使用すると、一方の接続の停滞に影響されないようになったようだ。いまのところゾンビも発生せずうまくいっている。多分接続数増加への耐性も上がっているだろう。

--- perlrtmp.pl 2009-07-25 09:51:05.000000000 +0900
+++ server.pl 2009-08-28 23:46:31.000000000 +0900
@@ -8,15 +8,14 @@
use POSIX ":sys_wait_h";

my $dir = $ARGV[0];
-my $port = $ARGV[1];
-my $dbn = $ARGV[2];

-if ($dir eq '' || $port eq '') {
- die "Usage: $0 <document> <server> <session>\n";
+if ($dir eq '') {
+ die "Usage: $0 <document>\n";
} else {
$dir =~ s/\/$//;
}

+my $port = '1935';
my $lsn = new IO::Socket::INET(Listen => 1, LocalPort => $port, Reuse => 1) or die;
my $sel = new IO::Select($lsn);

@@ -31,7 +30,7 @@
warn "[socket] connect from ", $new->peerhost, "\n";
$pidtable{$pid} = 1;
} elsif (defined $pid) {
- my $rtmp = RTMP->new($new, $dir, $dbn);
+ my $rtmp = RTMP->new($new, $dir);
my $cosel = new IO::Select($new);

while (1) {