Anonymous avatar Anonymous committed 388c2f9

Fix pg_test_fsync Win32 problems reported by the build farm; add
comments about the alarm method used on Win32.

Comments (0)

Files changed (1)

contrib/pg_test_fsync/pg_test_fsync.c

 	gettimeofday(&start_t, NULL); \
 } while (0)
 #else
+/* WIN32 doesn't support alarm, so we create a thread and sleep there */
 #define START_TIMER	\
 do { \
 	alarm_triggered = false; \
 static void test_open_syncs(void);
 static void test_open_sync(const char *msg, int writes_size);
 static void test_file_descriptor_sync(void);
+#ifndef WIN32
 static void process_alarm(int sig);
+#else
+static DWORD WINAPI process_alarm(LPVOID param);
+#endif
 static void signal_cleanup(int sig);
 
 #ifdef HAVE_FSYNC_WRITETHROUGH
 	printf(OPS_FORMAT "\n", per_second);
 }
 
+#ifndef WIN32
 static void
 process_alarm(int sig)
 {
-#ifdef WIN32
-	sleep(secs_per_test);
-#endif
 	alarm_triggered = true;
-#ifdef WIN32
+}
+#else
+static DWORD WINAPI
+process_alarm(LPVOID param)
+{
+	/* WIN32 doesn't support alarm, so we create a thread and sleep here */
+	Sleep(secs_per_test * 1000);
+	alarm_triggered = true;
 	ExitThread(0);
-#endif
 }
+#endif
 
 static void
 die(const char *str)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.