Multithreading okay

This commit is contained in:
Thomas Schwery 2010-08-15 19:30:07 +02:00
parent eb48e9e8d7
commit bd2ba4b7da

View file

@ -7,7 +7,6 @@
# TODO:
# - Support for a list of tags
# - Cleanup on ctrl-c
# - Multithreading
# - ...
use strict;
@ -19,8 +18,9 @@ use HTML::FormatText;
use Text::Wrap;
use Date::Parse;
use Date::Format;
use threads;
our $port = 70;
our $port = 7071;
our %entries = ();
$SIG{INT} = \&signal_handler_interrupt;
@ -32,6 +32,16 @@ drop_privileges('nobody');
while (1) {
my $listen_socket = $socket->accept();
print "New incoming connection ...\n";
my $thr = threads->create(\&connection_thread, $listen_socket);
print "Joining ...";
$thr->join();
print "Joined\n";
}
sub connection_thread {
my ($listen_socket) = @_;
print "New Thread\n";
$_ = <$listen_socket>;
s/\r*\n*//g;
s/\t.*//g; # Don't care about the parameters now ...
@ -58,6 +68,8 @@ while (1) {
$listen_socket->send($blog_entries . "\r\n");
$listen_socket->send("\r\n.\r\n");
}
$listen_socket->close();
}
sub generate_header {