~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_iocache.c

  • Committer: Monty Taylor
  • Date: 2008-07-02 14:35:48 UTC
  • mto: This revision was merged to the branch mainline in revision 51.
  • Revision ID: monty@inaugust.com-20080702143548-onj30ry0sugr01uw
Removed all references to THREAD.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
#endif
57
57
#include <errno.h>
58
58
 
59
 
#ifdef THREAD
60
59
#define lock_append_buffer(info) \
61
60
 pthread_mutex_lock(&(info)->append_buffer_lock)
62
61
#define unlock_append_buffer(info) \
63
62
 pthread_mutex_unlock(&(info)->append_buffer_lock)
64
 
#else
65
 
#define lock_append_buffer(info)
66
 
#define unlock_append_buffer(info)
67
 
#endif
68
63
 
69
64
#define IO_ROUND_UP(X) (((X)+IO_SIZE-1) & ~(IO_SIZE-1))
70
65
#define IO_ROUND_DN(X) ( (X)            & ~(IO_SIZE-1))
118
113
    break;
119
114
  default:
120
115
    info->read_function =
121
 
#ifdef THREAD
122
116
                          info->share ? _my_b_read_r :
123
 
#endif
124
117
                                        _my_b_read;
125
118
    info->write_function = _my_b_write;
126
119
  }
194
187
  }
195
188
 
196
189
  info->disk_writes= 0;
197
 
#ifdef THREAD
198
190
  info->share=0;
199
 
#endif
200
191
 
201
192
  if (!cachesize && !(cachesize= my_default_record_cache_size))
202
193
    DBUG_RETURN(1);                             /* No cache requested */
258
249
  {
259
250
    info->append_read_pos = info->write_pos = info->write_buffer;
260
251
    info->write_end = info->write_buffer + info->buffer_length;
261
 
#ifdef THREAD
262
252
    pthread_mutex_init(&info->append_buffer_lock,MY_MUTEX_INIT_FAST);
263
 
#endif
264
253
  }
265
 
#if defined(SAFE_MUTEX) && defined(THREAD)
 
254
#if defined(SAFE_MUTEX)
266
255
  else
267
256
  {
268
257
    /* Clear mutex so that safe_mutex will notice that it's not initialized */
551
540
}
552
541
 
553
542
 
554
 
#ifdef THREAD
555
543
/*
556
544
  Prepare IO_CACHE for shared use.
557
545
 
1111
1099
    write_length-= copy_length;
1112
1100
  }
1113
1101
}
1114
 
#endif /*THREAD*/
1115
1102
 
1116
1103
 
1117
1104
/*
1528
1515
    if (my_write(info->file, Buffer, length, info->myflags | MY_NABP))
1529
1516
      return info->error= -1;
1530
1517
 
1531
 
#ifdef THREAD
1532
1518
    /*
1533
1519
      In case of a shared I/O cache with a writer we normally do direct
1534
1520
      write cache to read cache copy. Simulate this here by direct
1542
1528
    */
1543
1529
    if (info->share)
1544
1530
      copy_to_read_buffer(info, Buffer, length);
1545
 
#endif
1546
1531
 
1547
1532
    Count-=length;
1548
1533
    Buffer+=length;
1564
1549
{
1565
1550
  size_t rest_length,length;
1566
1551
 
1567
 
#ifdef THREAD
1568
1552
  /*
1569
1553
    Assert that we cannot come here with a shared cache. If we do one
1570
1554
    day, we might need to add a call to copy_to_read_buffer().
1571
1555
  */
1572
1556
  DBUG_ASSERT(!info->share);
1573
 
#endif
1574
1557
 
1575
1558
  lock_append_buffer(info);
1576
1559
  rest_length= (size_t) (info->write_end - info->write_pos);
1632
1615
  size_t length;
1633
1616
  int error=0;
1634
1617
 
1635
 
#ifdef THREAD
1636
1618
  /*
1637
1619
    Assert that we cannot come here with a shared cache. If we do one
1638
1620
    day, we might need to add a call to copy_to_read_buffer().
1639
1621
  */
1640
1622
  DBUG_ASSERT(!info->share);
1641
 
#endif
1642
1623
 
1643
1624
  if (pos < info->pos_in_file)
1644
1625
  {
1683
1664
 
1684
1665
        /* Flush write cache */
1685
1666
 
1686
 
#ifdef THREAD
1687
1667
#define LOCK_APPEND_BUFFER if (need_append_buffer_lock) \
1688
1668
  lock_append_buffer(info);
1689
1669
#define UNLOCK_APPEND_BUFFER if (need_append_buffer_lock) \
1690
1670
  unlock_append_buffer(info);
1691
 
#else
1692
 
#define LOCK_APPEND_BUFFER
1693
 
#define UNLOCK_APPEND_BUFFER
1694
 
#endif
1695
 
 
1696
1671
 
1697
1672
int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
1698
1673
{
1716
1691
 
1717
1692
    if ((length=(size_t) (info->write_pos - info->write_buffer)))
1718
1693
    {
1719
 
#ifdef THREAD
1720
1694
      /*
1721
1695
        In case of a shared I/O cache with a writer we do direct write
1722
1696
        cache to read cache copy. Do it before the write here so that
1725
1699
      */
1726
1700
      if (info->share)
1727
1701
        copy_to_read_buffer(info, info->write_buffer, length);
1728
 
#endif
1729
1702
 
1730
1703
      pos_in_file=info->pos_in_file;
1731
1704
      /*
1804
1777
  DBUG_ENTER("end_io_cache");
1805
1778
  DBUG_PRINT("enter",("cache: 0x%lx", (ulong) info));
1806
1779
 
1807
 
#ifdef THREAD
1808
1780
  /*
1809
1781
    Every thread must call remove_io_thread(). The last one destroys
1810
1782
    the share elements.
1811
1783
  */
1812
1784
  DBUG_ASSERT(!info->share || !info->share->total_threads);
1813
 
#endif
1814
1785
 
1815
1786
  if ((pre_close=info->pre_close))
1816
1787
  {
1829
1800
  {
1830
1801
    /* Destroy allocated mutex */
1831
1802
    info->type= TYPE_NOT_SET;
1832
 
#ifdef THREAD
1833
1803
    pthread_mutex_destroy(&info->append_buffer_lock);
1834
 
#endif
1835
1804
  }
1836
1805
  DBUG_RETURN(error);
1837
1806
} /* end_io_cache */