ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/httpd.pl
(Generate patch)

Comparing Coro/myhttpd/httpd.pl (file contents):
Revision 1.39 by root, Sun Sep 2 12:23:04 2001 UTC vs.
Revision 1.40 by root, Mon Sep 3 00:06:06 2001 UTC

56 schedule; 56 schedule;
57 } 57 }
58 } 58 }
59} 59}
60 60
61sub listen_on {
62 my $listen = $_[0];
63
64 push @listen_sockets, $listen;
65
66 # the "main thread"
67 async {
68 slog 1, "accepting connections";
69 while () {
70 $connections->down;
71 push @newcons, [$listen->accept];
72 #slog 3, "accepted @$connections ".scalar(@pool);
73 if (@pool) {
74 (pop @pool)->ready;
75 } else {
76 async \&handler;
77 }
78
79 }
80 };
81}
82
61my $http_port = new Coro::Socket 83my $http_port = new Coro::Socket
62 LocalAddr => $SERVER_HOST, 84 LocalAddr => $SERVER_HOST,
63 LocalPort => $SERVER_PORT, 85 LocalPort => $SERVER_PORT,
64 ReuseAddr => 1, 86 ReuseAddr => 1,
65 Listen => 50, 87 Listen => 50,
66 or die "unable to start server"; 88 or die "unable to start server";
67 89
68push @listen_sockets, $http_port; 90listen_on $http_port;
91
92my $http_port = new Coro::Socket
93 LocalAddr => $SERVER_HOST,
94 LocalPort => $SERVER_PORT2,
95 ReuseAddr => 1,
96 Listen => 50,
97 or die "unable to start server";
98
99listen_on $http_port;
69 100
70our $NOW; 101our $NOW;
71our $HTTP_NOW; 102our $HTTP_NOW;
72 103
73Event->timer(interval => 1, hard => 1, cb => sub { 104Event->timer(interval => 1, hard => 1, cb => sub {
74 $NOW = time; 105 $NOW = time;
75 $HTTP_NOW = time2str $NOW; 106 $HTTP_NOW = time2str $NOW;
76})->now; 107})->now;
77
78# the "main thread"
79async {
80 slog 1, "accepting connections";
81 while () {
82 $connections->down;
83 push @newcons, [$http_port->accept];
84 #slog 3, "accepted @$connections ".scalar(@pool);
85 if (@pool) {
86 (pop @pool)->ready;
87 } else {
88 async \&handler;
89 }
90
91 }
92};
93 108
94package conn; 109package conn;
95 110
96use Socket; 111use Socket;
97use HTTP::Date; 112use HTTP::Date;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines