mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Ensure BackgroundWorker struct contents are well-defined.
Coverity complained because bgw.bgw_extra wasn't being filled in by ApplyLauncherRegister(). The most future-proof fix is to memset the whole BackgroundWorker struct to zeroes. While at it, let's apply the same coding rule to other places that set up BackgroundWorker structs; four out of five had the same or related issues.
This commit is contained in:
@@ -291,6 +291,7 @@ logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname, Oid userid,
|
||||
LWLockRelease(LogicalRepWorkerLock);
|
||||
|
||||
/* Register the new dynamic worker. */
|
||||
memset(&bgw, 0, sizeof(bgw));
|
||||
bgw.bgw_flags = BGWORKER_SHMEM_ACCESS |
|
||||
BGWORKER_BACKEND_DATABASE_CONNECTION;
|
||||
bgw.bgw_start_time = BgWorkerStart_RecoveryFinished;
|
||||
@@ -560,6 +561,10 @@ ApplyLauncherShmemSize(void)
|
||||
return size;
|
||||
}
|
||||
|
||||
/*
|
||||
* ApplyLauncherRegister
|
||||
* Register a background worker running the logical replication launcher.
|
||||
*/
|
||||
void
|
||||
ApplyLauncherRegister(void)
|
||||
{
|
||||
@@ -568,6 +573,7 @@ ApplyLauncherRegister(void)
|
||||
if (max_logical_replication_workers == 0)
|
||||
return;
|
||||
|
||||
memset(&bgw, 0, sizeof(bgw));
|
||||
bgw.bgw_flags = BGWORKER_SHMEM_ACCESS |
|
||||
BGWORKER_BACKEND_DATABASE_CONNECTION;
|
||||
bgw.bgw_start_time = BgWorkerStart_RecoveryFinished;
|
||||
|
||||
Reference in New Issue
Block a user