From dd8a449bfef3869097ae273fb6038f7f99086079 Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 27 Dec 2018 14:41:45 +0000 Subject: [PATCH] move the iterator variable in the private handle. it is now correctly reset between updates. ok gilles@ --- usr.sbin/smtpd/table_db.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/usr.sbin/smtpd/table_db.c b/usr.sbin/smtpd/table_db.c index add5dc0fd1a..fde3983eb3d 100644 --- a/usr.sbin/smtpd/table_db.c +++ b/usr.sbin/smtpd/table_db.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table_db.c,v 1.18 2018/12/27 14:23:41 eric Exp $ */ +/* $OpenBSD: table_db.c,v 1.19 2018/12/27 14:41:45 eric Exp $ */ /* * Copyright (c) 2011 Gilles Chehade @@ -79,6 +79,7 @@ struct dbhandle { DB *db; char pathname[PATH_MAX]; time_t mtime; + int iter; }; static int @@ -209,11 +210,11 @@ table_db_fetch(struct table *table, enum table_service service, char **dst) DBT dbd; int r; - if (table->t_iter == NULL) + if (handle->iter == 0) r = handle->db->seq(handle->db, &dbk, &dbd, R_FIRST); else r = handle->db->seq(handle->db, &dbk, &dbd, R_NEXT); - table->t_iter = handle->db; + handle->iter = 1; if (!r) { r = handle->db->seq(handle->db, &dbk, &dbd, R_FIRST); if (!r) -- 2.20.1