summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4bb0750)
raw | patch | inline | side by side (parent: 4bb0750)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Thu, 16 Oct 2008 21:05:51 +0000 (21:05 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Thu, 16 Oct 2008 21:05:51 +0000 (21:05 +0000) |
program/src/rrd_open.c | patch | blob | history | |
program/src/rrd_update.c | patch | blob | history |
diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c
index f262413befce5f8e9f561b4d32eef0bfaef8a87f..e407acc10a806b95bdff0838ca0b5b88078c6adb 100644 (file)
--- a/program/src/rrd_open.c
+++ b/program/src/rrd_open.c
}
#endif /* defined DEBUG && DEBUG > 1 */
+/*
+ * get exclusive lock to whole file.
+ * lock gets removed when we close the file
+ *
+ * returns 0 on success
+ */
+int rrd_lock(
+ rrd_file_t *file)
+{
+ int rcstat;
+
+ {
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
+ struct _stat st;
+
+ if (_fstat(file->fd, &st) == 0) {
+ rcstat = _locking(file->fd, _LK_NBLCK, st.st_size);
+ } else {
+ rcstat = -1;
+ }
+#else
+ struct flock lock;
+
+ lock.l_type = F_WRLCK; /* exclusive write lock */
+ lock.l_len = 0; /* whole file */
+ lock.l_start = 0; /* start of file */
+ lock.l_whence = SEEK_SET; /* end of file */
+
+ rcstat = fcntl(file->fd, F_SETLK, &lock);
+#endif
+ }
+
+ return (rcstat);
+}
+
/* drop cache except for the header and the active pages */
void rrd_dontneed(
index 5e26055a66db2fa20244860359f137f3f0b010b6..108dcbb0c048a1a379e7c029c6e97d854169d0a8 100644 (file)
--- a/program/src/rrd_update.c
+++ b/program/src/rrd_update.c
return -1;
}
-/*
- * get exclusive lock to whole file.
- * lock gets removed when we close the file
- *
- * returns 0 on success
- */
-int rrd_lock(
- rrd_file_t *file)
-{
- int rcstat;
-
- {
-#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
- struct _stat st;
-
- if (_fstat(file->fd, &st) == 0) {
- rcstat = _locking(file->fd, _LK_NBLCK, st.st_size);
- } else {
- rcstat = -1;
- }
-#else
- struct flock lock;
-
- lock.l_type = F_WRLCK; /* exclusive write lock */
- lock.l_len = 0; /* whole file */
- lock.l_start = 0; /* start of file */
- lock.l_whence = SEEK_SET; /* end of file */
-
- rcstat = fcntl(file->fd, F_SETLK, &lock);
-#endif
- }
-
- return (rcstat);
-}
-
/*
* Allocate some important arrays used, and initialize the template.
*