InsertXLogFile in pg_resetxlog
От | Martijn van Oosterhout |
---|---|
Тема | InsertXLogFile in pg_resetxlog |
Дата | |
Msg-id | 20060501102604.GB24561@svana.org обсуждение исходный текст |
Ответы |
Re: InsertXLogFile in pg_resetxlog
|
Список | pgsql-hackers |
There's been some new code added to pg_resetxlog which is confusing enough that Coverity is convinced there's a possible memory leak in InsertXLogFile. I think it may actually be a bug. At the least this bit needs rewriting to make it clearer what it does. What I think happens is this: 1. Assume the xlogfilelist has more than two entries already 2. In the loop CmpXLogFileOT returns true the first time, false the second At this point Prev = xlogfilelist and Curr = xlogfilelist->next and append2end = false. With these conditions all if tests fail and the file is never linked into the list. May I propose the entire part of that function after the comment /* the list is empty. */ be replaced with something like the following (or whatever idiom people prefer for singly-linked lists): --- cut --- /* currp points to memory location where the pointer needs to be updated */ XLogFileName **currp = &xlogfilelist; while( *currp && CmpXLogFileOT( NewSegFile, *currp ) )currp = &( (*currp)->next ); NewSegFile->next = *currp; *currp = NewSegFile; --- cut --- Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > From each according to his ability. To each according to his ability to litigate.
В списке pgsql-hackers по дате отправления: