Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a problem in lsm_write() occuring if the same pointer is passed as both key and value.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | multi-process
Files: files | file ages | folders
SHA1: 27ef4e84c11b2ecb1f737127146bd0a4c18b0d1d
User & Date: dan 2012-08-25 19:04:20.867
Context
2012-08-25
19:17
Fix another bug to do with large key-value pairs. check-in: 511a91e121 user: dan tags: multi-process
19:04
Fix a problem in lsm_write() occuring if the same pointer is passed as both key and value. check-in: 27ef4e84c1 user: dan tags: multi-process
18:51
Fix a problem with large key/value pairs. check-in: e229e3e35f user: dan tags: multi-process
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/lsm_tree.c.
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
    iRet = iWrite;
    pDb->treehdr.iWrite = iWrite + nByte;
    pDb->treehdr.nByte += nByte;
  }
  return iRet;
}

/*
** A wrapper around treeShmalloc that returns a pointer into shared memory
** instead of an offset value.
*/
static void *treeShmallocPtr(lsm_db *pDb, int bAlign, int nByte, int *pRc){
  u32 iPtr;
  iPtr = treeShmalloc(pDb, bAlign, nByte, pRc);
  return treeShmptr(pDb, iPtr, pRc);
}

/*
** Allocate and zero nByte bytes of space within the *-shm file.
*/
static void *treeShmallocZero(lsm_db *pDb, int nByte, u32 *piPtr, int *pRc){
  u32 iPtr;
  void *p;
  iPtr = treeShmalloc(pDb, 1, nByte, pRc);







<
<
<
<
<
<
<
<
<
<







571
572
573
574
575
576
577










578
579
580
581
582
583
584
    iRet = iWrite;
    pDb->treehdr.iWrite = iWrite + nByte;
    pDb->treehdr.nByte += nByte;
  }
  return iRet;
}











/*
** Allocate and zero nByte bytes of space within the *-shm file.
*/
static void *treeShmallocZero(lsm_db *pDb, int nByte, u32 *piPtr, int *pRc){
  u32 iPtr;
  void *p;
  iPtr = treeShmalloc(pDb, 1, nByte, pRc);
652
653
654
655
656
657
658
659
660
661
662
663
664
665

666
667
668
669
670
671
672
      int nAvail;

      iWrite = pDb->treehdr.iWrite;
      nAvail = LSM_SHM_CHUNK_SIZE - (iWrite & (LSM_SHM_CHUNK_SIZE-1));
      assert( ((iWrite+nAvail) % LSM_SHM_CHUNK_SIZE)==0 );
      nAlloc = LSM_MIN(nAvail, nRem);

      aAlloc = treeShmallocPtr(pDb, 0, nAlloc, pRc);
      if( aAlloc==0 ) break;
      memcpy(aAlloc, &a[n-nRem], nAlloc);
      nRem -= nAlloc;
    }
    a = (a==pKey ? pVal : 0);
    n = nRem = nVal;

  }

  if( *pRc ) return 0;
#if 0
  printf("store: %d %s\n", (int)iPtr, (char *)pKey);
#endif
  return p;







|




|

>







642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
      int nAvail;

      iWrite = pDb->treehdr.iWrite;
      nAvail = LSM_SHM_CHUNK_SIZE - (iWrite & (LSM_SHM_CHUNK_SIZE-1));
      assert( ((iWrite+nAvail) % LSM_SHM_CHUNK_SIZE)==0 );
      nAlloc = LSM_MIN(nAvail, nRem);

      aAlloc = treeShmptr(pDb, treeShmalloc(pDb, 0, nAlloc, pRc), pRc);
      if( aAlloc==0 ) break;
      memcpy(aAlloc, &a[n-nRem], nAlloc);
      nRem -= nAlloc;
    }
    a = pVal;
    n = nRem = nVal;
    pVal = 0;
  }

  if( *pRc ) return 0;
#if 0
  printf("store: %d %s\n", (int)iPtr, (char *)pKey);
#endif
  return p;