Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
    npro  
 Modern all-safe Rust Network Protocol library supporting h1, h2, h3, ws, wt sans-IO and with socket IO + tls
git clone https://npro.rs/repo/npro
 
root / src / common / struct-metadata.c
Author[]Andy Green <andy@warmcat.com> 2025-04-25 07:28 UTC
Committer[]Andy Green <andy@warmcat.com> 2025-04-25 08:15 UTC
Treeff3848acea29a14e4308bdf55b523ee33fa4a2af   Raw Patch
 
server: improve errors on event db open fail
server: improve errors on event db open fail
diff --git a/src/server/s-comms.c b/src/server/s-comms.c index bf4e0bf..2233271 100644 --- a/src/server/s-comms.c +++ b/src/server/s-comms.c @@ -115,6 +115,8 @@ sais_event_db_ensure_open(struct vhd *vhd, const char *event_uuid, char filepath[256], saf[33]; sais_sqlite_cache_t *sc; + lwsl_notice("%s: (sai-server) entry\n", __func__); + if (*ppdb) return 0; @@ -143,14 +145,14 @@ sais_event_db_ensure_open(struct vhd *vhd, const char *event_uuid, lwsl_err("%s: Unable to open db %s: %s\n", __func__, filepath, sqlite3_errmsg(*ppdb)); - return 1; + return 2; } /* create / add to the schema for the tables we will have in here */ if (lws_struct_sq3_create_table(*ppdb, lsm_schema_sq3_map_task)) { lwsl_err("%s: unable to create task table in %s\n", __func__, filepath); - return 1; + return 3; } sai_sqlite3_statement(*ppdb, "PRAGMA journal_mode=WAL;", "set WAL"); @@ -158,13 +160,13 @@ sais_event_db_ensure_open(struct vhd *vhd, const char *event_uuid, if (lws_struct_sq3_create_table(*ppdb, lsm_schema_sq3_map_log)) { lwsl_err("%s: unable to create log table in %s\n", __func__, filepath); - return 1; + return 4; } if (lws_struct_sq3_create_table(*ppdb, lsm_schema_sq3_map_artifact)) { lwsl_err("%s: unable to create artifact table in %s\n", __func__, filepath); - return 1; + return 5; } sc = malloc(sizeof(*sc)); @@ -174,7 +176,7 @@ sais_event_db_ensure_open(struct vhd *vhd, const char *event_uuid, lws_struct_sq3_close(ppdb); *ppdb = NULL; - return 1; + return 6; } lws_strncpy(sc->uuid, event_uuid, sizeof(sc->uuid)); diff --git a/src/server/s-notification.c b/src/server/s-notification.c index a3af6fa..019d627 100644 --- a/src/server/s-notification.c +++ b/src/server/s-notification.c @@ -918,10 +918,11 @@ sai_notification_file_upload_cb(void *data, const char *name, */ sai_uuid16_create(lws_get_context(pss->wsi), pss->sn.e.uuid); - if (sais_event_db_ensure_open(pss->vhd, pss->sn.e.uuid, 1, - (sqlite3 **)&pss->sn.e.pdb)) { - lwsl_err("%s: unable to open event-specific database\n", - __func__); + m = sais_event_db_ensure_open(pss->vhd, pss->sn.e.uuid, 1, + (sqlite3 **)&pss->sn.e.pdb); + if (m) { + lwsl_err("%s: XX %d unable to open event-specific database\n", + __func__, m); goto saifile_bail; } @@ -933,8 +934,9 @@ sai_notification_file_upload_cb(void *data, const char *name, (int)pss->sn.saifile_out_pos); sais_event_db_close(pss->vhd, (sqlite3 **)&pss->sn.e.pdb); if (m < 0) { - lwsl_notice("%s: saifile JSON decode failed '%s' (%d)\n", + lwsl_notice("%s: saifile JSON 1 decode failed '%s' (%d)\n", __func__, lejp_error_to_string(m), m); + puts(pss->sn.saifile); goto saifile_bail; } @@ -968,8 +970,9 @@ sai_notification_file_upload_cb(void *data, const char *name, free(pss->sn.saifile); pss->sn.saifile = NULL; if (m < 0) { - lwsl_notice("%s: saifile JSON decode failed '%s' (%d)\n", + lwsl_notice("%s: saifile JSON 2 decode failed '%s' (%d)\n", __func__, lejp_error_to_string(m), m); + puts(pss->sn.saifile); return m; } diff --git a/src/web/w-comms.c b/src/web/w-comms.c index c0b5b3b..35002ae 100644 --- a/src/web/w-comms.c +++ b/src/web/w-comms.c @@ -1,5 +1,5 @@ /* - * Sai server + * Sai web * * Copyright (C) 2019 - 2020 Andy Green <andy@warmcat.com> * @@ -134,6 +134,8 @@ sais_event_db_ensure_open(struct vhd *vhd, const char *event_uuid, char filepath[256], saf[33]; sais_sqlite_cache_t *sc; + lwsl_notice("%s: (sai-web) entry\n", __func__); + if (*ppdb) return 0; @@ -167,20 +169,30 @@ sais_event_db_ensure_open(struct vhd *vhd, const char *event_uuid, /* create / add to the schema for the tables we will have in here */ - if (lws_struct_sq3_create_table(*ppdb, lsm_schema_sq3_map_task)) + if (lws_struct_sq3_create_table(*ppdb, lsm_schema_sq3_map_task)) { + lwsl_err("%s: unable to create task table for %s\n", __func__, filepath); return 1; + } sai_sqlite3_statement(*ppdb, "PRAGMA journal_mode=WAL;", "set WAL"); - if (lws_struct_sq3_create_table(*ppdb, lsm_schema_sq3_map_log)) + if (lws_struct_sq3_create_table(*ppdb, lsm_schema_sq3_map_log)) { + lwsl_err("%s: unable to create log table for %s\n", __func__, filepath); + return 1; + } + + if (lws_struct_sq3_create_table(*ppdb, lsm_schema_sq3_map_artifact)) { + lwsl_err("%s: unable to create artifact table for %s\n", __func__, filepath); - if (lws_struct_sq3_create_table(*ppdb, lsm_schema_sq3_map_artifact)) return 1; + } sc = malloc(sizeof(*sc)); memset(sc, 0, sizeof(*sc)); if (!sc) { + lwsl_err("%s: unable to alloc sc for %s\n", __func__, filepath); + lws_struct_sq3_close(ppdb); *ppdb = NULL; return 1;
Page fetched 0s ago, creation time: 3ms (vhost etag hits: 0%, cache hits: 0%)