summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Hedenfal <martinh@cvs.openbsd.org>2010-07-06 20:10:58 +0000
committerMartin Hedenfal <martinh@cvs.openbsd.org>2010-07-06 20:10:58 +0000
commit04ca5b42a1294c87014c29bb6dc82d41cb3ca3d2 (patch)
tree6113be4ddb57e8cf47cee07118e46705934cf917
parent34bbfacafcb71253440a830bed3e6d1d937c3919 (diff)
Send empty statistics rather than segfault if "ldapctl stats" is run when a
database is being reopened due to compaction.
-rw-r--r--usr.sbin/ldapd/btree.c5
-rw-r--r--usr.sbin/ldapd/control.c11
2 files changed, 10 insertions, 6 deletions
diff --git a/usr.sbin/ldapd/btree.c b/usr.sbin/ldapd/btree.c
index 9befe56b529..7eb82ce3698 100644
--- a/usr.sbin/ldapd/btree.c
+++ b/usr.sbin/ldapd/btree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: btree.c,v 1.26 2010/07/06 13:28:35 martinh Exp $ */
+/* $OpenBSD: btree.c,v 1.27 2010/07/06 20:10:57 martinh Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
@@ -3157,6 +3157,9 @@ btree_get_path(struct btree *bt)
const struct btree_stat *
btree_stat(struct btree *bt)
{
+ if (bt == NULL)
+ return NULL;
+
bt->stat.branch_pages = bt->meta.branch_pages;
bt->stat.leaf_pages = bt->meta.leaf_pages;
bt->stat.overflow_pages = bt->meta.overflow_pages;
diff --git a/usr.sbin/ldapd/control.c b/usr.sbin/ldapd/control.c
index a5386775bc2..4e241fbebbd 100644
--- a/usr.sbin/ldapd/control.c
+++ b/usr.sbin/ldapd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.4 2010/06/30 17:16:09 martinh Exp $ */
+/* $OpenBSD: control.c,v 1.5 2010/07/06 20:10:57 martinh Exp $ */
/*
* Copyright (c) 2010 Martin Hedenfalk <martin@bzero.se>
@@ -193,12 +193,13 @@ send_stats(struct imsgev *iev)
TAILQ_FOREACH(ns, &conf->namespaces, next) {
if (namespace_has_referrals(ns))
continue;
+ bzero(&nss, sizeof(nss));
strlcpy(nss.suffix, ns->suffix, sizeof(nss.suffix));
- st = btree_stat(ns->data_db);
- bcopy(st, &nss.data_stat, sizeof(nss.data_stat));
+ if ((st = btree_stat(ns->data_db)) != NULL)
+ bcopy(st, &nss.data_stat, sizeof(nss.data_stat));
- st = btree_stat(ns->indx_db);
- bcopy(st, &nss.indx_stat, sizeof(nss.indx_stat));
+ if ((st = btree_stat(ns->indx_db)) != NULL)
+ bcopy(st, &nss.indx_stat, sizeof(nss.indx_stat));
imsg_compose(&iev->ibuf, IMSG_CTL_NSSTATS, 0, iev->ibuf.pid, -1,
&nss, sizeof(nss));