~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to src/port/open.c

Tags: upstream-8.4.0
ImportĀ upstreamĀ versionĀ 8.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 *
7
7
 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
8
8
 *
9
 
 * $PostgreSQL: pgsql/src/port/open.c,v 1.27 2009/01/01 17:24:04 momjian Exp $
 
9
 * $PostgreSQL: pgsql/src/port/open.c,v 1.28 2009/06/11 14:49:15 momjian Exp $
10
10
 *
11
11
 *-------------------------------------------------------------------------
12
12
 */
82
82
                                         ((fileFlags & O_WRONLY) ? GENERIC_WRITE : GENERIC_READ),
83
83
        /* These flags allow concurrent rename/unlink */
84
84
                                        (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE),
85
 
                                                &sa,
86
 
                                                openFlagsToCreateFileFlags(fileFlags),
87
 
                                                FILE_ATTRIBUTE_NORMAL |
 
85
                                                   &sa,
 
86
                                                   openFlagsToCreateFileFlags(fileFlags),
 
87
                                                   FILE_ATTRIBUTE_NORMAL |
88
88
                                         ((fileFlags & O_RANDOM) ? FILE_FLAG_RANDOM_ACCESS : 0) |
89
89
                           ((fileFlags & O_SEQUENTIAL) ? FILE_FLAG_SEQUENTIAL_SCAN : 0) |
90
90
                          ((fileFlags & _O_SHORT_LIVED) ? FILE_ATTRIBUTE_TEMPORARY : 0) |
91
91
                                ((fileFlags & O_TEMPORARY) ? FILE_FLAG_DELETE_ON_CLOSE : 0) |
92
92
                                          ((fileFlags & O_DIRECT) ? FILE_FLAG_NO_BUFFERING : 0) |
93
 
                                                ((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0),
94
 
                                                NULL)) == INVALID_HANDLE_VALUE)
 
93
                                           ((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0),
 
94
                                                   NULL)) == INVALID_HANDLE_VALUE)
95
95
        {
96
96
                /*
97
97
                 * Sharing violation or locking error can indicate antivirus, backup
98
 
                 * or similar software that's locking the file. Try again for 30 seconds
99
 
                 * before giving up.
 
98
                 * or similar software that's locking the file. Try again for 30
 
99
                 * seconds before giving up.
100
100
                 */
101
 
                DWORD err = GetLastError();
102
 
                if (err == ERROR_SHARING_VIOLATION || 
 
101
                DWORD           err = GetLastError();
 
102
 
 
103
                if (err == ERROR_SHARING_VIOLATION ||
103
104
                        err == ERROR_LOCK_VIOLATION)
104
105
                {
105
106
                        pg_usleep(100000);
108
109
#ifndef FRONTEND
109
110
                        if (loops == 50)
110
111
                                ereport(LOG,
111
 
                                    (errmsg("could not open file \"%s\": %s", fileName, 
112
 
                                          (err == ERROR_SHARING_VIOLATION)?_("sharing violation"):_("lock violation")),
113
 
                                         errdetail("Continuing to retry for 30 seconds."),
114
 
                                         errhint("You might have antivirus, backup, or similar software interfering with the database system.")));
 
112
                                                (errmsg("could not open file \"%s\": %s", fileName,
 
113
                                                                (err == ERROR_SHARING_VIOLATION) ? _("sharing violation") : _("lock violation")),
 
114
                                                 errdetail("Continuing to retry for 30 seconds."),
 
115
                                                 errhint("You might have antivirus, backup, or similar software interfering with the database system.")));
115
116
#endif
116
117
 
117
118
                        if (loops < 300)