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
Author[]Andy Green <andy@warmcat.com> 2025-07-29 08:21 UTC
Committer[]Andy Green <andy@warmcat.com> 2025-07-29 19:14 UTC
Tree86d54a96ce01b291253b655c6567b4e8ab30f81f   Raw Patch
 
event-delete: improve logging
event-delete: improve logging
diff --git a/src/server/s-comms.c b/src/server/s-comms.c index 9421ae9..557d5be 100644 --- a/src/server/s-comms.c +++ b/src/server/s-comms.c @@ -244,7 +244,7 @@ sais_event_db_close_all_now(struct vhd *vhd) int sais_event_db_delete_database(struct vhd *vhd, const char *event_uuid) { - char filepath[256], saf[33], r = 0; + char filepath[256], saf[33], r = 0, ra = 0; lws_strncpy(saf, event_uuid, sizeof(saf)); lws_filename_purify_inplace(saf); @@ -253,16 +253,33 @@ sais_event_db_delete_database(struct vhd *vhd, const char *event_uuid) vhd->sqlite3_path_lhs, saf); r = (char)!!unlink(filepath); + if (r) { + lwsl_err("%s: unable to delete %s (%d)\n", __func__, filepath, errno); + ra = 1; + } lws_snprintf(filepath, sizeof(filepath), "%s-event-%s.sqlite3-wal", vhd->sqlite3_path_lhs, saf); - r = (char)(r | !!unlink(filepath)); + r = (char)!!unlink(filepath); + if (r) { + lwsl_err("%s: unable to delete %s (%d)\n", __func__, filepath, errno); + ra = 1; + } lws_snprintf(filepath, sizeof(filepath), "%s-event-%s.sqlite3-shm", vhd->sqlite3_path_lhs, saf); - return r | !!unlink(filepath); + r = (char)!!unlink(filepath); + if (r) { + lwsl_err("%s: unable to delete %s (%d)\n", __func__, filepath, errno); + ra = 1; + } + + if (!ra) + lwsl_notice("%s: deleted %s OK\n", __func__, filepath); + + return ra; } diff --git a/src/server/s-websrv.c b/src/server/s-websrv.c index 79f5368..ec0735a 100644 --- a/src/server/s-websrv.c +++ b/src/server/s-websrv.c @@ -375,8 +375,10 @@ websrvss_ws_rx(void *userobj, const uint8_t *buf, size_t len, int flags) case SAIS_WS_WEBSRV_RX_EVENTDELETE: ei = (sai_browse_rx_evinfo_t *)a.dest; - if (sais_validate_id(ei->event_hash, SAI_EVENTID_LEN)) + if (sais_validate_id(ei->event_hash, SAI_EVENTID_LEN)) { + lwsl_err("%s: SAIS_WS_WEBSRV_RX_EVENTDELETE: unable to validate id %s\n", __func__, ei->event_hash); goto soft_error; + } lwsl_notice("%s: eventdelete %s\n", __func__, ei->event_hash); diff --git a/src/web/w-comms.c b/src/web/w-comms.c index 717a811..29880d0 100644 --- a/src/web/w-comms.c +++ b/src/web/w-comms.c @@ -244,7 +244,7 @@ sais_event_db_close(struct vhd *vhd, sqlite3 **ppdb) int sais_event_db_delete_database(struct vhd *vhd, const char *event_uuid) { - char filepath[256], saf[33]; + char filepath[256], saf[33], r = 0, ra = 0; lws_strncpy(saf, event_uuid, sizeof(saf)); lws_filename_purify_inplace(saf); @@ -252,10 +252,38 @@ sais_event_db_delete_database(struct vhd *vhd, const char *event_uuid) lws_snprintf(filepath, sizeof(filepath), "%s-event-%s.sqlite3", vhd->sqlite3_path_lhs, saf); - return unlink(filepath); + r = (char)!!unlink(filepath); + if (r) { + lwsl_err("%s (web): unable to delete %s (%d)\n", __func__, filepath, errno); + ra = 1; + } + + lws_snprintf(filepath, sizeof(filepath), "%s-event-%s.sqlite3-wal", + vhd->sqlite3_path_lhs, saf); + + r = (char)!!unlink(filepath); + if (r) { + lwsl_err("%s (web): unable to delete %s (%d)\n", __func__, filepath, errno); + ra = 1; + } + + lws_snprintf(filepath, sizeof(filepath), "%s-event-%s.sqlite3-shm", + vhd->sqlite3_path_lhs, saf); + + r = (char)!!unlink(filepath); + if (r) { + lwsl_err("%s (web): unable to delete %s (%d)\n", __func__, filepath, errno); + ra = 1; + } + + if (!ra) + lwsl_notice("%s (web): deleted %s OK\n", __func__, filepath); + + return ra; } + #if 0 static void sais_all_browser_on_writable(struct vhd *vhd)
Page fetched 0s ago, creation time: 3ms (vhost etag hits: 0%, cache hits: 0%)