logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

bk commit into 4.1 tree (1.1425): msg#00404

Subject: bk commit into 4.1 tree (1.1425)
Below is the list of changes that have just been committed into a local
4.1 repository of wax. When wax 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://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
  1.1425 02/12/31 16:58:41 wax@xxxxxxxxx +1 -0
  Change locks in sql_udf.cc to rw_locks (SCRUM)

  sql/sql_udf.cc
    1.22 02/12/31 16:58:35 wax@xxxxxxxxx +14 -13
    Change locks to rw_locks

# 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: wax
# Host: kishkin.ru
# Root: /home/wax/mysql-4rw

--- 1.21/sql/sql_udf.cc Thu Dec  5 19:44:10 2002
+++ 1.22/sql/sql_udf.cc Tue Dec 31 16:58:35 2002
@@ -33,6 +33,7 @@
 #endif
 
 #include "mysql_priv.h"
+#include <my_pthread.h>
 
 #ifdef HAVE_DLOPEN
 extern "C"
@@ -70,7 +71,7 @@
 static bool initialized = 0;
 static MEM_ROOT mem;
 static HASH udf_hash;
-static pthread_mutex_t THR_LOCK_udf;
+static rw_lock_t THR_LOCK_udf;
 
 
 static udf_func *add_udf(char *name, Item_result ret, char *dl,
@@ -122,8 +123,8 @@
   if (initialized)
     DBUG_VOID_RETURN;
 
-  pthread_mutex_init(&THR_LOCK_udf,MY_MUTEX_INIT_SLOW);
-
+  my_rwlock_init(&THR_LOCK_udf,NULL);
+  
   init_sql_alloc(&mem, 1024,0);
   THD *new_thd = new THD;
   if (!new_thd ||
@@ -262,7 +263,7 @@
 void free_udf(udf_func *udf)
 {
   DBUG_ENTER("free_udf");
-  pthread_mutex_lock(&THR_LOCK_udf);
+  rw_wrlock(&THR_LOCK_udf);
   if (!--udf->usage_count)
   {
     /*
@@ -274,7 +275,7 @@
     if (!find_udf_dl(udf->dl))
       dlclose(udf->dlhandle);
   }
-  pthread_mutex_unlock(&THR_LOCK_udf);
+  rw_unlock(&THR_LOCK_udf);
   DBUG_VOID_RETURN;
 }
 
@@ -287,7 +288,7 @@
   DBUG_ENTER("find_udf");
 
   /* TODO: This should be changed to reader locks someday! */
-  pthread_mutex_lock(&THR_LOCK_udf);
+  rw_rdlock(&THR_LOCK_udf);  
   if ((udf=(udf_func*) hash_search(&udf_hash,(byte*) name,
                                   length ? length : (uint) strlen(name))))
   {
@@ -296,7 +297,7 @@
     else if (mark_used)
       udf->usage_count++;
   }
-  pthread_mutex_unlock(&THR_LOCK_udf);
+  rw_unlock(&THR_LOCK_udf);
   DBUG_RETURN(udf);
 }
 
@@ -375,7 +376,7 @@
     DBUG_RETURN(1);
   }
 
-  pthread_mutex_lock(&THR_LOCK_udf);
+  rw_wrlock(&THR_LOCK_udf);
   if ((hash_search(&udf_hash,(byte*) udf->name, udf->name_length)))
   {
     net_printf(thd, ER_UDF_EXISTS, udf->name);
@@ -438,13 +439,13 @@
     del_udf(u_d);
     goto err;
   }
-  pthread_mutex_unlock(&THR_LOCK_udf);
+  rw_unlock(&THR_LOCK_udf);
   DBUG_RETURN(0);
 
  err:
   if (new_dl)
     dlclose(dl);
-  pthread_mutex_unlock(&THR_LOCK_udf);
+  rw_unlock(&THR_LOCK_udf);
   DBUG_RETURN(1);
 }
 
@@ -460,7 +461,7 @@
     send_error(thd, ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES));
     DBUG_RETURN(1);
   }
-  pthread_mutex_lock(&THR_LOCK_udf);
+  rw_wrlock(&THR_LOCK_udf);  
   if (!(udf=(udf_func*) hash_search(&udf_hash,(byte*) udf_name,
                                    (uint) strlen(udf_name))))
   {
@@ -490,10 +491,10 @@
   }
   close_thread_tables(thd);
 
-  pthread_mutex_unlock(&THR_LOCK_udf);
+  rw_unlock(&THR_LOCK_udf);  
   DBUG_RETURN(0);
  err:
-  pthread_mutex_unlock(&THR_LOCK_udf);
+  rw_unlock(&THR_LOCK_udf);
   DBUG_RETURN(1);
 }
 

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail internals-thread6271@xxxxxxxxxxxxxxx
To unsubscribe, e-mail <internals-unsubscribe@xxxxxxxxxxxxxxx>




<Prev in Thread] Current Thread [Next in Thread>