Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
e319ec4b
Commit
e319ec4b
authored
Aug 21, 2011
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify errno generating in thread testing program.
parent
b33f78df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
19 deletions
+41
-19
src/test/thread/thread_test.c
src/test/thread/thread_test.c
+41
-19
No files found.
src/test/thread/thread_test.c
View file @
e319ec4b
...
...
@@ -263,6 +263,9 @@ main(int argc, char *argv[])
}
}
/*
* func_call_1
*/
static
void
func_call_1
(
void
)
{
...
...
@@ -272,23 +275,38 @@ func_call_1(void)
void
*
p
;
#endif
#ifdef WIN32
HANDLE
h1
,
h2
;
HANDLE
h1
;
#else
int
fd
;
#endif
unlink
(
TEMP_FILENAME_1
);
/* Set errno = EEXIST */
/* create, then try to fail on exclusive create open */
#ifdef WIN32
h1
=
CreateFile
(
TEMP_FILENAME_1
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_ALWAYS
,
0
,
NULL
);
h2
=
CreateFile
(
TEMP_FILENAME_1
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_NEW
,
0
,
NULL
);
if
(
h1
==
INVALID_HANDLE_VALUE
||
GetLastError
()
!=
ERROR_FILE_EXISTS
)
if
((
h1
=
CreateFile
(
TEMP_FILENAME_1
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_ALWAYS
,
0
,
NULL
))
==
INVALID_HANDLE_VALUE
)
#else
if
((
fd
=
open
(
TEMP_FILENAME_1
,
O_RDWR
|
O_CREAT
,
0600
))
<
0
)
#endif
{
fprintf
(
stderr
,
"Could not create file %s in current directory
\n
"
,
TEMP_FILENAME_1
);
exit
(
1
);
}
#ifdef WIN32
if
(
CreateFile
(
TEMP_FILENAME_1
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_NEW
,
0
,
NULL
)
!=
INVALID_HANDLE_VALUE
||
GetLastError
()
!=
ERROR_FILE_EXISTS
)
#else
if
(
open
(
TEMP_FILENAME_1
,
O_RDWR
|
O_CREAT
,
0600
)
<
0
||
open
(
TEMP_FILENAME_1
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
)
>=
0
)
if
(
open
(
TEMP_FILENAME_1
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
)
>=
0
)
#endif
{
fprintf
(
stderr
,
"Could not create file in current directory or
\n
"
);
fprintf
(
stderr
,
"could not generate failure for create file in current directory **
\n
exiting
\n
"
);
fprintf
(
stderr
,
"Could not generate failure for exclusive file create of %s in current directory **
\n
exiting
\n
"
,
TEMP_FILENAME_1
);
exit
(
1
);
}
...
...
@@ -315,6 +333,11 @@ func_call_1(void)
exit
(
1
);
}
#ifdef WIN32
CloseHandle
(
h1
);
#else
close
(
fd
);
#endif
unlink
(
TEMP_FILENAME_1
);
#ifndef HAVE_STRERROR_R
...
...
@@ -352,6 +375,9 @@ func_call_1(void)
}
/*
* func_call_2
*/
static
void
func_call_2
(
void
)
{
...
...
@@ -363,15 +389,14 @@ func_call_2(void)
unlink
(
TEMP_FILENAME_2
);
/* open non-existant file */
#ifdef WIN32
CreateFile
(
TEMP_FILENAME_2
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
if
(
GetLastError
()
!=
ERROR_FILE_NOT_FOUND
)
#else
if
(
open
(
TEMP_FILENAME_2
,
O_RDONLY
,
0600
)
>=
0
)
#endif
/* Set errno = ENOENT */
/* This will fail, but we can't check errno yet */
if
(
unlink
(
TEMP_FILENAME_2
)
!=
-
1
)
{
fprintf
(
stderr
,
"Read-only open succeeded without create **
\n
exiting
\n
"
);
fprintf
(
stderr
,
"Could not generate failure for unlink of %s in current directory **
\n
exiting
\n
"
,
TEMP_FILENAME_2
);
exit
(
1
);
}
...
...
@@ -394,12 +419,9 @@ func_call_2(void)
#else
fprintf
(
stderr
,
"errno not thread-safe **
\n
exiting
\n
"
);
#endif
unlink
(
TEMP_FILENAME_2
);
exit
(
1
);
}
unlink
(
TEMP_FILENAME_2
);
#ifndef HAVE_STRERROR_R
/*
* If strerror() uses sys_errlist, the pointer might change for different
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment