From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | InsertXLogFile in pg_resetxlog |
Date: | 2006-05-01 10:26:04 |
Message-ID: | [email protected] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.
From | Date | Subject | |
---|---|---|---|
Next Message | Patrick Welche | 2006-05-01 12:55:08 | Re: inet increment with int |
Previous Message | Mark Wong | 2006-05-01 05:14:56 | XLOG_BLCKSZ vs. wal_buffers table |