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
ab7d4213
Commit
ab7d4213
authored
Dec 09, 2011
by
Robert Haas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If pg_test_fsync is interrupted, clean up the temp file.
Marti Raudsepp, with additional paranoia by me.
parent
5bcf8ede
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
contrib/pg_test_fsync/pg_test_fsync.c
contrib/pg_test_fsync/pg_test_fsync.c
+23
-0
No files found.
contrib/pg_test_fsync/pg_test_fsync.c
View file @
ab7d4213
...
...
@@ -9,6 +9,7 @@
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include "getopt_long.h"
#include "access/xlogdefs.h"
...
...
@@ -29,6 +30,7 @@
static
const
char
*
progname
;
static
int
ops_per_test
=
2000
;
static
int
needs_unlink
=
0
;
static
char
full_buf
[
XLOG_SEG_SIZE
],
*
buf
,
*
filename
=
FSYNC_FILENAME
;
...
...
@@ -44,6 +46,7 @@ static void test_sync(int writes_per_op);
static
void
test_open_syncs
(
void
);
static
void
test_open_sync
(
const
char
*
msg
,
int
writes_size
);
static
void
test_file_descriptor_sync
(
void
);
static
void
signal_cleanup
(
int
sig
);
#ifdef HAVE_FSYNC_WRITETHROUGH
static
int
pg_fsync_writethrough
(
int
fd
);
...
...
@@ -59,6 +62,14 @@ main(int argc, char *argv[])
handle_args
(
argc
,
argv
);
/* Prevent leaving behind the test file */
signal
(
SIGINT
,
signal_cleanup
);
signal
(
SIGTERM
,
signal_cleanup
);
#ifdef SIGHUP
/* Not defined on win32 */
signal
(
SIGHUP
,
signal_cleanup
);
#endif
prepare_buf
();
test_open
();
...
...
@@ -167,6 +178,7 @@ test_open(void)
*/
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
O_CREAT
,
S_IRUSR
|
S_IWUSR
))
==
-
1
)
die
(
"could not open output file"
);
needs_unlink
=
1
;
if
(
write
(
tmpfile
,
full_buf
,
XLOG_SEG_SIZE
)
!=
XLOG_SEG_SIZE
)
die
(
"write failed"
);
...
...
@@ -490,6 +502,17 @@ test_non_sync(void)
print_elapse
(
start_t
,
stop_t
);
}
static
void
signal_cleanup
(
int
signum
)
{
/* Delete the file if it exists. Ignore errors */
if
(
needs_unlink
)
unlink
(
filename
);
/* Finish incomplete line on stdout */
puts
(
""
);
exit
(
signum
);
}
#ifdef HAVE_FSYNC_WRITETHROUGH
static
int
...
...
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