source: trunk/third/rpm/db/os_win32/os_fsync.c @ 19079

Revision 19079, 1.1 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r19078, which included commits to RCS files with non-trunk default branches.
Line 
1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 1997-2002
5 *      Sleepycat Software.  All rights reserved.
6 */
7
8#include "db_config.h"
9
10#ifndef lint
11static const char revid[] = "Id: os_fsync.c,v 11.15 2002/07/12 18:56:54 bostic Exp ";
12#endif /* not lint */
13
14#ifndef NO_SYSTEM_INCLUDES
15#include <sys/types.h>
16
17#include <fcntl.h>                      /* XXX: Required by __hp3000s900 */
18#include <unistd.h>
19#include <string.h>
20#endif
21
22#include "db_int.h"
23
24/*
25 * __os_fsync --
26 *      Flush a file descriptor.
27 *
28 * PUBLIC: int __os_fsync __P((DB_ENV *, DB_FH *));
29 */
30int
31__os_fsync(dbenv, fhp)
32        DB_ENV *dbenv;
33        DB_FH *fhp;
34{
35        BOOL success;
36        int ret;
37
38        /*
39         * Do nothing if the file descriptor has been marked as not requiring
40         * any sync to disk.
41         */
42        if (F_ISSET(fhp, DB_FH_NOSYNC))
43                return (0);
44
45        ret = 0;
46        do {
47                if (DB_GLOBAL(j_fsync) != NULL)
48                        success = (DB_GLOBAL(j_fsync)(fhp->fd) == 0);
49                else {
50                        success = FlushFileBuffers(fhp->handle);
51                        if (!success)
52                                __os_set_errno(__os_win32_errno());
53                }
54        } while (!success && (ret = __os_get_errno()) == EINTR);
55
56        if (ret != 0)
57                __db_err(dbenv, "fsync %s", strerror(ret));
58        return (ret);
59}
Note: See TracBrowser for help on using the repository browser.