From: Tim Peters Date: Wed, 23 Apr 2003 20:14:12 +0000 (+0000) Subject: fsync(): Implemented for Windows, via calling MS _commit. This counts X-Git-Tag: v2.2.3c1~65 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c18cc56c2115dad6a118097d0fd722428364b4d2;p=thirdparty%2FPython%2Fcpython.git fsync(): Implemented for Windows, via calling MS _commit. This counts as "a bug" because there's no other way in core Python to ensure that bytes written are actually on disk. At least ZODB wants this guarantee, for robustness against crashes. --- diff --git a/Doc/lib/libos.tex b/Doc/lib/libos.tex index 3d0b4051bd3f..7a6383f2a5dd 100644 --- a/Doc/lib/libos.tex +++ b/Doc/lib/libos.tex @@ -433,8 +433,15 @@ Availability: \UNIX. \end{funcdesc} \begin{funcdesc}{fsync}{fd} -Force write of file with filedescriptor \var{fd} to disk. -Availability: \UNIX. +Force write of file with filedescriptor \var{fd} to disk. On \UNIX, +this calls the native \cfunction{fsync()} function; on Windows, the +MS \cfunction{_commit()} function. + +If you're starting with a Python file object \var{f}, first do +\code{\var{f}.flush()}, and then do \code{os.fsync(\var{f}.fileno()}, +to ensure that all internal buffers associated with \var{f} are written +to disk. +Availability: \UNIX, and Windows starting in 2.2.3. \end{funcdesc} \begin{funcdesc}{ftruncate}{fd, length} diff --git a/Misc/NEWS b/Misc/NEWS index b22a277c9505..ed690b5cb0fd 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -2,6 +2,10 @@ What's New in Python 2.2.3 ? Release date: XX-XXX-2003 ============================ +- Implemented os.fsync() for Windows, where it calls the MS _commit() + function. Before, there was no way in core Python to ensure file + writes actually showed up on disk when necessary. + - Make all the strip, lstrip, rstrip functions/methods on string/unicode/UserString consistent by adding and/or documenting the chars parameter. The chars parameter diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index f41d42dc8e47..a070ea6be7ec 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -72,6 +72,8 @@ corresponding Unix manual entries for more information on calls."; #else #ifdef _MSC_VER /* Microsoft compiler */ #define HAVE_GETCWD 1 +#define HAVE_FSYNC 1 +#define fsync _commit #ifdef MS_WIN32 #define HAVE_SPAWNV 1 #define HAVE_EXECV 1