Re: [exim] using perl

Top Page
Delete this message
Reply to this message
Author: Tom Bombadil
Date:  
To: exim-users
Subject: Re: [exim] using perl


Mike Cardwell wrote:
> * on the Fri, Mar 23, 2007 at 12:33:07PM -0700, Tom Bombadil wrote:
>
>> We are using perl to call a "webservice" for recipient checking, home
>> directories, etc instead of LDAP, or SQL...
>>
>> The question is: Can we somehow pre-connect once at startup using perl,
>> so we avoid the overhead of a new TCP connection on every query?
>
> Make the connection the first time the subroutine is called, and store
> it in a global variable. Eg:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> my $sock;
>
> sub first_sub {
>    my $sock = get_sock();
>    # do stuff
> }

>
> sub second_sub {
>    my $sock = get_sock();
>    # do other stuff
> }

>
> sub conn {
>    unless( defined $sock ){
>       # Set up your socket here and store in $sock
>    }
>    return $sock;
> }

>
> Note. The process that delivers the message is often different to the
> one that accepts the message so if you're performing webservice lookups
> in both the routers and the acl's you're going to make multiple
> connections.
>
> Personally I would write a standalone multithreaded daemon for this,
> and talk to it using a network connection with ${readsocket} that
> way you can maintain your own pool of connections to the web service
> that aren't constantly opening and closing, and you can share a cache
> between multiple deliveries/mail servers.
>
> *cough* I'm available for contract work ;)
>
> Mike
>


I see. That sounds great. I was actually wondering if global variables
could be used at all. Thanks a lot Mike.