|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.159 2004/02/1215:06:56 wieck Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.160 2004/02/1220:07:26 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -943,6 +943,7 @@ BufferBackgroundWriter(void)
|
943 | 943 | for (;;)
|
944 | 944 | {
|
945 | 945 | intn;
|
| 946 | +longudelay; |
946 | 947 |
|
947 | 948 | /*
|
948 | 949 | * Call BufferSync() with instructions to keep just the
|
@@ -970,8 +971,23 @@ BufferBackgroundWriter(void)
|
970 | 971 | /*
|
971 | 972 | * Nap for the configured time or sleep for 10 seconds if
|
972 | 973 | * there was nothing to do at all.
|
| 974 | + * |
| 975 | + * On some platforms, signals won't interrupt the sleep. To ensure |
| 976 | + * we respond reasonably promptly when the postmaster signals us, |
| 977 | + * break down the sleep into 1-second increments, and check for |
| 978 | + * interrupts after each nap. |
973 | 979 | */
|
974 |
| -pg_usleep((n>0) ?BgWriterDelay*1000L :10000000L); |
| 980 | +udelay= ((n>0) ?BgWriterDelay :10000)*1000L; |
| 981 | +while (udelay>1000000L) |
| 982 | +{ |
| 983 | +pg_usleep(1000000L); |
| 984 | +udelay-=1000000L; |
| 985 | +if (InterruptPending) |
| 986 | +return; |
| 987 | +} |
| 988 | +pg_usleep(udelay); |
| 989 | +if (InterruptPending) |
| 990 | +return; |
975 | 991 | }
|
976 | 992 | }
|
977 | 993 |
|
|