]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
modern C: use O_SYNC on open instead of calling fsync after each writes
authorBaptiste Daroussin <bapt@FreeBSD.org>
Wed, 20 Apr 2022 10:20:08 +0000 (12:20 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 20 Oct 2022 11:17:50 +0000 (13:17 +0200)
src/mlmmj-send.c

index 5112f13b5efde868771cd6c353afd193fe073639..2775de3b5e2f8b482db01d9e938ada1c8a06c353 100644 (file)
@@ -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);
                        }