Lift limitation that PGPROC->links must be the first field
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 5 Jul 2024 08:21:46 +0000 (11:21 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 5 Jul 2024 08:21:46 +0000 (11:21 +0300)
Since commit 5764f611e1, we've been using the ilist.h functions for
handling the linked list. There's no need for 'links' to be the first
element of the struct anymore, except for one call in InitProcess
where we used a straight cast from the 'dlist_node *' to PGPROC *,
without the dlist_container() macro. That was just an oversight in
commit 5764f611e1, fix it.

There no imminent need to move 'links' from being the first field, but
let's be tidy.

Reviewed-by: Aleksander Alekseev, Andres Freund
Discussion: https://www.postgresql.org/message-id/22aa749e-cc1a-424a-b455-21325473a794@iki.fi

src/backend/storage/lmgr/proc.c
src/include/storage/proc.h

index ce29da901213e7cc40b1f43c80b63ed00198f39e..1b23efb26f35bc3ef09fb235428344de18b7b003 100644 (file)
@@ -330,7 +330,7 @@ InitProcess(void)
 
    if (!dlist_is_empty(procgloballist))
    {
-       MyProc = (PGPROC *) dlist_pop_head_node(procgloballist);
+       MyProc = dlist_container(PGPROC, links, dlist_pop_head_node(procgloballist));
        SpinLockRelease(ProcStructLock);
    }
    else
index 9488bf1857c8e5b9b3675cac5786bea0989903ec..7d3fc2bfa605ab17b316124a549dad0966b4af14 100644 (file)
@@ -161,7 +161,6 @@ typedef enum
  */
 struct PGPROC
 {
-   /* proc->links MUST BE FIRST IN STRUCT (see ProcSleep,ProcWakeup,etc) */
    dlist_node  links;          /* list link if process is in a list */
    dlist_head *procgloballist; /* procglobal list that owns this PGPROC */