diff --git a/overlay_mdp.c b/overlay_mdp.c index 07311750..33e23d4f 100644 --- a/overlay_mdp.c +++ b/overlay_mdp.c @@ -64,6 +64,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "keyring.h" #include "socket.h" #include "server.h" +#include "rhizome.h" #include "route_link.h" #include "debug.h" @@ -1620,7 +1621,7 @@ static void mdp_process_packet(struct socket_address *client, struct mdp_header break; case MDP_SYNC_RHIZOME: DEBUGF(mdprequests, "Processing MDP_SYNC_RHIZOME from %s", alloca_socket_address(client)); - server_rhizome_add_bundle(INT64_MAX); + rhizome_process_added_bundles(INT64_MAX); mdp_reply_ok(client, header); break; case MDP_INTERFACE: diff --git a/rhizome.h b/rhizome.h index 4f3913b8..912380a6 100644 --- a/rhizome.h +++ b/rhizome.h @@ -910,6 +910,7 @@ int rhizome_cache_close(); int rhizome_database_filehash_from_id(const rhizome_bid_t *bidp, uint64_t version, rhizome_filehash_t *hashp); +void rhizome_process_added_bundles(uint64_t up_to_rowid); void rhizome_sync_status(); DECLARE_ALARM(rhizome_fetch_status); diff --git a/rhizome_database.c b/rhizome_database.c index daca5a0e..e389a1ca 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -1564,7 +1564,7 @@ enum rhizome_bundle_status rhizome_add_manifest_to_store(rhizome_manifest *m, rh // due to potential race conditions, we have to do this here // even though the CLI will try to send us a MDP_SYNC_RHIZOME message if (m->rowid > max_rowid+1) - server_rhizome_add_bundle(m->rowid); + rhizome_process_added_bundles(m->rowid); max_rowid = m->rowid; CALL_TRIGGER(bundle_add, m); }else{ @@ -2028,14 +2028,14 @@ end: return ret; } -// Detect bundles added from the cmdline, and call trigger functions -void server_rhizome_add_bundle(uint64_t rowid){ +// Detect bundles added from the cmdline, and call trigger functions. +void rhizome_process_added_bundles(uint64_t up_to_rowid) { assert(serverMode); sqlite_retry_state retry = SQLITE_RETRY_STATE_DEFAULT; sqlite3_stmt *statement = sqlite_prepare_bind(&retry, "SELECT id, manifest, version, inserttime, author, rowid FROM manifests WHERE rowid > ? AND rowid < ?" "ORDER BY rowid", - INT64, max_rowid, INT64, rowid, END); + INT64, max_rowid, INT64, up_to_rowid, END); while (sqlite_step_retry(&retry, statement) == SQLITE_ROW) { rhizome_manifest *m = rhizome_new_manifest(); if (!m) diff --git a/server.h b/server.h index 4afa71ce..b9ca675b 100644 --- a/server.h +++ b/server.h @@ -52,8 +52,6 @@ void server_loop(time_ms_t (*waiting)(time_ms_t, time_ms_t, time_ms_t), void (*w int server_write_proc_state(const char *path, const char *fmt, ...); int server_unlink_proc_state(const char *path); -void server_rhizome_add_bundle(uint64_t rowid); - DECLARE_TRIGGER(startup); DECLARE_TRIGGER(shutdown);