summaryrefslogtreecommitdiff
path: root/mysys/my_copy.c
diff options
context:
space:
mode:
authorunknown <gbichot@production.mysql.com>2005-07-04 22:27:16 +0200
committerunknown <gbichot@production.mysql.com>2005-07-04 22:27:16 +0200
commit1a260574283bbd510745e15862e5f02f7cde14b9 (patch)
treebaf0c231ae2622de89fc8f58bf7dbb40271dadc6 /mysys/my_copy.c
parentba50dc04d2b8726484c459a50127487273166189 (diff)
downloadmariadb-git-1a260574283bbd510745e15862e5f02f7cde14b9.tar.gz
Making rpl_until more robust if machine is slow. Removing rpl_trunc_binlog
which is wrong now that slave recovers gracefully from a crashed binlog (thx Serg). stat -> my_stat in my_copy.c so that failing stat() does not hang client connection. BitKeeper/deleted/.del-rpl_trunc_binlog.test~961b1f6ac73d37c8: Delete: mysql-test/t/rpl_trunc_binlog.test BitKeeper/deleted/.del-rpl_trunc_binlog.result~14b4a61886a332e8: Delete: mysql-test/r/rpl_trunc_binlog.result mysql-test/std_data/trunc_binlog.000001: Rename: BitKeeper/deleted/.del-trunc_binlog.000001~b504d840c7efde25 -> mysql-test/std_data/trunc_binlog.000001 mysql-test/t/rpl_until.test: making test more robust if machine is slow. We still need to sleep before testing if slave SQL thread stopped, because otherwise it may not have started yet when we test for stop, then we would return too early. When we have "START SLAVE" wait a few secs until slave threads actually started well (WL#2688) these "sleep 2" could be removed. mysys/my_copy.c: Using my_stat() instead of stat(). Reason is that my_stat() reports an error message if wanted (MY_WME), which is critical for an error being sent to the client. Before this patch, a failing stat() caused the client connection to hang (because error was not set because my_error was never called). Adding an assertion to match the comment at the start of the function.
Diffstat (limited to 'mysys/my_copy.c')
-rw-r--r--mysys/my_copy.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index 03f3feb54d3..072492172e3 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -16,7 +16,7 @@
#define USES_TYPES /* sys/types is included */
#include "mysys_priv.h"
-#include <sys/stat.h>
+#include <my_dir.h> /* for stat */
#include <m_string.h>
#if defined(HAVE_UTIME_H)
#include <utime.h>
@@ -53,26 +53,28 @@ struct utimbuf {
int my_copy(const char *from, const char *to, myf MyFlags)
{
uint Count;
- int new_file_stat, create_flag;
+ my_bool new_file_stat; /* 1 if we could stat "to" */
+ int create_flag;
File from_file,to_file;
char buff[IO_SIZE];
- struct stat stat_buff,new_stat_buff;
+ MY_STAT stat_buff,new_stat_buff;
DBUG_ENTER("my_copy");
DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags));
from_file=to_file= -1;
- new_file_stat=0;
+ LINT_INIT(new_file_stat);
+ DBUG_ASSERT(!(MyFlags & (MY_FNABP | MY_NABP))); /* for my_read/my_write */
if (MyFlags & MY_HOLD_ORIGINAL_MODES) /* Copy stat if possible */
- new_file_stat=stat((char*) to, &new_stat_buff);
+ new_file_stat= test(my_stat((char*) to, &new_stat_buff, MYF(0)));
if ((from_file=my_open(from,O_RDONLY | O_SHARE,MyFlags)) >= 0)
{
- if (stat(from,&stat_buff))
+ if (!my_stat(from, &stat_buff, MyFlags))
{
my_errno=errno;
goto err;
}
- if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
+ if (MyFlags & MY_HOLD_ORIGINAL_MODES && new_file_stat)
stat_buff=new_stat_buff;
create_flag= (MyFlags & MY_DONT_OVERWRITE_FILE) ? O_EXCL : O_TRUNC;
@@ -91,7 +93,7 @@ int my_copy(const char *from, const char *to, myf MyFlags)
/* Copy modes if possible */
- if (MyFlags & MY_HOLD_ORIGINAL_MODES && new_file_stat)
+ if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
DBUG_RETURN(0); /* File copyed but not stat */
VOID(chmod(to, stat_buff.st_mode & 07777)); /* Copy modes */
#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) && !defined(__NETWARE__)