From 9cfdf2861a55c94a420380630d47e8ab8119cc82 Mon Sep 17 00:00:00 2001 From: "gbichot@production.mysql.com" <> Date: Mon, 4 Jul 2005 22:27:16 +0200 Subject: 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. --- mysys/my_copy.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'mysys/my_copy.c') 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 +#include /* for stat */ #include #if defined(HAVE_UTIME_H) #include @@ -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__) -- cgit v1.2.1