/ Check-in [4f20f8ba]
Login

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

Overview
Comment:If MEM_STATUS is disabled, avoid holding the STATIC_MEM mutex when calling the user-defined xMalloc method. Holding the mutex causes problems for memsys3 and memsys5.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4f20f8ba73691c8a1dc33d2fcd1e793dd08f00a8
User & Date: dan 2010-09-02 10:08:41
Context
2010-09-02
11:53
Add tests for the EXISTS operator to e_expr.test. check-in: 9f9a95cc user: dan tags: trunk
10:08
If MEM_STATUS is disabled, avoid holding the STATIC_MEM mutex when calling the user-defined xMalloc method. Holding the mutex causes problems for memsys3 and memsys5. check-in: 4f20f8ba user: dan tags: trunk
04:30
Fix a few typos. Update evidence marks. check-in: c90a68b7 user: shaneh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/malloc.c.

348
349
350
351
352
353
354

355
356
357
358
359

360

361
362
363
364
365

366
367
368
369
370
371
372
  sqlite3_mutex_enter(mem0.mutex);
  if( mem0.nScratchFree && sqlite3GlobalConfig.szScratch>=n ){
    p = mem0.pScratchFree;
    mem0.pScratchFree = mem0.pScratchFree->pNext;
    mem0.nScratchFree--;
    sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1);
    sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);

  }else{
    if( sqlite3GlobalConfig.bMemstat ){
      sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
      n = mallocWithAlarm(n, &p);
      if( p ) sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, n);

    }else{

      p = sqlite3GlobalConfig.m.xMalloc(n);
    }
    sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH);
  }
  sqlite3_mutex_leave(mem0.mutex);


#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)
  /* Verify that no more than two scratch allocations per thread
  ** are outstanding at one time.  (This is only checked in the
  ** single-threaded case since checking in the multi-threaded case
  ** would be much more complicated.) */
  assert( scratchAllocOut<=1 );







>





>

>




|
>







348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
  sqlite3_mutex_enter(mem0.mutex);
  if( mem0.nScratchFree && sqlite3GlobalConfig.szScratch>=n ){
    p = mem0.pScratchFree;
    mem0.pScratchFree = mem0.pScratchFree->pNext;
    mem0.nScratchFree--;
    sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1);
    sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
    sqlite3_mutex_leave(mem0.mutex);
  }else{
    if( sqlite3GlobalConfig.bMemstat ){
      sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
      n = mallocWithAlarm(n, &p);
      if( p ) sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, n);
      sqlite3_mutex_leave(mem0.mutex);
    }else{
      sqlite3_mutex_leave(mem0.mutex);
      p = sqlite3GlobalConfig.m.xMalloc(n);
    }
    sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH);
  }
  assert( !sqlite3_mutex_held(mem0.mutex) );


#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)
  /* Verify that no more than two scratch allocations per thread
  ** are outstanding at one time.  (This is only checked in the
  ** single-threaded case since checking in the multi-threaded case
  ** would be much more complicated.) */
  assert( scratchAllocOut<=1 );

Changes to test/permutations.test.

583
584
585
586
587
588
589

590
591
592
593
594
595
596
  test_suite "memsys5-2" -description {
    Run tests using the allocator in mem5.c in a different configuration.
  } -files {
    select1.test 
  } -initialize {
    catch {db close}
    sqlite3_shutdown

    sqlite3_config_heap 40000000 16
    sqlite3_config_lookaside 0 0
    install_malloc_faultsim 1 
    sqlite3_initialize
    autoinstall_test_functions
  } -shutdown {
    catch {db close}







>







583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
  test_suite "memsys5-2" -description {
    Run tests using the allocator in mem5.c in a different configuration.
  } -files {
    select1.test 
  } -initialize {
    catch {db close}
    sqlite3_shutdown
    sqlite3_config_memstatus 0
    sqlite3_config_heap 40000000 16
    sqlite3_config_lookaside 0 0
    install_malloc_faultsim 1 
    sqlite3_initialize
    autoinstall_test_functions
  } -shutdown {
    catch {db close}