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 /fileio.c | |
parent | b2549ccc0f2eb25e2724093d47a3a83562deed97 (diff) | |
download | wfm-b38eb34d289866be7fd3adb1f005126facfcd280.tar.gz |
file locking support
Diffstat (limited to 'fileio.c')
-rw-r--r-- | fileio.c | 7 |
1 files changed, 6 insertions, 1 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)); |