Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit74d0994

Browse files
committed
Measure WaitLatch's timeout parameter in milliseconds, not microseconds.
The original definition had the problem that timeouts exceeding about 2100seconds couldn't be specified on 32-bit machines. Milliseconds seem likesufficient resolution, and finer grain than that would be fantasy anywayon many platforms.Back-patch to 9.1 so that this aspect of the latch API won't change between9.1 and later releases.Peter Geoghegan
1 parent6760a4d commit74d0994

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10161,7 +10161,7 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt,
1016110161
/*
1016210162
* Wait for more WAL to arrive, or timeout to be reached
1016310163
*/
10164-
WaitLatch(&XLogCtl->recoveryWakeupLatch,5000000L);
10164+
WaitLatch(&XLogCtl->recoveryWakeupLatch,5000L);
1016510165
ResetLatch(&XLogCtl->recoveryWakeupLatch);
1016610166
}
1016710167
else

‎src/backend/port/unix_latch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ DisownLatch(volatile Latch *latch)
134134
* Wait for given latch to be set or until timeout is exceeded.
135135
* If the latch is already set, the function returns immediately.
136136
*
137-
* The 'timeout' is given inmicroseconds, and -1 means wait forever.
137+
* The 'timeout' is given inmilliseconds, and -1 means wait forever.
138138
* On some platforms, signals cause the timeout to be restarted, so beware
139139
* that the function can sleep for several times longer than the specified
140140
* timeout.
@@ -173,8 +173,8 @@ WaitLatchOrSocket(volatile Latch *latch, pgsocket sock, bool forRead,
173173
/* Initialize timeout */
174174
if (timeout >=0)
175175
{
176-
tv.tv_sec=timeout /1000000L;
177-
tv.tv_usec=timeout %1000000L;
176+
tv.tv_sec=timeout /1000L;
177+
tv.tv_usec=(timeout %1000L)*1000L;
178178
tvp=&tv;
179179
}
180180

‎src/backend/port/win32_latch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ WaitLatchOrSocket(volatile Latch *latch, pgsocket sock, bool forRead,
137137
}
138138

139139
rc=WaitForMultipleObjects(numevents,events, FALSE,
140-
(timeout >=0) ?(timeout /1000) :INFINITE);
140+
(timeout >=0) ?timeout :INFINITE);
141141
if (rc==WAIT_FAILED)
142142
elog(ERROR,"WaitForMultipleObjects() failed: error code %d", (int)GetLastError());
143143
elseif (rc==WAIT_TIMEOUT)

‎src/backend/replication/syncrep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ SyncRepWaitForLSN(XLogRecPtr XactCommitLSN)
251251
* cancel/die signal or postmaster death regularly while waiting. Note
252252
* that timeout here does not necessarily release from loop.
253253
*/
254-
WaitLatch(&MyProc->waitLatch,60000000L);
254+
WaitLatch(&MyProc->waitLatch,60000L);
255255
}
256256

257257
/*

‎src/backend/replication/walsender.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ WalSndLoop(void)
807807
/* Sleep */
808808
WaitLatchOrSocket(&MyWalSnd->latch,MyProcPort->sock,
809809
true,pq_is_send_pending(),
810-
sleeptime*1000L);
810+
sleeptime);
811811

812812
/* Check for replication timeout */
813813
if (replication_timeout>0&&

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp