mutex.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2000-2002, 2004, 2005, 2007, 2008, 2011, 2012, 2014-2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: mutex.c,v 1.18 2011/01/04 23:47:14 tbox Exp $ */
/*! \file */
#include <config.h>
#include <stdio.h>
#include <time.h>
#include <errno.h>
#include <isc/strerror.h>
/*@{*/
do { \
} \
} while (0)
do { \
} \
} while (0)
/*@}*/
#define ISC_MUTEX_MAX_LOCKERS 32
typedef struct {
const char * file;
int line;
unsigned count;
struct timeval locked_total;
struct timeval wait_total;
struct isc_mutexstats {
const char * file; /*%< File mutex was created in. */
int line; /*%< Line mutex was created on. */
unsigned count;
struct timeval locked_total;
struct timeval wait_total;
};
#ifndef ISC_MUTEX_PROFTABLESIZE
#endif
static int stats_next = 0;
int i, err;
return (ISC_R_NOMEMORY);
if (err != 0)
return (ISC_R_UNEXPECTED);
if (stats_init == ISC_FALSE)
/*
* If all statistics entries have been used, give up and trigger an
* assertion failure. There would be no other way to deal with this
* because we'd like to keep record of all locks for the purpose of
* debugging and the number of necessary locks is unpredictable.
* If this failure is triggered while debugging, named should be
* rebuilt with an increased ISC_MUTEX_PROFTABLESIZE.
*/
for (i = 0; i < ISC_MUTEX_MAX_LOCKERS; i++) {
}
return (ISC_R_SUCCESS);
}
struct timeval postlock_t;
int i;
return (ISC_R_UNEXPECTED);
for (i = 0; i < ISC_MUTEX_MAX_LOCKERS; i++) {
break;
break;
}
}
}
return (ISC_R_SUCCESS);
}
}
}
void
int i, j;
for (i = 0; i < stats_next; i++) {
i);
for (j = 0; j < ISC_MUTEX_MAX_LOCKERS; j++) {
continue;
i);
}
}
}
#endif /* ISC_MUTEX_PROFILE */
#if ISC_MUTEX_DEBUG && defined(PTHREAD_MUTEX_ERRORCHECK)
static pthread_mutexattr_t errcheck;
static void
initialize_errcheck(void) {
(&errcheck, PTHREAD_MUTEX_ERRORCHECK) == 0);
}
int err;
return (ISC_R_NOMEMORY);
}
#endif
PTHREAD_MUTEX_ERRORCHECK, /* m_type */
0 /* m_flags, which appears to be unused. */
};
#endif
static pthread_mutexattr_t attr;
#endif /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
static void
initialize_attr(void) {
(&attr, PTHREAD_MUTEX_ADAPTIVE_NP) == 0);
}
#endif /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
char strbuf[ISC_STRERRORSIZE];
int err;
#else /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
#endif /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
return (ISC_R_NOMEMORY);
if (err != 0) {
strbuf);
}
return (result);
}
#endif