summaryrefslogtreecommitdiff
path: root/src/libdcache/dcache_save.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2024-09-13 09:38:07 +0000
committerLaurent Bercot <ska@appnovation.com>2024-09-13 09:38:07 +0000
commitfb355e4200fcf98f36a4f3e1fbeb1e16b4761ee6 (patch)
treebf78792e9206e121607ad786432c0b60bbdcdc72 /src/libdcache/dcache_save.c
parent45c04a53fb9fbefe4dd86514c7563b4af1961dfb (diff)
downloadshibari-main.tar.xz
Push what I have for nowHEADmain
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libdcache/dcache_save.c')
-rw-r--r--src/libdcache/dcache_save.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libdcache/dcache_save.c b/src/libdcache/dcache_save.c
index 62c55a2..3cff3c5 100644
--- a/src/libdcache/dcache_save.c
+++ b/src/libdcache/dcache_save.c
@@ -12,7 +12,6 @@
#include <skalibs/buffer.h>
#include <skalibs/tai.h>
#include <skalibs/djbunix.h>
-#include <skalibs/skamisc.h>
#include <skalibs/gensetdyn.h>
#include <shibari/dcache.h>
@@ -21,13 +20,18 @@ static int write_node_iter (void *data, void *aux)
{
dcache_node *y = data ;
buffer *b = aux ;
- char pack[TAI_PACK * 2 + 4] ;
+ char pack[TAI_PACK] ;
+ uint16_t len ;
+ if (y->sa.a != y->sa.len) return 1 ;
tai_pack(pack, &y->entry) ;
+ if (buffer_put(b, pack, TAI_PACK) == -1) return 0 ;
tai_pack(pack + TAI_PACK, &y->expire) ;
-// uint16_pack(pack + TAI_PACK * 2, y->key.len) ;
-// uint16_pack(pack + TAI_PACK * 2 + 2, y->datalen) ;
- if (buffer_put(b, pack, TAI_PACK * 2 + 4) == -1) return 0 ;
-// if (buffer_put(b, y->key.s, y->key.len + y->datalen) == -1) return 0 ;
+ if (buffer_put(b, pack, TAI_PACK) == -1) return 0 ;
+ uint16_unpack_big(y->sa.s + 2, &len) ;
+ len = y->sa.len - len ;
+ uint16_pack_big(pack, len) ;
+ if (buffer_put(b, pack, 2) == -1) return 0 ;
+ if (buffer_put(b, y->sa.s, y->sa.len) == -1) return 0 ;
if (buffer_put(b, "", 1) == -1) return 0 ;
return 1 ;
}