Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Thread-safe SSL IMAP

by gxbacher (Novice)
on Sep 21, 2011 at 16:37 UTC ( #927177=perlquestion: print w/ replies, xml ) Need Help??
gxbacher has asked for the wisdom of the Perl Monks concerning the following question:

I've run into problems (on Windows) using Mail::IMAPClient and Net::IMAP::Simple::SSL because IO-Socket-SSL isn't thread-safe. Does anybody know of a Perl IMAP module that is SSL-capable and doesn't use IO-Socket-SSL? Or how about a drop-in replacement for IO-Socket-SSL that is thread-safe? Thanks!

Comment on Thread-safe SSL IMAP
Replies are listed 'Best First'.
Re: Thread-safe SSL IMAP
by onelesd (Pilgrim) on Sep 21, 2011 at 17:39 UTC

    See this thread for a similar case.

    I ended up isolating the SSL bits of code in a separate script, and using bi-di IPC (see: IPC::Open2) to circumvent the issue of Crypt::SSLeay not being thread-safe. If you don't need bi-di communication, just use perl's open.

Re: Thread-safe SSL IMAP
by Anonymous Monk on Sep 21, 2011 at 16:57 UTC
    Then thread-safety isn't such a big deal if you do it like
    my $safeIfTheOnlyOne = threads->create('oneAndOnlyMailer', 'argument') +; sub oneAndOnlyMailer { require IO::Socket::SSL; require Mail::IMAPClient ; require Net::IMAP::Simple::SSL; ... }

    If you need multiple mailers, then it would pay to make IO::Socket::SSL thread-safe

Re: Thread-safe SSL IMAP
by Corion (Pope) on Sep 22, 2011 at 07:12 UTC

    If you need to multiplex more than one IMAP connection, or do some fake "multiple email" thing, it might be worth it to look into AnyEvent::TLS, which provides SSL sockets for AnyEvent and potentially Net::Async::IMAP::Client, which seems to be based on IO::Async, which works with AnyEvent.

Re: Thread-safe SSL IMAP
by gxbacher (Novice) on Jan 26, 2012 at 15:52 UTC

    Thanks for all the suggestions. Since I'm stuck on Windows, I ended up creating separate processes instead of threads or using forking.

    I'm using Win32::Process to kick off my "children", and that returns an object I can use to manage them if they go astray.

    I'm using Win32::MMF for shared memory, sort of.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://927177]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2015-07-31 11:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls