diff options
| author | 2025-09-12 19:29:17 +0330 | |
|---|---|---|
| committer | 2025-09-12 19:29:17 +0330 | |
| commit | cad89335a2d03921a0f349673114e0f69adc54d4 (patch) | |
| tree | 570e84d433abe4b91254f9d5fa15e94b3baa065f /firehose.c | |
| parent | starting commit (diff) | |
bug fixes
Diffstat (limited to 'firehose.c')
| -rw-r--r-- | firehose.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -62,6 +62,8 @@ void firehose_push(hash new_hash, uint64_t storage_index) { uint16_t firehose_get_count() { return firehose_buffer.count; } uint64_t firehose_get_total_packets() { return firehose_buffer.total_packets; } +pthread_mutex_t packet_storage_mutex; + uint16_t firehose_get_packets(uint64_t offset, uint16_t count, water_splash* output_entries) { pthread_mutex_lock(&firehose_buffer.mutex); @@ -80,6 +82,7 @@ uint16_t firehose_get_packets(uint64_t offset, uint16_t count, water_splash* out } uint16_t start_index = (firehose_buffer.head + relative_offset) % FIREHOSE_BUFFER_SIZE; + pthread_mutex_lock(&packet_storage_mutex); for (int i = 0; i < count; i++) { if (relative_offset + i >= firehose_buffer.count) { break; } @@ -88,6 +91,7 @@ uint16_t firehose_get_packets(uint64_t offset, uint16_t count, water_splash* out &output_entries[ i ], &firehose_buffer.entries[ current_index ], sizeof(water_splash)); copied_count++; } + pthread_mutex_unlock(&packet_storage_mutex); pthread_mutex_unlock(&firehose_buffer.mutex); return copied_count; |
