Skip to content

Commit

Permalink
Fixed issue where it would not parse subsequent requests coming from …
Browse files Browse the repository at this point in the history
…stdin.

Specifically requests with the same timestamp upon using --restore.

Co-authored-by: 0bi-w6n-K3nobi <[email protected]>
  • Loading branch information
allinurl and 0bi-w6n-K3nobi committed Nov 2, 2020
1 parent 46844be commit ef22f6a
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2702,8 +2702,6 @@ pre_process_log (GLog * glog, char *line, int dry_run) {
cleanup:
free_glog (logitem);

ht_insert_last_parse (0, glog->lp);

return ret;
}

Expand Down Expand Up @@ -2878,12 +2876,29 @@ set_initial_persisted_data (GLog * glog, const char *fn) {
if ((mmapd = mmap (0, size, PROT_READ, MAP_PRIVATE, fd, 0)) == MAP_FAILED)
FATAL ("Unable to mmap '%s'. %s", fn, strerror (errno));

memcpy(glog->mmapd, mmapd, size);
memcpy (glog->mmapd, mmapd, size);
glog->mmapd_len = size;

return 0;
}

static void
persist_last_parse (GLog * glog) {
/* insert last parsed data for the recently file parsed */
if (glog->inode && glog->size) {
glog->lp.line = glog->read;
glog->lp.mmapd_len = glog->mmapd_len;

memcpy (glog->lp.mmapd, glog->mmapd, glog->mmapd_len);

ht_insert_last_parse (glog->inode, glog->lp);
}
/* probably from a pipe */
else if (!glog->inode) {
ht_insert_last_parse (0, glog->lp);
}
}

/* Read the given log line by line and process its data.
*
* On error, 1 is returned.
Expand Down Expand Up @@ -2921,15 +2936,7 @@ read_log (GLog ** glog, const char *fn, int dry_run) {
return 1;
}

/* insert last parsed data for the recently file parsed */
if ((*glog)->inode && (*glog)->size) {
(*glog)->lp.line = (*glog)->read;

(*glog)->lp.mmapd_len = (*glog)->mmapd_len;
memcpy((*glog)->lp.mmapd, (*glog)->mmapd, (*glog)->mmapd_len);

ht_insert_last_parse ((*glog)->inode, (*glog)->lp);
}
persist_last_parse ((*glog));

/* close log file if not a pipe */
if (!piping)
Expand Down

0 comments on commit ef22f6a

Please sign in to comment.