diff options
| author | Alvaro Herrera | 2012-10-16 20:36:30 +0000 |
|---|---|---|
| committer | Alvaro Herrera | 2012-10-17 14:31:20 +0000 |
| commit | a66ee69add6e129c7674a59f8c3ba010ed4c9386 (patch) | |
| tree | 8e3b1f182d2b302904b7d6e32563da03e5c6aa61 /src/backend/postmaster | |
| parent | f862a326efa3087440bc86cbfe58ea11c977068a (diff) | |
Embedded list interface
Provide a common implementation of embedded singly-linked and
doubly-linked lists. "Embedded" in the sense that the nodes'
next/previous pointers exist within some larger struct; this design
choice reduces memory allocation overhead.
Most of the implementation uses inlineable functions (where supported),
for performance.
Some existing uses of both types of lists have been converted to the new
code, for demonstration purposes. Other uses can (and probably will) be
converted in the future. Since dllist.c is unused after this conversion,
it has been removed.
Author: Andres Freund
Some tweaks by me
Reviewed by Tom Lane, Peter Geoghegan
Diffstat (limited to 'src/backend/postmaster')
| -rw-r--r-- | src/backend/postmaster/autovacuum.c | 214 | ||||
| -rw-r--r-- | src/backend/postmaster/postmaster.c | 57 |
2 files changed, 120 insertions, 151 deletions
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 74db821387..afd15aac97 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -77,7 +77,7 @@ #include "catalog/pg_database.h" #include "commands/dbcommands.h" #include "commands/vacuum.h" -#include "lib/dllist.h" +#include "lib/ilist.h" #include "libpq/pqsignal.h" #include "miscadmin.h" #include "pgstat.h" @@ -152,6 +152,7 @@ typedef struct avl_dbase Oid adl_datid; /* hash key -- must be first */ TimestampTz adl_next_worker; int adl_score; + dlist_node adl_node; } avl_dbase; /* struct to keep track of databases in worker */ @@ -208,7 +209,7 @@ typedef struct autovac_table */ typedef struct WorkerInfoData { - SHM_QUEUE wi_links; + dlist_node wi_links; Oid wi_dboid; Oid wi_tableoid; PGPROC *wi_proc; @@ -251,15 +252,18 @@ typedef struct { sig_atomic_t av_signal[AutoVacNumSignals]; pid_t av_launcherpid; - WorkerInfo av_freeWorkers; - SHM_QUEUE av_runningWorkers; + dlist_head av_freeWorkers; + dlist_head av_runningWorkers; WorkerInfo av_startingWorker; } AutoVacuumShmemStruct; static AutoVacuumShmemStruct *AutoVacuumShmem; -/* the database list in the launcher, and the context that contains it */ -static Dllist *DatabaseList = NULL; +/* + * the database list (of avl_dbase elements) in the launcher, and the context + * that contains it + */ +static dlist_head DatabaseList = DLIST_STATIC_INIT(DatabaseList); static MemoryContext DatabaseListCxt = NULL; /* Pointer to my own WorkerInfo, valid on each worker */ @@ -508,7 +512,7 @@ AutoVacLauncherMain(int argc, char *argv[]) /* don't leave dangling pointers to freed memory */ DatabaseListCxt = NULL; - DatabaseList = NULL; + dlist_init(&DatabaseList); /* * Make sure pgstat also considers our stat data as gone. Note: we @@ -576,7 +580,7 @@ AutoVacLauncherMain(int argc, char *argv[]) struct timeval nap; TimestampTz current_time = 0; bool can_launch; - Dlelem *elem; + avl_dbase *avdb; int rc; /* @@ -586,7 +590,7 @@ AutoVacLauncherMain(int argc, char *argv[]) * wakening conditions. */ - launcher_determine_sleep((AutoVacuumShmem->av_freeWorkers != NULL), + launcher_determine_sleep(!dlist_is_empty(&AutoVacuumShmem->av_freeWorkers), false, &nap); /* Allow sinval catchup interrupts while sleeping */ @@ -679,7 +683,7 @@ AutoVacLauncherMain(int argc, char *argv[]) current_time = GetCurrentTimestamp(); LWLockAcquire(AutovacuumLock, LW_SHARED); - can_launch = (AutoVacuumShmem->av_freeWorkers != NULL); + can_launch = !dlist_is_empty(&AutoVacuumShmem->av_freeWorkers); if (AutoVacuumShmem->av_startingWorker != NULL) { @@ -721,8 +725,7 @@ AutoVacLauncherMain(int argc, char *argv[]) worker->wi_tableoid = InvalidOid; worker->wi_proc = NULL; worker->wi_launchtime = 0; - worker->wi_links.next = (SHM_QUEUE *) AutoVacuumShmem->av_freeWorkers; - AutoVacuumShmem->av_freeWorkers = worker; + dlist_push_head(&AutoVacuumShmem->av_freeWorkers, &worker->wi_links); AutoVacuumShmem->av_startingWorker = NULL; elog(WARNING, "worker took too long to start; canceled"); } @@ -738,20 +741,7 @@ AutoVacLauncherMain(int argc, char *argv[]) /* We're OK to start a new worker */ - elem = DLGetTail(DatabaseList); - if (elem != NULL) - { - avl_dbase *avdb = DLE_VAL(elem); - - /* - * launch a worker if next_worker is right now or it is in the - * past - */ - if (TimestampDifferenceExceeds(avdb->adl_next_worker, - current_time, 0)) - launch_worker(current_time); - } - else + if (dlist_is_empty(&DatabaseList)) { /* * Special case when the list is empty: start a worker right away. @@ -763,6 +753,23 @@ AutoVacLauncherMain(int argc, char *argv[]) */ launch_worker(current_time); } + else + { + /* + * because rebuild_database_list constructs a list with most + * distant adl_next_worker first, we obtain our database from the + * tail of the list. + */ + avdb = dlist_tail_element(avl_dbase, adl_node, &DatabaseList); + + /* + * launch a worker if next_worker is right now or it is in the + * past + */ + if (TimestampDifferenceExceeds(avdb->adl_next_worker, + current_time, 0)) + launch_worker(current_time); + } } /* Normal exit from the autovac launcher is here */ @@ -783,7 +790,7 @@ AutoVacLauncherMain(int argc, char *argv[]) static void launcher_determine_sleep(bool canlaunch, bool recursing, struct timeval * nap) { - Dlelem *elem; + avl_dbase *avdb; /* * We sleep until the next scheduled vacuum. We trust that when the @@ -796,14 +803,15 @@ launcher_determine_sleep(bool canlaunch, bool recursing, struct timeval * nap) nap->tv_sec = autovacuum_naptime; nap->tv_usec = 0; } - else if ((elem = DLGetTail(DatabaseList)) != NULL) + else if (!dlist_is_empty(&DatabaseList)) { - avl_dbase *avdb = DLE_VAL(elem); TimestampTz current_time = GetCurrentTimestamp(); TimestampTz next_wakeup; long secs; int usecs; + avdb = dlist_tail_element(avl_dbase, adl_node, &DatabaseList); + next_wakeup = avdb->adl_next_worker; TimestampDifference(current_time, next_wakeup, &secs, &usecs); @@ -867,6 +875,7 @@ rebuild_database_list(Oid newdb) int score; int nelems; HTAB *dbhash; + dlist_iter iter; /* use fresh stats */ autovac_refresh_stats(); @@ -927,36 +936,28 @@ rebuild_database_list(Oid newdb) } /* Now insert the databases from the existing list */ - if (DatabaseList != NULL) + dlist_foreach(iter, &DatabaseList) { - Dlelem *elem; - - elem = DLGetHead(DatabaseList); - while (elem != NULL) - { - avl_dbase *avdb = DLE_VAL(elem); - avl_dbase *db; - bool found; - PgStat_StatDBEntry *entry; - - elem = DLGetSucc(elem); + avl_dbase *avdb = dlist_container(avl_dbase, adl_node, iter.cur); + avl_dbase *db; + bool found; + PgStat_StatDBEntry *entry; - /* - * skip databases with no stat entries -- in particular, this gets - * rid of dropped databases - */ - entry = pgstat_fetch_stat_dbentry(avdb->adl_datid); - if (entry == NULL) - continue; + /* + * skip databases with no stat entries -- in particular, this gets + * rid of dropped databases + */ + entry = pgstat_fetch_stat_dbentry(avdb->adl_datid); + if (entry == NULL) + continue; - db = hash_search(dbhash, &(avdb->adl_datid), HASH_ENTER, &found); + db = hash_search(dbhash, &(avdb->adl_datid), HASH_ENTER, &found); - if (!found) - { - /* hash_search already filled in the key */ - db->adl_score = score++; - /* next_worker is filled in later */ - } + if (!found) + { + /* hash_search already filled in the key */ + db->adl_score = score++; + /* next_worker is filled in later */ } } @@ -987,7 +988,7 @@ rebuild_database_list(Oid newdb) /* from here on, the allocated memory belongs to the new list */ MemoryContextSwitchTo(newcxt); - DatabaseList = DLNewList(); + dlist_init(&DatabaseList); if (nelems > 0) { @@ -1029,15 +1030,13 @@ rebuild_database_list(Oid newdb) for (i = 0; i < nelems; i++) { avl_dbase *db = &(dbary[i]); - Dlelem *elem; current_time = TimestampTzPlusMilliseconds(current_time, millis_increment); db->adl_next_worker = current_time; - elem = DLNewElem(db); /* later elements should go closer to the head of the list */ - DLAddHead(DatabaseList, elem); + dlist_push_head(&DatabaseList, &db->adl_node); } } @@ -1086,7 +1085,7 @@ do_start_worker(void) /* return quickly when there are no free workers */ LWLockAcquire(AutovacuumLock, LW_SHARED); - if (AutoVacuumShmem->av_freeWorkers == NULL) + if (dlist_is_empty(&AutoVacuumShmem->av_freeWorkers)) { LWLockRelease(AutovacuumLock); return InvalidOid; @@ -1147,7 +1146,7 @@ do_start_worker(void) foreach(cell, dblist) { avw_dbase *tmp = lfirst(cell); - Dlelem *elem; + dlist_iter iter; /* Check to see if this one is at risk of wraparound */ if (TransactionIdPrecedes(tmp->adw_frozenxid, xidForceLimit)) @@ -1179,11 +1178,10 @@ do_start_worker(void) * autovacuum time yet. */ skipit = false; - elem = DatabaseList ? DLGetTail(DatabaseList) : NULL; - while (elem != NULL) + dlist_reverse_foreach(iter, &DatabaseList) { - avl_dbase *dbp = DLE_VAL(elem); + avl_dbase *dbp = dlist_container(avl_dbase, adl_node, iter.cur); if (dbp->adl_datid == tmp->adw_datid) { @@ -1200,7 +1198,6 @@ do_start_worker(void) break; } - elem = DLGetPred(elem); } if (skipit) continue; @@ -1218,20 +1215,17 @@ do_start_worker(void) if (avdb != NULL) { WorkerInfo worker; + dlist_node *wptr; LWLockAcquire(AutovacuumLock, LW_EXCLUSIVE); /* * Get a worker entry from the freelist. We checked above, so there - * really should be a free slot -- complain very loudly if there - * isn't. + * really should be a free slot. */ - worker = AutoVacuumShmem->av_freeWorkers; - if (worker == NULL) - elog(FATAL, "no free worker found"); - - AutoVacuumShmem->av_freeWorkers = (WorkerInfo) worker->wi_links.next; + wptr = dlist_pop_head_node(&AutoVacuumShmem->av_freeWorkers); + worker = dlist_container(WorkerInfoData, wi_links, wptr); worker->wi_dboid = avdb->adw_datid; worker->wi_proc = NULL; worker->wi_launchtime = GetCurrentTimestamp(); @@ -1274,22 +1268,25 @@ static void launch_worker(TimestampTz now) { Oid dbid; - Dlelem *elem; + dlist_iter iter; dbid = do_start_worker(); if (OidIsValid(dbid)) { + bool found = false; + /* * Walk the database list and update the corresponding entry. If the * database is not on the list, we'll recreate the list. */ - elem = (DatabaseList == NULL) ? NULL : DLGetHead(DatabaseList); - while (elem != NULL) + dlist_foreach(iter, &DatabaseList) { - avl_dbase *avdb = DLE_VAL(elem); + avl_dbase *avdb = dlist_container(avl_dbase, adl_node, iter.cur); if (avdb->adl_datid == dbid) { + found = true; + /* * add autovacuum_naptime seconds to the current time, and use * that as the new "next_worker" field for this database. @@ -1297,10 +1294,9 @@ launch_worker(TimestampTz now) avdb->adl_next_worker = TimestampTzPlusMilliseconds(now, autovacuum_naptime * 1000); - DLMoveToFront(elem); + dlist_move_head(&DatabaseList, iter.cur); break; } - elem = DLGetSucc(elem); } /* @@ -1310,7 +1306,7 @@ launch_worker(TimestampTz now) * pgstat entry, but this is not a problem because we don't want to * schedule workers regularly into those in any case. */ - if (elem == NULL) + if (!found) rebuild_database_list(dbid); } } @@ -1590,8 +1586,8 @@ AutoVacWorkerMain(int argc, char *argv[]) MyWorkerInfo->wi_proc = MyProc; /* insert into the running list */ - SHMQueueInsertBefore(&AutoVacuumShmem->av_runningWorkers, - &MyWorkerInfo->wi_links); + dlist_push_head(&AutoVacuumShmem->av_runningWorkers, + &MyWorkerInfo->wi_links); /* * remove from the "starting" pointer, so that the launcher can start @@ -1681,8 +1677,7 @@ FreeWorkerInfo(int code, Datum arg) */ AutovacuumLauncherPid = AutoVacuumShmem->av_launcherpid; - SHMQueueDelete(&MyWorkerInfo->wi_links); - MyWorkerInfo->wi_links.next = (SHM_QUEUE *) AutoVacuumShmem->av_freeWorkers; + dlist_delete(&AutoVacuumShmem->av_runningWorkers, &MyWorkerInfo->wi_links); MyWorkerInfo->wi_dboid = InvalidOid; MyWorkerInfo->wi_tableoid = InvalidOid; MyWorkerInfo->wi_proc = NULL; @@ -1690,7 +1685,7 @@ FreeWorkerInfo(int code, Datum arg) MyWorkerInfo->wi_cost_delay = 0; MyWorkerInfo->wi_cost_limit = 0; MyWorkerInfo->wi_cost_limit_base = 0; - AutoVacuumShmem->av_freeWorkers = MyWorkerInfo; + dlist_push_head(&AutoVacuumShmem->av_freeWorkers, &MyWorkerInfo->wi_links); /* not mine anymore */ MyWorkerInfo = NULL; @@ -1740,7 +1735,7 @@ autovac_balance_cost(void) autovacuum_vac_cost_delay : VacuumCostDelay); double cost_total; double cost_avail; - WorkerInfo worker; + dlist_iter iter; /* not set? nothing to do */ if (vac_cost_limit <= 0 || vac_cost_delay <= 0) @@ -1748,19 +1743,14 @@ autovac_balance_cost(void) /* caculate the total base cost limit of active workers */ cost_total = 0.0; - worker = (WorkerInfo) SHMQueueNext(&AutoVacuumShmem->av_runningWorkers, - &AutoVacuumShmem->av_runningWorkers, - offsetof(WorkerInfoData, wi_links)); - while (worker) + dlist_foreach(iter, &AutoVacuumShmem->av_runningWorkers) { + WorkerInfo worker = dlist_container(WorkerInfoData, wi_links, iter.cur); + if (worker->wi_proc != NULL && worker->wi_cost_limit_base > 0 && worker->wi_cost_delay > 0) cost_total += (double) worker->wi_cost_limit_base / worker->wi_cost_delay; - - worker = (WorkerInfo) SHMQueueNext(&AutoVacuumShmem->av_runningWorkers, - &worker->wi_links, - offsetof(WorkerInfoData, wi_links)); } /* there are no cost limits -- nothing to do */ if (cost_total <= 0) @@ -1771,11 +1761,10 @@ autovac_balance_cost(void) * limit to autovacuum_vacuum_cost_limit. */ cost_avail = (double) vac_cost_limit / vac_cost_delay; - worker = (WorkerInfo) SHMQueueNext(&AutoVacuumShmem->av_runningWorkers, - &AutoVacuumShmem->av_runningWorkers, - offsetof(WorkerInfoData, wi_links)); - while (worker) + dlist_foreach(iter, &AutoVacuumShmem->av_runningWorkers) { + WorkerInfo worker = dlist_container(WorkerInfoData, wi_links, iter.cur); + if (worker->wi_proc != NULL && worker->wi_cost_limit_base > 0 && worker->wi_cost_delay > 0) { @@ -1797,10 +1786,6 @@ autovac_balance_cost(void) worker->wi_cost_limit, worker->wi_cost_limit_base, worker->wi_cost_delay); } - - worker = (WorkerInfo) SHMQueueNext(&AutoVacuumShmem->av_runningWorkers, - &worker->wi_links, - offsetof(WorkerInfoData, wi_links)); } } @@ -2177,10 +2162,10 @@ do_autovacuum(void) { Oid relid = lfirst_oid(cell); autovac_table *tab; - WorkerInfo worker; bool skipit; int stdVacuumCostDelay; int stdVacuumCostLimit; + dlist_iter iter; CHECK_FOR_INTERRUPTS(); @@ -2197,29 +2182,23 @@ do_autovacuum(void) * worker. */ skipit = false; - worker = (WorkerInfo) SHMQueueNext(&AutoVacuumShmem->av_runningWorkers, - &AutoVacuumShmem->av_runningWorkers, - offsetof(WorkerInfoData, wi_links)); - while (worker) + dlist_foreach(iter, &AutoVacuumShmem->av_runningWorkers) { + WorkerInfo worker = dlist_container(WorkerInfoData, wi_links, iter.cur); + /* ignore myself */ if (worker == MyWorkerInfo) - goto next_worker; + continue; /* ignore workers in other databases */ if (worker->wi_dboid != MyDatabaseId) - goto next_worker; + continue; if (worker->wi_tableoid == relid) { skipit = true; break; } - - next_worker: - worker = (WorkerInfo) SHMQueueNext(&AutoVacuumShmem->av_runningWorkers, - &worker->wi_links, - offsetof(WorkerInfoData, wi_links)); } LWLockRelease(AutovacuumLock); if (skipit) @@ -2875,8 +2854,8 @@ AutoVacuumShmemInit(void) Assert(!found); AutoVacuumShmem->av_launcherpid = 0; - AutoVacuumShmem->av_freeWorkers = NULL; - SHMQueueInit(&AutoVacuumShmem->av_runningWorkers); + dlist_init(&AutoVacuumShmem->av_freeWorkers); + dlist_init(&AutoVacuumShmem->av_runningWorkers); AutoVacuumShmem->av_startingWorker = NULL; worker = (WorkerInfo) ((char *) AutoVacuumShmem + @@ -2884,10 +2863,7 @@ AutoVacuumShmemInit(void) /* initialize the WorkerInfo free list */ for (i = 0; i < autovacuum_max_workers; i++) - { - worker[i].wi_links.next = (SHM_QUEUE *) AutoVacuumShmem->av_freeWorkers; - AutoVacuumShmem->av_freeWorkers = &worker[i]; - } + dlist_push_head(&AutoVacuumShmem->av_freeWorkers, &worker[i].wi_links); } else Assert(found); diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index dfe40492d2..c8a80f038c 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -95,7 +95,7 @@ #include "access/xlog.h" #include "bootstrap/bootstrap.h" #include "catalog/pg_control.h" -#include "lib/dllist.h" +#include "lib/ilist.h" #include "libpq/auth.h" #include "libpq/ip.h" #include "libpq/libpq.h" @@ -146,10 +146,10 @@ typedef struct bkend int child_slot; /* PMChildSlot for this backend, if any */ bool is_autovacuum; /* is it an autovacuum process? */ bool dead_end; /* is it going to send an error and quit? */ - Dlelem elem; /* list link in BackendList */ + dlist_node elem; /* list link in BackendList */ } Backend; -static Dllist *BackendList; +static dlist_head BackendList = DLIST_STATIC_INIT(BackendList); #ifdef EXEC_BACKEND static Backend *ShmemBackendArray; @@ -1028,11 +1028,6 @@ PostmasterMain(int argc, char *argv[]) set_stack_base(); /* - * Initialize the list of active backends. - */ - BackendList = DLNewList(); - - /* * Initialize pipe (or process handle on Windows) that allows children to * wake up from sleep on postmaster death. */ @@ -1872,7 +1867,7 @@ processCancelRequest(Port *port, void *pkt) Backend *bp; #ifndef EXEC_BACKEND - Dlelem *curr; + dlist_iter iter; #else int i; #endif @@ -1886,9 +1881,9 @@ processCancelRequest(Port *port, void *pkt) * duplicate array in shared memory. */ #ifndef EXEC_BACKEND - for (curr = DLGetHead(BackendList); curr; curr = DLGetSucc(curr)) + dlist_foreach(iter, &BackendList) { - bp = (Backend *) DLE_VAL(curr); + bp = dlist_container(Backend, elem, iter.cur); #else for (i = MaxLivePostmasterChildren() - 1; i >= 0; i--) { @@ -2648,7 +2643,7 @@ static void CleanupBackend(int pid, int exitstatus) /* child's exit status. */ { - Dlelem *curr; + dlist_mutable_iter iter; LogChildExit(DEBUG2, _("server process"), pid, exitstatus); @@ -2680,9 +2675,9 @@ CleanupBackend(int pid, return; } - for (curr = DLGetHead(BackendList); curr; curr = DLGetSucc(curr)) + dlist_foreach_modify(iter, &BackendList) { - Backend *bp = (Backend *) DLE_VAL(curr); + Backend *bp = dlist_container(Backend, elem, iter.cur); if (bp->pid == pid) { @@ -2701,7 +2696,7 @@ CleanupBackend(int pid, ShmemBackendArrayRemove(bp); #endif } - DLRemove(curr); + dlist_delete(&BackendList, iter.cur); free(bp); break; } @@ -2718,8 +2713,7 @@ CleanupBackend(int pid, static void HandleChildCrash(int pid, int exitstatus, const char *procname) { - Dlelem *curr, - *next; + dlist_mutable_iter iter; Backend *bp; /* @@ -2734,10 +2728,10 @@ HandleChildCrash(int pid, int exitstatus, const char *procname) } /* Process regular backends */ - for (curr = DLGetHead(BackendList); curr; curr = next) + dlist_foreach_modify(iter, &BackendList) { - next = DLGetSucc(curr); - bp = (Backend *) DLE_VAL(curr); + bp = dlist_container(Backend, elem, iter.cur); + if (bp->pid == pid) { /* @@ -2750,7 +2744,7 @@ HandleChildCrash(int pid, int exitstatus, const char *procname) ShmemBackendArrayRemove(bp); #endif } - DLRemove(curr); + dlist_delete(&BackendList, iter.cur); free(bp); /* Keep looping so we can signal remaining backends */ } @@ -3113,7 +3107,7 @@ PostmasterStateMachine(void) * normal state transition leading up to PM_WAIT_DEAD_END, or during * FatalError processing. */ - if (DLGetHead(BackendList) == NULL && + if (dlist_is_empty(&BackendList) && PgArchPID == 0 && PgStatPID == 0) { /* These other guys should be dead already */ @@ -3239,12 +3233,12 @@ signal_child(pid_t pid, int signal) static bool SignalSomeChildren(int signal, int target) { - Dlelem *curr; + dlist_iter iter; bool signaled = false; - for (curr = DLGetHead(BackendList); curr; curr = DLGetSucc(curr)) + dlist_foreach(iter, &BackendList) { - Backend *bp = (Backend *) DLE_VAL(curr); + Backend *bp = dlist_container(Backend, elem, iter.cur); if (bp->dead_end) continue; @@ -3382,8 +3376,8 @@ BackendStartup(Port *port) */ bn->pid = pid; bn->is_autovacuum = false; - DLInitElem(&bn->elem, bn); - DLAddHead(BackendList, &bn->elem); + dlist_push_head(&BackendList, &bn->elem); + #ifdef EXEC_BACKEND if (!bn->dead_end) ShmemBackendArrayAdd(bn); @@ -4491,12 +4485,12 @@ PostmasterRandom(void) static int CountChildren(int target) { - Dlelem *curr; + dlist_iter iter; int cnt = 0; - for (curr = DLGetHead(BackendList); curr; curr = DLGetSucc(curr)) + dlist_foreach(iter, &BackendList) { - Backend *bp = (Backend *) DLE_VAL(curr); + Backend *bp = dlist_container(Backend, elem, iter.cur); if (bp->dead_end) continue; @@ -4675,8 +4669,7 @@ StartAutovacuumWorker(void) if (bn->pid > 0) { bn->is_autovacuum = true; - DLInitElem(&bn->elem, bn); - DLAddHead(BackendList, &bn->elem); + dlist_push_head(&BackendList, &bn->elem); #ifdef EXEC_BACKEND ShmemBackendArrayAdd(bn); #endif |
