List:Commits« Previous MessageNext Message »
From:Tatjana A Nuernberg Date:May 11 2006 10:33am
Subject:bk commit into 5.1 tree (tnurnberg:1.2384)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of azundris. When azundris 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.2384 06/05/11 12:33:43 tnurnberg@stripped +1 -0
  Merge tnurnberg@stripped:/home/bk/mysql-5.1-new
  into  mysql.com:/home/mysql-5.1-19509

  sql/sql_acl.cc
    1.190 06/05/11 12:33:33 tnurnberg@stripped +0 -0
    Auto merged

# 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:	tnurnberg
# Host:	salvation.intern.azundris.com
# Root:	/home/mysql-5.1-19509/RESYNC

--- 1.189/sql/sql_acl.cc	2006-05-08 07:47:27 +02:00
+++ 1.190/sql/sql_acl.cc	2006-05-11 12:33:33 +02:00
@@ -1156,6 +1156,8 @@
 			    USER_RESOURCES  *mqh,
 			    ulong privileges)
 {
+  safe_mutex_assert_owner(&acl_cache->lock);
+
   for (uint i=0 ; i < acl_users.elements ; i++)
   {
     ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*);
@@ -1206,6 +1208,9 @@
 			    ulong privileges)
 {
   ACL_USER acl_user;
+
+  safe_mutex_assert_owner(&acl_cache->lock);
+
   acl_user.user=*user ? strdup_root(&mem,user) : 0;
   update_hostname(&acl_user.host, *host ? strdup_root(&mem, host): 0);
   acl_user.access=privileges;
@@ -1235,6 +1240,8 @@
 static void acl_update_db(const char *user, const char *host, const char *db,
 			  ulong privileges)
 {
+  safe_mutex_assert_owner(&acl_cache->lock);
+
   for (uint i=0 ; i < acl_dbs.elements ; i++)
   {
     ACL_DB *acl_db=dynamic_element(&acl_dbs,i,ACL_DB*);
@@ -1660,6 +1667,9 @@
 {
   DBUG_ENTER("find_acl_user");
   DBUG_PRINT("enter",("host: '%s'  user: '%s'",host,user));
+
+  safe_mutex_assert_owner(&acl_cache->lock);
+
   for (uint i=0 ; i < acl_users.elements ; i++)
   {
     ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*);
@@ -1672,7 +1682,7 @@
     if (!acl_user->user && !user[0] ||
 	acl_user->user && !strcmp(user,acl_user->user))
     {
-      if (exact ? !my_strcasecmp(&my_charset_latin1, host,
+      if (exact ? !my_strcasecmp(system_charset_info, host,
                                  acl_user->host.hostname ?
 				 acl_user->host.hostname : "") :
           compare_hostname(&acl_user->host,host,host))
@@ -2998,6 +3008,7 @@
     create_new_users= test_if_create_new_users(thd);
   bool result= FALSE;
   rw_wrlock(&LOCK_grant);
+  pthread_mutex_lock(&acl_cache->lock);
   MEM_ROOT *old_root= thd->mem_root;
   thd->mem_root= &memex;
   grant_version++;
@@ -3015,12 +3026,10 @@
       continue;
     }
     /* Create user if needed */
-    pthread_mutex_lock(&acl_cache->lock);
     error=replace_user_table(thd, tables[0].table, *Str,
 			     0, revoke_grant, create_new_users,
                              test(thd->variables.sql_mode &
                                   MODE_NO_AUTO_CREATE_USER));
-    pthread_mutex_unlock(&acl_cache->lock);
     if (error)
     {
       result= TRUE;				// Remember error
@@ -3112,6 +3121,7 @@
   }
   grant_option=TRUE;
   thd->mem_root= old_root;
+  pthread_mutex_unlock(&acl_cache->lock);
   rw_unlock(&LOCK_grant);
   if (!result)
     send_ok(thd);
@@ -3204,6 +3214,7 @@
   if (!revoke_grant)
     create_new_users= test_if_create_new_users(thd);
   rw_wrlock(&LOCK_grant);
+  pthread_mutex_lock(&acl_cache->lock);
   MEM_ROOT *old_root= thd->mem_root;
   thd->mem_root= &memex;
 
@@ -3223,12 +3234,10 @@
       continue;
     }
     /* Create user if needed */
-    pthread_mutex_lock(&acl_cache->lock);
     error=replace_user_table(thd, tables[0].table, *Str,
 			     0, revoke_grant, create_new_users,
                              test(thd->variables.sql_mode &
                                   MODE_NO_AUTO_CREATE_USER));
-    pthread_mutex_unlock(&acl_cache->lock);
     if (error)
     {
       result= TRUE;				// Remember error
@@ -3270,6 +3279,7 @@
   }
   grant_option=TRUE;
   thd->mem_root= old_root;
+  pthread_mutex_unlock(&acl_cache->lock);
   rw_unlock(&LOCK_grant);
   if (!result && !no_error)
     send_ok(thd);
@@ -4246,20 +4256,15 @@
     DBUG_RETURN(TRUE);
   }
 
-  for (counter=0 ; counter < acl_users.elements ; counter++)
-  {
-    const char *user,*host;
-    acl_user=dynamic_element(&acl_users,counter,ACL_USER*);
-    if (!(user=acl_user->user))
-      user= "";
-    if (!(host=acl_user->host.hostname))
-      host= "";
-    if (!strcmp(lex_user->user.str,user) &&
-	!my_strcasecmp(system_charset_info, lex_user->host.str, host))
-      break;
-  }
-  if (counter == acl_users.elements)
+  rw_rdlock(&LOCK_grant);
+  VOID(pthread_mutex_lock(&acl_cache->lock));
+
+  acl_user= find_acl_user(lex_user->host.str, lex_user->user.str, TRUE);
+  if (!acl_user)
   {
+    VOID(pthread_mutex_unlock(&acl_cache->lock));
+    rw_unlock(&LOCK_grant);
+
     my_error(ER_NONEXISTING_GRANT, MYF(0),
              lex_user->user.str, lex_user->host.str);
     DBUG_RETURN(TRUE);
@@ -4274,10 +4279,12 @@
   field_list.push_back(field);
   if (protocol->send_fields(&field_list,
                             Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
-    DBUG_RETURN(TRUE);
+  {
+    VOID(pthread_mutex_unlock(&acl_cache->lock));
+    rw_unlock(&LOCK_grant);
 
-  rw_wrlock(&LOCK_grant);
-  VOID(pthread_mutex_lock(&acl_cache->lock));
+    DBUG_RETURN(TRUE);
+  }
 
   /* Add first global access grants */
   {
@@ -4685,10 +4692,15 @@
 void get_mqh(const char *user, const char *host, USER_CONN *uc)
 {
   ACL_USER *acl_user;
+
+  pthread_mutex_lock(&acl_cache->lock);
+
   if (initialized && (acl_user= find_acl_user(host,user, FALSE)))
     uc->user_resources= acl_user->user_resource;
   else
     bzero((char*) &uc->user_resources, sizeof(uc->user_resources));
+
+  pthread_mutex_unlock(&acl_cache->lock);
 }
 
 /*
@@ -4768,31 +4780,6 @@
   DBUG_RETURN(0);
 }
 
-ACL_USER *check_acl_user(LEX_USER *user_name,
-			 uint *acl_acl_userdx)
-{
-  ACL_USER *acl_user= 0;
-  uint counter;
-
-  for (counter= 0 ; counter < acl_users.elements ; counter++)
-  {
-    const char *user,*host;
-    acl_user= dynamic_element(&acl_users, counter, ACL_USER*);
-    if (!(user=acl_user->user))
-      user= "";
-    if (!(host=acl_user->host.hostname))
-      host= "";
-    if (!strcmp(user_name->user.str,user) &&
-	!my_strcasecmp(system_charset_info, user_name->host.str, host))
-      break;
-  }
-  if (counter == acl_users.elements)
-    return 0;
-
-  *acl_acl_userdx= counter;
-  return acl_user;
-}
-
 
 /*
   Modify a privilege table.
@@ -5039,6 +5026,8 @@
   LINT_INIT(user);
   LINT_INIT(host);
 
+  safe_mutex_assert_owner(&acl_cache->lock);
+
   /* Get the number of elements in the in-memory structure. */
   switch (struct_no) {
   case 0:
@@ -5501,7 +5490,7 @@
   List_iterator <LEX_USER> user_list(list);
   while ((lex_user=user_list++))
   {
-    if (!check_acl_user(lex_user, &counter))
+    if (!find_acl_user(lex_user->host.str, lex_user->user.str, TRUE))
     {
       sql_print_error("REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' does not "
                       "exists", lex_user->user.str, lex_user->host.str);
@@ -5737,6 +5726,7 @@
 
   combo->user.str= sctx->user;
   
+  VOID(pthread_mutex_lock(&acl_cache->lock));
   if (!find_acl_user(combo->host.str=(char*)sctx->host_or_ip, combo->user.str,
                      FALSE) &&
       !find_acl_user(combo->host.str=(char*)sctx->host, combo->user.str,
@@ -5744,7 +5734,11 @@
       !find_acl_user(combo->host.str=(char*)sctx->ip, combo->user.str,
                      FALSE) &&
       !find_acl_user(combo->host.str=(char*)"%", combo->user.str, FALSE))
+  {
+    VOID(pthread_mutex_unlock(&acl_cache->lock));
     DBUG_RETURN(TRUE);
+  }
+  VOID(pthread_mutex_unlock(&acl_cache->lock));
 
   bzero((char*)tables, sizeof(TABLE_LIST));
   user_list.empty();
@@ -5862,6 +5856,8 @@
   char *curr_host= thd->security_ctx->priv_host_name();
   DBUG_ENTER("fill_schema_user_privileges");
 
+  pthread_mutex_lock(&acl_cache->lock);
+
   for (counter=0 ; counter < acl_users.elements ; counter++)
   {
     const char *user,*host, *is_grantable="YES";
@@ -5897,6 +5893,9 @@
       }
     }
   }
+
+  pthread_mutex_unlock(&acl_cache->lock);
+
   DBUG_RETURN(0);
 #else
   return(0);
@@ -5916,6 +5915,8 @@
   char *curr_host= thd->security_ctx->priv_host_name();
   DBUG_ENTER("fill_schema_schema_privileges");
 
+  pthread_mutex_lock(&acl_cache->lock);
+
   for (counter=0 ; counter < acl_dbs.elements ; counter++)
   {
     const char *user, *host, *is_grantable="YES";
@@ -5954,6 +5955,9 @@
       }
     }
   }
+
+  pthread_mutex_unlock(&acl_cache->lock);
+
   DBUG_RETURN(0);
 #else
   return (0);
@@ -5971,6 +5975,8 @@
   char *curr_host= thd->security_ctx->priv_host_name();
   DBUG_ENTER("fill_schema_table_privileges");
 
+  rw_rdlock(&LOCK_grant);
+
   for (index=0 ; index < column_priv_hash.records ; index++)
   {
     const char *user, *is_grantable= "YES";
@@ -6016,6 +6022,9 @@
       }
     }
   }
+
+  rw_unlock(&LOCK_grant);
+
   DBUG_RETURN(0);
 #else
   return (0);
@@ -6033,6 +6042,8 @@
   char *curr_host= thd->security_ctx->priv_host_name();
   DBUG_ENTER("fill_schema_table_privileges");
 
+  rw_rdlock(&LOCK_grant);
+
   for (index=0 ; index < column_priv_hash.records ; index++)
   {
     const char *user, *is_grantable= "YES";
@@ -6084,6 +6095,9 @@
       }
     }
   }
+
+  rw_unlock(&LOCK_grant);
+
   DBUG_RETURN(0);
 #else
   return (0);
Thread
bk commit into 5.1 tree (tnurnberg:1.2384)Tatjana A Nuernberg11 May