]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
aio: Remove obsolete IO worker ID references.
authorThomas Munro <tmunro@postgresql.org>
Sat, 12 Jul 2025 01:47:59 +0000 (13:47 +1200)
committerThomas Munro <tmunro@postgresql.org>
Sat, 12 Jul 2025 02:45:36 +0000 (14:45 +1200)
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

src/backend/postmaster/postmaster.c

index 490f7ce36645bfb4e5780d98d301ee544e7b55f8..cca9b946e5384af4743a47a538c8f7ed20baf271 100644 (file)
@@ -4337,15 +4337,15 @@ maybe_start_bgworkers(void)
 static bool
 maybe_reap_io_worker(int pid)
 {
-       for (int id = 0; id < MAX_IO_WORKERS; ++id)
+       for (int i = 0; i < MAX_IO_WORKERS; ++i)
        {
-               if (io_worker_children[id] &&
-                       io_worker_children[id]->pid == pid)
+               if (io_worker_children[i] &&
+                       io_worker_children[i]->pid == pid)
                {
-                       ReleasePostmasterChildSlot(io_worker_children[id]);
+                       ReleasePostmasterChildSlot(io_worker_children[i]);
 
                        --io_worker_count;
-                       io_worker_children[id] = NULL;
+                       io_worker_children[i] = NULL;
                        return true;
                }
        }
@@ -4389,22 +4389,22 @@ maybe_adjust_io_workers(void)
        while (io_worker_count < io_workers)
        {
                PMChild    *child;
-               int                     id;
+               int                     i;
 
                /* find unused entry in io_worker_children array */
-               for (id = 0; id < MAX_IO_WORKERS; ++id)
+               for (i = 0; i < MAX_IO_WORKERS; ++i)
                {
-                       if (io_worker_children[id] == NULL)
+                       if (io_worker_children[i] == NULL)
                                break;
                }
-               if (id == MAX_IO_WORKERS)
-                       elog(ERROR, "could not find a free IO worker ID");
+               if (i == MAX_IO_WORKERS)
+                       elog(ERROR, "could not find a free IO worker slot");
 
                /* Try to launch one. */
                child = StartChildProcess(B_IO_WORKER);
                if (child != NULL)
                {
-                       io_worker_children[id] = child;
+                       io_worker_children[i] = child;
                        ++io_worker_count;
                }
                else
@@ -4415,11 +4415,11 @@ maybe_adjust_io_workers(void)
        if (io_worker_count > io_workers)
        {
                /* ask the IO worker in the highest slot to exit */
-               for (int id = MAX_IO_WORKERS - 1; id >= 0; --id)
+               for (int i = MAX_IO_WORKERS - 1; i >= 0; --i)
                {
-                       if (io_worker_children[id] != NULL)
+                       if (io_worker_children[i] != NULL)
                        {
-                               kill(io_worker_children[id]->pid, SIGUSR2);
+                               kill(io_worker_children[i]->pid, SIGUSR2);
                                break;
                        }
                }