~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/internal/mf_iocache.cc

  • Committer: Andrew Hutchings
  • Date: 2010-10-31 21:54:29 UTC
  • mto: This revision was merged to the branch mainline in revision 1907.
  • Revision ID: andrew@linuxjedi.co.uk-20101031215429-zn3p2uxeptkqojp5
Add global constraint on read buffer

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
#include "drizzled/internal/my_sys.h"
53
53
#include "drizzled/internal/m_string.h"
 
54
#include "drizzled/drizzled.h"
54
55
#ifdef HAVE_AIOWAIT
55
56
#include "drizzled/error.h"
56
57
#include "drizzled/internal/aio_result.h"
247
248
      if (cachesize < min_cache)
248
249
        cachesize = min_cache;
249
250
      buffer_block= cachesize;
 
251
      if ((type == READ_CACHE) and (not global_read_buffer.add(buffer_block)))
 
252
      {
 
253
        my_error(ER_OUT_OF_GLOBAL_READMEMORY, MYF(ME_ERROR+ME_WAITTANG));
 
254
        return 2;
 
255
      }
 
256
 
250
257
      if ((info->buffer=
251
258
           (unsigned char*) malloc(buffer_block)) != 0)
252
259
      {
255
262
        break;                                  /* Enough memory found */
256
263
      }
257
264
      if (cachesize == min_cache)
 
265
      {
 
266
        if (type == READ_CACHE)
 
267
          global_read_buffer.sub(buffer_block);
258
268
        return(2);                              /* Can't alloc cache */
 
269
      }
259
270
      /* Try with less memory */
 
271
      if (type == READ_CACHE)
 
272
        global_read_buffer.sub(buffer_block);
260
273
      cachesize= (cachesize*3/4 & ~(min_cache-1));
261
274
    }
262
275
  }
928
941
  }
929
942
  if (info->alloced_buffer)
930
943
  {
 
944
    if (info->type == READ_CACHE)
 
945
      global_read_buffer.sub(info->buffer_length);
931
946
    info->alloced_buffer=0;
932
947
    if (info->file != -1)                       /* File doesn't exist */
933
948
      error= my_b_flush_io_cache(info,1);