List:Commits« Previous MessageNext Message »
From:ahmad.abdullateef Date:November 2 2012 9:54am
Subject:bzr push into mysql-trunk branch (ahmad.abdullateef:4886 to 4887)
Bug#11763004
View as plain text  
 4887 Ahmad Abdullateef	2012-11-02
      BUG#11763004 - _DOSMAPERR WIPES OUT THE ERRNO SET IN
                     _OPEN_OSFHANDLE AND GIVES (ERRNO: 2 
      
      DESCRIPTION:
      When an API or function call fails in mysqld.exe under windows,
      Error Logs report Error Code 22 for certain cases.
      
      ANALYSIS :
      When an error occurs my_osmaperr() is called with the value 
      from GetLastError(). The mapping which exists in my_winerr.c 
      is fairly limited and EINVAL (22) is returned for a lot 
      Windows Error Codes, which makes it hard to detect the cause 
      from error Logs.
      
      Reproducing an issue which returns an unmapped Windows Error
      Codes is very difficult, hence an test case for this issue hs
      intentionally been left out.
      
      FIX :
      my_osmaperr() now saves the original GetLastError() value in
      thr_winerr. This saved value is used again in my_strerror()
      incase the nr value is EINVAL (22) to give a better error
      message.

    modified:
      include/my_pthread.h
      mysys/my_error.c
      mysys/my_winerr.c
 4886 horst.hunger@stripped	2012-11-02
      To avoid differenced in the result.

    modified:
      mysql-test/suite/sys_vars/r/slow_launch_time_func.result
=== modified file 'include/my_pthread.h'
--- a/include/my_pthread.h	2012-07-17 07:52:54 +0000
+++ b/include/my_pthread.h	2012-11-02 09:53:34 +0000
@@ -822,6 +822,14 @@ extern int pthread_dummy(int);
 struct st_my_thread_var
 {
   int thr_errno;
+#if defined(__WIN__)
+/*
+  thr_winerr is used for returning the original OS error-code in Windows,
+  my_osmaperr() returns EINVAL for all unknown Windows errors, hence we
+  preserve the original Windows Error code in thr_winerr.
+*/
+  int thr_winerr;
+#endif
   mysql_cond_t suspend;
   mysql_mutex_t mutex;
   mysql_mutex_t * volatile current_mutex;
@@ -846,6 +854,10 @@ extern void **my_thread_var_dbug();
 extern uint my_thread_end_wait_time;
 #define my_thread_var (_my_thread_var())
 #define my_errno my_thread_var->thr_errno
+
+#if defined(__WIN__)
+#define my_winerr my_thread_var->thr_winerr
+#endif
 /*
   Keep track of shutdown,signal, and main threads so that my_end() will not
   report errors with them

=== modified file 'mysys/my_error.c'
--- a/mysys/my_error.c	2012-05-03 08:40:15 +0000
+++ b/mysys/my_error.c	2012-11-02 09:53:34 +0000
@@ -94,6 +94,24 @@ char *my_strerror(char *buf, size_t len,
     */
 #if defined(__WIN__)
     strerror_s(buf, len, nr);
+    if (my_winerr != 0)
+    {
+      /*
+        If error code is EINVAL, and Windows Error code has been set, we append
+        the Windows error code to the message.
+      */
+      if (nr == EINVAL)
+      {
+        char tmp_buff[256] ;
+
+        my_snprintf(tmp_buff, sizeof(tmp_buff), 
+                    " [OS Error Code : 0x%x]", my_winerr);
+
+        strcat_s(buf, len, tmp_buff);
+      }
+
+      my_winerr= 0;
+    }
 #elif ((defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE >= 200112L)) ||    \
        (defined _XOPEN_SOURCE   && (_XOPEN_SOURCE >= 600)))      &&    \
       ! defined _GNU_SOURCE

=== modified file 'mysys/my_winerr.c'
--- a/mysys/my_winerr.c	2012-10-22 06:58:47 +0000
+++ b/mysys/my_winerr.c	2012-11-02 09:53:34 +0000
@@ -119,7 +119,12 @@ static int get_errno_from_oserr(unsigned
 }
 
 /* Set errno corresponsing to GetLastError() value */
-void my_osmaperr ( unsigned long oserrno)
+void my_osmaperr( unsigned long oserrno)
 {
-    errno= get_errno_from_oserr(oserrno);
+  /*
+    set my_winerr so that we could return the Windows Error Code
+    when it is EINVAL.
+  */
+  my_winerr= oserrno;
+  errno= get_errno_from_oserr(oserrno);
 }

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (ahmad.abdullateef:4886 to 4887)Bug#11763004ahmad.abdullateef6 Nov