Skip to content

Commit b4c19da

Browse files
committed
aio: Remove obsolete IO worker ID references.
In an ancient ancestor of this code, the postmaster assigned IDs to IO workers. Now it tracks them in an unordered array and doesn't know their IDs, so it might be confusing to readers that it still referred to their indexes as IDs. No change in behavior, just variable name and error message cleanup. Back-patch to 18. Discussion: https://postgr.es/m/CA%2BhUKG%2BwbaZZ9Nwc_bTopm4f-7vDmCwLk80uKDHj9mq%2BUp0E%2Bg%40mail.gmail.com
1 parent b2afb06 commit b4c19da

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4337,15 +4337,15 @@ maybe_start_bgworkers(void)
43374337
static bool
43384338
maybe_reap_io_worker(int pid)
43394339
{
4340-
for (int id = 0; id < MAX_IO_WORKERS; ++id)
4340+
for (int i = 0; i < MAX_IO_WORKERS; ++i)
43414341
{
4342-
if (io_worker_children[id] &&
4343-
io_worker_children[id]->pid == pid)
4342+
if (io_worker_children[i] &&
4343+
io_worker_children[i]->pid == pid)
43444344
{
4345-
ReleasePostmasterChildSlot(io_worker_children[id]);
4345+
ReleasePostmasterChildSlot(io_worker_children[i]);
43464346

43474347
--io_worker_count;
4348-
io_worker_children[id] = NULL;
4348+
io_worker_children[i] = NULL;
43494349
return true;
43504350
}
43514351
}
@@ -4389,22 +4389,22 @@ maybe_adjust_io_workers(void)
43894389
while (io_worker_count < io_workers)
43904390
{
43914391
PMChild *child;
4392-
int id;
4392+
int i;
43934393

43944394
/* find unused entry in io_worker_children array */
4395-
for (id = 0; id < MAX_IO_WORKERS; ++id)
4395+
for (i = 0; i < MAX_IO_WORKERS; ++i)
43964396
{
4397-
if (io_worker_children[id] == NULL)
4397+
if (io_worker_children[i] == NULL)
43984398
break;
43994399
}
4400-
if (id == MAX_IO_WORKERS)
4401-
elog(ERROR, "could not find a free IO worker ID");
4400+
if (i == MAX_IO_WORKERS)
4401+
elog(ERROR, "could not find a free IO worker slot");
44024402

44034403
/* Try to launch one. */
44044404
child = StartChildProcess(B_IO_WORKER);
44054405
if (child != NULL)
44064406
{
4407-
io_worker_children[id] = child;
4407+
io_worker_children[i] = child;
44084408
++io_worker_count;
44094409
}
44104410
else
@@ -4415,11 +4415,11 @@ maybe_adjust_io_workers(void)
44154415
if (io_worker_count > io_workers)
44164416
{
44174417
/* ask the IO worker in the highest slot to exit */
4418-
for (int id = MAX_IO_WORKERS - 1; id >= 0; --id)
4418+
for (int i = MAX_IO_WORKERS - 1; i >= 0; --i)
44194419
{
4420-
if (io_worker_children[id] != NULL)
4420+
if (io_worker_children[i] != NULL)
44214421
{
4422-
kill(io_worker_children[id]->pid, SIGUSR2);
4422+
kill(io_worker_children[i]->pid, SIGUSR2);
44234423
break;
44244424
}
44254425
}

0 commit comments

Comments
 (0)