forked from cory/tildefriends
Reduce some common log noise.
This commit is contained in:
parent
21cf503a59
commit
574292b798
@ -1674,10 +1674,6 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
|||||||
tf_trace_end(connection->ssb->trace);
|
tf_trace_end(connection->ssb->trace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
tf_printf("No request callback for %p %d\n", connection, -request_number);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (close_connection)
|
if (close_connection)
|
||||||
|
16
src/ssb.db.c
16
src/ssb.db.c
@ -281,7 +281,7 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
|||||||
tf_ssb_release_db_writer(ssb, db);
|
tf_ssb_release_db_writer(ssb, db);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _tf_ssb_db_previous_message_exists(sqlite3* db, const char* author, int64_t sequence, const char* previous)
|
static bool _tf_ssb_db_previous_message_exists(sqlite3* db, const char* author, int64_t sequence, const char* previous, bool* out_id_mismatch)
|
||||||
{
|
{
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
if (sequence == 1)
|
if (sequence == 1)
|
||||||
@ -291,12 +291,13 @@ static bool _tf_ssb_db_previous_message_exists(sqlite3* db, const char* author,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
sqlite3_stmt* statement;
|
sqlite3_stmt* statement;
|
||||||
if (sqlite3_prepare(db, "SELECT COUNT(*) FROM messages WHERE author = ?1 AND sequence = ?2 AND id = ?3", -1, &statement, NULL) == SQLITE_OK)
|
if (sqlite3_prepare(db, "SELECT COUNT(*), id != ?3 AS is_mismatch FROM messages WHERE author = ?1 AND sequence = ?2", -1, &statement, NULL) == SQLITE_OK)
|
||||||
{
|
{
|
||||||
if (sqlite3_bind_text(statement, 1, author, -1, NULL) == SQLITE_OK && sqlite3_bind_int64(statement, 2, sequence - 1) == SQLITE_OK &&
|
if (sqlite3_bind_text(statement, 1, author, -1, NULL) == SQLITE_OK && sqlite3_bind_int64(statement, 2, sequence - 1) == SQLITE_OK &&
|
||||||
sqlite3_bind_text(statement, 3, previous, -1, NULL) == SQLITE_OK && sqlite3_step(statement) == SQLITE_ROW)
|
sqlite3_bind_text(statement, 3, previous, -1, NULL) == SQLITE_OK && sqlite3_step(statement) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
exists = sqlite3_column_int(statement, 0) != 0;
|
exists = sqlite3_column_int(statement, 0) != 0;
|
||||||
|
*out_id_mismatch = sqlite3_column_int(statement, 1) != 0;
|
||||||
}
|
}
|
||||||
sqlite3_finalize(statement);
|
sqlite3_finalize(statement);
|
||||||
}
|
}
|
||||||
@ -309,8 +310,9 @@ static int64_t _tf_ssb_db_store_message_raw(tf_ssb_t* ssb, const char* id, const
|
|||||||
{
|
{
|
||||||
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
||||||
int64_t last_row_id = -1;
|
int64_t last_row_id = -1;
|
||||||
|
bool id_mismatch = false;
|
||||||
|
|
||||||
if (_tf_ssb_db_previous_message_exists(db, author, sequence, previous))
|
if (_tf_ssb_db_previous_message_exists(db, author, sequence, previous, &id_mismatch))
|
||||||
{
|
{
|
||||||
const char* query = "INSERT INTO messages (id, previous, author, sequence, timestamp, content, hash, signature, flags) VALUES (?, ?, ?, ?, ?, jsonb(?), "
|
const char* query = "INSERT INTO messages (id, previous, author, sequence, timestamp, content, hash, signature, flags) VALUES (?, ?, ?, ?, ?, jsonb(?), "
|
||||||
"?, ?, ?) ON CONFLICT DO NOTHING";
|
"?, ?, ?) ON CONFLICT DO NOTHING";
|
||||||
@ -345,8 +347,14 @@ static int64_t _tf_ssb_db_store_message_raw(tf_ssb_t* ssb, const char* id, const
|
|||||||
tf_printf("%s: prepare failed: %s\n", __FUNCTION__, sqlite3_errmsg(db));
|
tf_printf("%s: prepare failed: %s\n", __FUNCTION__, sqlite3_errmsg(db));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (id_mismatch)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
** Only warn if we find a previous message with the wrong ID.
|
||||||
|
** If a feed is forked, we would otherwise warn on every
|
||||||
|
** message when trying to receive what we don't have, and
|
||||||
|
** that's not helping anybody.
|
||||||
|
*/
|
||||||
tf_printf("%p: Previous message doesn't exist for author=%s sequence=%" PRId64 " previous=%s.\n", db, author, sequence, previous);
|
tf_printf("%p: Previous message doesn't exist for author=%s sequence=%" PRId64 " previous=%s.\n", db, author, sequence, previous);
|
||||||
}
|
}
|
||||||
tf_ssb_release_db_writer(ssb, db);
|
tf_ssb_release_db_writer(ssb, db);
|
||||||
|
Loading…
Reference in New Issue
Block a user