Dont treat database lock errors the same as missing records

This commit is contained in:
Jeremy Lakeman 2014-07-14 15:26:50 +09:30
parent bc87f8c7c0
commit eaf069e1c3
2 changed files with 18 additions and 6 deletions

View File

@ -132,7 +132,8 @@ static enum meshms_status get_database_conversations(const sid_t *my_sid, const
const char *their_sid_hex = alloca_tohex_sid_t(*(their_sid ? their_sid : my_sid));
DEBUGF("Looking for conversations for %s, %s", my_sid_hex, their_sid_hex);
}
while (sqlite_step_retry(&retry, statement) == SQLITE_ROW) {
int r;
while ((r=sqlite_step_retry(&retry, statement)) == SQLITE_ROW) {
const char *id_hex = (const char *)sqlite3_column_text(statement, 0);
uint64_t version = sqlite3_column_int64(statement, 1);
int64_t size = sqlite3_column_int64(statement, 2);
@ -176,6 +177,8 @@ static enum meshms_status get_database_conversations(const sid_t *my_sid, const
p->size = size;
}
sqlite3_finalize(statement);
if (r==-1)
return MESHMS_STATUS_ERROR;
return MESHMS_STATUS_OK;
}

View File

@ -1693,11 +1693,20 @@ int rhizome_retrieve_manifest(const rhizome_bid_t *bidp, rhizome_manifest *m)
END);
if (!statement)
return -1;
int ret = 1;
if (sqlite_step_retry(&retry, statement) == SQLITE_ROW)
ret = unpack_manifest_row(m, statement);
else if (config.debug.rhizome)
DEBUGF("Manifest id=%s not found", alloca_tohex_rhizome_bid_t(*bidp));
int ret;
switch(sqlite_step_retry(&retry, statement)){
case SQLITE_ROW:
ret = unpack_manifest_row(m, statement);
break;
case -1:
ret = -1;
break;
default:
ret = 1;
if (config.debug.rhizome)
DEBUGF("Manifest id=%s not found", alloca_tohex_rhizome_bid_t(*bidp));
}
sqlite3_finalize(statement);
return ret;
}