aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortenox7 <as@tenoware.com>2018-05-01 02:51:34 -0700
committertenox7 <as@tenoware.com>2018-05-01 02:51:34 -0700
commitb38eb34d289866be7fd3adb1f005126facfcd280 (patch)
treed41b869004e424b0e45a3fac1ccd70b9e8d50268
parentb2549ccc0f2eb25e2724093d47a3a83562deed97 (diff)
downloadwfm-b38eb34d289866be7fd3adb1f005126facfcd280.tar.gz
file locking support
-rw-r--r--fileio.c7
-rw-r--r--wfm.h3
2 files changed, 8 insertions, 2 deletions
diff --git a/fileio.c b/fileio.c
index c703898..0e2b389 100644
--- a/fileio.c
+++ b/fileio.c
@@ -2,7 +2,6 @@
#include "wfm.h"
-
/*
// Debug dump vars
//void debugdumpvars(void) {
@@ -104,6 +103,9 @@ void receivefile(void) {
if(!output)
error("Unable to open file %s for writing.<BR>%s", virt_filename, strerror(errno));
+ if(flock(fileno(output), LOCK_EX) == -1)
+ error("Unable to lock file %s.<BR>%s", virt_filename, strerror(errno));
+
while(cgiFormFileRead(input, buff, sizeof(buff), &got) == cgiFormSuccess)
if(got)
if(fwrite(buff, got, 1, output) != 1)
@@ -221,6 +223,9 @@ void edit_save(void) {
if(!tempf)
error("Unable to open temporary file %s.<BR>%s", basename(tempname), strerror(errno));
+ if(flock(fileno(tempf), LOCK_EX) == -1)
+ error("Unable to lock file %s.<BR>%s", basename(tempname), strerror(errno));
+
if(fwrite(buff, strlen(buff), 1, tempf) != 1)
error("Unable to write to temporary file %s.<BR>%s", basename(tempname), strerror(errno));
diff --git a/wfm.h b/wfm.h
index 5657590..7e315bd 100644
--- a/wfm.h
+++ b/wfm.h
@@ -1,4 +1,4 @@
-#define VERSION "1.3.1"
+#define VERSION "1.3.2"
#define copyright "<!-- WFM Version " VERSION ", Mountain View, CA, " __DATE__ " [" __TIME__ "] -->\n" \
"<!-- Copyright (c) 1994-2018 by Antoni Sawicki -->\n"
@@ -52,6 +52,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/shm.h>
+#include <sys/file.h>
//#include <sys/dir.h>
#include "md5.h"
#include "cgic.h"