fix problem with multiple databases -- keybuf trashed
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 2 Jun 1993 22:27:38 +0000 (14:27 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 2 Jun 1993 22:27:38 +0000 (14:27 -0800)
SCCS-vsn: usr.sbin/sendmail/src/udb.c 6.23

usr/src/usr.sbin/sendmail/src/udb.c

index a2206af..b0324c1 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef USERDB
 
 #ifndef lint
 #ifdef USERDB
-static char sccsid [] = "@(#)udb.c     6.22 (Berkeley) %G% (with USERDB)";
+static char sccsid [] = "@(#)udb.c     6.23 (Berkeley) %G% (with USERDB)";
 #else
 #else
-static char sccsid [] = "@(#)udb.c     6.22 (Berkeley) %G% (without USERDB)";
+static char sccsid [] = "@(#)udb.c     6.23 (Berkeley) %G% (without USERDB)";
 #endif
 #endif
 
 #endif
 #endif
 
@@ -170,6 +170,8 @@ udbexpand(a, sendq, e)
                  case UDB_DBFETCH:
                        key.data = keybuf;
                        key.size = keylen;
                  case UDB_DBFETCH:
                        key.data = keybuf;
                        key.size = keylen;
+                       if (tTd(28, 80))
+                               printf("udbexpand: trying %s\n", keybuf);
                        i = (*up->udb_dbp->seq)(up->udb_dbp, &key, &info, R_CURSOR);
                        if (i > 0 || info.size <= 0)
                        {
                        i = (*up->udb_dbp->seq)(up->udb_dbp, &key, &info, R_CURSOR);
                        if (i > 0 || info.size <= 0)
                        {
@@ -177,6 +179,9 @@ udbexpand(a, sendq, e)
                                        printf("udbexpand: no match on %s\n", keybuf);
                                continue;
                        }
                                        printf("udbexpand: no match on %s\n", keybuf);
                                continue;
                        }
+                       if (tTd(28, 80))
+                               printf("udbexpand: match %.*s: %.*s\n",
+                                       key.size, key.data, info.size, info.data);
 
                        naddrs = 0;
                        a->q_flags &= ~QSELFREF;
 
                        naddrs = 0;
                        a->q_flags &= ~QSELFREF;
@@ -214,6 +219,11 @@ udbexpand(a, sendq, e)
                                /* get the next record */
                                i = (*up->udb_dbp->seq)(up->udb_dbp, &key, &info, R_NEXT);
                        }
                                /* get the next record */
                                i = (*up->udb_dbp->seq)(up->udb_dbp, &key, &info, R_NEXT);
                        }
+
+                       /* if nothing ever matched, try next database */
+                       if (!breakout)
+                               continue;
+
                        if (naddrs > 0 && !bitset(QSELFREF, a->q_flags))
                        {
                                if (tTd(28, 5))
                        if (naddrs > 0 && !bitset(QSELFREF, a->q_flags))
                        {
                                if (tTd(28, 5))