~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_iocache.c

Fixed the test programs linking issue. (I hope)
Made the plugin def use libmyisam.la instead of libmyisam.a so that we 
can take advantage of libtool convenience libs. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
 
148
148
int init_io_cache(IO_CACHE *info, File file, size_t cachesize,
149
149
                  enum cache_type type, my_off_t seek_offset,
150
 
                  bool use_async_io, myf cache_myflags)
 
150
                  pbool use_async_io, myf cache_myflags)
151
151
{
152
152
  size_t min_cache;
153
153
  my_off_t pos;
154
154
  my_off_t end_of_file= ~(my_off_t) 0;
 
155
  DBUG_ENTER("init_io_cache");
 
156
  DBUG_PRINT("enter",("cache: 0x%lx  type: %d  pos: %ld",
 
157
                      (ulong) info, (int) type, (ulong) seek_offset));
155
158
 
156
159
  info->file= file;
157
160
  info->type= TYPE_NOT_SET;         /* Don't set it until mutex are created */
177
180
        the beginning of whatever this file is, then somebody made a bad
178
181
        assumption.
179
182
      */
180
 
      assert(seek_offset == 0);
 
183
      DBUG_ASSERT(seek_offset == 0);
181
184
    }
182
185
    else
183
186
      info->seek_not_done= test(seek_offset != pos);
187
190
  info->share=0;
188
191
 
189
192
  if (!cachesize && !(cachesize= my_default_record_cache_size))
190
 
    return(1);                          /* No cache requested */
 
193
    DBUG_RETURN(1);                             /* No cache requested */
191
194
  min_cache=use_async_io ? IO_SIZE*4 : IO_SIZE*2;
192
195
  if (type == READ_CACHE || type == SEQ_READ_APPEND)
193
196
  {                                             /* Assume file isn't growing */
232
235
        break;                                  /* Enough memory found */
233
236
      }
234
237
      if (cachesize == min_cache)
235
 
        return(2);                              /* Can't alloc cache */
 
238
        DBUG_RETURN(2);                         /* Can't alloc cache */
236
239
      /* Try with less memory */
237
240
      cachesize= (cachesize*3/4 & ~(min_cache-1));
238
241
    }
239
242
  }
240
243
 
 
244
  DBUG_PRINT("info",("init_io_cache: cachesize = %lu", (ulong) cachesize));
241
245
  info->read_length=info->buffer_length=cachesize;
242
246
  info->myflags=cache_myflags & ~(MY_NABP | MY_FNABP);
243
247
  info->request_pos= info->read_pos= info->write_pos = info->buffer;
269
273
#ifdef HAVE_AIOWAIT
270
274
  if (use_async_io && ! my_disable_async_io)
271
275
  {
 
276
    DBUG_PRINT("info",("Using async io"));
272
277
    info->read_length/=2;
273
278
    info->read_function=_my_b_async_read;
274
279
  }
275
280
  info->inited=info->aio_result.pending=0;
276
281
#endif
277
 
  return(0);
 
282
  DBUG_RETURN(0);
278
283
}                                               /* init_io_cache */
279
284
 
280
285
        /* Wait until current request is ready */
291
296
      {
292
297
        if (errno == EINTR)
293
298
          continue;
 
299
        DBUG_PRINT("error",("No aio request, error: %d",errno));
294
300
        result->pending=0;                      /* Assume everythings is ok */
295
301
        break;
296
302
      }
311
317
  in the cache, we are reusing this memory without flushing it to disk.
312
318
*/
313
319
 
314
 
bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
 
320
my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
315
321
                        my_off_t seek_offset,
316
 
                        bool use_async_io __attribute__((unused)),
317
 
                        bool clear_cache)
 
322
                        pbool use_async_io __attribute__((unused)),
 
323
                        pbool clear_cache)
318
324
{
 
325
  DBUG_ENTER("reinit_io_cache");
 
326
  DBUG_PRINT("enter",("cache: 0x%lx type: %d  seek_offset: %lu  clear_cache: %d",
 
327
                      (ulong) info, type, (ulong) seek_offset,
 
328
                      (int) clear_cache));
 
329
 
319
330
  /* One can't do reinit with the following types */
320
 
  assert(type != READ_NET && info->type != READ_NET &&
 
331
  DBUG_ASSERT(type != READ_NET && info->type != READ_NET &&
321
332
              type != WRITE_NET && info->type != WRITE_NET &&
322
333
              type != SEQ_READ_APPEND && info->type != SEQ_READ_APPEND);
323
334
 
366
377
      info->end_of_file=my_b_tell(info);
367
378
    /* flush cache if we want to reuse it */
368
379
    if (!clear_cache && my_b_flush_io_cache(info,1))
369
 
      return(1);
 
380
      DBUG_RETURN(1);
370
381
    info->pos_in_file=seek_offset;
371
382
    /* Better to do always do a seek */
372
383
    info->seek_not_done=1;
396
407
  }
397
408
  info->inited=0;
398
409
#endif
399
 
  return(0);
 
410
  DBUG_RETURN(0);
400
411
} /* reinit_io_cache */
401
412
 
402
413
 
433
444
{
434
445
  size_t length,diff_length,left_length, max_length;
435
446
  my_off_t pos_in_file;
 
447
  DBUG_ENTER("_my_b_read");
436
448
 
437
449
  if ((left_length= (size_t) (info->read_end-info->read_pos)))
438
450
  {
439
 
    assert(Count >= left_length);       /* User is not using my_b_read() */
 
451
    DBUG_ASSERT(Count >= left_length);  /* User is not using my_b_read() */
440
452
    memcpy(Buffer,info->read_pos, left_length);
441
453
    Buffer+=left_length;
442
454
    Count-=left_length;
466
478
        info->file is a pipe or socket or FIFO.  We never should have tried
467
479
        to seek on that.  See Bugs#25807 and #22828 for more info.
468
480
      */
469
 
      assert(my_errno != ESPIPE);
 
481
      DBUG_ASSERT(my_errno != ESPIPE);
470
482
      info->error= -1;
471
 
      return(1);
 
483
      DBUG_RETURN(1);
472
484
    }
473
485
  }
474
486
 
479
491
    if (info->end_of_file <= pos_in_file)
480
492
    {                                   /* End of file */
481
493
      info->error= (int) left_length;
482
 
      return(1);
 
494
      DBUG_RETURN(1);
483
495
    }
484
496
    length=(Count & (size_t) ~(IO_SIZE-1))-diff_length;
485
497
    if ((read_length= my_read(info->file,Buffer, length, info->myflags))
487
499
    {
488
500
      info->error= (read_length == (size_t) -1 ? -1 :
489
501
                    (int) (read_length+left_length));
490
 
      return(1);
 
502
      DBUG_RETURN(1);
491
503
    }
492
504
    Count-=length;
493
505
    Buffer+=length;
505
517
    if (Count)
506
518
    {
507
519
      info->error= left_length;         /* We only got this many char */
508
 
      return(1);
 
520
      DBUG_RETURN(1);
509
521
    }
510
522
    length=0;                           /* Didn't read any chars */
511
523
  }
518
530
    info->pos_in_file= pos_in_file;
519
531
    info->error= length == (size_t) -1 ? -1 : (int) (length+left_length);
520
532
    info->read_pos=info->read_end=info->buffer;
521
 
    return(1);
 
533
    DBUG_RETURN(1);
522
534
  }
523
535
  info->read_pos=info->buffer+Count;
524
536
  info->read_end=info->buffer+length;
525
537
  info->pos_in_file=pos_in_file;
526
538
  memcpy(Buffer, info->buffer, Count);
527
 
  return(0);
 
539
  DBUG_RETURN(0);
528
540
}
529
541
 
530
542
 
599
611
void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare,
600
612
                         IO_CACHE *write_cache, uint num_threads)
601
613
{
602
 
  assert(num_threads > 1);
603
 
  assert(read_cache->type == READ_CACHE);
604
 
  assert(!write_cache || (write_cache->type == WRITE_CACHE));
 
614
  DBUG_ENTER("init_io_cache_share");
 
615
  DBUG_PRINT("io_cache_share", ("read_cache: 0x%lx  share: 0x%lx  "
 
616
                                "write_cache: 0x%lx  threads: %u",
 
617
                                (long) read_cache, (long) cshare,
 
618
                                (long) write_cache, num_threads));
 
619
 
 
620
  DBUG_ASSERT(num_threads > 1);
 
621
  DBUG_ASSERT(read_cache->type == READ_CACHE);
 
622
  DBUG_ASSERT(!write_cache || (write_cache->type == WRITE_CACHE));
605
623
 
606
624
  pthread_mutex_init(&cshare->mutex, MY_MUTEX_INIT_FAST);
607
625
  pthread_cond_init(&cshare->cond, 0);
623
641
  if (write_cache)
624
642
    write_cache->share= cshare;
625
643
 
626
 
  return;
 
644
  DBUG_VOID_RETURN;
627
645
}
628
646
 
629
647
 
650
668
{
651
669
  IO_CACHE_SHARE *cshare= cache->share;
652
670
  uint total;
 
671
  DBUG_ENTER("remove_io_thread");
653
672
 
654
673
  /* If the writer goes, it needs to flush the write cache. */
655
674
  if (cache == cshare->source_cache)
656
675
    flush_io_cache(cache);
657
676
 
658
677
  pthread_mutex_lock(&cshare->mutex);
 
678
  DBUG_PRINT("io_cache_share", ("%s: 0x%lx",
 
679
                                (cache == cshare->source_cache) ?
 
680
                                "writer" : "reader", (long) cache));
659
681
 
660
682
  /* Remove from share. */
661
683
  total= --cshare->total_threads;
 
684
  DBUG_PRINT("io_cache_share", ("remaining threads: %u", total));
662
685
 
663
686
  /* Detach from share. */
664
687
  cache->share= NULL;
666
689
  /* If the writer goes, let the readers know. */
667
690
  if (cache == cshare->source_cache)
668
691
  {
 
692
    DBUG_PRINT("io_cache_share", ("writer leaves"));
669
693
    cshare->source_cache= NULL;
670
694
  }
671
695
 
672
696
  /* If all threads are waiting for me to join the lock, wake them. */
673
697
  if (!--cshare->running_threads)
674
698
  {
 
699
    DBUG_PRINT("io_cache_share", ("the last running thread leaves, wake all"));
675
700
    pthread_cond_signal(&cshare->cond_writer);
676
701
    pthread_cond_broadcast(&cshare->cond);
677
702
  }
680
705
 
681
706
  if (!total)
682
707
  {
 
708
    DBUG_PRINT("io_cache_share", ("last thread removed, destroy share"));
683
709
    pthread_cond_destroy (&cshare->cond_writer);
684
710
    pthread_cond_destroy (&cshare->cond);
685
711
    pthread_mutex_destroy(&cshare->mutex);
686
712
  }
687
713
 
688
 
  return;
 
714
  DBUG_VOID_RETURN;
689
715
}
690
716
 
691
717
 
720
746
static int lock_io_cache(IO_CACHE *cache, my_off_t pos)
721
747
{
722
748
  IO_CACHE_SHARE *cshare= cache->share;
 
749
  DBUG_ENTER("lock_io_cache");
723
750
 
724
751
  /* Enter the lock. */
725
752
  pthread_mutex_lock(&cshare->mutex);
726
753
  cshare->running_threads--;
 
754
  DBUG_PRINT("io_cache_share", ("%s: 0x%lx  pos: %lu  running: %u",
 
755
                                (cache == cshare->source_cache) ?
 
756
                                "writer" : "reader", (long) cache, (ulong) pos,
 
757
                                cshare->running_threads));
727
758
 
728
759
  if (cshare->source_cache)
729
760
  {
734
765
      /* The writer waits until all readers are here. */
735
766
      while (cshare->running_threads)
736
767
      {
 
768
        DBUG_PRINT("io_cache_share", ("writer waits in lock"));
737
769
        pthread_cond_wait(&cshare->cond_writer, &cshare->mutex);
738
770
      }
 
771
      DBUG_PRINT("io_cache_share", ("writer awoke, going to copy"));
 
772
 
739
773
      /* Stay locked. Leave the lock later by unlock_io_cache(). */
740
 
      return(1);
 
774
      DBUG_RETURN(1);
741
775
    }
742
776
 
743
777
    /* The last thread wakes the writer. */
744
778
    if (!cshare->running_threads)
745
779
    {
 
780
      DBUG_PRINT("io_cache_share", ("waking writer"));
746
781
      pthread_cond_signal(&cshare->cond_writer);
747
782
    }
748
783
 
754
789
    while ((!cshare->read_end || (cshare->pos_in_file < pos)) &&
755
790
           cshare->source_cache)
756
791
    {
 
792
      DBUG_PRINT("io_cache_share", ("reader waits in lock"));
757
793
      pthread_cond_wait(&cshare->cond, &cshare->mutex);
758
794
    }
759
795
 
767
803
    */
768
804
    if (!cshare->read_end || (cshare->pos_in_file < pos))
769
805
    {
 
806
      DBUG_PRINT("io_cache_share", ("reader found writer removed. EOF"));
770
807
      cshare->read_end= cshare->buffer; /* Empty buffer. */
771
808
      cshare->error= 0; /* EOF is not an error. */
772
809
    }
779
816
    */
780
817
    if (!cshare->running_threads)
781
818
    {
 
819
      DBUG_PRINT("io_cache_share", ("last thread joined, going to read"));
782
820
      /* Stay locked. Leave the lock later by unlock_io_cache(). */
783
 
      return(1);
 
821
      DBUG_RETURN(1);
784
822
    }
785
823
 
786
824
    /*
793
831
    while ((!cshare->read_end || (cshare->pos_in_file < pos)) &&
794
832
           cshare->running_threads)
795
833
    {
 
834
      DBUG_PRINT("io_cache_share", ("reader waits in lock"));
796
835
      pthread_cond_wait(&cshare->cond, &cshare->mutex);
797
836
    }
798
837
 
799
838
    /* If the block is not yet read, continue with a locked cache and read. */
800
839
    if (!cshare->read_end || (cshare->pos_in_file < pos))
801
840
    {
 
841
      DBUG_PRINT("io_cache_share", ("reader awoke, going to read"));
802
842
      /* Stay locked. Leave the lock later by unlock_io_cache(). */
803
 
      return(1);
 
843
      DBUG_RETURN(1);
804
844
    }
805
845
 
806
846
    /* Another thread did read the block already. */
807
847
  }
 
848
  DBUG_PRINT("io_cache_share", ("reader awoke, going to process %u bytes",
 
849
                                (uint) (cshare->read_end ? (size_t)
 
850
                                        (cshare->read_end - cshare->buffer) :
 
851
                                        0)));
808
852
 
809
853
  /*
810
854
    Leave the lock. Do not call unlock_io_cache() later. The thread that
811
855
    filled the buffer did this and marked all threads as running.
812
856
  */
813
857
  pthread_mutex_unlock(&cshare->mutex);
814
 
  return(0);
 
858
  DBUG_RETURN(0);
815
859
}
816
860
 
817
861
 
845
889
static void unlock_io_cache(IO_CACHE *cache)
846
890
{
847
891
  IO_CACHE_SHARE *cshare= cache->share;
 
892
  DBUG_ENTER("unlock_io_cache");
 
893
  DBUG_PRINT("io_cache_share", ("%s: 0x%lx  pos: %lu  running: %u",
 
894
                                (cache == cshare->source_cache) ?
 
895
                                "writer" : "reader",
 
896
                                (long) cache, (ulong) cshare->pos_in_file,
 
897
                                cshare->total_threads));
848
898
 
849
899
  cshare->running_threads= cshare->total_threads;
850
900
  pthread_cond_broadcast(&cshare->cond);
851
901
  pthread_mutex_unlock(&cshare->mutex);
852
 
  return;
 
902
  DBUG_VOID_RETURN;
853
903
}
854
904
 
855
905
 
895
945
  my_off_t pos_in_file;
896
946
  size_t length, diff_length, left_length;
897
947
  IO_CACHE_SHARE *cshare= cache->share;
 
948
  DBUG_ENTER("_my_b_read_r");
898
949
 
899
950
  if ((left_length= (size_t) (cache->read_end - cache->read_pos)))
900
951
  {
901
 
    assert(Count >= left_length);       /* User is not using my_b_read() */
 
952
    DBUG_ASSERT(Count >= left_length);  /* User is not using my_b_read() */
902
953
    memcpy(Buffer, cache->read_pos, left_length);
903
954
    Buffer+= left_length;
904
955
    Count-= left_length;
919
970
    if (length == 0)
920
971
    {
921
972
      cache->error= (int) left_length;
922
 
      return(1);
 
973
      DBUG_RETURN(1);
923
974
    }
924
975
    if (lock_io_cache(cache, pos_in_file))
925
976
    {
926
977
      /* With a synchronized write/read cache we won't come here... */
927
 
      assert(!cshare->source_cache);
 
978
      DBUG_ASSERT(!cshare->source_cache);
928
979
      /*
929
980
        ... unless the writer has gone before this thread entered the
930
981
        lock. Simulate EOF in this case. It can be distinguished by
947
998
          {
948
999
            cache->error= -1;
949
1000
            unlock_io_cache(cache);
950
 
            return(1);
 
1001
            DBUG_RETURN(1);
951
1002
          }
952
1003
        }
953
1004
        len= my_read(cache->file, cache->buffer, length, cache->myflags);
954
1005
      }
 
1006
      DBUG_PRINT("io_cache_share", ("read %lu bytes", (ulong) len));
 
1007
 
955
1008
      cache->read_end=    cache->buffer + (len == (size_t) -1 ? 0 : len);
956
1009
      cache->error=       (len == length ? 0 : (int) len);
957
1010
      cache->pos_in_file= pos_in_file;
981
1034
    cache->seek_not_done= 0;
982
1035
    if (len == 0 || len == (size_t) -1)
983
1036
    {
 
1037
      DBUG_PRINT("io_cache_share", ("reader error. len %lu  left %lu",
 
1038
                                    (ulong) len, (ulong) left_length));
984
1039
      cache->error= (int) left_length;
985
 
      return(1);
 
1040
      DBUG_RETURN(1);
986
1041
    }
987
1042
    cnt= (len > Count) ? Count : len;
988
1043
    memcpy(Buffer, cache->read_pos, cnt);
991
1046
    left_length+= cnt;
992
1047
    cache->read_pos+= cnt;
993
1048
  }
994
 
  return(0);
 
1049
  DBUG_RETURN(0);
995
1050
}
996
1051
 
997
1052
 
1017
1072
{
1018
1073
  IO_CACHE_SHARE *cshare= write_cache->share;
1019
1074
 
1020
 
  assert(cshare->source_cache == write_cache);
 
1075
  DBUG_ASSERT(cshare->source_cache == write_cache);
1021
1076
  /*
1022
1077
    write_length is usually less or equal to buffer_length.
1023
1078
    It can be bigger if _my_b_write() is called with a big length.
1029
1084
 
1030
1085
    rc= lock_io_cache(write_cache, write_cache->pos_in_file);
1031
1086
    /* The writing thread does always have the lock when it awakes. */
1032
 
    assert(rc);
 
1087
    DBUG_ASSERT(rc);
1033
1088
 
1034
1089
    memcpy(cshare->buffer, write_buffer, copy_length);
1035
1090
 
1068
1123
  /* first, read the regular buffer */
1069
1124
  if ((left_length=(size_t) (info->read_end-info->read_pos)))
1070
1125
  {
1071
 
    assert(Count > left_length);        /* User is not using my_b_read() */
 
1126
    DBUG_ASSERT(Count > left_length);   /* User is not using my_b_read() */
1072
1127
    memcpy(Buffer,info->read_pos, left_length);
1073
1128
    Buffer+=left_length;
1074
1129
    Count-=left_length;
1150
1205
 
1151
1206
      /*
1152
1207
         added the line below to make
1153
 
         assert(pos_in_file==info->end_of_file) pass.
 
1208
         DBUG_ASSERT(pos_in_file==info->end_of_file) pass.
1154
1209
         otherwise this does not appear to be needed
1155
1210
      */
1156
1211
      pos_in_file += length;
1177
1232
    size_t copy_len;
1178
1233
    size_t transfer_len;
1179
1234
 
1180
 
    assert(info->append_read_pos <= info->write_pos);
 
1235
    DBUG_ASSERT(info->append_read_pos <= info->write_pos);
1181
1236
    /*
1182
1237
      TODO: figure out if the assert below is needed or correct.
1183
1238
    */
1184
 
    assert(pos_in_file == info->end_of_file);
 
1239
    DBUG_ASSERT(pos_in_file == info->end_of_file);
1185
1240
    copy_len=min(Count, len_in_buff);
1186
1241
    memcpy(Buffer, info->append_read_pos, copy_len);
1187
1242
    info->append_read_pos += copy_len;
1283
1338
        read_length-=offset;                    /* Bytes left from read_pos */
1284
1339
      }
1285
1340
    }
 
1341
#ifndef DBUG_OFF
 
1342
    if (info->aio_read_pos > info->pos_in_file)
 
1343
    {
 
1344
      my_errno=EINVAL;
 
1345
      return(info->read_length= (size_t) -1);
 
1346
    }
 
1347
#endif
1286
1348
        /* Copy found bytes to buffer */
1287
1349
    length=min(Count,read_length);
1288
1350
    memcpy(Buffer,info->read_pos,(size_t) length);
1361
1423
  if (max_length)
1362
1424
  {
1363
1425
    info->aio_result.result.aio_errno=AIO_INPROGRESS;   /* Marker for test */
 
1426
    DBUG_PRINT("aioread",("filepos: %ld  length: %lu",
 
1427
                          (ulong) next_pos_in_file, (ulong) max_length));
1364
1428
    if (aioread(info->file,read_buffer, max_length,
1365
1429
                (my_off_t) next_pos_in_file,MY_SEEK_SET,
1366
1430
                &info->aio_result.result))
1367
1431
    {                                           /* Skip async io */
1368
1432
      my_errno=errno;
 
1433
      DBUG_PRINT("error",("got error: %d, aio_result: %d from aioread, async skipped",
 
1434
                          errno, info->aio_result.result.aio_errno));
1369
1435
      if (info->request_pos != info->buffer)
1370
1436
      {
1371
1437
        bmove(info->buffer,info->request_pos,
1487
1553
    Assert that we cannot come here with a shared cache. If we do one
1488
1554
    day, we might need to add a call to copy_to_read_buffer().
1489
1555
  */
1490
 
  assert(!info->share);
 
1556
  DBUG_ASSERT(!info->share);
1491
1557
 
1492
1558
  lock_append_buffer(info);
1493
1559
  rest_length= (size_t) (info->write_end - info->write_pos);
1553
1619
    Assert that we cannot come here with a shared cache. If we do one
1554
1620
    day, we might need to add a call to copy_to_read_buffer().
1555
1621
  */
1556
 
  assert(!info->share);
 
1622
  DBUG_ASSERT(!info->share);
1557
1623
 
1558
1624
  if (pos < info->pos_in_file)
1559
1625
  {
1606
1672
int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
1607
1673
{
1608
1674
  size_t length;
1609
 
  bool append_cache;
 
1675
  my_bool append_cache;
1610
1676
  my_off_t pos_in_file;
 
1677
  DBUG_ENTER("my_b_flush_io_cache");
 
1678
  DBUG_PRINT("enter", ("cache: 0x%lx", (long) info));
1611
1679
 
1612
1680
  if (!(append_cache = (info->type == SEQ_READ_APPEND)))
1613
1681
    need_append_buffer_lock=0;
1617
1685
    if (info->file == -1)
1618
1686
    {
1619
1687
      if (real_open_cached_file(info))
1620
 
        return((info->error= -1));
 
1688
        DBUG_RETURN((info->error= -1));
1621
1689
    }
1622
1690
    LOCK_APPEND_BUFFER;
1623
1691
 
1643
1711
            MY_FILEPOS_ERROR)
1644
1712
        {
1645
1713
          UNLOCK_APPEND_BUFFER;
1646
 
          return((info->error= -1));
 
1714
          DBUG_RETURN((info->error= -1));
1647
1715
        }
1648
1716
        if (!append_cache)
1649
1717
          info->seek_not_done=0;
1665
1733
      else
1666
1734
      {
1667
1735
        info->end_of_file+=(info->write_pos-info->append_read_pos);
1668
 
        assert(info->end_of_file == my_tell(info->file,MYF(0)));
 
1736
        DBUG_ASSERT(info->end_of_file == my_tell(info->file,MYF(0)));
1669
1737
      }
1670
1738
 
1671
1739
      info->append_read_pos=info->write_pos=info->write_buffer;
1672
1740
      ++info->disk_writes;
1673
1741
      UNLOCK_APPEND_BUFFER;
1674
 
      return(info->error);
 
1742
      DBUG_RETURN(info->error);
1675
1743
    }
1676
1744
  }
1677
1745
#ifdef HAVE_AIOWAIT
1682
1750
  }
1683
1751
#endif
1684
1752
  UNLOCK_APPEND_BUFFER;
1685
 
  return(0);
 
1753
  DBUG_RETURN(0);
1686
1754
}
1687
1755
 
1688
1756
/*
1706
1774
{
1707
1775
  int error=0;
1708
1776
  IO_CACHE_CALLBACK pre_close;
 
1777
  DBUG_ENTER("end_io_cache");
 
1778
  DBUG_PRINT("enter",("cache: 0x%lx", (ulong) info));
1709
1779
 
1710
1780
  /*
1711
1781
    Every thread must call remove_io_thread(). The last one destroys
1712
1782
    the share elements.
1713
1783
  */
1714
 
  assert(!info->share || !info->share->total_threads);
 
1784
  DBUG_ASSERT(!info->share || !info->share->total_threads);
1715
1785
 
1716
1786
  if ((pre_close=info->pre_close))
1717
1787
  {
1732
1802
    info->type= TYPE_NOT_SET;
1733
1803
    pthread_mutex_destroy(&info->append_buffer_lock);
1734
1804
  }
1735
 
  return(error);
 
1805
  DBUG_RETURN(error);
1736
1806
} /* end_io_cache */
1737
1807
 
1738
1808