Skip to content

Commit

Permalink
zstd debug
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed May 10, 2024
1 parent 0d9bf67 commit cba8b56
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions readsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,12 @@ static void *jsonEntryPoint(void *arg) {
threadpool_buffer_t pass_buffer = { 0 };
threadpool_buffer_t zstd_buffer = { 0 };

if (Modes.debug_zstd) { fprintf(stderr, "calling ZSTD_createCCtx()\n"); }

ZSTD_CCtx* cctx = ZSTD_createCCtx();

if (Modes.debug_zstd) { fprintf(stderr, "ZSTD_createCCtx() returned %p\n", cctx); }

while (!Modes.exit) {

struct timespec start_time;
Expand Down Expand Up @@ -1926,6 +1930,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
if (strcasecmp(token[0], "debugGPS") == 0) {
Modes.debug_gps = 1;
}
if (strcasecmp(token[0], "debugZstd") == 0) {
Modes.debug_zstd = 1;
}

sfree(argdup);
}
Expand Down
1 change: 1 addition & 0 deletions readsb.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ struct _Modes
int8_t debug_lastStatus;
int8_t debug_gps;
int8_t debug_planefinder;
int8_t debug_zstd;
int8_t incrementId;
int8_t omitGlobeFiles;
int8_t enableAcasCsv;
Expand Down
12 changes: 11 additions & 1 deletion util.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,13 @@ struct char_buffer generateZstd(ZSTD_CCtx* cctx, threadpool_buffer_t *pbuffer, s

check_grow_threadpool_buffer_t(pbuffer, ZSTD_compressBound(src.len));

//fprintf(stderr, "pbuffer->size: %ld src.len %ld\n", (long) pbuffer->size, (long) src.len);
if (Modes.debug_zstd) {
fprintf(stderr, "calling ZSTD_compressCCtx() with cctx %p pbuffer->size %ld"
"src.buffer %p src.len %ld level %d src.buffer[0] 0x%02x cctx_first_byte 0x%02x\n"
, cctx, (long) pbuffer->size,
src.buffer, (long) src.len, level, (uint8_t) src.buffer[0], (uint8_t) ((uint8_t *) cctx)[0]
);
}

/*
* size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
Expand All @@ -878,6 +884,10 @@ struct char_buffer generateZstd(ZSTD_CCtx* cctx, threadpool_buffer_t *pbuffer, s
src.buffer, src.len,
level);

if (Modes.debug_zstd) {
fprintf(stderr, "calling ZSTD_isError() with compressedSize: %zd\n", compressedSize);
}

if (ZSTD_isError(compressedSize)) {
fprintf(stderr, "generateZstd() zstd error: %s\n", ZSTD_getErrorName(compressedSize));
cb.buffer = NULL;
Expand Down

0 comments on commit cba8b56

Please sign in to comment.