mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
Use uint64_t for Rhizome manifest version
Instead of int64_t. Fixes some -Wsign-compare warnings. Replace sqlite_exec_int64() with sqlite_exec_uint64(). Also store rowid as uint64_t, and use 0 not -1 to indicate unset.
This commit is contained in:
parent
608a705403
commit
075f9c7c27
4
meshms.c
4
meshms.c
@ -171,7 +171,7 @@ static int get_database_conversations(const sid_t *my_sid, const sid_t *their_si
|
||||
}
|
||||
while (sqlite_step_retry(&retry, statement) == SQLITE_ROW) {
|
||||
const char *id_hex = (const char *)sqlite3_column_text(statement, 0);
|
||||
int64_t version = sqlite3_column_int64(statement, 1);
|
||||
uint64_t version = sqlite3_column_int64(statement, 1);
|
||||
int64_t size = sqlite3_column_int64(statement, 2);
|
||||
int64_t tail = sqlite3_column_int64(statement, 3);
|
||||
const char *sender = (const char *)sqlite3_column_text(statement, 4);
|
||||
@ -263,7 +263,7 @@ static int ply_read_open(struct ply_read *ply, const rhizome_bid_t *bid, rhizome
|
||||
return -1;
|
||||
int ret = rhizome_open_decrypt_read(m, &ply->read);
|
||||
if (ret == 1)
|
||||
WARNF("Payload was not found for manifest %s, %"PRId64, alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), m->version);
|
||||
WARNF("Payload was not found for manifest %s, %"PRIu64, alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), m->version);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
assert(m->filesize != RHIZOME_SIZE_UNSET);
|
||||
|
14
rhizome.c
14
rhizome.c
@ -165,11 +165,11 @@ int rhizome_bundle_import_files(rhizome_manifest *m, const char *manifest_path,
|
||||
return WHY("could not verify manifest");
|
||||
|
||||
/* Do we already have this manifest or newer? */
|
||||
int64_t dbVersion = -1;
|
||||
if (sqlite_exec_int64(&dbVersion, "SELECT version FROM MANIFESTS WHERE id = ?;", RHIZOME_BID_T, &m->cryptoSignPublic, END) == -1)
|
||||
uint64_t dbVersion = 0;
|
||||
if (sqlite_exec_uint64(&dbVersion, "SELECT version FROM MANIFESTS WHERE id = ?;", RHIZOME_BID_T, &m->cryptoSignPublic, END) == -1)
|
||||
return WHY("Select failure");
|
||||
|
||||
if (dbVersion>=m->version)
|
||||
if (dbVersion >= m->version)
|
||||
return 2;
|
||||
|
||||
int status = rhizome_import_file(m, filepath);
|
||||
@ -301,8 +301,8 @@ int rhizome_add_manifest(rhizome_manifest *m, int ttl)
|
||||
return WHY("Manifest does not have an ID");
|
||||
|
||||
/* Discard the new manifest unless it is newer than the most recent known version with the same ID */
|
||||
int64_t storedversion = -1;
|
||||
switch (sqlite_exec_int64(&storedversion, "SELECT version FROM MANIFESTS WHERE id = ?;", RHIZOME_BID_T, &m->cryptoSignPublic, END)) {
|
||||
uint64_t storedversion = -1;
|
||||
switch (sqlite_exec_uint64(&storedversion, "SELECT version FROM MANIFESTS WHERE id = ?;", RHIZOME_BID_T, &m->cryptoSignPublic, END)) {
|
||||
case -1:
|
||||
return WHY("Select failed");
|
||||
case 0:
|
||||
@ -310,11 +310,11 @@ int rhizome_add_manifest(rhizome_manifest *m, int ttl)
|
||||
break;
|
||||
case 1:
|
||||
if (config.debug.rhizome)
|
||||
DEBUGF("Found existing version=%"PRId64", new version=%"PRId64, storedversion, m->version);
|
||||
DEBUGF("Found existing version=%"PRIu64", new version=%"PRIu64, storedversion, m->version);
|
||||
if (m->version < storedversion)
|
||||
return WHY("Newer version exists");
|
||||
if (m->version == storedversion)
|
||||
return WHYF("Already have %s:%"PRId64", not adding", alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), m->version);
|
||||
return WHYF("Already have %s:%"PRIu64", not adding", alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), m->version);
|
||||
break;
|
||||
default:
|
||||
return WHY("Select found too many rows!");
|
||||
|
21
rhizome.h
21
rhizome.h
@ -161,9 +161,8 @@ typedef struct rhizome_manifest
|
||||
|
||||
/* Version of the manifest. Typically the number of milliseconds since 1970.
|
||||
* A value of zero (0) means it has not been set yet.
|
||||
* TODO: change this to uint64_t.
|
||||
*/
|
||||
int64_t version;
|
||||
uint64_t version;
|
||||
|
||||
/* Payload is described by the offset of its tail (number of missing bytes
|
||||
* before the first byte in the payload), its size (number of bytes) and the
|
||||
@ -360,7 +359,7 @@ typedef struct rhizome_manifest
|
||||
#define rhizome_manifest_del_author(m) _rhizome_manifest_del_author(__WHENCE__,(m))
|
||||
|
||||
void _rhizome_manifest_set_id(struct __sourceloc, rhizome_manifest *, const rhizome_bid_t *);
|
||||
void _rhizome_manifest_set_version(struct __sourceloc, rhizome_manifest *, int64_t); // TODO change to uint64_t
|
||||
void _rhizome_manifest_set_version(struct __sourceloc, rhizome_manifest *, uint64_t);
|
||||
void _rhizome_manifest_set_filesize(struct __sourceloc, rhizome_manifest *, uint64_t);
|
||||
void _rhizome_manifest_set_filehash(struct __sourceloc, rhizome_manifest *, const rhizome_filehash_t *);
|
||||
void _rhizome_manifest_set_tail(struct __sourceloc, rhizome_manifest *, uint64_t);
|
||||
@ -445,7 +444,7 @@ sqlite_retry_state sqlite_retry_state_init(int serverLimit, int serverSleep, int
|
||||
|
||||
struct rhizome_manifest_summary {
|
||||
rhizome_bid_t bid;
|
||||
int64_t version;
|
||||
uint64_t version;
|
||||
size_t body_len;
|
||||
};
|
||||
|
||||
@ -538,8 +537,8 @@ void _sqlite_retry_done(struct __sourceloc, sqlite_retry_state *retry, const cha
|
||||
int _sqlite_step(struct __sourceloc, int log_level, sqlite_retry_state *retry, sqlite3_stmt *statement);
|
||||
int _sqlite_exec_void(struct __sourceloc, int log_level, const char *sqltext, ...);
|
||||
int _sqlite_exec_void_retry(struct __sourceloc, int log_level, sqlite_retry_state *retry, const char *sqltext, ...);
|
||||
int _sqlite_exec_int64(struct __sourceloc, int64_t *result, const char *sqltext, ...);
|
||||
int _sqlite_exec_int64_retry(struct __sourceloc, sqlite_retry_state *retry, int64_t *result, const char *sqltext, ...);
|
||||
int _sqlite_exec_uint64(struct __sourceloc, uint64_t *result, const char *sqltext, ...);
|
||||
int _sqlite_exec_uint64_retry(struct __sourceloc, sqlite_retry_state *retry, uint64_t *result, const char *sqltext, ...);
|
||||
int _sqlite_exec_strbuf(struct __sourceloc, strbuf sb, const char *sqltext, ...);
|
||||
int _sqlite_exec_strbuf_retry(struct __sourceloc, sqlite_retry_state *retry, strbuf sb, const char *sqltext, ...);
|
||||
int _sqlite_vexec_strbuf_retry(struct __sourceloc, sqlite_retry_state *retry, strbuf sb, const char *sqltext, va_list ap);
|
||||
@ -565,8 +564,8 @@ int _sqlite_vexec_strbuf_retry(struct __sourceloc, sqlite_retry_state *retry, st
|
||||
#define sqlite_exec_void_loglevel(ll,sql,arg,...) _sqlite_exec_void(__WHENCE__, (ll), (sql), arg, ##__VA_ARGS__)
|
||||
#define sqlite_exec_void_retry(rs,sql,arg,...) _sqlite_exec_void_retry(__WHENCE__, LOG_LEVEL_ERROR, (rs), (sql), arg, ##__VA_ARGS__)
|
||||
#define sqlite_exec_void_retry_loglevel(ll,rs,sql,arg,...) _sqlite_exec_void_retry(__WHENCE__, (ll), (rs), (sql), arg, ##__VA_ARGS__)
|
||||
#define sqlite_exec_int64(res,sql,arg,...) _sqlite_exec_int64(__WHENCE__, (res), (sql), arg, ##__VA_ARGS__)
|
||||
#define sqlite_exec_int64_retry(rs,res,sql,arg,...) _sqlite_exec_int64_retry(__WHENCE__, (rs), (res), (sql), arg, ##__VA_ARGS__)
|
||||
#define sqlite_exec_uint64(res,sql,arg,...) _sqlite_exec_uint64(__WHENCE__, (res), (sql), arg, ##__VA_ARGS__)
|
||||
#define sqlite_exec_uint64_retry(rs,res,sql,arg,...) _sqlite_exec_uint64_retry(__WHENCE__, (rs), (res), (sql), arg, ##__VA_ARGS__)
|
||||
#define sqlite_exec_strbuf(sb,sql,arg,...) _sqlite_exec_strbuf(__WHENCE__, (sb), (sql), arg, ##__VA_ARGS__)
|
||||
#define sqlite_exec_strbuf_retry(rs,sb,sql,arg,...) _sqlite_exec_strbuf_retry(__WHENCE__, (rs), (sb), (sql), arg, ##__VA_ARGS__)
|
||||
|
||||
@ -575,7 +574,7 @@ int rhizome_manifest_extract_signature(rhizome_manifest *m, unsigned *ofs);
|
||||
int rhizome_update_file_priority(const char *fileid);
|
||||
int rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found);
|
||||
int rhizome_manifest_to_bar(rhizome_manifest *m,unsigned char *bar);
|
||||
int64_t rhizome_bar_version(const unsigned char *bar);
|
||||
uint64_t rhizome_bar_version(const unsigned char *bar);
|
||||
uint64_t rhizome_bar_bidprefix_ll(unsigned char *bar);
|
||||
int rhizome_is_bar_interesting(unsigned char *bar);
|
||||
int rhizome_is_manifest_interesting(rhizome_manifest *m);
|
||||
@ -689,7 +688,7 @@ struct rhizome_write
|
||||
unsigned char nonce[crypto_stream_xsalsa20_NONCEBYTES];
|
||||
|
||||
SHA512_CTX sha512_context;
|
||||
int64_t blob_rowid;
|
||||
uint64_t blob_rowid;
|
||||
int blob_fd;
|
||||
sqlite3_blob *sql_blob;
|
||||
};
|
||||
@ -712,7 +711,7 @@ struct rhizome_read
|
||||
SHA512_CTX sha512_context;
|
||||
char invalid;
|
||||
|
||||
int64_t blob_rowid;
|
||||
uint64_t blob_rowid;
|
||||
int blob_fd;
|
||||
|
||||
uint64_t tail;
|
||||
|
@ -38,13 +38,13 @@ static const char *rhizome_manifest_get(const rhizome_manifest *m, const char *v
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int64_t rhizome_manifest_get_ll(rhizome_manifest *m, const char *var)
|
||||
static uint64_t rhizome_manifest_get_ui64(rhizome_manifest *m, const char *var)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < m->var_count; ++i)
|
||||
if (strcmp(m->vars[i], var) == 0) {
|
||||
int64_t val;
|
||||
return str_to_int64(m->values[i], 10, &val, NULL) ? val : -1;
|
||||
uint64_t val;
|
||||
return str_to_uint64(m->values[i], 10, &val, NULL) ? val : -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -75,7 +75,7 @@ static int _rhizome_manifest_del(struct __sourceloc __whence, rhizome_manifest *
|
||||
}
|
||||
|
||||
#define rhizome_manifest_set(m,var,value) _rhizome_manifest_set(__WHENCE__, (m), (var), (value))
|
||||
#define rhizome_manifest_set_ll(m,var,value) _rhizome_manifest_set_ll(__WHENCE__, (m), (var), (value))
|
||||
#define rhizome_manifest_set_ui64(m,var,value) _rhizome_manifest_set_ui64(__WHENCE__, (m), (var), (value))
|
||||
#define rhizome_manifest_del(m,var) _rhizome_manifest_del(__WHENCE__, (m), (var))
|
||||
|
||||
static const char *_rhizome_manifest_set(struct __sourceloc __whence, rhizome_manifest *m, const char *var, const char *value)
|
||||
@ -108,10 +108,10 @@ static const char *_rhizome_manifest_set(struct __sourceloc __whence, rhizome_ma
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const char *_rhizome_manifest_set_ll(struct __sourceloc __whence, rhizome_manifest *m, char *var, int64_t value)
|
||||
static const char *_rhizome_manifest_set_ui64(struct __sourceloc __whence, rhizome_manifest *m, char *var, uint64_t value)
|
||||
{
|
||||
char str[50];
|
||||
snprintf(str, sizeof str, "%" PRId64, value);
|
||||
snprintf(str, sizeof str, "%" PRIu64, value);
|
||||
return rhizome_manifest_set(m, var, str);
|
||||
}
|
||||
|
||||
@ -136,16 +136,16 @@ void _rhizome_manifest_set_id(struct __sourceloc __whence, rhizome_manifest *m,
|
||||
}
|
||||
}
|
||||
|
||||
void _rhizome_manifest_set_version(struct __sourceloc __whence, rhizome_manifest *m, int64_t version)
|
||||
void _rhizome_manifest_set_version(struct __sourceloc __whence, rhizome_manifest *m, uint64_t version)
|
||||
{
|
||||
const char *v = rhizome_manifest_set_ll(m, "version", version);
|
||||
const char *v = rhizome_manifest_set_ui64(m, "version", version);
|
||||
assert(v); // TODO: remove known manifest fields from vars[]
|
||||
m->version = version;
|
||||
}
|
||||
|
||||
void _rhizome_manifest_set_filesize(struct __sourceloc __whence, rhizome_manifest *m, uint64_t size)
|
||||
{
|
||||
const char *v = rhizome_manifest_set_ll(m, "filesize", size);
|
||||
const char *v = rhizome_manifest_set_ui64(m, "filesize", size);
|
||||
assert(v); // TODO: remove known manifest fields from vars[]
|
||||
m->filesize = size;
|
||||
if (m->filesize == 0)
|
||||
@ -171,7 +171,7 @@ void _rhizome_manifest_set_filehash(struct __sourceloc __whence, rhizome_manifes
|
||||
|
||||
void _rhizome_manifest_set_tail(struct __sourceloc __whence, rhizome_manifest *m, uint64_t tail)
|
||||
{
|
||||
const char *v = rhizome_manifest_set_ll(m, "tail", tail);
|
||||
const char *v = rhizome_manifest_set_ui64(m, "tail", tail);
|
||||
assert(v); // TODO: remove known manifest fields from vars[]
|
||||
m->tail = tail;
|
||||
m->is_journal = (tail != RHIZOME_SIZE_UNSET);
|
||||
@ -245,7 +245,7 @@ void _rhizome_manifest_del_name(struct __sourceloc __whence, rhizome_manifest *m
|
||||
|
||||
void _rhizome_manifest_set_date(struct __sourceloc __whence, rhizome_manifest *m, time_ms_t date)
|
||||
{
|
||||
const char *v = rhizome_manifest_set_ll(m, "date", date);
|
||||
const char *v = rhizome_manifest_set_ui64(m, "date", (uint64_t)date);
|
||||
assert(v); // TODO: remove known manifest fields from vars[]
|
||||
m->date = date;
|
||||
m->has_date = 1;
|
||||
@ -478,7 +478,7 @@ int rhizome_manifest_inspect(const char *buf, size_t len, struct rhizome_manifes
|
||||
state = Error; // invalid "id" field
|
||||
} else if (has_version == 1) {
|
||||
const char *e;
|
||||
if (str_to_uint64(begin, 10, (uint64_t*)&summ->version, &e) && e == eol)
|
||||
if (str_to_uint64(begin, 10, &summ->version, &e) && e == eol)
|
||||
has_version = 2;
|
||||
else
|
||||
state = Error; // invalid "version" field
|
||||
|
@ -82,8 +82,8 @@ uuid_t rhizome_db_uuid;
|
||||
/* XXX Requires a messy join that might be slow. */
|
||||
int rhizome_manifest_priority(sqlite_retry_state *retry, const rhizome_bid_t *bidp)
|
||||
{
|
||||
int64_t result = 0;
|
||||
if (sqlite_exec_int64_retry(retry, &result,
|
||||
uint64_t result = 0;
|
||||
if (sqlite_exec_uint64_retry(retry, &result,
|
||||
"SELECT max(grouplist.priorty) FROM GROUPLIST,MANIFESTS,GROUPMEMBERSHIPS"
|
||||
" WHERE MANIFESTS.id = ?"
|
||||
" AND GROUPLIST.id = GROUPMEMBERSHIPS.groupid"
|
||||
@ -264,8 +264,8 @@ int rhizome_opendb()
|
||||
|
||||
sqlite_retry_state retry = SQLITE_RETRY_STATE_DEFAULT;
|
||||
|
||||
int64_t version;
|
||||
if (sqlite_exec_int64_retry(&retry, &version, "PRAGMA user_version;", END) == -1)
|
||||
uint64_t version;
|
||||
if (sqlite_exec_uint64_retry(&retry, &version, "PRAGMA user_version;", END) == -1)
|
||||
RETURN(-1);
|
||||
|
||||
if (version<1){
|
||||
@ -958,7 +958,7 @@ int _sqlite_exec_void_retry(struct __sourceloc __whence, int log_level, sqlite_r
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int _sqlite_vexec_int64(struct __sourceloc __whence, sqlite_retry_state *retry, int64_t *result, const char *sqltext, va_list ap)
|
||||
static int _sqlite_vexec_uint64(struct __sourceloc __whence, sqlite_retry_state *retry, uint64_t *result, const char *sqltext, va_list ap)
|
||||
{
|
||||
sqlite3_stmt *statement = _sqlite_prepare(__whence, LOG_LEVEL_ERROR, retry, sqltext);
|
||||
if (!statement)
|
||||
@ -981,7 +981,7 @@ static int _sqlite_vexec_int64(struct __sourceloc __whence, sqlite_retry_state *
|
||||
if (!sqlite_code_ok(stepcode) || ret == -1)
|
||||
return -1;
|
||||
if (sqlite_trace_func())
|
||||
DEBUGF("rowcount=%d changes=%d result=%"PRId64, rowcount, sqlite3_changes(rhizome_db), *result);
|
||||
DEBUGF("rowcount=%d changes=%d result=%"PRIu64, rowcount, sqlite3_changes(rhizome_db), *result);
|
||||
return rowcount;
|
||||
}
|
||||
|
||||
@ -995,28 +995,28 @@ static int _sqlite_vexec_int64(struct __sourceloc __whence, sqlite_retry_state *
|
||||
*
|
||||
* @author Andrew Bettison <andrew@servalproject.com>
|
||||
*/
|
||||
int _sqlite_exec_int64(struct __sourceloc __whence, int64_t *result, const char *sqlformat,...)
|
||||
int _sqlite_exec_uint64(struct __sourceloc __whence, uint64_t *result, const char *sqlformat,...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, sqlformat);
|
||||
sqlite_retry_state retry = SQLITE_RETRY_STATE_DEFAULT;
|
||||
int ret = _sqlite_vexec_int64(__whence, &retry, result, sqlformat, ap);
|
||||
int ret = _sqlite_vexec_uint64(__whence, &retry, result, sqlformat, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Same as sqlite_exec_int64() but if the statement cannot be executed because the database is
|
||||
/* Same as sqlite_exec_uint64() but if the statement cannot be executed because the database is
|
||||
* currently locked for updates, then will call sqlite_retry() on the supplied retry state variable
|
||||
* instead of its own, internal one. If 'retry' is passed as NULL, then will not sleep and retry at
|
||||
* all in the event of a busy condition, but will log it as an error and return immediately.
|
||||
*
|
||||
* @author Andrew Bettison <andrew@servalproject.com>
|
||||
*/
|
||||
int _sqlite_exec_int64_retry(struct __sourceloc __whence, sqlite_retry_state *retry, int64_t *result, const char *sqlformat,...)
|
||||
int _sqlite_exec_uint64_retry(struct __sourceloc __whence, sqlite_retry_state *retry, uint64_t *result, const char *sqlformat,...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, sqlformat);
|
||||
int ret = _sqlite_vexec_int64(__whence, retry, result, sqlformat, ap);
|
||||
int ret = _sqlite_vexec_uint64(__whence, retry, result, sqlformat, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
@ -1071,16 +1071,18 @@ int _sqlite_vexec_strbuf_retry(struct __sourceloc __whence, sqlite_retry_state *
|
||||
return sqlite_code_ok(stepcode) && ret != -1 ? rowcount : -1;
|
||||
}
|
||||
|
||||
int64_t rhizome_database_used_bytes()
|
||||
static uint64_t rhizome_database_used_bytes()
|
||||
{
|
||||
int64_t db_page_size;
|
||||
int64_t db_page_count;
|
||||
int64_t db_free_page_count;
|
||||
if ( sqlite_exec_int64(&db_page_size, "PRAGMA page_size;", END) == -1LL
|
||||
|| sqlite_exec_int64(&db_page_count, "PRAGMA page_count;", END) == -1LL
|
||||
|| sqlite_exec_int64(&db_free_page_count, "PRAGMA free_count;", END) == -1LL
|
||||
)
|
||||
return WHY("Cannot measure database used bytes");
|
||||
uint64_t db_page_size;
|
||||
uint64_t db_page_count;
|
||||
uint64_t db_free_page_count;
|
||||
if ( sqlite_exec_uint64(&db_page_size, "PRAGMA page_size;", END) == -1LL
|
||||
|| sqlite_exec_uint64(&db_page_count, "PRAGMA page_count;", END) == -1LL
|
||||
|| sqlite_exec_uint64(&db_free_page_count, "PRAGMA free_count;", END) == -1LL
|
||||
) {
|
||||
WHY("Cannot measure database used bytes");
|
||||
return UINT64_MAX;
|
||||
}
|
||||
return db_page_size * (db_page_count - db_free_page_count);
|
||||
}
|
||||
|
||||
@ -1092,7 +1094,7 @@ int rhizome_database_filehash_from_id(const rhizome_bid_t *bidp, uint64_t versio
|
||||
INT64, version, RHIZOME_BID_T, bidp, END) == -1)
|
||||
RETURN(-1);
|
||||
if (strbuf_overrun(hash_sb) || str_to_rhizome_filehash_t(hashp, strbuf_str(hash_sb)) == -1)
|
||||
RETURN(WHYF("malformed file hash for bid=%s version=%"PRId64, alloca_tohex_rhizome_bid_t(*bidp), version));
|
||||
RETURN(WHYF("malformed file hash for bid=%s version=%"PRIu64, alloca_tohex_rhizome_bid_t(*bidp), version));
|
||||
RETURN(0);
|
||||
OUT();
|
||||
}
|
||||
@ -1213,8 +1215,8 @@ int rhizome_make_space(int group_priority, uint64_t bytes)
|
||||
if (bytes >= limit)
|
||||
return WHYF("bytes=%"PRIu64" is too large", bytes);
|
||||
|
||||
int64_t db_used = rhizome_database_used_bytes();
|
||||
if (db_used == -1)
|
||||
uint64_t db_used = rhizome_database_used_bytes();
|
||||
if (db_used == UINT64_MAX)
|
||||
return -1;
|
||||
|
||||
rhizome_cleanup(NULL);
|
||||
@ -1230,9 +1232,7 @@ int rhizome_make_space(int group_priority, uint64_t bytes)
|
||||
INT, group_priority, END);
|
||||
if (!statement)
|
||||
return -1;
|
||||
while (rhizome_database_used_bytes() + bytes > limit
|
||||
&& sqlite_step_retry(&retry, statement) == SQLITE_ROW
|
||||
) {
|
||||
while (db_used + bytes > limit && sqlite_step_retry(&retry, statement) == SQLITE_ROW) {
|
||||
/* Make sure we can drop this blob, and if so drop it, and recalculate number of bytes required */
|
||||
const char *id;
|
||||
/* Get values */
|
||||
@ -1257,6 +1257,8 @@ int rhizome_make_space(int group_priority, uint64_t bytes)
|
||||
* to be paranoid, and it also protects against inconsistency in the database.
|
||||
*/
|
||||
rhizome_drop_stored_file(&hash, group_priority + 1);
|
||||
if ((db_used = rhizome_database_used_bytes()) == UINT64_MAX)
|
||||
break;
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(statement);
|
||||
@ -1458,7 +1460,7 @@ int rhizome_store_bundle(rhizome_manifest *m)
|
||||
|
||||
if (sqlite_exec_void_retry(&retry, "COMMIT;", END) != -1){
|
||||
// This message used in tests; do not modify or remove.
|
||||
INFOF("RHIZOME ADD MANIFEST service=%s bid=%s version=%"PRId64,
|
||||
INFOF("RHIZOME ADD MANIFEST service=%s bid=%s version=%"PRIu64,
|
||||
m->service ? m->service : "NULL",
|
||||
alloca_tohex_rhizome_bid_t(m->cryptoSignPublic),
|
||||
m->version
|
||||
@ -1590,7 +1592,7 @@ int rhizome_list_next(sqlite_retry_state *retry, struct rhizome_list_cursor *c)
|
||||
const char *q_manifestid = (const char *) sqlite3_column_text(c->_statement, 0);
|
||||
const char *manifestblob = (char *) sqlite3_column_blob(c->_statement, 1);
|
||||
size_t manifestblobsize = sqlite3_column_bytes(c->_statement, 1); // must call after sqlite3_column_blob()
|
||||
int64_t q_version = sqlite3_column_int64(c->_statement, 2);
|
||||
uint64_t q_version = sqlite3_column_int64(c->_statement, 2);
|
||||
int64_t q_inserttime = sqlite3_column_int64(c->_statement, 3);
|
||||
const char *q_author = (const char *) sqlite3_column_text(c->_statement, 4);
|
||||
sid_t *author = NULL;
|
||||
@ -1611,7 +1613,7 @@ int rhizome_list_next(sqlite_retry_state *retry, struct rhizome_list_cursor *c)
|
||||
continue;
|
||||
}
|
||||
if (m->version != q_version) {
|
||||
WHYF("MANIFESTS row id=%s version=%"PRId64" does not match manifest blob version=%"PRId64" -- skipped",
|
||||
WHYF("MANIFESTS row id=%s version=%"PRIu64" does not match manifest blob version=%"PRIu64" -- skipped",
|
||||
q_manifestid, q_version, m->version);
|
||||
continue;
|
||||
}
|
||||
@ -1668,20 +1670,21 @@ void rhizome_bytes_to_hex_upper(unsigned const char *in, char *out, int byteCoun
|
||||
int rhizome_update_file_priority(const char *fileid)
|
||||
{
|
||||
/* work out the highest priority of any referrer */
|
||||
int64_t highestPriority = -1;
|
||||
uint64_t highestPriority = 0;
|
||||
sqlite_retry_state retry = SQLITE_RETRY_STATE_DEFAULT;
|
||||
if (sqlite_exec_int64_retry(&retry, &highestPriority,
|
||||
if (sqlite_exec_uint64_retry(&retry, &highestPriority,
|
||||
"SELECT max(grouplist.priority) FROM MANIFESTS, GROUPMEMBERSHIPS, GROUPLIST"
|
||||
" WHERE MANIFESTS.filehash = ?"
|
||||
" AND GROUPMEMBERSHIPS.manifestid = MANIFESTS.id"
|
||||
" AND GROUPMEMBERSHIPS.groupid = GROUPLIST.id;",
|
||||
TEXT_TOUPPER, fileid, END) == -1)
|
||||
TEXT_TOUPPER, fileid, END
|
||||
) == -1
|
||||
)
|
||||
return -1;
|
||||
if ( highestPriority >= 0
|
||||
&& sqlite_exec_void_retry(&retry,
|
||||
"UPDATE files SET highestPriority = ? WHERE id = ?;",
|
||||
INT, highestPriority, TEXT_TOUPPER, fileid, END
|
||||
) == -1
|
||||
if (sqlite_exec_void_retry(&retry,
|
||||
"UPDATE files SET highestPriority = ? WHERE id = ?;",
|
||||
INT64, highestPriority, TEXT_TOUPPER, fileid, END
|
||||
) == -1
|
||||
)
|
||||
return WHYF("cannot update priority for fileid=%s", fileid);
|
||||
return 0;
|
||||
@ -1779,7 +1782,7 @@ static int unpack_manifest_row(rhizome_manifest *m, sqlite3_stmt *statement)
|
||||
{
|
||||
const char *q_id = (const char *) sqlite3_column_text(statement, 0);
|
||||
const char *q_blob = (char *) sqlite3_column_blob(statement, 1);
|
||||
int64_t q_version = sqlite3_column_int64(statement, 2);
|
||||
uint64_t q_version = sqlite3_column_int64(statement, 2);
|
||||
int64_t q_inserttime = sqlite3_column_int64(statement, 3);
|
||||
const char *q_author = (const char *) sqlite3_column_text(statement, 4);
|
||||
size_t q_blobsize = sqlite3_column_bytes(statement, 1); // must call after sqlite3_column_blob()
|
||||
@ -1794,7 +1797,7 @@ static int unpack_manifest_row(rhizome_manifest *m, sqlite3_stmt *statement)
|
||||
rhizome_manifest_set_author(m, &author);
|
||||
}
|
||||
if (m->version != q_version)
|
||||
WARNF("Version mismatch, manifest is %"PRId64", database is %"PRId64, m->version, q_version);
|
||||
WARNF("Version mismatch, manifest is %"PRIu64", database is %"PRIu64, m->version, q_version);
|
||||
rhizome_manifest_set_rowid(m, q_rowid);
|
||||
rhizome_manifest_set_inserttime(m, q_inserttime);
|
||||
return 0;
|
||||
@ -1957,7 +1960,7 @@ int rhizome_delete_file(const rhizome_filehash_t *hashp)
|
||||
return rhizome_delete_file_retry(&retry, hashp);
|
||||
}
|
||||
|
||||
static int is_interesting(const char *id_hex, int64_t version)
|
||||
static int is_interesting(const char *id_hex, uint64_t version)
|
||||
{
|
||||
IN();
|
||||
int ret=1;
|
||||
@ -1990,7 +1993,7 @@ static int is_interesting(const char *id_hex, int64_t version)
|
||||
|
||||
int rhizome_is_bar_interesting(unsigned char *bar)
|
||||
{
|
||||
int64_t version = rhizome_bar_version(bar);
|
||||
uint64_t version = rhizome_bar_version(bar);
|
||||
char id_hex[RHIZOME_BAR_PREFIX_BYTES *2 + 2];
|
||||
tohex(id_hex, RHIZOME_BAR_PREFIX_BYTES * 2, &bar[RHIZOME_BAR_PREFIX_OFFSET]);
|
||||
strcat(id_hex, "%");
|
||||
|
@ -350,8 +350,8 @@ rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response(unsigned char *bu
|
||||
rhizome_bar_bidprefix_ll(&usbuffer[10+us*RHIZOME_BAR_BYTES]));
|
||||
} else {
|
||||
/* We each have a version of this bundle, so see whose is newer */
|
||||
int64_t them_version = rhizome_bar_version(&buffer[10+them*RHIZOME_BAR_BYTES]);
|
||||
int64_t us_version = rhizome_bar_version(&usbuffer[10+us*RHIZOME_BAR_BYTES]);
|
||||
uint64_t them_version = rhizome_bar_version(&buffer[10+them*RHIZOME_BAR_BYTES]);
|
||||
uint64_t us_version = rhizome_bar_version(&usbuffer[10+us*RHIZOME_BAR_BYTES]);
|
||||
if (them_version>us_version) {
|
||||
/* They have the newer version of the bundle */
|
||||
c->buffer[c->buffer_offset_bytes+c->buffer_used]=0x01; /* Please send */
|
||||
@ -359,10 +359,10 @@ rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response(unsigned char *bu
|
||||
&c->buffer[c->buffer_offset_bytes+c->buffer_used+1],
|
||||
RHIZOME_BAR_PREFIX_BYTES);
|
||||
c->buffer_used+=1+RHIZOME_BAR_PREFIX_BYTES;
|
||||
DEBUGF("They have newer version of bundle %016"PRIx64"* (%"PRId64" versus %"PRId64")",
|
||||
DEBUGF("They have newer version of bundle %016"PRIx64"* (%"PRIu64" versus %"PRIu64")",
|
||||
rhizome_bar_bidprefix_ll(&usbuffer[10+us*RHIZOME_BAR_BYTES]),
|
||||
rhizome_bar_version(&usbuffer[10+us*RHIZOME_BAR_BYTES]),
|
||||
rhizome_bar_version(&buffer[10+them*RHIZOME_BAR_BYTES]));
|
||||
them_version,
|
||||
us_version);
|
||||
} else if (them_version<us_version) {
|
||||
/* We have the newer version of the bundle */
|
||||
c->buffer[c->buffer_offset_bytes+c->buffer_used]=0x02; /* I have [newer] */
|
||||
@ -370,10 +370,10 @@ rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response(unsigned char *bu
|
||||
&c->buffer[c->buffer_offset_bytes+c->buffer_used+1],
|
||||
RHIZOME_BAR_PREFIX_BYTES);
|
||||
c->buffer_used+=1+RHIZOME_BAR_PREFIX_BYTES;
|
||||
DEBUGF("We have newer version of bundle %016"PRIx64"* (%"PRId64" versus %"PRId64")",
|
||||
DEBUGF("We have newer version of bundle %016"PRIx64"* (%"PRIu64" versus %"PRIu64")",
|
||||
rhizome_bar_bidprefix_ll(&usbuffer[10+us*RHIZOME_BAR_BYTES]),
|
||||
rhizome_bar_version(&usbuffer[10+us*RHIZOME_BAR_BYTES]),
|
||||
rhizome_bar_version(&buffer[10+them*RHIZOME_BAR_BYTES]));
|
||||
us_version,
|
||||
them_version);
|
||||
} else {
|
||||
DEBUGF("We both have the same version of %016"PRIx64"*",
|
||||
rhizome_bar_bidprefix_ll(&buffer[10+them*RHIZOME_BAR_BYTES]));
|
||||
|
@ -644,7 +644,7 @@ void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
|
||||
DEBUGF("bundle id = %s", alloca_tohex_rhizome_bid_t(m->cryptoSignPublic));
|
||||
DEBUGF("bundle filehash = %s", alloca_tohex_rhizome_filehash_t(m->filehash));
|
||||
DEBUGF("file size = %"PRId64, m->filesize);
|
||||
DEBUGF("version = %"PRId64, m->version);
|
||||
DEBUGF("version = %"PRIu64, m->version);
|
||||
}
|
||||
|
||||
/* We now have everything we need to compose the POST request and send it.
|
||||
|
@ -79,7 +79,7 @@ struct rhizome_fetch_slot {
|
||||
|
||||
/* MDP transport specific elements */
|
||||
rhizome_bid_t bid;
|
||||
int64_t bidVersion;
|
||||
uint64_t bidVersion;
|
||||
int prefix_length;
|
||||
int mdpIdleTimeout;
|
||||
time_ms_t mdp_last_request_time;
|
||||
@ -493,12 +493,12 @@ static int schedule_fetch(struct rhizome_fetch_slot *slot)
|
||||
slot->start_time=gettime_ms();
|
||||
slot->alarm.poll.fd = -1;
|
||||
slot->write_state.blob_fd=-1;
|
||||
slot->write_state.blob_rowid=-1;
|
||||
slot->write_state.blob_rowid = 0;
|
||||
|
||||
if (slot->manifest) {
|
||||
slot->bid = slot->manifest->cryptoSignPublic;
|
||||
slot->prefix_length = sizeof slot->bid.binary;
|
||||
slot->bidVersion=slot->manifest->version;
|
||||
slot->bidVersion = slot->manifest->version;
|
||||
/* Don't provide a filename, because we will stream the file straight into
|
||||
the database. */
|
||||
slot->manifest->dataFileName = NULL;
|
||||
@ -668,7 +668,7 @@ rhizome_fetch(struct rhizome_fetch_slot *slot, rhizome_manifest *m, const struct
|
||||
*/
|
||||
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("Fetching bundle slot=%d bid=%s version=%"PRId64" size=%"PRIu64" peerip=%s",
|
||||
DEBUGF("Fetching bundle slot=%d bid=%s version=%"PRIu64" size=%"PRIu64" peerip=%s",
|
||||
slotno(slot),
|
||||
alloca_tohex_rhizome_bid_t(m->cryptoSignPublic),
|
||||
m->version,
|
||||
@ -878,7 +878,7 @@ int rhizome_suggest_queue_manifest_import(rhizome_manifest *m, const struct sock
|
||||
int priority=100; /* normal priority */
|
||||
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("Considering import bid=%s version=%"PRId64" size=%"PRIu64" priority=%d:",
|
||||
DEBUGF("Considering import bid=%s version=%"PRIu64" size=%"PRIu64" priority=%d:",
|
||||
alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), m->version, m->filesize, priority);
|
||||
|
||||
if (!rhizome_is_manifest_interesting(m)) {
|
||||
@ -889,9 +889,9 @@ int rhizome_suggest_queue_manifest_import(rhizome_manifest *m, const struct sock
|
||||
}
|
||||
|
||||
if (config.debug.rhizome_rx) {
|
||||
int64_t stored_version;
|
||||
if (sqlite_exec_int64(&stored_version, "SELECT version FROM MANIFESTS WHERE id = ?", RHIZOME_BID_T, &m->cryptoSignPublic, END) > 0)
|
||||
DEBUGF(" is new (have version %"PRId64")", stored_version);
|
||||
uint64_t stored_version;
|
||||
if (sqlite_exec_uint64(&stored_version, "SELECT version FROM MANIFESTS WHERE id = ?", RHIZOME_BID_T, &m->cryptoSignPublic, END) > 0)
|
||||
DEBUGF(" is new (have version %"PRIu64")", stored_version);
|
||||
}
|
||||
|
||||
assert(m->filesize != RHIZOME_SIZE_UNSET);
|
||||
@ -1026,8 +1026,7 @@ static int rhizome_fetch_close(struct rhizome_fetch_slot *slot)
|
||||
rhizome_manifest_free(slot->previous);
|
||||
slot->previous = NULL;
|
||||
|
||||
if (slot->write_state.blob_fd>=0 ||
|
||||
slot->write_state.blob_rowid>=0)
|
||||
if (slot->write_state.blob_fd != -1 || slot->write_state.blob_rowid != 0)
|
||||
rhizome_fail_write(&slot->write_state);
|
||||
|
||||
// Release the fetch slot.
|
||||
|
@ -277,7 +277,7 @@ void rhizome_server_poll(struct sched_ent *alarm)
|
||||
request->uuid = rhizome_http_request_uuid_counter++;
|
||||
request->data_file_name[0] = '\0';
|
||||
request->u.read_state.blob_fd = -1;
|
||||
request->u.read_state.blob_rowid = -1;
|
||||
request->u.read_state.blob_rowid = 0;
|
||||
if (peerip)
|
||||
request->http.client_sockaddr_in = *peerip;
|
||||
request->http.handle_headers = rhizome_dispatch;
|
||||
@ -498,7 +498,7 @@ static int restful_rhizome_bundlelist_json_content_chunk(sqlite_retry_state *ret
|
||||
strbuf_putc(b, ',');
|
||||
strbuf_json_hex(b, m->cryptoSignPublic.binary, sizeof m->cryptoSignPublic.binary);
|
||||
strbuf_putc(b, ',');
|
||||
strbuf_sprintf(b, "%"PRId64, m->version);
|
||||
strbuf_sprintf(b, "%"PRIu64, m->version);
|
||||
strbuf_putc(b, ',');
|
||||
if (m->has_date)
|
||||
strbuf_sprintf(b, "%"PRItime_ms_t, m->date);
|
||||
|
@ -120,12 +120,12 @@ int rhizome_manifest_to_bar(rhizome_manifest *m,unsigned char *bar)
|
||||
OUT();
|
||||
}
|
||||
|
||||
int64_t rhizome_bar_version(const unsigned char *bar)
|
||||
uint64_t rhizome_bar_version(const unsigned char *bar)
|
||||
{
|
||||
int64_t version=0;
|
||||
uint64_t version=0;
|
||||
int i;
|
||||
for(i=0;i<7;i++)
|
||||
version|=((int64_t)(bar[RHIZOME_BAR_VERSION_OFFSET+6-i]))<<(8LL*i);
|
||||
version|=((uint64_t)(bar[RHIZOME_BAR_VERSION_OFFSET+6-i]))<<(8LL*i);
|
||||
return version;
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ static int append_bars(struct overlay_buffer *e, sqlite_retry_state *retry, cons
|
||||
/* Periodically queue BAR advertisements
|
||||
Always advertise the most recent 3 manifests in the table, cycle through the rest of the table, adding 17 BAR's at a time
|
||||
*/
|
||||
int64_t bundles_available=0;
|
||||
static uint64_t bundles_available=0;
|
||||
void overlay_rhizome_advertise(struct sched_ent *alarm)
|
||||
{
|
||||
bundles_available=0;
|
||||
@ -204,7 +204,7 @@ void overlay_rhizome_advertise(struct sched_ent *alarm)
|
||||
goto end;
|
||||
|
||||
/* Get number of bundles available */
|
||||
if (sqlite_exec_int64_retry(&retry, &bundles_available, "SELECT COUNT(BAR) FROM MANIFESTS;", END) != 1){
|
||||
if (sqlite_exec_uint64_retry(&retry, &bundles_available, "SELECT COUNT(BAR) FROM MANIFESTS;", END) != 1){
|
||||
WHY("Could not count BARs for advertisement");
|
||||
goto end;
|
||||
}
|
||||
@ -272,7 +272,7 @@ int rhizome_advertise_manifest(struct subscriber *dest, rhizome_manifest *m){
|
||||
if (overlay_payload_enqueue(frame) == -1)
|
||||
goto error;
|
||||
if (config.debug.rhizome_ads)
|
||||
DEBUGF("Advertising manifest %s %"PRId64" to %s",
|
||||
DEBUGF("Advertising manifest %s %"PRIu64" to %s",
|
||||
alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), m->version, dest?alloca_tohex_sid_t(dest->sid):"broadcast");
|
||||
return 0;
|
||||
error:
|
||||
@ -329,7 +329,7 @@ int overlay_rhizome_saw_advertisements(struct decode_context *context, struct ov
|
||||
}
|
||||
|
||||
if (config.debug.rhizome_ads)
|
||||
DEBUGF("manifest id=%s version=%"PRId64, alloca_tohex_rhizome_bid_t(summ.bid), summ.version);
|
||||
DEBUGF("manifest id=%s version=%"PRIu64, alloca_tohex_rhizome_bid_t(summ.bid), summ.version);
|
||||
|
||||
// If it looks like there is no signature at all, ignore the announcement but don't brown-list
|
||||
// the manifest ID, so that we will still process other offers of the same manifest with
|
||||
@ -421,7 +421,7 @@ next:
|
||||
if (log2_size!=0xFF && rhizome_fetch_has_queue_space(log2_size)!=1)
|
||||
continue;
|
||||
|
||||
int64_t version = rhizome_bar_version(bar);
|
||||
uint64_t version = rhizome_bar_version(bar);
|
||||
// are we already fetching this bundle [or later]?
|
||||
rhizome_manifest *m=rhizome_fetch_search(&bar[RHIZOME_BAR_PREFIX_OFFSET], RHIZOME_BAR_PREFIX_BYTES);
|
||||
if (m && m->version >= version)
|
||||
|
@ -27,8 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
int rhizome_exists(const rhizome_filehash_t *hashp)
|
||||
{
|
||||
int64_t gotfile = 0;
|
||||
if (sqlite_exec_int64(&gotfile, "SELECT COUNT(*) FROM FILES WHERE id = ? and datavalid = 1;", RHIZOME_FILEHASH_T, hashp, END) != 1)
|
||||
uint64_t gotfile = 0;
|
||||
if (sqlite_exec_uint64(&gotfile, "SELECT COUNT(*) FROM FILES WHERE id = ? and datavalid = 1;", RHIZOME_FILEHASH_T, hashp, END) != 1)
|
||||
return 0;
|
||||
return gotfile;
|
||||
}
|
||||
@ -467,7 +467,7 @@ int rhizome_fail_write(struct rhizome_write *write)
|
||||
|
||||
int rhizome_finish_write(struct rhizome_write *write)
|
||||
{
|
||||
if (write->blob_rowid==-1 && write->blob_fd == -1)
|
||||
if (write->blob_rowid==0 && write->blob_fd == -1)
|
||||
return WHY("Can't finish a write that has already been closed");
|
||||
if (write->buffer_list){
|
||||
if (rhizome_random_write(write, 0, NULL, 0))
|
||||
@ -565,7 +565,7 @@ int rhizome_finish_write(struct rhizome_write *write)
|
||||
if (config.debug.rhizome)
|
||||
DEBUGF("Stored file %s", alloca_tohex_rhizome_filehash_t(write->id));
|
||||
}
|
||||
write->blob_rowid=-1;
|
||||
write->blob_rowid = 0;
|
||||
return 0;
|
||||
|
||||
dbfailure:
|
||||
@ -666,7 +666,7 @@ static int rhizome_write_derive_key(rhizome_manifest *m, struct rhizome_write *w
|
||||
return -1;
|
||||
|
||||
if (config.debug.rhizome)
|
||||
DEBUGF("Encrypting payload contents for %s, %"PRId64, alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), m->version);
|
||||
DEBUGF("Encrypting payload contents for %s, %"PRIu64, alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), m->version);
|
||||
|
||||
write->crypt=1;
|
||||
if (m->is_journal && m->tail > 0)
|
||||
@ -713,16 +713,16 @@ failure:
|
||||
int rhizome_open_read(struct rhizome_read *read, const rhizome_filehash_t *hashp)
|
||||
{
|
||||
read->id = *hashp;
|
||||
read->blob_rowid = -1;
|
||||
read->blob_rowid = 0;
|
||||
read->blob_fd = -1;
|
||||
if (sqlite_exec_int64(&read->blob_rowid,
|
||||
if (sqlite_exec_uint64(&read->blob_rowid,
|
||||
"SELECT FILEBLOBS.rowid "
|
||||
"FROM FILEBLOBS, FILES "
|
||||
"WHERE FILEBLOBS.id = FILES.id"
|
||||
" AND FILES.id = ?"
|
||||
" AND FILES.datavalid != 0", RHIZOME_FILEHASH_T, &read->id, END) == -1)
|
||||
return -1;
|
||||
if (read->blob_rowid != -1) {
|
||||
if (read->blob_rowid != 0) {
|
||||
read->length = RHIZOME_SIZE_UNSET; // discover the length on opening the db BLOB
|
||||
} else {
|
||||
// No row in FILEBLOBS, look for an external blob file.
|
||||
@ -763,7 +763,7 @@ static ssize_t rhizome_read_retry(sqlite_retry_state *retry, struct rhizome_read
|
||||
DEBUGF("Read %zu bytes from fd=%d @%"PRIx64, (size_t) rd, read_state->blob_fd, read_state->offset);
|
||||
RETURN(rd);
|
||||
}
|
||||
if (read_state->blob_rowid == -1)
|
||||
if (read_state->blob_rowid == 0)
|
||||
RETURN(WHY("file not open"));
|
||||
sqlite3_blob *blob = NULL;
|
||||
int ret;
|
||||
@ -1110,7 +1110,7 @@ static int read_derive_key(rhizome_manifest *m, struct rhizome_read *read_state)
|
||||
return WHY("Unable to decrypt bundle, valid key not found");
|
||||
}
|
||||
if (config.debug.rhizome)
|
||||
DEBUGF("Decrypting payload contents for bid=%s version=%"PRId64, alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), m->version);
|
||||
DEBUGF("Decrypting payload contents for bid=%s version=%"PRIu64, alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), m->version);
|
||||
if (m->is_journal && m->tail > 0)
|
||||
read_state->tail = m->tail;
|
||||
bcopy(m->payloadKey, read_state->key, sizeof(read_state->key));
|
||||
|
@ -120,7 +120,7 @@ static void rhizome_sync_send_requests(struct subscriber *subscriber, struct rhi
|
||||
if (log2_size!=0xFF && rhizome_fetch_has_queue_space(log2_size)!=1)
|
||||
continue;
|
||||
|
||||
int64_t version = rhizome_bar_version(state->bars[i].bar);
|
||||
uint64_t version = rhizome_bar_version(state->bars[i].bar);
|
||||
// are we already fetching this bundle [or later]?
|
||||
rhizome_manifest *m=rhizome_fetch_search(prefix, RHIZOME_BAR_PREFIX_BYTES);
|
||||
if (m && m->version >= version)
|
||||
@ -176,14 +176,14 @@ static int sync_bundle_inserted(struct subscriber *subscriber, void *context)
|
||||
return 0;
|
||||
|
||||
const unsigned char *id = &bar[RHIZOME_BAR_PREFIX_OFFSET];
|
||||
int64_t version = rhizome_bar_version(bar);
|
||||
uint64_t version = rhizome_bar_version(bar);
|
||||
|
||||
struct rhizome_sync *state = subscriber->sync_state;
|
||||
int i;
|
||||
for (i=state->bar_count -1;i>=0;i--){
|
||||
unsigned char *this_bar = state->bars[i].bar;
|
||||
unsigned char *this_id = &this_bar[RHIZOME_BAR_PREFIX_OFFSET];
|
||||
int64_t this_version = rhizome_bar_version(this_bar);
|
||||
uint64_t this_version = rhizome_bar_version(this_bar);
|
||||
if (memcmp(this_id, id, RHIZOME_BAR_PREFIX_BYTES)==0 && version >= this_version){
|
||||
// remove this BAR and shift the last BAR down to this position if required.
|
||||
if (config.debug.rhizome)
|
||||
|
1
serval.h
1
serval.h
@ -709,7 +709,6 @@ int upper7_decode(struct slip_decode_state *state,unsigned char byte);
|
||||
uint32_t Crc32_ComputeBuf( uint32_t inCrc32, const void *buf,
|
||||
size_t bufLen );
|
||||
void rhizome_fetch_log_short_status();
|
||||
extern int64_t bundles_available;
|
||||
extern char crash_handler_clue[1024];
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user