Thread

Posted on Fri Mar 9 21:41:06 2007 by jesus144
Segmentation fault when I use client socket in a subroutine
Good evening,
I have a script which work properly with a IO::Socket::INET. I'm trying to encrypt the communication using IO::Socket::SSL. After socket building, I wait for a connection with:

while (my $sock = $server->accept()) { print ">New connection\n"; threads->new( \&perform, $sock, $self); }

When the perform method runs, I can not access to $sock without having a Segementation Fault (then the script crash). The code of my subroutine is clean, if I replace subroutine call by the code, everything works properly... It really seems to be a problem passing the socket to the perform method.
How can I pass the socket to the subroutine???
Thank you very much :-)
Direct Responses: 4939 | Write a response
Posted on Fri Apr 20 15:07:33 2007 by noxxi in response to 4534
Re: Segmentation fault when I use client socket in a subroutine
IO::Socket::SSL is not thread safe. From the IO::Socket::SSL manpage:
| IO::Socket::SSL is not threadsafe. This is because IO::Socket::SSL is based on Net::SSLeay | which uses a global object to access some of the API of openssl and is therefore not | threadsafe.
Write a response