in reply to Re: Mail::Sender hangs once in a while
in thread Mail::Sender hangs once in a while

OK, you're right, I missed the logging information. Well, it tells me, that the script, WHEN it hangs, it hangs always between $Log->debug("attaching file..."); and $Log->debug("sending mail to $to ($task_id)");

The whole thing runs in an endless loop. And I don't know howto debug this issue through the perl debugger or strace, as it only occurs once in a while

Replies are listed 'Best First'.
Re^3: Mail::Sender hangs once in a while
by apl (Monsignor) on Oct 20, 2009 at 13:36 UTC
    You use
    filename="Fax '.scalar localtime ($task_info->{'task_ctime'}).'.pdf"; +type="PDF Document"', file => $attach_file
    Consider putting that concatenated value into a variable, checking for it's existence before you try to attach it, and displaying the filename in your $Log->debug("attaching file..."); statement.

    For that matter, what is the value of $attach_file, and how do the file and filename values interact?

      I believe filename is the name that is put into the email as the hypothetical filename of the attachement. $attach_file seems to me more interesting as it is the name of the actual file on disc that is attached. And $attach_file is printed into the logfile a bit earlier in this line: $Log->debug("found attach_file $attach_file");

      MichaelMeyer, apart from following apls advice you might check whether in the case that the script hangs the attach_file exists and is readable and the filename doesn't have some strangeness (i.e. is an empty string, begins with '..', '-' or has spaces in it).

        Given what Michael says about the log entries, it looks as if $Sender->Attach() is the location of interest.

        There are some classes of files that can block on reading, such a FIFO on Unix. Try a quick ls (or dir on windows) to peek at the file. Some variant of the following scrap

        -e $attachfile and do{ $ENV{f}=$attachfile; system('(echo file is "$f"; ls -l "$f" ) 2>&1 >> EXTRA_DEBUG_LS_OUT +PUT') };

        But it's funny: I wouldn't use fifo's in mailing/pdf-creation scenarios.

        My other guess would be that we've e.g. '|' at the end of name and the module allows unsafe 2-argument open. In this case, the forked process creating the pdf might hang (check for child processes, e.g. with ps).

        But that depends on some still missing parts of the big picture surrounding what you've already told us.

        HTH
        Peter

        PS: Micheal, <READMORE> is a good friend of us monks and helps with browsing and saving screen real-estate by allowing optional display of long listings :). Thx!