aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2008-03-01 15:54:16 -0500
committerBrian Cully <bjc@kublai.com>2008-03-01 15:54:16 -0500
commit172b5f0aef9e49e3c4af4f6c8a4077aef833b7f3 (patch)
treeffae6652bad4f1bc3184762c5dc443a700f26db6
parent0c021f75dd5676e642436092da908223f28b4c61 (diff)
downloadmysqlerl-172b5f0aef9e49e3c4af4f6c8a4077aef833b7f3.tar.gz
mysqlerl-172b5f0aef9e49e3c4af4f6c8a4077aef833b7f3.zip
Use a switch dispatch and crash on unknown types.
-rw-r--r--src/mysqlerl.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mysqlerl.c b/src/mysqlerl.c
index 0f88a49..dfd7ef0 100644
--- a/src/mysqlerl.c
+++ b/src/mysqlerl.c
@@ -175,8 +175,16 @@ write_cmd(const char *cmd, msglen_t len)
void
dispatch_db_cmd(MYSQL *dbh, msg_t *msg)
{
- logmsg("DEBUG: type: %d, msg: %s.", msg->type, msg->msg);
- write_cmd(msg->msg, msg->msglen);
+ switch (msg->type) {
+ case QUERY_MSG:
+ logmsg("DEBUG: got query msg: %s.", msg->msg);
+ write_cmd(msg->msg, msg->msglen);
+ break;
+
+ default:
+ logmsg("WARNING: message type %d unknown.", msg->type);
+ exit(3);
+ }
}
void