diff options
author | Sergey Poznyakoff <gray@nxc.no> | 2014-06-01 15:32:25 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@nxc.no> | 2014-06-01 15:34:19 +0200 |
commit | 6054989b78b7a481770a1608c809a56e1cf5cc7d (patch) | |
tree | 23404bef612baef8fbc97364b012496cf0db9c7b /src/binlogsel.c | |
parent | 6c0f32b6f37bbb70445731988b5ac180ef054357 (diff) | |
download | vmod-binlog-6054989b78b7a481770a1608c809a56e1cf5cc7d.tar.gz vmod-binlog-6054989b78b7a481770a1608c809a56e1cf5cc7d.tar.bz2 |
Fix -d (timediff) option in binlogsel.
* src/binlogsel.c (selmem): Don't attempt to modify rec.
Diffstat (limited to 'src/binlogsel.c')
-rw-r--r-- | src/binlogsel.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/binlogsel.c b/src/binlogsel.c index d44c1b8..b3fb75b 100644 --- a/src/binlogsel.c +++ b/src/binlogsel.c @@ -270,14 +270,14 @@ searchts(void *base, size_t recsize, size_t from, size_t to, time_t ts, return searchts(base, recsize, from, middle, ts, ret); } void selmem(const char *name, void *base) { - struct binlog_file_header *hdr; - struct binlog_record *rec; + struct binlog_file_header const *hdr; + struct binlog_record const *rec; struct packenv *env; struct packinst *inst; char *p; size_t i, start; time_t start_ts; char timebuf[128]; @@ -347,21 +347,25 @@ selmem(const char *name, void *base) ++start; } } else start = 0; for (i = 0; start < hdr->recnum; i++, start++) { + time_t ts; + rec = getrec(base, hdr->recsize, start); if ((timemask & STOP_TIME) && rec->ts > to_time) break; + + ts = rec->ts; if (timediff_option) { if (i == 0) - start_ts = rec->ts; - rec->ts -= start_ts; + start_ts = ts; + ts -= start_ts; } strftime(timebuf, sizeof timebuf, timefmt, localtime(&rec->ts)); memcpy(env->buf_base, rec->data, env->buf_size); for (ip = interval_head; ip; ip = ip->next) { if ((ip->timemask & START_TIME) && ip->start > rec->ts) @@ -369,13 +373,13 @@ selmem(const char *name, void *base) if ((ip->timemask & STOP_TIME) && ip->end < rec->ts) continue; last_ts = rec->ts; if (module_record) - module_record(ip->name, rec->ts, env->buf_base); + module_record(ip->name, ts, env->buf_base); else { if (ip->name) printf("%s ", ip->name); else if (ip == interval_head && ip->next) printf("default "); if (number_option) |