From: Baptiste Daroussin Date: Wed, 20 Apr 2022 10:20:08 +0000 (+0200) Subject: modern C: use O_SYNC on open instead of calling fsync after each writes X-Git-Tag: RELEASE_1_4_0a1~86 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eff8f1bb386a5bcf255fb2fcb1838db262f98a57;p=thirdparty%2Fmlmmj.git modern C: use O_SYNC on open instead of calling fsync after each writes --- diff --git a/src/mlmmj-send.c b/src/mlmmj-send.c index 5112f13b..2775de3b 100644 --- a/src/mlmmj-send.c +++ b/src/mlmmj-send.c @@ -1101,12 +1101,11 @@ int main(int argc, char **argv) myfree(tmpstr); break; } - tmpfd = open(tmpstr, O_WRONLY|O_CREAT|O_TRUNC, + tmpfd = open(tmpstr, O_WRONLY|O_CREAT|O_TRUNC|O_SYNC, S_IRUSR|S_IWUSR); myfree(tmpstr); if(tmpfd >= 0) { dprintf(tmpfd, "%s", bounceaddr); - fsync(tmpfd); } close(tmpfd); tmpstr = concatstr(2, mailfilename, ".reciptto"); @@ -1114,12 +1113,11 @@ int main(int argc, char **argv) myfree(tmpstr); break; } - tmpfd = open(tmpstr, O_WRONLY|O_CREAT|O_TRUNC, + tmpfd = open(tmpstr, O_WRONLY|O_CREAT|O_TRUNC|O_SYNC, S_IRUSR|S_IWUSR); myfree(tmpstr); if(tmpfd >= 0) { dprintf(tmpfd, "%s", to_addr); - fsync(tmpfd); } close(tmpfd); if(replyto) { @@ -1129,12 +1127,11 @@ int main(int argc, char **argv) myfree(tmpstr); break; } - tmpfd = open(tmpstr, O_WRONLY|O_CREAT|O_TRUNC, + tmpfd = open(tmpstr, O_WRONLY|O_CREAT|O_TRUNC|O_SYNC, S_IRUSR|S_IWUSR); myfree(tmpstr); if(tmpfd >= 0) { dprintf(tmpfd, "%s", replyto); - fsync(tmpfd); } close(tmpfd); }