Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Fix for win32 sleep


  • From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
  • To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>, PostgreSQL Win32 port list <pgsql-hackers-win32(at)postgreSQL(dot)org>
  • Subject: Fix for win32 sleep
  • Date: Fri, 30 Jan 2004 10:58:44 -0500 (EST)
  • Message-id: <200401301558(dot)i0UFwi223189(at)candle(dot)pha(dot)pa(dot)us>

I have applied the following patch for the following reasons:
	
	Remove sleep() and use single PG_SLEEP call for Win32 signal handling
	and consistency.
	
	Change PG_USLEEP to use SleepEx() for signal interuptability.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/backend/storage/buffer/bufmgr.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/storage/buffer/bufmgr.c,v
retrieving revision 1.153
diff -c -c -r1.153 bufmgr.c
*** src/backend/storage/buffer/bufmgr.c	24 Jan 2004 20:00:45 -0000	1.153
--- src/backend/storage/buffer/bufmgr.c	30 Jan 2004 15:55:05 -0000
***************
*** 1058,1067 ****
  		 * Nap for the configured time or sleep for 10 seconds if
  		 * there was nothing to do at all.
  		 */
! 		if (n > 0)
! 			PG_USLEEP(BgWriterDelay * 1000);
! 		else
! 			sleep(10);
  	}
  }
  
--- 1058,1064 ----
  		 * Nap for the configured time or sleep for 10 seconds if
  		 * there was nothing to do at all.
  		 */
! 		PG_USLEEP((n > 0) ? BgWriterDelay * 1000 : 10000000);
  	}
  }
  
Index: src/include/miscadmin.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/miscadmin.h,v
retrieving revision 1.148
diff -c -c -r1.148 miscadmin.h
*** src/include/miscadmin.h	26 Jan 2004 22:59:53 -0000	1.148
--- src/include/miscadmin.h	30 Jan 2004 15:55:06 -0000
***************
*** 109,115 ****
  #else
  #define PG_USLEEP(_usec) \
  do { \
! 	Sleep((_usec) < 500 ? 1 : ((_usec)+500)/ 1000); \
  } while(0)
  #endif
  
--- 109,115 ----
  #else
  #define PG_USLEEP(_usec) \
  do { \
! 	SleepEx(((_usec) < 500 ? 1 : ((_usec) + 500) / 1000), TRUE); \
  } while(0)
  #endif
  


Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group