diff options
author | tenox7 <as@tenoware.com> | 2018-05-01 02:51:34 -0700 |
---|---|---|
committer | tenox7 <as@tenoware.com> | 2018-05-01 02:51:34 -0700 |
commit | b38eb34d289866be7fd3adb1f005126facfcd280 (patch) | |
tree | d41b869004e424b0e45a3fac1ccd70b9e8d50268 | |
parent | b2549ccc0f2eb25e2724093d47a3a83562deed97 (diff) | |
download | wfm-b38eb34d289866be7fd3adb1f005126facfcd280.tar.gz |
file locking support
-rw-r--r-- | fileio.c | 7 | ||||
-rw-r--r-- | wfm.h | 3 |
2 files changed, 8 insertions, 2 deletions
@@ -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)); @@ -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" |