Skip to content

Commit 388c2f9

Browse files
committed
Fix pg_test_fsync Win32 problems reported by the build farm; add
comments about the alarm method used on Win32.
1 parent 7ae2db1 commit 388c2f9

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

contrib/pg_test_fsync/pg_test_fsync.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ do { \
3636
gettimeofday(&start_t, NULL); \
3737
} while (0)
3838
#else
39+
/* WIN32 doesn't support alarm, so we create a thread and sleep there */
3940
#define START_TIMER \
4041
do { \
4142
alarm_triggered = false; \
@@ -76,7 +77,11 @@ static void test_sync(int writes_per_op);
7677
static void test_open_syncs(void);
7778
static void test_open_sync(const char *msg, int writes_size);
7879
static void test_file_descriptor_sync(void);
80+
#ifndef WIN32
7981
static void process_alarm(int sig);
82+
#else
83+
static DWORD WINAPI process_alarm(LPVOID param);
84+
#endif
8085
static void signal_cleanup(int sig);
8186

8287
#ifdef HAVE_FSYNC_WRITETHROUGH
@@ -566,17 +571,22 @@ print_elapse(struct timeval start_t, struct timeval stop_t, int ops)
566571
printf(OPS_FORMAT "\n", per_second);
567572
}
568573

574+
#ifndef WIN32
569575
static void
570576
process_alarm(int sig)
571577
{
572-
#ifdef WIN32
573-
sleep(secs_per_test);
574-
#endif
575578
alarm_triggered = true;
576-
#ifdef WIN32
579+
}
580+
#else
581+
static DWORD WINAPI
582+
process_alarm(LPVOID param)
583+
{
584+
/* WIN32 doesn't support alarm, so we create a thread and sleep here */
585+
Sleep(secs_per_test * 1000);
586+
alarm_triggered = true;
577587
ExitThread(0);
578-
#endif
579588
}
589+
#endif
580590

581591
static void
582592
die(const char *str)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy