List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:May 18 2009 8:30pm
Subject:bzr commit into mysql-6.0-bugteam branch (vvaintroub:3297) Bug#41190
View as plain text  
#At file:///H:/bzr/mysql-6.0-bugteam/ based on revid:gshchepa@stripped

 3297 Vladislav Vaintroub	2009-05-18
      Bug #41190 shared memory connections do not work in Vista, if server started 
      from cmdline 
            
      In Vista and later and also in when using terminal services, when server is started
      from  command line, client cannot connect to it via shared memory protocol.
            
      This is a regression introduced when  Bug#24731 was fixed.
      The reason is that client is trying to attach to shared memory using global kernel
      object  namespace (all kernel objects are prefixed with Global\). However, server 
      started from the command line in Vista and later will create shared memory and 
      events using current  session namespace. Thus, client is unable to find the server
      and connection fails.
            
      The fix for the client is to first try to find server using "local" names  (omitting
      Global\  prefix) and only if server is not found, trying global namespace.

    modified:
      sql-common/client.c
=== modified file 'sql-common/client.c'
--- a/sql-common/client.c	2009-04-21 09:27:46 +0000
+++ b/sql-common/client.c	2009-05-18 20:30:46 +0000
@@ -480,6 +480,9 @@ HANDLE create_shared_memory(MYSQL *mysql
   DWORD error_code = 0;
   DWORD event_access_rights= SYNCHRONIZE | EVENT_MODIFY_STATE;
   char *shared_memory_base_name = mysql->options.shared_memory_base_name;
+  static const char *name_prefixes[] = {"","Global\\"};
+  const char *prefix;
+  int i;
 
   /*
      get enough space base-name + '_' + longest suffix we might ever send
@@ -494,9 +497,18 @@ HANDLE create_shared_memory(MYSQL *mysql
     shared_memory_base_name is unique value for each server
     unique_part is uniquel value for each object (events and file-mapping)
   */
-  suffix_pos = strxmov(tmp, "Global\\", shared_memory_base_name, "_", NullS);
-  strmov(suffix_pos, "CONNECT_REQUEST");
-  if (!(event_connect_request= OpenEvent(event_access_rights, FALSE, tmp)))
+  for (i = 0; i< array_elements(name_prefixes); i++)
+  {
+    prefix= name_prefixes[i];
+    suffix_pos = strxmov(tmp, prefix , shared_memory_base_name, "_", NullS);
+    strmov(suffix_pos, "CONNECT_REQUEST");
+    event_connect_request= OpenEvent(event_access_rights, FALSE, tmp);
+    if (event_connect_request)
+    {
+      break;
+    }
+  }
+  if (!event_connect_request)
   {
     error_allow = CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR;
     goto err;
@@ -548,7 +560,7 @@ HANDLE create_shared_memory(MYSQL *mysql
     unique_part is uniquel value for each object (events and file-mapping)
     number_of_connection is number of connection between server and client
   */
-  suffix_pos = strxmov(tmp, "Global\\", shared_memory_base_name, "_", connect_number_char,
+  suffix_pos = strxmov(tmp, prefix , shared_memory_base_name, "_", connect_number_char,
 		       "_", NullS);
   strmov(suffix_pos, "DATA");
   if ((handle_file_map = OpenFileMapping(FILE_MAP_WRITE,FALSE,tmp)) == NULL)


Attachment: [text/bzr-bundle] bzr/vvaintroub@mysql.com-20090518203046-nmsw5sz99my1m20m.bundle
Thread
bzr commit into mysql-6.0-bugteam branch (vvaintroub:3297) Bug#41190Vladislav Vaintroub18 May