summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-04-14 20:52:24 -0400
committerrsiddharth <s@ricketyspace.net>2020-04-17 20:56:37 -0400
commit09f04a6bdd80450ab8a972262cc07c5cbf0aa0fa (patch)
treee1ac237ff9dd7262bba96f719127222b8320bc6e
parent0e0bc28ea8cc29b8b9c8b6a85ffc3fbf888ace4b (diff)
nserver: Update ssload.
* nserver/src/protocol.c (ssload): Insert loaded record int TSTree only if the record was newly created.
-rw-r--r--nserver/src/protocol.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/nserver/src/protocol.c b/nserver/src/protocol.c
index 5fab817..4c7b94f 100644
--- a/nserver/src/protocol.c
+++ b/nserver/src/protocol.c
@@ -255,9 +255,11 @@ int ssload(char *from, char *to)
check(st != NULL, "stats unstringify failed");
// 5. create Record if needed.
+ int rec_created = 0;
if (rec == NULL) {
rec = (Record *) calloc(1, sizeof(Record));
check_mem(rec);
+ rec_created = 1;
}
// 6. get things ready for insertiion
@@ -268,9 +270,11 @@ int ssload(char *from, char *to)
rec->st = st;
rec->deleted = 0;
- // 7. insert Record into 'to' key in the TSTree.
- tst = TSTree_insert(tst, to, strlen(to), rec);
- check(tst != NULL, "tstree insert failed");
+ // 7. insert Record into 'to' key in the TSTree if needed.
+ if (rec_created == 1) {
+ tst = TSTree_insert(tst, to, strlen(to), rec);
+ check(tst != NULL, "tstree insert failed");
+ }
return 0;
error: