/* Initialize locks and shared memory area */
char *ptr;
Size offset;
- int slotno;
Assert(!found);
}
ptr += BUFFERALIGN(offset);
- for (slotno = 0; slotno < nslots; slotno++)
+ for (int slotno = 0; slotno < nslots; slotno++)
{
LWLockInitialize(&shared->buffer_locks[slotno].lock,
tranche_id);
SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
- int slotno;
/* Try to find the page while holding only shared lock */
LWLockAcquire(shared->ControlLock, LW_SHARED);
/* See if page is already in a buffer */
- for (slotno = 0; slotno < shared->num_slots; slotno++)
+ for (int slotno = 0; slotno < shared->num_slots; slotno++)
{
if (shared->page_number[slotno] == pageno &&
shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
/* If we failed, and we're in a flush, better close the files */
if (!ok && fdata)
{
- int i;
-
- for (i = 0; i < fdata->num_files; i++)
+ for (int i = 0; i < fdata->num_files; i++)
CloseTransientFile(fdata->fd[i]);
}
* transaction-commit path).
*/
XLogRecPtr max_lsn;
- int lsnindex,
- lsnoff;
+ int lsnindex;
lsnindex = slotno * shared->lsn_groups_per_page;
max_lsn = shared->group_lsn[lsnindex++];
- for (lsnoff = 1; lsnoff < shared->lsn_groups_per_page; lsnoff++)
+ for (int lsnoff = 1; lsnoff < shared->lsn_groups_per_page; lsnoff++)
{
XLogRecPtr this_lsn = shared->group_lsn[lsnindex++];
*/
if (fdata)
{
- int i;
-
- for (i = 0; i < fdata->num_files; i++)
+ for (int i = 0; i < fdata->num_files; i++)
{
if (fdata->segno[i] == segno)
{
/* Outer loop handles restart after I/O */
for (;;)
{
- int slotno;
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
- for (slotno = 0; slotno < shared->num_slots; slotno++)
+ for (int slotno = 0; slotno < shared->num_slots; slotno++)
{
if (shared->page_number[slotno] == pageno &&
shared->page_status[slotno] != SLRU_PAGE_EMPTY)
* multiple pages with the same lru_count.
*/
cur_count = (shared->cur_lru_count)++;
- for (slotno = 0; slotno < shared->num_slots; slotno++)
+ for (int slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
int64 this_page_number;
{
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
- int slotno;
int64 pageno = 0;
- int i;
bool ok;
/* update the stats counter of flushes */
LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
- for (slotno = 0; slotno < shared->num_slots; slotno++)
+ for (int slotno = 0; slotno < shared->num_slots; slotno++)
{
SlruInternalWritePage(ctl, slotno, &fdata);
* Now close any files that were open
*/
ok = true;
- for (i = 0; i < fdata.num_files; i++)
+ for (int i = 0; i < fdata.num_files; i++)
{
if (CloseTransientFile(fdata.fd[i]) != 0)
{
SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
- int slotno;
bool did_write;
/* Clean out any possibly existing references to the segment. */
LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
restart:
did_write = false;
- for (slotno = 0; slotno < shared->num_slots; slotno++)
+ for (int slotno = 0; slotno < shared->num_slots; slotno++)
{
int pagesegno = shared->page_number[slotno] / SLRU_PAGES_PER_SEGMENT;