nserver

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit 09f04a6bdd80450ab8a972262cc07c5cbf0aa0fa
parent 0e0bc28ea8cc29b8b9c8b6a85ffc3fbf888ace4b
Author: rsiddharth <s@ricketyspace.net>
Date:   Tue, 14 Apr 2020 20:52:24 -0400

nserver: Update ssload.

* nserver/src/protocol.c (ssload): Insert loaded record int TSTree
only if the record was newly created.

Diffstat:
nserver/src/protocol.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git 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: