about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-18 01:03:25 -0500
committerJune McEnroe <june@causal.agency>2019-12-18 01:03:25 -0500
commit8cc7ef2fa96a936a04886353c64f94309bcdbfd2 (patch)
tree1e0750185374f23da6dd003de8d224d9a56fd283
parentRewrite litterbox statements with functions (diff)
downloadlitterbox-8cc7ef2fa96a936a04886353c64f94309bcdbfd2.tar.gz
litterbox-8cc7ef2fa96a936a04886353c64f94309bcdbfd2.zip
Wrap handlers in transactions
-rw-r--r--litterbox.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/litterbox.c b/litterbox.c
index e37f78a..1401112 100644
--- a/litterbox.c
+++ b/litterbox.c
@@ -258,21 +258,24 @@ static void handlePing(struct Message *msg) {
 
 static const struct {
 	const char *cmd;
+	bool transaction;
 	Handler *fn;
 } Handlers[] = {
-	{ "001", handleReplyWelcome },
-	{ "005", handleReplyISupport },
-	{ "CAP", handleCap },
-	{ "NOTICE", handlePrivmsg },
-	{ "PING", handlePing },
-	{ "PRIVMSG", handlePrivmsg },
+	{ "001", false, handleReplyWelcome },
+	{ "005", false, handleReplyISupport },
+	{ "CAP", false, handleCap },
+	{ "NOTICE", true, handlePrivmsg },
+	{ "PING", false, handlePing },
+	{ "PRIVMSG", true, handlePrivmsg },
 };
 
 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;));
 		break;
 	}
 }
2021-04-18Add freecellJune McEnroe 2021-04-18Allow cumulative score gamesJune McEnroe 2021-01-31Check isattyJune McEnroe 2021-01-31Launch game immediately with SSH_ORIGINAL_COMMANDJune McEnroe 2021-01-29Handle getch ERR in menuJune McEnroe 2021-01-29Set process title to chosen gameJune McEnroe I just like to see :) 2021-01-29Add pause to snakeJune McEnroe 2021-01-29Add menu to choose 2048 or snakeJune McEnroe 2021-01-29Actually wait for a non-direction keyJune McEnroe 2021-01-29Give the snake a tailJune McEnroe 2021-01-29Don't let the snake snap its own neckJune McEnroe