aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgilles <gilles@poolp.org>2013-03-20 14:46:41 +0100
committergilles <gilles@poolp.org>2013-03-20 14:46:41 +0100
commit03ed0c066d27cd1462afdbafee6d78b12c29e27f (patch)
treeaecbca3dcf6b4b212b6c23e26953d32f29163eb5
parentMerge branch 'master' into portable (diff)
parentupon db update, the dbhandle needs to be reset in table_db_lookup (diff)
downloadOpenSMTPD-03ed0c066d27cd1462afdbafee6d78b12c29e27f.tar.xz
OpenSMTPD-03ed0c066d27cd1462afdbafee6d78b12c29e27f.zip
Merge branch 'master' into portable
-rw-r--r--smtpd/table_db.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/smtpd/table_db.c b/smtpd/table_db.c
index 096ccca0..96df2332 100644
--- a/smtpd/table_db.c
+++ b/smtpd/table_db.c
@@ -111,6 +111,7 @@ table_db_update(struct table *table)
table_db_close(table->t_handle);
table->t_handle = handle;
+ log_debug("HANDLE: %p", handle);
return 1;
}
@@ -156,6 +157,7 @@ table_db_lookup(void *hdl, const char *key, enum table_service service,
void **retp)
{
struct dbhandle *handle = hdl;
+ struct table *table = NULL;
char *line;
size_t len = 0;
int ret;
@@ -167,17 +169,20 @@ table_db_lookup(void *hdl, const char *key, enum table_service service,
return -1;
/* DB has changed, close and reopen */
- if (sb.st_mtime != handle->mtime)
+ if (sb.st_mtime != handle->mtime) {
+ table = handle->table;
table_db_update(handle->table);
+ handle = table->t_handle;
+ }
for (i = 0; i < nitems(keycmp); ++i)
if (keycmp[i].service == service)
match = keycmp[i].func;
if (match == NULL)
- line = table_db_get_entry(hdl, key, &len);
+ line = table_db_get_entry(handle, key, &len);
else
- line = table_db_get_entry_match(hdl, key, &len, match);
+ line = table_db_get_entry_match(handle, key, &len, match);
if (line == NULL)
return 0;