summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreric <eric@openbsd.org>2018-12-27 08:57:03 +0000
committereric <eric@openbsd.org>2018-12-27 08:57:03 +0000
commita4c00f8a22c1ceb79ff905846e180e49e4edcfaf (patch)
tree14fee7e4df8d8ab2b10e7911bc25032bb9ff3b82
parentMake the backend open method return an int to report success. (diff)
downloadwireguard-openbsd-a4c00f8a22c1ceb79ff905846e180e49e4edcfaf.tar.xz
wireguard-openbsd-a4c00f8a22c1ceb79ff905846e180e49e4edcfaf.zip
change the close() method to take the table pointer
ok gilles
-rw-r--r--usr.sbin/smtpd/smtpd.h4
-rw-r--r--usr.sbin/smtpd/table.c4
-rw-r--r--usr.sbin/smtpd/table_db.c18
-rw-r--r--usr.sbin/smtpd/table_getpwnam.c6
-rw-r--r--usr.sbin/smtpd/table_proc.c8
-rw-r--r--usr.sbin/smtpd/table_static.c8
6 files changed, 29 insertions, 19 deletions
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 68b710c54e0..397427d3957 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.608 2018/12/27 08:08:06 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.609 2018/12/27 08:57:03 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -367,7 +367,7 @@ struct table_backend {
int (*config)(struct table *);
int (*open)(struct table *);
int (*update)(struct table *);
- void (*close)(void *);
+ void (*close)(struct table *);
int (*lookup)(void *, enum table_service, const char *, char **);
int (*fetch)(void *, enum table_service, char **);
};
diff --git a/usr.sbin/smtpd/table.c b/usr.sbin/smtpd/table.c
index 0c23f1b14b4..e6190afa3b9 100644
--- a/usr.sbin/smtpd/table.c
+++ b/usr.sbin/smtpd/table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table.c,v 1.39 2018/12/27 08:08:06 eric Exp $ */
+/* $OpenBSD: table.c,v 1.40 2018/12/27 08:57:03 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -349,7 +349,7 @@ void
table_close(struct table *t)
{
if (t->t_backend->close)
- t->t_backend->close(t->t_handle);
+ t->t_backend->close(t);
}
int
diff --git a/usr.sbin/smtpd/table_db.c b/usr.sbin/smtpd/table_db.c
index 3d668d0e2ba..3f1074dcdd6 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.15 2018/12/27 08:08:06 eric Exp $ */
+/* $OpenBSD: table_db.c,v 1.16 2018/12/27 08:57:03 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
@@ -46,7 +46,8 @@ static int table_db_open(struct table *);
static void *table_db_open2(struct table *);
static int table_db_lookup(void *, enum table_service, const char *, char **);
static int table_db_fetch(void *, enum table_service, char **);
-static void table_db_close(void *);
+static void table_db_close(struct table *);
+static void table_db_close2(void *);
static char *table_db_get_entry(void *, const char *, size_t *);
static char *table_db_get_entry_match(void *, const char *, size_t *,
@@ -88,7 +89,7 @@ table_db_config(struct table *table)
if (handle == NULL)
return 0;
- table_db_close(handle);
+ table_db_close2(handle);
return 1;
}
@@ -101,7 +102,7 @@ table_db_update(struct table *table)
if (handle == NULL)
return 0;
- table_db_close(table->t_handle);
+ table_db_close2(table->t_handle);
table->t_handle = handle;
return 1;
}
@@ -115,6 +116,13 @@ table_db_open(struct table *table)
return 1;
}
+static void
+table_db_close(struct table *table)
+{
+ table_db_close2(table->t_handle);
+ table->t_handle = NULL;
+}
+
static void *
table_db_open2(struct table *table)
{
@@ -145,7 +153,7 @@ error:
}
static void
-table_db_close(void *hdl)
+table_db_close2(void *hdl)
{
struct dbhandle *handle = hdl;
handle->db->close(handle->db);
diff --git a/usr.sbin/smtpd/table_getpwnam.c b/usr.sbin/smtpd/table_getpwnam.c
index 9e81e102d43..45a377aaf65 100644
--- a/usr.sbin/smtpd/table_getpwnam.c
+++ b/usr.sbin/smtpd/table_getpwnam.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table_getpwnam.c,v 1.9 2018/12/27 08:08:06 eric Exp $ */
+/* $OpenBSD: table_getpwnam.c,v 1.10 2018/12/27 08:57:03 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
@@ -43,7 +43,7 @@ static int table_getpwnam_update(struct table *);
static int table_getpwnam_open(struct table *);
static int table_getpwnam_lookup(void *, enum table_service, const char *,
char **);
-static void table_getpwnam_close(void *);
+static void table_getpwnam_close(struct table *);
struct table_backend table_backend_getpwnam = {
"getpwnam",
@@ -77,7 +77,7 @@ table_getpwnam_open(struct table *table)
}
static void
-table_getpwnam_close(void *hdl)
+table_getpwnam_close(struct table *table)
{
return;
}
diff --git a/usr.sbin/smtpd/table_proc.c b/usr.sbin/smtpd/table_proc.c
index 970419db24f..22fd20c916b 100644
--- a/usr.sbin/smtpd/table_proc.c
+++ b/usr.sbin/smtpd/table_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table_proc.c,v 1.12 2018/12/27 08:08:06 eric Exp $ */
+/* $OpenBSD: table_proc.c,v 1.13 2018/12/27 08:57:03 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -160,12 +160,14 @@ table_proc_update(struct table *table)
}
static void
-table_proc_close(void *arg)
+table_proc_close(struct table *table)
{
- struct table_proc_priv *priv = arg;
+ struct table_proc_priv *priv = table->t_handle;
imsg_compose(&priv->ibuf, PROC_TABLE_CLOSE, 0, 0, -1, NULL, 0);
imsg_flush(&priv->ibuf);
+
+ table->t_handle = NULL;
}
static int
diff --git a/usr.sbin/smtpd/table_static.c b/usr.sbin/smtpd/table_static.c
index d8b9da9fc9f..bdd3a59ee42 100644
--- a/usr.sbin/smtpd/table_static.c
+++ b/usr.sbin/smtpd/table_static.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table_static.c,v 1.25 2018/12/27 08:08:06 eric Exp $ */
+/* $OpenBSD: table_static.c,v 1.26 2018/12/27 08:57:03 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -45,7 +45,7 @@ static int table_static_open(struct table *);
static int table_static_lookup(void *, enum table_service, const char *,
char **);
static int table_static_fetch(void *, enum table_service, char **);
-static void table_static_close(void *);
+static void table_static_close(struct table *);
struct table_backend table_backend_static = {
"static",
@@ -210,9 +210,9 @@ table_static_open(struct table *table)
}
static void
-table_static_close(void *hdl)
+table_static_close(struct table *table)
{
- return;
+ table->t_handle = NULL;
}
static int