fix: WS frame parser — skip oversized payload to keep sync
- ws_client.c: When payload exceeds buffer, consume remaining bytes before returning error to prevent parser desynchronization. - market_feed.c: Increase receive buffer 4K→64K, support both standard (symbol/timestamp) and compact (s/ts) JSON field names. - ws_client.c: Disable per-frame debug print in release mode. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+6
-4
@@ -351,7 +351,7 @@ int main(int argc, char *argv[])
|
||||
rte_ring_sp_enqueue_burst(ring->in, (void **)rx, nb_rx, NULL);
|
||||
|
||||
/* Receive WebSocket frame */
|
||||
uint8_t buf[4096];
|
||||
uint8_t buf[65536];
|
||||
int opcode = 0, buflen = sizeof(buf);
|
||||
int ws_ret = ws_recv_frame(sockfd, &opcode, buf, &buflen);
|
||||
|
||||
@@ -360,11 +360,13 @@ int main(int argc, char *argv[])
|
||||
buf[buflen] = '\0';
|
||||
uint64_t now_us = rte_get_timer_cycles() * 1000000 / tsc_hz;
|
||||
|
||||
/* Parse symbol and timestamp from JSON */
|
||||
/* Parse symbol and timestamp from JSON (supports compact & full keys) */
|
||||
char sym[32] = "unknown";
|
||||
uint64_t ts_us = 0;
|
||||
json_get_str((char *)buf, "symbol", sym, sizeof(sym));
|
||||
json_get_int((char *)buf, "timestamp", &ts_us);
|
||||
if (json_get_str((char *)buf, "symbol", sym, sizeof(sym)) < 0)
|
||||
json_get_str((char *)buf, "s", sym, sizeof(sym)); /* compact format */
|
||||
if (json_get_int((char *)buf, "timestamp", &ts_us) < 0)
|
||||
json_get_int((char *)buf, "ts", &ts_us); /* compact format */
|
||||
|
||||
int idx = stats_find_or_add(sym);
|
||||
if (idx >= 0 && ts_us > 0 && now_us > ts_us)
|
||||
|
||||
Reference in New Issue
Block a user