Bug #38969 Unused mutex LOCK_hostname

Submitted: 22 Aug 2008 17:31 Modified: 3 Nov 2008 2:00
Reporter: Marc ALFF Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S5 (Performance)
Version:6.0-bzr OS:Any
Assigned to: Marc ALFF CPU Architecture:Any

[22 Aug 2008 17:31] Marc ALFF
Description:
The following mutex:

sql/hostname.cc:static pthread_mutex_t LOCK_hostname;

is initialized and destroyed, but never locked / unlocked in the server code.

How to repeat:
Code review

Suggested fix:
Remove
[22 Aug 2008 17:47] Valeriy Kravchuk
On 6.0-bzr I've got:

openxs@suse:/home2/openxs/bzr/mysql-6.0> grep -r -n LOCK_hostname *
sql/hostname.cc:52:static pthread_mutex_t LOCK_hostname;
sql/hostname.cc:69:  (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
sql/hostname.cc:78:    (void) pthread_mutex_destroy(&LOCK_hostname);
sql/udf_example.c:142:static pthread_mutex_t LOCK_hostname;
sql/udf_example.c:722:  (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
sql/udf_example.c:730:  (void) pthread_mutex_destroy(&LOCK_hostname);
sql/udf_example.c:765:  pthread_mutex_lock(&LOCK_hostname);
sql/udf_example.c:768:    pthread_mutex_unlock(&LOCK_hostname);
sql/udf_example.c:772:  pthread_mutex_unlock(&LOCK_hostname);
sql/udf_example.c:802:  (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
sql/udf_example.c:810:  (void) pthread_mutex_destroy(&LOCK_hostname);
sql/udf_example.c:869:  pthread_mutex_lock(&LOCK_hostname);
sql/udf_example.c:872:    pthread_mutex_unlock(&LOCK_hostname);
sql/udf_example.c:876:  pthread_mutex_unlock(&LOCK_hostname);

So, it is used.

On 5.1-bzr I've got:

openxs@suse:/home2/openxs/bzr/mysql-5.1> grep -r -n LOCK_hostname *
sql/hostname.cc:54:static pthread_mutex_t LOCK_hostname;
sql/hostname.cc:71:  (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
sql/hostname.cc:79:    (void) pthread_mutex_destroy(&LOCK_hostname);
sql/hostname.cc:217:  VOID(pthread_mutex_lock(&LOCK_hostname));
sql/hostname.cc:220:    VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/hostname.cc:230:    VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/hostname.cc:236:    VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/hostname.cc:240:  VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/udf_example.c:142:static pthread_mutex_t LOCK_hostname;
sql/udf_example.c:722:  (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
sql/udf_example.c:730:  (void) pthread_mutex_destroy(&LOCK_hostname);
sql/udf_example.c:765:  VOID(pthread_mutex_lock(&LOCK_hostname));
sql/udf_example.c:768:    VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/udf_example.c:772:  VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/udf_example.c:802:  (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
sql/udf_example.c:810:  (void) pthread_mutex_destroy(&LOCK_hostname);
sql/udf_example.c:869:  VOID(pthread_mutex_lock(&LOCK_hostname));
sql/udf_example.c:872:    VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/udf_example.c:876:  VOID(pthread_mutex_unlock(&LOCK_hostname));

So, it is also used, IMHO. Finally, with 5.0-bzr:

openxs@suse:/home2/openxs/bzr/mysql-5.0> grep -r -n LOCK_hostname *
sql/hostname.cc:49:static pthread_mutex_t LOCK_hostname;
sql/hostname.cc:66:  (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
sql/hostname.cc:74:    (void) pthread_mutex_destroy(&LOCK_hostname);
sql/hostname.cc:212:  VOID(pthread_mutex_lock(&LOCK_hostname));
sql/hostname.cc:215:    VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/hostname.cc:225:    VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/hostname.cc:231:    VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/hostname.cc:235:  VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/udf_example.c:142:static pthread_mutex_t LOCK_hostname;
sql/udf_example.c:722:  (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
sql/udf_example.c:730:  (void) pthread_mutex_destroy(&LOCK_hostname);
sql/udf_example.c:765:  VOID(pthread_mutex_lock(&LOCK_hostname));
sql/udf_example.c:768:    VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/udf_example.c:772:  VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/udf_example.c:802:  (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
sql/udf_example.c:810:  (void) pthread_mutex_destroy(&LOCK_hostname);
sql/udf_example.c:869:  VOID(pthread_mutex_lock(&LOCK_hostname));
sql/udf_example.c:872:    VOID(pthread_mutex_unlock(&LOCK_hostname));
sql/udf_example.c:876:  VOID(pthread_mutex_unlock(&LOCK_hostname));

Isn't sql/hostname.cc a part of server's code?
[22 Aug 2008 17:57] Marc ALFF
There are 2 variables named "LOCK_hostname",
- one is in sql/hostname.cc, which is part of the server,
- one is in udf/udf_example.cc, which is not part of the server.
These two variables are independent (note the static keyword).

The grep in sql/hostname.cc just verified that this bug is present in 6.0-bzr only.

LOCK_hostname is used in 5.0 and 5.1, and should only be removed in 6.0
[23 Aug 2008 6:17] Valeriy Kravchuk
OK, so this is 6.0 bug.
[23 Aug 2008 23:34] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/52385

2684 Marc Alff	2008-08-23
      Bug#38969 (Unused mutex LOCK_hostname)
      
      Removed the unused mutex LOCK_hostname in sql/hostname.cc
[1 Nov 2008 18:30] Bugs System
Pushed into 6.0.7-alpha  (revid:marc.alff@sun.com-20080823233428-o2s8sbw33jndr8bq) (version source revid:marc.alff@sun.com-20080823233428-o2s8sbw33jndr8bq) (pib:5)
[3 Nov 2008 2:00] Paul DuBois
Cosmetic change. No changelog entry needed.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.058 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.