Hi Folks,

imagine the following situation:

You are running two qmail instances on the same box. One ist listed as MX
for your domains, the second one is used by your customers to carry in mails
via smtp. If you don't use clustering everything is fine: you are just
using the same control/locals and control/rcpthosts for both instances
(rcpthosts should not be needed, though, as only customers having
RELAYCLIENT set should send mails, but this does not matter here). Both
qmail instances deliver directly to the Maildirs, which is no problem due to
the lock-free Maildir design.
If you turn on clustering there will be an extra delivery for each mail in
one of those two instances: qmail-lspawn detects the difference between the
mailHost attribute in LDAP and control/me and forwards the mail via qmqp to
the second instance on the same machine. This is unneeded and of course has a
performance penalty. You could of course link qmail-queue from one instance
to the other to only have obe queue, but having two independent queues is
one of the targets in this setup.
The small patch below adds a new control file "ldapmailhost". qmail-lspawn
now delivers locally if mailHost=control/me. With this patch, it delivers
locally if either mailHost=control/me or mailHost=control/ldapmailhost.
The patch is small and IMHO clean. It has no disadvantages if
control/ldapmailhost does not exist, and I'd love to see it included in the
next release instead of maintaining my 6th third-party patch.

btw, the scenario above applies also if you are running more than one box
with direct access to the same maildirs, e. g. over NFS, but need
clustering, too, e. g. if you have a box located in another country and want
to store some mailboxes there.

An implementation sidenote: I decided to default control/ldapmailhost to
control/me so the behaviour on accounts with empty mailHost attributes 
does not change.

Greetings

Henning


diff -u qmail/qldap-ldaplib.c qmail-customer/qldap-ldaplib.c
--- qmail/qldap-ldaplib.c       Mon Aug  6 14:43:14 2001
+++ qmail-customer/qldap-ldaplib.c      Mon Aug  6 21:22:19 2001
@@ -31,6 +31,7 @@
 
 /* internal data structures */
 stralloc qldap_me = {0};                               /* server name, also external 
visible */
+stralloc qldap_mailhost = {0};                  /* LDAP_MAILHOST for clustering, 
+defaults to me */
 stralloc qldap_objectclass = {0};              /* the search objectclass, external 
visible */
 
 /* internal use only vars */
@@ -89,6 +90,12 @@
        if (!stralloc_0(&qldap_me)) return -1;
        log(64, "init_ldap: control/me: %s\n", qldap_me.s);
 
+       t = cf;
+       t += fmt_strn(cf, "control/ldapmailhost", 64); *t=0;
+       if (control_rldef(&qldap_mailhost, ctrl_file, 0, qldap_me.s) == -1) return -1;
+       if (!stralloc_0(&qldap_mailhost)) return -1;
+       log(64, "init_ldap: control/mailhost: %s\n", qldap_mailhost.s);
+   
        t = cf;
        t += fmt_strn(cf, "control/ldapserver", 64); *t=0;
        if (control_rldef(&qldap_server, ctrl_file, 0, (char *) 0) != 1) {
diff -u qmail/qmail-lspawn.c qmail-customer/qmail-lspawn.c
--- qmail/qmail-lspawn.c        Mon Aug  6 14:43:15 2001
+++ qmail-customer/qmail-lspawn.c       Mon Aug  6 21:29:18 2001
@@ -40,6 +40,7 @@
 
 /* initialize the string arrays, this uses DJB's libs */
 extern stralloc qldap_me;
+extern stralloc qldap_mailhost;
 extern stralloc qldap_objectclass;
 stralloc    qldap_defdotmode = {0};
 stralloc    qldap_defaultquota = {0};
@@ -497,7 +498,7 @@
 
 #ifdef QLDAP_CLUSTER
    /* check if the I'm the right host */
-   if ( qldap_cluster && info.host && str_diff(qldap_me.s, info.host) ) {
+   if ( qldap_cluster && info.host && str_diff(qldap_me.s, info.host) && 
+str_diff(qldap_mailhost.s, info.host) ) {
       /* hostname is different, so I reconnect */
       forward_mail(info.host, mail, from, fdmess);
       /* that's it. Function does not return */
diff -u qmail/qmail-showctl.c qmail-customer/qmail-showctl.c
--- qmail/qmail-showctl.c       Mon Aug  6 14:43:17 2001
+++ qmail-customer/qmail-showctl.c      Mon Aug  6 21:36:02 2001
@@ -301,7 +301,8 @@
   do_lst("relaymailfrom","Relaymailfrom not enabled.","Envelope senders allowed to 
relay: ",".");
   do_lst("rbllist","No RBL listed.","RBL to check: ",".");
   do_lst("rbltags","No RBL listed.","RBL to check: ",".");
-
+  do_str("ldapmailhost", 0, "no alternate MailHost for clustering", "Alternate 
+MailHost for clustering: ", "");
+   
   substdio_puts(subfdout,"\n");
   
   
@@ -357,6 +358,7 @@
     if (str_equal(d->d_name,"tarpitdelay")) continue;
     if (str_equal(d->d_name,"badrcptto")) continue;
     if (str_equal(d->d_name,"dirmaker")) continue;
+    if (str_equal(d->d_name,"ldapmailhost")) continue;
     if (str_equal(d->d_name,"ldappasswdappend")) {
         substdio_puts(subfdout,"ldappasswdappend: No longer used, please remove.\n");
         continue;


-- 
* Henning Brauer, [EMAIL PROTECTED], http://www.bsws.de *
* Roedingsmarkt 14, 20459 Hamburg, Germany               *
Unix is very simple, but it takes a genius to understand the simplicity.
(Dennis Ritchie)

Reply via email to