List:Commits« Previous MessageNext Message »
From:Alex Ivanov Notebook Date:June 28 2006 6:21am
Subject:bk commit into 5.0 tree (aivanov:1.2191) BUG#19208
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of alexi. When alexi does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2191 06/06/28 10:21:01 aivanov@stripped +4 -0
  Fixing BUG#17719 "Delete of binlog files fails on Windows"
   and BUG#19208 "Test 'rpl000017' hangs on Windows".
   Both bugs are caused by attempting to delete an opened
   file and to create immediatedly a new one with the same
   name. On Windows it can be supported only on NT-platforms
   (by using FILE_SHARE_DELETE mode and with renaming the
   file before deletion). Because deleting not-closed files
   is not supported on all platforms (e.g. Win 98|ME) this
   is to be considered harmful and should be eliminated by
   a "code redesign".

  sql/log.cc
    1.189 06/06/28 10:20:56 aivanov@stripped +2 -2
    MYSQL_LOG::reset_logs(): Deleting usually not
     closed binlog files.

  mysys/my_delete.c
    1.6 06/06/28 10:20:56 aivanov@stripped +51 -0
    Adding nt_share_delete() function implementing
     a (possibly) not closed file deletion on Windows NT.

  include/my_sys.h
    1.181 06/06/28 10:20:56 aivanov@stripped +8 -0
    Adding my_delete_allow_opened to be invoked to delete
     a (possibly) not closed file on Windows NT-platforms.

  VC++Files/mysys/mysys.vcproj
    1.5 06/06/28 10:20:56 aivanov@stripped +5 -5
    To be sure that __NT__ is defined for Win configurations.
     Temporary, to be changed in more appropriate way.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	aivanov
# Host:	mysqld.localdomain
# Root:	/home/alexi/bugs/mysql-5.0-19208

--- 1.180/include/my_sys.h	2006-05-15 20:07:52 +04:00
+++ 1.181/include/my_sys.h	2006-06-28 10:20:56 +04:00
@@ -541,6 +541,7 @@
 
 #include <my_alloc.h>
 
+
 	/* Prototypes for mysys and my_func functions */
 
 extern int my_copy(const char *from,const char *to,myf MyFlags);
@@ -612,6 +613,13 @@
 #define my_access access
 #endif
 extern int check_if_legal_filename(const char *path);
+
+#if defined(__WIN__) && defined(__NT__)
+extern int nt_share_delete(const char *name,myf MyFlags);
+#define my_delete_allow_opened(fname,flags)  nt_share_delete((fname),(flags))
+#else
+#define my_delete_allow_opened(fname,flags)  my_delete((fname),(flags))
+#endif
 
 #ifndef TERMINATE
 extern void TERMINATE(FILE *file);

--- 1.5/mysys/my_delete.c	2001-12-06 15:10:42 +03:00
+++ 1.6/mysys/my_delete.c	2006-06-28 10:20:56 +04:00
@@ -32,3 +32,54 @@
   }
   DBUG_RETURN(err);
 } /* my_delete */
+
+#if defined(__WIN__) && defined(__NT__)
+/*
+  Delete file which is possibly not closed.
+
+  This function is intended to be used exclusively as a temporal solution
+  for Win NT in case when it is needed to delete a not closed file (note
+  that the file must be opened everywhere with FILE_SHARE_DELETE mode).
+  Deleting not-closed files can not be supported on Win 98|ME (and because
+  of that is considered harmful).
+  
+  The function deletes the file with its preliminary renaming. This is
+  because when not-closed share-delete file is deleted it still lives on
+  a disk until it will not be closed everwhere. This may conflict with an
+  attempt to create a new file with the same name. The deleted file is
+  renamed to <name>.<num>.deleted where <name> - the initial name of the
+  file, <num> - a hexadecimal number chosen to make the temporal name to
+  be unique.
+*/
+int nt_share_delete(const char *name, myf MyFlags)
+{
+  char buf[MAX_PATH + 20];
+  ulong cnt;
+  DBUG_ENTER("nt_share_delete");
+  DBUG_PRINT("my",("name %s MyFlags %d", name, MyFlags));
+  
+  for (cnt= GetTickCount(); cnt; cnt--)
+  {
+    sprintf(buf, "%s.%08X.deleted", name, cnt);
+    if (MoveFile(name, buf))
+      break;
+      
+    if ((errno= GetLastError()) == ERROR_ALREADY_EXISTS)
+      continue;
+      
+    DBUG_PRINT("warning", ("Failed to rename %s to %s, errno: %d",
+                           name, buf, errno));
+    break;
+  }
+
+  if (DeleteFile(buf))
+    DBUG_RETURN(0);
+
+  my_errno= GetLastError();
+  if (MyFlags & (MY_FAE+MY_WME))
+    my_error(EE_DELETE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)),
+	       name, my_errno);
+
+  DBUG_RETURN(-1);
+}
+#endif

--- 1.188/sql/log.cc	2006-03-31 13:47:59 +04:00
+++ 1.189/sql/log.cc	2006-06-28 10:20:56 +04:00
@@ -959,14 +959,14 @@
 
   for (;;)
   {
-    my_delete(linfo.log_file_name, MYF(MY_WME));
+    my_delete_allow_opened(linfo.log_file_name, MYF(MY_WME));
     if (find_next_log(&linfo, 0))
       break;
   }
 
   /* Start logging with a new file */
   close(LOG_CLOSE_INDEX);
-  my_delete(index_file_name, MYF(MY_WME));	// Reset (open will update)
+  my_delete_allow_opened(index_file_name, MYF(MY_WME));	// Reset (open will update)
   if (!thd->slave_thread)
     need_start_event=1;
   if (!open_index_file(index_file_name, 0))

--- 1.4/VC++Files/mysys/mysys.vcproj	2006-05-02 11:19:50 +04:00
+++ 1.5/VC++Files/mysys/mysys.vcproj	2006-06-28 10:20:56 +04:00
@@ -22,7 +22,7 @@
 				Optimization="0"
 				OptimizeForProcessor="2"
 				AdditionalIncludeDirectories="../include,../zlib"
-				PreprocessorDefinitions="_DEBUG;SAFEMALLOC;SAFE_MUTEX;_WINDOWS;USE_SYMDIR"
+				PreprocessorDefinitions="__NT__;_DEBUG;SAFEMALLOC;SAFE_MUTEX;_WINDOWS;USE_SYMDIR"
 				RuntimeLibrary="1"
 				PrecompiledHeaderFile=".\debug/mysys.pch"
 				AssemblerListingLocation=".\debug/"
@@ -71,7 +71,7 @@
 				InlineFunctionExpansion="1"
 				OptimizeForProcessor="2"
 				AdditionalIncludeDirectories="../include,../zlib"
-				PreprocessorDefinitions="USE_SYMDIR;NDEBUG;DBUG_OFF;_WINDOWS"
+				PreprocessorDefinitions="__NT__;USE_SYMDIR;NDEBUG;DBUG_OFF;_WINDOWS"
 				StringPooling="TRUE"
 				RuntimeLibrary="0"
 				EnableFunctionLevelLinking="TRUE"
@@ -121,7 +121,7 @@
 				InlineFunctionExpansion="1"
 				OptimizeForProcessor="2"
 				AdditionalIncludeDirectories="../include,../zlib"
-				PreprocessorDefinitions="DBUG_OFF;_WINDOWS;NDEBUG"
+				PreprocessorDefinitions="__NT__;DBUG_OFF;_WINDOWS;NDEBUG"
 				StringPooling="TRUE"
 				RuntimeLibrary="0"
 				EnableFunctionLevelLinking="TRUE"
@@ -170,7 +170,7 @@
 				Optimization="0"
 				OptimizeForProcessor="2"
 				AdditionalIncludeDirectories="../include,../zlib"
-				PreprocessorDefinitions="_DEBUG;SAFEMALLOC;SAFE_MUTEX;_WINDOWS;USE_SYMDIR;USE_TLS"
+				PreprocessorDefinitions="__NT__;_DEBUG;SAFEMALLOC;SAFE_MUTEX;_WINDOWS;USE_SYMDIR;USE_TLS"
 				RuntimeLibrary="1"
 				PrecompiledHeaderFile=".\mysys___Win32_TLS_DEBUG/mysys.pch"
 				AssemblerListingLocation=".\mysys___Win32_TLS_DEBUG/"
@@ -219,7 +219,7 @@
 				InlineFunctionExpansion="1"
 				OptimizeForProcessor="2"
 				AdditionalIncludeDirectories="../include,../zlib"
-				PreprocessorDefinitions="DBUG_OFF;_WINDOWS;NDEBUG;USE_TLS"
+				PreprocessorDefinitions="__NT__;DBUG_OFF;_WINDOWS;NDEBUG;USE_TLS"
 				StringPooling="TRUE"
 				RuntimeLibrary="0"
 				EnableFunctionLevelLinking="TRUE"
Thread
bk commit into 5.0 tree (aivanov:1.2191) BUG#19208Alex Ivanov Notebook27 Jun