diff options
author | June McEnroe <june@causal.agency> | 2019-12-23 22:09:47 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-12-23 22:09:47 -0500 |
commit | 333673fc990e2677bb5d8a56808e4f4d25f3496e (patch) | |
tree | 72098e0fefab6891250d1d4c22d05c3a2c6a1daa | |
parent | Take optional explicit path in dbFind (diff) | |
download | litterbox-333673fc990e2677bb5d8a56808e4f4d25f3496e.tar.gz litterbox-333673fc990e2677bb5d8a56808e4f4d25f3496e.zip |
Actually only use a transaction for handlers that need it
How did I manage that?
Diffstat (limited to '')
-rw-r--r-- | litterbox.c | 10 |
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; } } |