From: oetiker Date: Thu, 18 Sep 2008 13:30:48 +0000 (+0000) Subject: Fix for debian bug 498183 ... never *advise after the end of the X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5dbf3e89f37fc075f2acd54dc593bed7558d6df1;p=rrdtool-all.git Fix for debian bug 498183 ... never *advise after the end of the file. On sparc this causes a segfault. Thanks to Sebastian Harl and Jurij Smakov for finding this. git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.3@1512 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c index d2ec68cd..a6c04e28 100644 --- a/program/src/rrd_open.c +++ b/program/src/rrd_open.c @@ -363,14 +363,19 @@ void rrd_dontneed( rrd->rra_def[i].row_cnt * rrd->stat_head->ds_cnt * sizeof(rrd_value_t); } + + if (dontneed_start < rrd_file->file_len) { #ifdef USE_MADVISE - madvise(rrd_file->file_start + dontneed_start, - rrd_file->file_len - dontneed_start, MADV_DONTNEED); + madvise(rrd_file->file_start + dontneed_start, + rrd_file->file_len - dontneed_start, MADV_DONTNEED); #endif #ifdef HAVE_POSIX_FADVISE - posix_fadvise(rrd_file->fd, dontneed_start, - rrd_file->file_len - dontneed_start, POSIX_FADV_DONTNEED); + posix_fadvise(rrd_file->fd, dontneed_start, + rrd_file->file_len - dontneed_start, + POSIX_FADV_DONTNEED); #endif + } + #if defined DEBUG && DEBUG > 1 mincore_print(rrd_file, "after"); #endif