Skip to content

Commit

Permalink
Output the progress once more when the whole scan process finished (#828
Browse files Browse the repository at this point in the history
)

* fix: output the missing completed state into status output file (#823)

* fix: add missing header file stdbool.h (#823)

* Refactor monitor_run function and add export_then_update function (#823, #828)
  • Loading branch information
WangYihang committed Mar 18, 2024
1 parent df098d8 commit 4d4166e
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/monitor.c
Expand Up @@ -16,6 +16,7 @@
#include <assert.h>
#include <errno.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -464,12 +465,7 @@ void monitor_init(void)
}
}

void monitor_run(iterator_t *it, pthread_mutex_t *lock)
{
int_status_t *internal_status = xmalloc(sizeof(int_status_t));
export_status_t *export_status = xmalloc(sizeof(export_status_t));

while (!(zsend.complete && zrecv.complete)) {
void export_then_update(int_status_t *internal_status, iterator_t *it, export_status_t *export_status, pthread_mutex_t *lock) {
update_pcap_stats(lock);
export_stats(internal_status, export_status, it);
log_drop_warnings(export_status);
Expand All @@ -487,8 +483,21 @@ void monitor_run(iterator_t *it, pthread_mutex_t *lock)
if (status_fd) {
update_status_updates_file(export_status, status_fd);
}
}

void monitor_run(iterator_t *it, pthread_mutex_t *lock)
{
int_status_t *internal_status = xmalloc(sizeof(int_status_t));
export_status_t *export_status = xmalloc(sizeof(export_status_t));

// wait for the scanning process to finish
while (!(zsend.complete && zrecv.complete)) {
export_then_update(internal_status, it, export_status, lock);
sleep(UPDATE_INTERVAL);
}
// final update
export_then_update(internal_status, it, export_status, lock);

if (!zconf.quiet) {
lock_file(stderr);
fflush(stderr);
Expand Down

0 comments on commit 4d4166e

Please sign in to comment.