Subject: | IO::Socket::SSL not threadsave? |
Date: | Thu, 03 Aug 2006 10:32:14 +0200 |
To: | bug-IO-Socket-SSL [...] rt.cpan.org |
From: | Nicolas Lerch <nicolas [...] hni.uni-paderborn.de> |
Hallo,
I have tried to build a multi threaded SSL server but every time a
client tries to connect the server crashes with a segmentation fault:
Server:
nicolas@plucky[perl]>>./ssl_server.pl
Enter PEM pass phrase:
Client:
nicolas@plucky[perl]>>./ssl_client.pl
write_all VM at entry=vm_unknown
partial `Hallo
'
written so far 6:6 bytes (VM=vm_unknown)
nicolas@plucky[perl]>>
Server:
Segmentation fault
nicolas@plucky[perl]>>
I have tested it with the versions 0.96 and 0.994 of the IO::Socket::SSL
module. My perl version is 5.8.4 running on Debian Linux with 2.6.15 kernel.
Below is the code for the client and the server. The same code without
threads works as it should.
Server:
---------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use threads;
use IO::Socket::SSL qw(debug4);
my $listen = new IO::Socket::SSL (
LocalPort => 6666,
Proto => 'tcp',
Listen => 10,
SSL_key_file => 'certs/test-key.pem',
SSL_cert_file => 'certs/test-cert.pem',
SSL_use_cert => 1,
SSL_ca_file => 'certs/testca-cacert.pem'
) or die "Error: $!\n";
while(my $socket = $listen->accept) {
async(\&receive, $socket)->detach;
}
sub receive {
my $socket = shift;
while (<$socket>) {
print "DATA: ".$_."\n";
}
}
---------------------------------------------------------------
Client:
---------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use threads;
use IO::Socket::SSL qw(debug4);
my $port = 6666;
my $server = 'plucky.hni.uni-paderborn.de';
my $sock = new IO::Socket::SSL (
PeerAddr => 'localhost',
PeerPort => 6666,
Proto => 'tcp',
Timeout => '5',
SSL_verify_mode => 0x01,
SSL_ca_file => 'certs/testca-cacert.pem'
);
my $select = IO::Select->new();
$select->add($sock);
print $sock "Hallo\n";
---------------------------------------------------------------
Best regards
Nicolas Lerch
--
======================================================
Nicolas Lerch
HNI Rechnerbetrieb
nicolas@hni.uni-paderborn.de
======================================================