Browse Source

assert in safe_mutex_lock that the mutex is initialized

also replace 0x%lx with %p
pull/3958/head
Sergei Golubchik 8 months ago
parent
commit
a3257038d1
  1. 12
      mysys/thr_mutex.c

12
mysys/thr_mutex.c

@ -179,7 +179,7 @@ int safe_mutex_init(safe_mutex_t *mp,
const char *name, const char *file, uint line) const char *name, const char *file, uint line)
{ {
DBUG_ENTER("safe_mutex_init"); DBUG_ENTER("safe_mutex_init");
DBUG_PRINT("enter",("mutex: 0x%lx name: %s", (ulong) mp, name));
DBUG_PRINT("enter",("mutex: %p name: %s", mp, name));
bzero((char*) mp,sizeof(*mp)); bzero((char*) mp,sizeof(*mp));
pthread_mutex_init(&mp->global,MY_MUTEX_INIT_ERRCHK); pthread_mutex_init(&mp->global,MY_MUTEX_INIT_ERRCHK);
pthread_mutex_init(&mp->mutex,attr); pthread_mutex_init(&mp->mutex,attr);
@ -227,8 +227,8 @@ int safe_mutex_lock(safe_mutex_t *mp, myf my_flags, const char *file,
uint line) uint line)
{ {
int error; int error;
DBUG_PRINT("mutex", ("%s (0x%lx) locking", mp->name ? mp->name : "Null",
(ulong) mp));
DBUG_PRINT("mutex", ("%s (%p) locking", mp->name, mp));
DBUG_ASSERT(mp->name);
DBUG_PUSH_EMPTY; DBUG_PUSH_EMPTY;
pthread_mutex_lock(&mp->global); pthread_mutex_lock(&mp->global);
@ -394,7 +394,7 @@ int safe_mutex_lock(safe_mutex_t *mp, myf my_flags, const char *file,
end: end:
DBUG_POP_EMPTY; DBUG_POP_EMPTY;
if (!error) if (!error)
DBUG_PRINT("mutex", ("%s (0x%lx) locked", mp->name, (ulong) mp));
DBUG_PRINT("mutex", ("%s (%p) locked", mp->name, mp));
return error; return error;
} }
@ -402,7 +402,7 @@ end:
int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line) int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line)
{ {
int error; int error;
DBUG_PRINT("mutex", ("%s (0x%lx) unlocking", mp->name, (ulong) mp));
DBUG_PRINT("mutex", ("%s (%p) unlocking", mp->name, mp));
pthread_mutex_lock(&mp->global); pthread_mutex_lock(&mp->global);
if (mp->count == 0) if (mp->count == 0)
{ {
@ -578,7 +578,7 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line)
{ {
int error=0; int error=0;
DBUG_ENTER("safe_mutex_destroy"); DBUG_ENTER("safe_mutex_destroy");
DBUG_PRINT("enter", ("mutex: 0x%lx name: %s", (ulong) mp, mp->name));
DBUG_PRINT("enter", ("mutex: %p name: %s", mp, mp->name));
if (!mp->file) if (!mp->file)
{ {
fprintf(stderr, fprintf(stderr,

Loading…
Cancel
Save