#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    7
    Rep Power
    0

    Timeout with alarm inside a thread?


    Here is where I create my threads:
    Code:
    # %FILERS declared as shared
    my %FILERS : shared = ();                                                                                              
    my %THREADS         = (); 
    
    foreach my $filer (sort keys %FILERS) {
        my $thread = threads->create(\&filerCollect, $filer, $OPTS{sshtimeout});
        $THREADS{$filer}{'tid'} = $thread->tid();                                                                                                                            
        $threadcnt++;                                                                                                                                                        
    }
    I have the following code that sits inside the filerCollect() function. I've already verified that my values passed to this function are valid so that isn't the problem.

    Code:
        eval {
            local $SIG{ALRM} = sub { die "cmdtimeout"; };
            alarm($timeout);
            @DATA = `$OPTS{'sshcmd'} -l $OPTS{'sshuser'} $filer < $OPTS{'worker'}`;
            $retcode = $? >> 8;
            alarm(0);
        };
    I'm using the following versions of Perl and modules:
    Threads = 1.89
    Threads:Shared = 1.43
    Perl: = 5.008008
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    833
    Rep Power
    496
    Please detail the error that you get.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    7
    Rep Power
    0
    I don't get an error, the timeout simply does not work. There is one filer that takes about 15min for this to run and with timeout set to 60 is just keeps chugging for 15 minutes.

IMN logo majestic logo threadwatch logo seochat tools logo