BtSpinLatch readwr[1]; // read/write lock
BtSpinLatch access[1]; // access intent lock
BtSpinLatch parent[1]; // parent SMO lock
BtSpinLatch readwr[1]; // read/write lock
BtSpinLatch access[1]; // access intent lock
BtSpinLatch parent[1]; // parent SMO lock
uint cnt; // count of keys in page
uint act; // count of active keys
uint min; // next key offset
uint cnt; // count of keys in page
uint act; // count of active keys
uint min; // next key offset
unsigned char bits; // page size in bits
unsigned char lvl:6; // level of page
unsigned char kill:1; // page is being deleted
unsigned char bits; // page size in bits
unsigned char lvl:6; // level of page
unsigned char kill:1; // page is being deleted
unsigned long long int lru; // number of times accessed
uid basepage; // mapped base page number
char *map; // mapped memory pointer
unsigned long long int lru; // number of times accessed
uid basepage; // mapped base page number
char *map; // mapped memory pointer
ushort slot; // slot index in this array
void *hashprev; // previous pool entry for the same hash idx
void *hashnext; // next pool entry for the same hash idx
ushort slot; // slot index in this array
void *hashprev; // previous pool entry for the same hash idx
void *hashnext; // next pool entry for the same hash idx
ushort poolmax; // highest page pool node allocated
ushort poolmask; // total size of pages in mmap segment - 1
ushort hashsize; // size of Hash Table for pool entries
ushort poolmax; // highest page pool node allocated
ushort poolmask; // total size of pages in mmap segment - 1
ushort hashsize; // size of Hash Table for pool entries
ushort *hash; // hash table of pool entries
BtPool *pool; // memory pool page segments
BtSpinLatch *latch; // latches for pool hash slots
ushort *hash; // hash table of pool entries
BtPool *pool; // memory pool page segments
BtSpinLatch *latch; // latches for pool hash slots
- latch->exclusive = 1, latch->pending = 0;
+#ifdef unix
+ __sync_fetch_and_or((ushort *)latch, Write);
+#else
+ _InterlockedOr16((ushort *)latch, Write);
+#endif
- if ( bt_lockpage(bt, ALLOC_page, BtLockWrite, &bt->alloc) )
+ if( bt_lockpage(bt, ALLOC_page, BtLockWrite, &bt->alloc) )
#ifdef unix
memset(bt->zero, 0, 3 * sizeof(BtSpinLatch)); // clear locks
memcpy((char *)bt->zero + 3 * sizeof(BtSpinLatch), (char *)page + 3 * sizeof(BtSpinLatch), bt->mgr->page_size - 3 * sizeof(BtSpinLatch));
#ifdef unix
memset(bt->zero, 0, 3 * sizeof(BtSpinLatch)); // clear locks
memcpy((char *)bt->zero + 3 * sizeof(BtSpinLatch), (char *)page + 3 * sizeof(BtSpinLatch), bt->mgr->page_size - 3 * sizeof(BtSpinLatch));
if( bt_lockpage(bt, new_page, BtLockWrite, &pmap) )
return 0;
if( bt_lockpage(bt, new_page, BtLockWrite, &pmap) )
return 0;
- memcpy(pmap, page, bt->mgr->page_size);
+ // copy source page, but leave latch area intact
+
+ memcpy((char *)pmap + 3 * sizeof(BtSpinLatch), (char *)page + 3 * sizeof(BtSpinLatch), bt->mgr->page_size - 3 * sizeof(BtSpinLatch));