Re: [exim] Returning static strings from dlfunc?

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Janne Snabb
Date:  
À: exim-users
Sujet: Re: [exim] Returning static strings from dlfunc?
On 05/07/2012 05:37 PM, Phil Pennock wrote:
> On 2012-05-07 at 17:22 +0700, Janne Snabb wrote:
>> However if my dlfunc is called from acl_smtp_connect the current default
>> "store_pool" is set to POOL_MAIN and likewise if it is called from
>> acl_smtp_rcvd.
>
> What are you doing with the result?
>
> If you're setting an $acl_c_* variable, then the pool will be set to
> POOL_PERM.


I made now the following test dlfunc:

#include "local_scan.h"

int foobar(uschar **yield, int argc, uschar *argv[])
{
*yield = string_copy(US"foobar");

  log_write(0, LOG_MAIN,
      "POOL_PERM = %d, POOL_MAIN = %d, store_pool = %d, arg = %s",
      POOL_PERM, POOL_MAIN, store_pool, argv[0]);


return OK;
}

My ACLs are set up as follows:

acl_smtp_connect = acl_check_connect
acl_smtp_data = acl_check_data

And the ACLs itself:

acl_check_connect:
  warn
    set acl_c_foobar = ${dlfunc{/usr/lib/exim4/foobar.so}{foobar}{conn}}


acl_check_data:
  warn
    set acl_m_foobar = ${dlfunc{/usr/lib/exim4/foobar.so}{foobar}{data}}


This produces the following log entries:

2012-05-07 11:33:12 [7246] POOL_PERM = 1, POOL_MAIN = 0, store_pool = 0,
arg = conn
2012-05-07 11:33:14 [7246] 1SRMBm-0001ss-1w POOL_PERM = 1, POOL_MAIN =
0, store_pool = 0, arg = data

Thus looks like "store_pool" is 0 (POOL_MAIN) in both cases. Exim is not
automatically switching the pool when I set acl_c_* variable from SMTP
connect ACL.

Or maybe I am missing something? I am not referring to acl_c_foobar or
acl_m_foobar anywhere after setting them. I am assuming that Exim does
not realize this and does not optimize it on its own.

My ACLs contain other things as well, but they should be unrelated to
this. I am using Exim 4.76 as distributed by Ubuntu 12.04 x86_64 in
exim4-daemon-heavy package. "exim --version" outputs the following:

Exim version 4.76 #1 built 24-Nov-2011 07:42:08
Copyright (c) University of Cambridge, 1995 - 2007
Berkeley DB: Berkeley DB 5.1.25: (January 28, 2011)
Support for: crypteq iconv() IPv6 PAM Perl Expand_dlfunc GnuTLS
move_frozen_messages Content_Scanning DKIM Old_Demime
Lookups (built-in): lsearch wildlsearch nwildlsearch iplsearch cdb dbm
dbmnz dnsdb dsearch ldap ldapdn ldapm mysql nis nis0 passwd pgsql sqlite
Authenticators: cram_md5 cyrus_sasl dovecot plaintext spa
Routers: accept dnslookup ipliteral iplookup manualroute queryprogram
redirect
Transports: appendfile/maildir/mailstore/mbx autoreply lmtp pipe smtp
Fixed never_users: 0
Size of off_t: 8
Configuration file is /var/lib/exim4/config.autogenerated

> It's possible that the default pool should change for some ACLs, but I
> don't have enough context to know what problem you're encountering.


Looks like this is not happening.

> POOL_PERM lasts for the lifetime of the process, but Exim is a forking
> server, so each connection is handled in one process, and deliveries get
> fork/exec'd.


Ah, yes of course. Then using POOL_PERM in every case would not be such
a big sin... the leaked memory will not get accumulated over time.

>> Or should my dlfunc do some magic on its own to determine what
>> "store_pool" it should use, depending on which ACL is calling it?
>
> Almost certainly not; but it's possible that you should be temporarily
> setting the pool to POOL_PERM for your particular use-case, always.


This sounds sensible given the current situation.

--
Janne Snabb / EPIPE Communications
snabb@??? - http://epipe.com/