diff --git a/src/ssb.c b/src/ssb.c index 2e41a9a7..624e7c7b 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -2832,15 +2832,6 @@ void tf_ssb_destroy(tf_ssb_t* ssb) JS_FreeRuntime(ssb->runtime); ssb->own_context = false; } - if (ssb->db_writer) - { - int r = sqlite3_close(ssb->db_writer); - if (r != SQLITE_OK) - { - tf_printf("sqlite3_close: %s\n", sqlite3_errstr(r)); - } - ssb->db_writer = NULL; - } while (ssb->broadcasts) { tf_ssb_broadcast_t* broadcast = ssb->broadcasts; @@ -2856,6 +2847,15 @@ void tf_ssb_destroy(tf_ssb_t* ssb) tf_printf("sqlite3_close: %s\n", sqlite3_errstr(r)); } } + if (ssb->db_writer) + { + int r = sqlite3_close(ssb->db_writer); + if (r != SQLITE_OK) + { + tf_printf("sqlite3_close: %s\n", sqlite3_errstr(r)); + } + ssb->db_writer = NULL; + } ssb->db_readers_count = 0; if (ssb->db_readers) {