Fix for win32 sleep

Поиск
Список
Период
Сортировка
Искать

Fix for win32 sleep

От:
Bruce Momjian <pgman@candle.pha.pa.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@candle.pha.pa.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
  
FAQ