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 | |
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.
-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 | |||
@@ -273,8 +273,8 @@ searchts(void *base, size_t recsize, size_t from, size_t to, time_t ts, | |||
273 | void | 273 | void |
274 | selmem(const char *name, void *base) | 274 | selmem(const char *name, void *base) |
275 | { | 275 | { |
276 | struct binlog_file_header *hdr; | 276 | struct binlog_file_header const *hdr; |
277 | struct binlog_record *rec; | 277 | struct binlog_record const *rec; |
278 | struct packenv *env; | 278 | struct packenv *env; |
279 | struct packinst *inst; | 279 | struct packinst *inst; |
280 | char *p; | 280 | char *p; |
@@ -350,15 +350,19 @@ selmem(const char *name, void *base) | |||
350 | start = 0; | 350 | start = 0; |
351 | 351 | ||
352 | for (i = 0; start < hdr->recnum; i++, start++) { | 352 | for (i = 0; start < hdr->recnum; i++, start++) { |
353 | time_t ts; | ||
354 | |||
353 | rec = getrec(base, hdr->recsize, start); | 355 | rec = getrec(base, hdr->recsize, start); |
354 | 356 | ||
355 | if ((timemask & STOP_TIME) && rec->ts > to_time) | 357 | if ((timemask & STOP_TIME) && rec->ts > to_time) |
356 | break; | 358 | break; |
359 | |||
360 | ts = rec->ts; | ||
357 | 361 | ||
358 | if (timediff_option) { | 362 | if (timediff_option) { |
359 | if (i == 0) | 363 | if (i == 0) |
360 | start_ts = rec->ts; | 364 | start_ts = ts; |
361 | rec->ts -= start_ts; | 365 | ts -= start_ts; |
362 | } | 366 | } |
363 | strftime(timebuf, sizeof timebuf, timefmt, | 367 | strftime(timebuf, sizeof timebuf, timefmt, |
364 | localtime(&rec->ts)); | 368 | localtime(&rec->ts)); |
@@ -372,7 +376,7 @@ selmem(const char *name, void *base) | |||
372 | last_ts = rec->ts; | 376 | last_ts = rec->ts; |
373 | 377 | ||
374 | if (module_record) | 378 | if (module_record) |
375 | module_record(ip->name, rec->ts, env->buf_base); | 379 | module_record(ip->name, ts, env->buf_base); |
376 | else { | 380 | else { |
377 | if (ip->name) | 381 | if (ip->name) |
378 | printf("%s ", ip->name); | 382 | printf("%s ", ip->name); |