- 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/program@1085
a5681a0c-68f1-0310-ab6d-
d61299d08faa
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);
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");
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
}
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));
(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);