summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-28 18:27:21 -0500
committerJune McEnroe <june@causal.agency>2019-12-28 18:27:21 -0500
commit36298c7ba6872cb3088223bc7701db79f90a8349 (patch)
treeb070e438b330439beeab8df30357f1fcb32679ba
parentMove querySearch code around (diff)
downloadlitterbox-36298c7ba6872cb3088223bc7701db79f90a8349.tar.gz
litterbox-36298c7ba6872cb3088223bc7701db79f90a8349.zip
Call tls_close and dbClose in atexit
-rw-r--r--litterbox.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/litterbox.c b/litterbox.c
index 8ba0923..5924680 100644
--- a/litterbox.c
+++ b/litterbox.c
@@ -549,8 +549,6 @@ static void handlePing(struct Message *msg) {
 
 static void handleError(struct Message *msg) {
 	require(msg, false, 1);
-	tls_close(client);
-	dbClose();
 	errx(EX_UNAVAILABLE, "%s", msg->params[0]);
 }
 
@@ -600,11 +598,15 @@ static void handle(struct Message msg) {
 	}
 }
 
+static void atExit(void) {
+	if (client) tls_close(client);
+	dbClose();
+}
+
 static void quit(int sig) {
 	(void)sig;
 	format("QUIT\r\n");
-	tls_close(client);
-	dbClose();
+	atExit();
 	_exit(EX_OK);
 }
 
@@ -645,6 +647,7 @@ int main(int argc, char *argv[]) {
 	int flags = SQLITE_OPEN_READWRITE;
 	if (init) flags |= SQLITE_OPEN_CREATE;
 	dbFind(path, flags);
+	atexit(atExit);
 
 	if (init) {
 		dbInit();
cedfcdfeb677a436ec8a730364650&follow=1'>Call clientConsume before clientRecvJune McEnroe This might reduce the frequency of a client getting its own message back because it was behind in the ring when it sent it. 2019-11-06Use -l:filename in Linux.mkJune McEnroe 2019-11-06Fix compat.h for #defined strlcpyJune McEnroe 2019-11-06Allow unsetting LIBRESSL_PREFIXJune McEnroe 2019-11-06Document calico service configurationJune McEnroe 2019-11-06Document SASL EXTERNAL configuration in more detailJune McEnroe 2019-11-06Document pounce service configurationJune McEnroe 2019-11-06Mention Darwin and GNU/Linux in READMEJune McEnroe 2019-11-06Assume LibreSSL from brew on DarwinJune McEnroe 2019-11-06Remove -DNO_EXPLICIT_BZERO from Darwin.mkJune McEnroe 2019-11-06Don't install rc scripts or dirs on LinuxJune McEnroe