[PACKET_IO]delete useless timestamp
This commit is contained in:
@@ -429,8 +429,7 @@ static ssize_t pcap_directory_get_modified_time(char *pfile, struct timespec *ou
|
||||
}
|
||||
|
||||
struct pending_file *
|
||||
find_pending_file_to_add(struct pio_pcap_file_device_context *pfile_dev_ctx, struct dirent *dir,
|
||||
struct timespec *deadline)
|
||||
find_pending_file_to_add(struct pio_pcap_file_device_context *pfile_dev_ctx, struct dirent *dir)
|
||||
{
|
||||
char abs_path[PATH_MAX] = {0};
|
||||
|
||||
@@ -442,15 +441,6 @@ find_pending_file_to_add(struct pio_pcap_file_device_context *pfile_dev_ctx, str
|
||||
log_debug("unable to get modified time on %s, skipping", abs_path);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* skip files outside of out time range */
|
||||
if (compare_timespec(&temp_time, &pfile_dev_ctx->shared.last_processed_ts) <= 0) {
|
||||
log_debug("skipping old file %s", abs_path);
|
||||
return nullptr;
|
||||
} else if (compare_timespec(&temp_time, deadline) >= 0) {
|
||||
log_debug("skipping new file %s", abs_path);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct pending_file *file_to_add = CALLOC(struct pending_file, 1);
|
||||
ssize_t ret = strncpy_safe(file_to_add->file_name, abs_path, sizeof(file_to_add->file_name));
|
||||
@@ -702,7 +692,7 @@ static ssize_t validate_pcap_file(struct pio_pcap_file_device_context *pfile_dev
|
||||
return -1;
|
||||
}
|
||||
|
||||
static ssize_t pcap_directory_collect_pending_files(struct pio_pcap_file_device_context *pfile_dev_ctx, struct timespec *deadline)
|
||||
static ssize_t pcap_directory_collect_pending_files(struct pio_pcap_file_device_context *pfile_dev_ctx)
|
||||
{
|
||||
if (nullptr == pfile_dev_ctx) {
|
||||
return -1;
|
||||
@@ -732,7 +722,7 @@ static ssize_t pcap_directory_collect_pending_files(struct pio_pcap_file_device_
|
||||
continue;
|
||||
}
|
||||
|
||||
file_to_add = find_pending_file_to_add(pfile_dev_ctx, dir, deadline);
|
||||
file_to_add = find_pending_file_to_add(pfile_dev_ctx, dir);
|
||||
if (nullptr == file_to_add) {
|
||||
continue;
|
||||
}
|
||||
@@ -749,23 +739,13 @@ static ssize_t pcap_directory_collect_pending_files(struct pio_pcap_file_device_
|
||||
static ssize_t pcap_directory_files_dispatch(struct pio_pcap_file_device_context *pfile_dev_ctx, uint32_t rxq_id)
|
||||
{
|
||||
ssize_t res = -1;
|
||||
struct timespec deadline;
|
||||
|
||||
memset(&deadline, 0, sizeof(struct timespec));
|
||||
get_current_timespec(&deadline);
|
||||
|
||||
/* the newest file which can be processed */
|
||||
deadline.tv_sec = deadline.tv_sec - pfile_dev_ctx->entity.dir->delay;
|
||||
|
||||
/* collect pending files in current directory */
|
||||
if (pcap_directory_collect_pending_files(pfile_dev_ctx, &deadline) < 0) {
|
||||
if (pcap_directory_collect_pending_files(pfile_dev_ctx) < 0) {
|
||||
log_error(ST_ERR_PCAP_FILE_COLLECT_FAILED, "failed to collect pending files in directory.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct timespec last_time_seen;
|
||||
memset(&last_time_seen, 0, sizeof(struct timespec));
|
||||
|
||||
/* not open file yet */
|
||||
if (nullptr == pfile_dev_ctx->entity.dir->current_file[rxq_id]) {
|
||||
pthread_mutex_lock(&g_pending_file_queue.queue_mutex);
|
||||
@@ -815,19 +795,13 @@ static ssize_t pcap_directory_files_dispatch(struct pio_pcap_file_device_context
|
||||
if (res < 0) {
|
||||
FREE(pfile_dev_ctx->entity.dir->pending_file[rxq_id]);
|
||||
return -1;
|
||||
}
|
||||
log_info("processed file %s, processed up to %" PRIuMAX,
|
||||
current_file->file_name, (uintmax_t)timespec_to_millisecond(¤t_file->modified_time));
|
||||
|
||||
if (compare_timespec(¤t_file->modified_time, &last_time_seen) > 0) {
|
||||
copy_timespec(¤t_file->modified_time, &last_time_seen);
|
||||
}
|
||||
|
||||
if (res == 0) { // reach the end of the file
|
||||
} else if (res == 0) {
|
||||
cleanup_pcap_plain_file_info(pfile_dev_ctx->entity.dir->current_file[rxq_id]);
|
||||
FREE(pfile_dev_ctx->entity.dir->current_file[rxq_id]);
|
||||
FREE(pfile_dev_ctx->entity.dir->pending_file[rxq_id]);
|
||||
}
|
||||
log_info("processed file %s, processed up to %" PRIuMAX,
|
||||
current_file->file_name, (uintmax_t)timespec_to_millisecond(¤t_file->modified_time));
|
||||
}
|
||||
} else {
|
||||
/* file has been opened */
|
||||
@@ -842,11 +816,6 @@ static ssize_t pcap_directory_files_dispatch(struct pio_pcap_file_device_context
|
||||
}
|
||||
}
|
||||
|
||||
if (compare_timespec(&last_time_seen, &pfile_dev_ctx->shared.last_processed_ts) > 0) {
|
||||
log_info("updating processed to %" PRIuMAX, (uintmax_t)timespec_to_millisecond(&last_time_seen));
|
||||
copy_timespec(&last_time_seen, &pfile_dev_ctx->shared.last_processed_ts);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,6 @@ struct pcap_file_shared_info {
|
||||
/* if delete when pcapfile is processed */
|
||||
int should_delete;
|
||||
|
||||
/* the timestamp of the last process */
|
||||
struct timespec last_processed_ts;
|
||||
|
||||
/* counters */
|
||||
uint64_t pkts;
|
||||
uint64_t bytes;
|
||||
|
||||
Reference in New Issue
Block a user