forked from cory/tildefriends
Minor cleanup. Missing traces.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4356 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
16
src/ssb.db.c
16
src/ssb.db.c
@ -19,6 +19,11 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
typedef struct _message_store_t message_store_t;
|
||||
|
||||
static void _tf_ssb_db_store_message_work_finish(message_store_t* store);
|
||||
static void _tf_ssb_db_store_message_after_work(uv_work_t* work, int status);
|
||||
|
||||
static void _tf_ssb_db_exec(sqlite3* db, const char* statement)
|
||||
{
|
||||
char* error = NULL;
|
||||
@ -290,7 +295,6 @@ static int64_t _tf_ssb_db_store_message_raw(
|
||||
if (r != SQLITE_DONE)
|
||||
{
|
||||
tf_printf("_tf_ssb_db_store_message_raw: %s\n", sqlite3_errmsg(db));
|
||||
abort();
|
||||
}
|
||||
if (r == SQLITE_DONE && sqlite3_changes(db) != 0)
|
||||
{
|
||||
@ -355,7 +359,6 @@ static char* _tf_ssb_db_get_message_blob_wants(tf_ssb_t* ssb, int64_t rowid)
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct _message_store_t message_store_t;
|
||||
typedef struct _message_store_t
|
||||
{
|
||||
uv_work_t work;
|
||||
@ -382,17 +385,17 @@ typedef struct _message_store_t
|
||||
static void _tf_ssb_db_store_message_work(uv_work_t* work)
|
||||
{
|
||||
message_store_t* store = work->data;
|
||||
tf_trace_t* trace = tf_ssb_get_trace(store->ssb);
|
||||
tf_trace_begin(trace, "message_store_work");
|
||||
int64_t last_row_id = _tf_ssb_db_store_message_raw(store->ssb, store->id, *store->previous ? store->previous : NULL, store->author, store->sequence, store->timestamp, store->content, store->length, store->signature, store->sequence_before_author);
|
||||
if (last_row_id != -1)
|
||||
{
|
||||
store->out_stored = true;
|
||||
store->out_blob_wants = _tf_ssb_db_get_message_blob_wants(store->ssb, last_row_id);
|
||||
}
|
||||
tf_trace_end(trace);
|
||||
}
|
||||
|
||||
static void _tf_ssb_db_store_message_work_finish(message_store_t* store);
|
||||
static void _tf_ssb_db_store_message_after_work(uv_work_t* work, int status);
|
||||
|
||||
static void _wake_up_queue(tf_ssb_t* ssb, tf_ssb_store_queue_t* queue)
|
||||
{
|
||||
if (!queue->running)
|
||||
@ -433,6 +436,8 @@ static void _tf_ssb_db_store_message_work_finish(message_store_t* store)
|
||||
static void _tf_ssb_db_store_message_after_work(uv_work_t* work, int status)
|
||||
{
|
||||
message_store_t* store = work->data;
|
||||
tf_trace_t* trace = tf_ssb_get_trace(store->ssb);
|
||||
tf_trace_begin(trace, "message_store_after_work");
|
||||
if (store->out_stored)
|
||||
{
|
||||
tf_ssb_notify_message_added(store->ssb, store->id);
|
||||
@ -446,6 +451,7 @@ static void _tf_ssb_db_store_message_after_work(uv_work_t* work, int status)
|
||||
tf_free(store->out_blob_wants);
|
||||
}
|
||||
_tf_ssb_db_store_message_work_finish(store);
|
||||
tf_trace_end(trace);
|
||||
}
|
||||
|
||||
void tf_ssb_db_store_message(tf_ssb_t* ssb, JSContext* context, const char* id, JSValue val, const char* signature, bool sequence_before_author, tf_ssb_db_store_message_callback_t* callback, void* user_data)
|
||||
|
Reference in New Issue
Block a user