summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorsasha@mysql.sashanet.com <>2002-01-26 22:26:24 -0700
committersasha@mysql.sashanet.com <>2002-01-26 22:26:24 -0700
commit7275dcef35d14ff5f82f3520fe6e6e0766bc13b5 (patch)
tree7805cfd6c7eb661c4f3022b7fc37478a0908a190 /mysys
parent40fcae6d4b7c02e6cd18b98d8d3b8c525e51aeae (diff)
downloadmariadb-git-7275dcef35d14ff5f82f3520fe6e6e0766bc13b5.tar.gz
misc replication bugfixes including some needed modifications in IO_CACHE
likely() and unlikely() branch prediction compiler hint macros clean-up of comments
Diffstat (limited to 'mysys')
-rw-r--r--mysys/mf_iocache.c29
-rw-r--r--mysys/mf_iocache2.c24
2 files changed, 42 insertions, 11 deletions
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 34de5dfd7f3..6095cc23716 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -542,7 +542,7 @@ read_append_buffer:
DBUG_ASSERT(info->append_read_pos <= info->write_pos);
/*
- TODO: figure out if the below assert is needed or correct.
+ TODO: figure out if the assert below is needed or correct.
*/
DBUG_ASSERT(pos_in_file == info->end_of_file);
copy_len=min(Count, len_in_buff);
@@ -889,6 +889,17 @@ int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count,
/* Flush write cache */
+#ifdef THREAD
+#define LOCK_APPEND_BUFFER if (need_append_buffer_lock) \
+ lock_append_buffer(info);
+#define UNLOCK_APPEND_BUFFER if (need_append_buffer_lock) \
+ unlock_append_buffer(info);
+#else
+#define LOCK_APPEND_BUFFER
+#define UNLOCK_APPEND_BUFFER
+#endif
+
+
int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
{
uint length;
@@ -906,8 +917,8 @@ int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
if (real_open_cached_file(info))
DBUG_RETURN((info->error= -1));
}
- if (need_append_buffer_lock)
- lock_append_buffer(info);
+ LOCK_APPEND_BUFFER;
+
if ((length=(uint) (info->write_pos - info->write_buffer)))
{
pos_in_file=info->pos_in_file;
@@ -919,8 +930,7 @@ int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
if (my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0)) ==
MY_FILEPOS_ERROR)
{
- if (need_append_buffer_lock)
- unlock_append_buffer(info);
+ UNLOCK_APPEND_BUFFER;
DBUG_RETURN((info->error= -1));
}
if (!append_cache)
@@ -941,11 +951,13 @@ int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
set_if_bigger(info->end_of_file,(pos_in_file+length));
}
else
+ {
info->end_of_file+=(info->write_pos-info->append_read_pos);
+ DBUG_ASSERT(info->end_of_file == my_tell(info->file,MYF(0)));
+ }
info->append_read_pos=info->write_pos=info->write_buffer;
- if (need_append_buffer_lock)
- unlock_append_buffer(info);
+ UNLOCK_APPEND_BUFFER;
DBUG_RETURN(info->error);
}
}
@@ -956,8 +968,7 @@ int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
info->inited=0;
}
#endif
- if (need_append_buffer_lock)
- unlock_append_buffer(info);
+ UNLOCK_APPEND_BUFFER;
DBUG_RETURN(0);
}
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c
index ca9c9938cd2..a343829d32e 100644
--- a/mysys/mf_iocache2.c
+++ b/mysys/mf_iocache2.c
@@ -23,10 +23,30 @@
#include <m_string.h>
#include <stdarg.h>
#include <m_ctype.h>
+#include <assert.h>
+
+my_off_t my_b_append_tell(IO_CACHE* info)
+{
+ my_off_t res;
+/* we need to lock the append buffer mutex to keep flush_io_cache()
+ from messing with the variables that we need in order to provide the
+ answer to the question.
+*/
+#ifdef THREAD
+ pthread_mutex_lock(&info->append_buffer_lock);
+#endif
+ DBUG_ASSERT(info->end_of_file - (info->append_read_pos-info->write_buffer)
+ == my_tell(info->file,MYF(0)));
+ res = info->end_of_file + (info->write_pos-info->append_read_pos);
+#ifdef THREAD
+ pthread_mutex_unlock(&info->append_buffer_lock);
+#endif
+ return res;
+}
/*
- Fix that next read will be made at certain position
- For write cache, make next write happen at a certain position
+ Make next read happen at the given position
+ For write cache, make next write happen at the given position
*/
void my_b_seek(IO_CACHE *info,my_off_t pos)