summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3710c35)
raw | patch | inline | side by side (parent: 3710c35)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Fri, 25 May 2007 13:14:35 +0000 (13:14 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Fri, 25 May 2007 13:14:35 +0000 (13:14 +0000) |
- add some more rrd_sterror calls to failure paths.
- make rrdtool updatev work like 1.2.23 (i.e. multiple values are still
broken, but at least updating a single value works; see
http://oss.oetiker.ch/rrdtool-trac/ticket/8)
- indent touched files.
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1085 a5681a0c-68f1-0310-ab6d-d61299d08faa
- make rrdtool updatev work like 1.2.23 (i.e. multiple values are still
broken, but at least updating a single value works; see
http://oss.oetiker.ch/rrdtool-trac/ticket/8)
- indent touched files.
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1085 a5681a0c-68f1-0310-ab6d-d61299d08faa
diff --git a/program/src/rrd_dump.c b/program/src/rrd_dump.c
index 3b2a0250642b296d0364c20d3dd59c67638f27fa..0b9310334734374989caef73d4a52995d0250bb3 100644 (file)
--- a/program/src/rrd_dump.c
+++ b/program/src/rrd_dump.c
rrd_value_t value;
struct tm tm;
- rrd_file = rrd_open(filename, &rrd, RRD_READONLY|RRD_READAHEAD);
+ rrd_file = rrd_open(filename, &rrd, RRD_READONLY | RRD_READAHEAD);
if (rrd_file == NULL) {
rrd_free(&rrd);
return (-1);
index 866bf9742ed851d6a298debe7ce17e95963ec25f..87c3cd6789b66b6f10b87e645a7bebfb9910627e 100644 (file)
--- a/program/src/rrd_fetch.c
+++ b/program/src/rrd_fetch.c
else
rra_pointer = rrd.rra_ptr[chosen_rra].cur_row + 1 + start_offset;
- if (rrd_seek(rrd_file, (rra_base
- + (rra_pointer
- * (*ds_cnt)
- * sizeof(rrd_value_t))), SEEK_SET) != 0) {
+ if (rrd_seek(rrd_file, (rra_base + (rra_pointer * (*ds_cnt)
+ * sizeof(rrd_value_t))),
+ SEEK_SET) != 0) {
rrd_set_error("seek error in RRA");
for (i = 0; (unsigned) i < *ds_cnt; i++)
free((*ds_namv)[i]);
* be wrapped*/
if (rra_pointer >= (signed) rrd.rra_def[chosen_rra].row_cnt) {
rra_pointer -= rrd.rra_def[chosen_rra].row_cnt;
- if (rrd_seek(rrd_file, (rra_base + rra_pointer
- * (*ds_cnt)
+ if (rrd_seek(rrd_file, (rra_base + rra_pointer * (*ds_cnt)
* sizeof(rrd_value_t)),
SEEK_SET) != 0) {
rrd_set_error("wrap seek in RRA did fail");
diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c
index 07ee109abc6ae6544dc2797dc621c17279a9760e..baeb00355308de85f3a83e6a54c25947ff08fde9 100644 (file)
--- a/program/src/rrd_open.c
+++ b/program/src/rrd_open.c
int rrd_close(
rrd_file_t *rrd_file)
{
- int ret = 0;
+ int ret;
#ifdef HAVE_MMAP
ret = munmap(rrd_file->file_start, rrd_file->file_len);
-// if (ret != 0)
-// rrd_set_error("munmap rrd_file");
+ if (ret != 0)
+ rrd_set_error("munmap rrd_file: %s", rrd_strerror(errno));
#endif
+ ret = close(rrd_file->fd);
+ if (ret != 0)
+ rrd_set_error("closing file: %s", rrd_strerror(errno));
free(rrd_file);
rrd_file = NULL;
return ret;
const void *buf,
size_t count)
{
- ssize_t ret = count;
-
#ifdef HAVE_MMAP
- char *off, *new_pos;
-
- off = rrd_file->file_start + rrd_file->pos;
- new_pos = memmove(rrd_file->file_start + rrd_file->pos, buf, count);
- ret = new_pos - off;
+ memmove(rrd_file->file_start + rrd_file->pos, buf, count);
+ return count; /* mimmic write() semantics */
#else
- ret = write(rrd_file->fd, buf, count);
+ return write(rrd_file->fd, buf, count);
#endif
- return ret;
}
/* flush all data pending to be written to FD. */
free(rrd->pdp_prep);
free(rrd->cdp_prep);
free(rrd->rrd_value);
+//XXX: ? rrd_init(rrd);
#endif
}
index e29f2dd2181f8b206b9283cd760c653ffda0b0d7..f64615cf62bfb39e0927de16e8e23cd35528701b 100644 (file)
--- a/program/src/rrd_resize.c
+++ b/program/src/rrd_resize.c
return (-1);
}
- rrd_out_file = rrd_open(outfilename, &rrdnew, RRD_READWRITE|RRD_CREAT);
+ rrd_out_file = rrd_open(outfilename, &rrdnew, RRD_READWRITE | RRD_CREAT);
if (rrd_out_file == NULL) {
rrd_set_error("Can't create '%s': %s", outfilename,
rrd_strerror(errno));
index 7890f284d06843472c76a3a780f24016c0611cba..eb08f78af02231c4512eb756ee3d9a6aab931625 100644 (file)
--- a/program/src/rrd_update.c
+++ b/program/src/rrd_update.c
(rrd_file,
&(rrd->cdp_prep[cdp_idx].scratch[CDP_scratch_idx].u_val),
sizeof(rrd_value_t) * 1) != sizeof(rrd_value_t) * 1) {
- rrd_set_error("writing rrd");
+ rrd_set_error("writing rrd: %s", rrd_strerror(errno));
return 0;
}
*rra_current += sizeof(rrd_value_t);
free(rra_step_cnt);
rpnstack_free(&rpnstack);
-#ifdef HAVE_MMAP
+#if 0 //def HAVE_MMAP
if (munmap(rrd_file->file_start, rrd_file->file_len) == -1) {
rrd_set_error("error writing(unmapping) file: %s", filename);
}
+#else
+ rrd_flush(rrd_file); //XXX: really needed?
#endif
/* if we got here and if there is an error and if the file has not been
* written to, then close things up and return. */
return (-1);
}
#endif
- close(rrd_file->fd);
- }
-
- /* OK now close the files and free the memory */
- if (close(rrd_file->fd) != 0) {
- rrd_set_error("closing rrd");
- free(updvals);
- free(tmpl_idx);
- rrd_free(&rrd);
- free(pdp_temp);
- free(pdp_new);
- return (-1);
}
+ rrd_close(rrd_file);
rrd_free(&rrd);
free(updvals);
free(tmpl_idx);