summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-23 22:09:47 -0500
committerJune McEnroe <june@causal.agency>2019-12-23 22:09:47 -0500
commit333673fc990e2677bb5d8a56808e4f4d25f3496e (patch)
tree72098e0fefab6891250d1d4c22d05c3a2c6a1daa
parentTake optional explicit path in dbFind (diff)
downloadlitterbox-333673fc990e2677bb5d8a56808e4f4d25f3496e.tar.gz
litterbox-333673fc990e2677bb5d8a56808e4f4d25f3496e.zip
Actually only use a transaction for handlers that need it
How did I manage that?
-rw-r--r--litterbox.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/litterbox.c b/litterbox.c
index 8015cec..39fce8f 100644
--- a/litterbox.c
+++ b/litterbox.c
@@ -368,9 +368,13 @@ static void handle(struct Message msg) {
 	if (!msg.cmd) return;
 	for (size_t i = 0; i < ARRAY_LEN(Handlers); ++i) {
 		if (strcmp(msg.cmd, Handlers[i].cmd)) continue;
-		dbExec(db, SQL(BEGIN TRANSACTION;));
-		Handlers[i].fn(&msg);
-		dbExec(db, SQL(COMMIT TRANSACTION;));
+		if (Handlers[i].transaction) {
+			dbExec(db, SQL(BEGIN TRANSACTION;));
+			Handlers[i].fn(&msg);
+			dbExec(db, SQL(COMMIT TRANSACTION;));
+		} else {
+			Handlers[i].fn(&msg);
+		}
 		break;
 	}
 }