Re: about SFTP and Thread dependency
- From: Jenda@xxxxxxxxxxx (Jenda Krynicky)
- Date: Wed, 28 May 2008 16:07:03 +0200
From: "Rajnikant" <rajnikant_jachak@xxxxxxxxxxxxxxxx>
I was trying to use SFTP in multithreaded application. I observed many
segmentation faults there.
Following is the code snipet:
use threads;
use Net::SFTP;
my $thrId = 1;
my $thread = threads->new (\&ftpThreadEntry,$thrId);
$thrId = 2;
print("Creating second thread \n");
my $thread1 = threads->new (\&ftpThreadEntry,$thrId);
sub ftpThreadEntry()
{
my $ThrId = shift;
print (" Thread $ThrId in ftpThreadEntry func\n");
}
$thread->join();
$thread1->join();
My Observations :
1. If we comment out 'use Net::SFTP' then this code runs fine without
segmentation fault.
2. If we uncomment 'use Net::SFTP', it gives segmentation fault :(.
Can anyone experienced such situation? Is there any dependency in these
modules or
I'm doing it wrong?
The module is most likely not threadsafe ... or uses something that
is not. Try to load it only in one thread and only after the other
thread was created.
Keep in mind that you'll have to use either
require Net::SFTP;
or
eval "use Net::SFTP";
otherwise the module would still be loaded too soon.
Jenda
===== Jenda@xxxxxxxxxxx === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
.
- References:
- about SFTP and Thread dependency
- From: Rajnikant
- about SFTP and Thread dependency
- Prev by Date: Re: about SFTP and Thread dependency
- Next by Date: efficient max() function from sort
- Previous by thread: Re: about SFTP and Thread dependency
- Next by thread: CGI-Ajax-0.701 - How Do I Capture Table Of Data Via Right-Mouse-Click, Then, 'Export to Excel'
- Index(es):