summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2023-09-28 10:01:09 +0200
committerJose M. Guisado <jguisado@soleta.eu>2023-09-28 10:07:07 +0200
commit35a3b0a1a3230e465b3a434603cd6608b3350121 (patch)
treec0504931071a35f2f4bbbbb9f3356e719116a39f /src/main.c
parente080fd5526949a5615ae391ea9dda8b70c95f345 (diff)
schema: fix bug when og_dbi_open cannot open a connection
When og_dbi_open cannot open a connection during schema update, then ogServer crashes. og_dbi_open returns NULL when it cannot open a DB connection. Do not use dbi variable if og_dbi_open is unable to open a DB connection. Add syslog message when database schema couldn't be updated.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index c4148a5..d8453de 100644
--- a/src/main.c
+++ b/src/main.c
@@ -92,8 +92,10 @@ int main(int argc, char *argv[])
ev_io_init(&ev_io_agent_rest, og_server_accept_cb, socket_agent_rest, EV_READ);
ev_io_start(og_loop, &ev_io_agent_rest);
- if (og_dbi_schema_update() < 0)
+ if (og_dbi_schema_update() < 0) {
+ syslog(LOG_ERR, "Cannot update the database schema\n");
exit(EXIT_FAILURE);
+ }
if (og_dbi_schedule_get() < 0) {
syslog(LOG_ERR, "Cannot connect to database\n");