mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-21 15:19:34 -05:00
use GMP for multiple precision in counters
This commit is contained in:
parent
04734610de
commit
a637926bf2
9 changed files with 396 additions and 159 deletions
|
|
@ -193,7 +193,7 @@ SLAPD_SQL_LDFLAGS = @SLAPD_SQL_LDFLAGS@
|
||||||
SLAPD_SQL_INCLUDES = @SLAPD_SQL_INCLUDES@
|
SLAPD_SQL_INCLUDES = @SLAPD_SQL_INCLUDES@
|
||||||
SLAPD_SQL_LIBS = @SLAPD_SQL_LIBS@
|
SLAPD_SQL_LIBS = @SLAPD_SQL_LIBS@
|
||||||
|
|
||||||
SLAPD_LIBS = @SLAPD_LIBS@ @SLAPD_PERL_LDFLAGS@ @SLAPD_SQL_LDFLAGS@ @SLAPD_SQL_LIBS@ @SLAPD_SLP_LIBS@
|
SLAPD_LIBS = @SLAPD_LIBS@ @SLAPD_PERL_LDFLAGS@ @SLAPD_SQL_LDFLAGS@ @SLAPD_SQL_LIBS@ @SLAPD_SLP_LIBS@ @SLAPD_GMP_LIBS@
|
||||||
SLURPD_LIBS = @SLURPD_LIBS@
|
SLURPD_LIBS = @SLURPD_LIBS@
|
||||||
|
|
||||||
# Our Defaults
|
# Our Defaults
|
||||||
|
|
|
||||||
14
configure.in
14
configure.in
|
|
@ -553,6 +553,7 @@ LIBSLAPITOOLS=
|
||||||
AUTH_LIBS=
|
AUTH_LIBS=
|
||||||
|
|
||||||
SLAPD_SLP_LIBS=
|
SLAPD_SLP_LIBS=
|
||||||
|
SLAPD_GMP_LIBS=
|
||||||
|
|
||||||
dnl ================================================================
|
dnl ================================================================
|
||||||
dnl Checks for programs
|
dnl Checks for programs
|
||||||
|
|
@ -2228,6 +2229,18 @@ if test $ol_enable_slp != no ; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dnl ----------------------------------------------------------------
|
||||||
|
dnl Check for GMP API Library
|
||||||
|
AC_CHECK_HEADERS( gmp.h )
|
||||||
|
|
||||||
|
if test $ac_cv_header_gmp_h = yes ; then
|
||||||
|
AC_CHECK_LIB(gmp, __gmpz_add_ui, [have_gmp=yes], [have_gmp=no])
|
||||||
|
if test $have_gmp = yes ; then
|
||||||
|
AC_DEFINE(HAVE_GMP, 1, [define if you have -lgmp])
|
||||||
|
SLAPD_GMP_LIBS=-lgmp
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
dnl ----------------------------------------------------------------
|
dnl ----------------------------------------------------------------
|
||||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||||
|
|
||||||
|
|
@ -2843,6 +2856,7 @@ AC_SUBST(LIBSLAPITOOLS)
|
||||||
AC_SUBST(AUTH_LIBS)
|
AC_SUBST(AUTH_LIBS)
|
||||||
|
|
||||||
AC_SUBST(SLAPD_SLP_LIBS)
|
AC_SUBST(SLAPD_SLP_LIBS)
|
||||||
|
AC_SUBST(SLAPD_GMP_LIBS)
|
||||||
|
|
||||||
AC_SUBST(SLAPD_SQL_LDFLAGS)
|
AC_SUBST(SLAPD_SQL_LDFLAGS)
|
||||||
AC_SUBST(SLAPD_SQL_LIBS)
|
AC_SUBST(SLAPD_SQL_LIBS)
|
||||||
|
|
|
||||||
|
|
@ -28,19 +28,21 @@
|
||||||
#include "back-monitor.h"
|
#include "back-monitor.h"
|
||||||
#include "lber_pvt.h"
|
#include "lber_pvt.h"
|
||||||
|
|
||||||
static struct berval
|
struct monitor_ops_t {
|
||||||
bv_op[] = {
|
struct berval rdn;
|
||||||
BER_BVC( "Bind" ),
|
struct berval nrdn;
|
||||||
BER_BVC( "Unbind" ),
|
} monitor_op[] = {
|
||||||
BER_BVC( "Add" ),
|
{ BER_BVC( "cn=Bind" ), BER_BVC( "cn=bind" ) },
|
||||||
BER_BVC( "Delete" ),
|
{ BER_BVC( "cn=Unbind" ), BER_BVC( "cn=unbind" ) },
|
||||||
BER_BVC( "Modrdn" ),
|
{ BER_BVC( "cn=Add" ), BER_BVC( "cn=add" ) },
|
||||||
BER_BVC( "Modify" ),
|
{ BER_BVC( "cn=Delete" ), BER_BVC( "cn=delete" ) },
|
||||||
BER_BVC( "Compare" ),
|
{ BER_BVC( "cn=Modrdn" ), BER_BVC( "cn=modrdn" ) },
|
||||||
BER_BVC( "Search" ),
|
{ BER_BVC( "cn=Modify" ), BER_BVC( "cn=modify" ) },
|
||||||
BER_BVC( "Abandon" ),
|
{ BER_BVC( "cn=Compare" ), BER_BVC( "cn=compare" ) },
|
||||||
BER_BVC( "Extended" ),
|
{ BER_BVC( "cn=Search" ), BER_BVC( "cn=search" ) },
|
||||||
BER_BVNULL
|
{ BER_BVC( "cn=Abandon" ), BER_BVC( "cn=abandon" ) },
|
||||||
|
{ BER_BVC( "cn=Extended" ), BER_BVC( "cn=extended" ) },
|
||||||
|
{ BER_BVNULL, BER_BVNULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -64,9 +66,9 @@ monitor_subsys_ops_init(
|
||||||
&monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn, &e_op ) ) {
|
&monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn, &e_op ) ) {
|
||||||
Debug( LDAP_DEBUG_ANY,
|
Debug( LDAP_DEBUG_ANY,
|
||||||
"monitor_subsys_ops_init: "
|
"monitor_subsys_ops_init: "
|
||||||
"unable to get entry '%s'\n%s%s",
|
"unable to get entry \"%s\"\n",
|
||||||
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn.bv_val,
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn.bv_val,
|
||||||
"", "" );
|
0, 0 );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +83,7 @@ monitor_subsys_ops_init(
|
||||||
* Initiated ops
|
* Initiated ops
|
||||||
*/
|
*/
|
||||||
snprintf( buf, sizeof( buf ),
|
snprintf( buf, sizeof( buf ),
|
||||||
"dn: cn=%s,%s\n"
|
"dn: %s,%s\n"
|
||||||
"objectClass: %s\n"
|
"objectClass: %s\n"
|
||||||
"structuralObjectClass: %s\n"
|
"structuralObjectClass: %s\n"
|
||||||
"cn: %s\n"
|
"cn: %s\n"
|
||||||
|
|
@ -91,11 +93,11 @@ monitor_subsys_ops_init(
|
||||||
"modifiersName: %s\n"
|
"modifiersName: %s\n"
|
||||||
"createTimestamp: %s\n"
|
"createTimestamp: %s\n"
|
||||||
"modifyTimestamp: %s\n",
|
"modifyTimestamp: %s\n",
|
||||||
bv_op[ i ].bv_val,
|
monitor_op[ i ].rdn.bv_val,
|
||||||
monitor_subsys[SLAPD_MONITOR_OPS].mss_dn.bv_val,
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_dn.bv_val,
|
||||||
mi->mi_oc_monitorOperation->soc_cname.bv_val,
|
mi->mi_oc_monitorOperation->soc_cname.bv_val,
|
||||||
mi->mi_oc_monitorOperation->soc_cname.bv_val,
|
mi->mi_oc_monitorOperation->soc_cname.bv_val,
|
||||||
bv_op[ i ].bv_val,
|
&monitor_op[ i ].rdn.bv_val[STRLENOF( "cn=" )],
|
||||||
mi->mi_ad_monitorOpInitiated->ad_cname.bv_val,
|
mi->mi_ad_monitorOpInitiated->ad_cname.bv_val,
|
||||||
mi->mi_ad_monitorOpCompleted->ad_cname.bv_val,
|
mi->mi_ad_monitorOpCompleted->ad_cname.bv_val,
|
||||||
mi->mi_creatorsName.bv_val,
|
mi->mi_creatorsName.bv_val,
|
||||||
|
|
@ -107,8 +109,8 @@ monitor_subsys_ops_init(
|
||||||
if ( e == NULL ) {
|
if ( e == NULL ) {
|
||||||
Debug( LDAP_DEBUG_ANY,
|
Debug( LDAP_DEBUG_ANY,
|
||||||
"monitor_subsys_ops_init: "
|
"monitor_subsys_ops_init: "
|
||||||
"unable to create entry 'cn=%s,%s'\n",
|
"unable to create entry \"%s,%s\"\n",
|
||||||
bv_op[ i ].bv_val,
|
monitor_op[ i ].rdn.bv_val,
|
||||||
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn.bv_val, 0 );
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn.bv_val, 0 );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
@ -124,8 +126,8 @@ monitor_subsys_ops_init(
|
||||||
if ( monitor_cache_add( mi, e ) ) {
|
if ( monitor_cache_add( mi, e ) ) {
|
||||||
Debug( LDAP_DEBUG_ANY,
|
Debug( LDAP_DEBUG_ANY,
|
||||||
"monitor_subsys_ops_init: "
|
"monitor_subsys_ops_init: "
|
||||||
"unable to add entry 'cn=%s,%s'\n",
|
"unable to add entry \"%s,%s\"\n",
|
||||||
bv_op[ i ].bv_val,
|
monitor_op[ i ].rdn.bv_val,
|
||||||
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn.bv_val, 0 );
|
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn.bv_val, 0 );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
@ -147,33 +149,58 @@ monitor_subsys_ops_update(
|
||||||
Entry *e
|
Entry *e
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
|
struct monitorinfo *mi =
|
||||||
long nInitiated = 0, nCompleted = 0;
|
(struct monitorinfo *)op->o_bd->be_private;
|
||||||
char *rdnvalue;
|
|
||||||
|
#ifdef HAVE_GMP
|
||||||
|
mpz_t nInitiated,
|
||||||
|
nCompleted;
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
unsigned long nInitiated = 0,
|
||||||
|
nCompleted = 0;
|
||||||
|
char buf[] = "+9223372036854775807L";
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
struct berval rdn;
|
||||||
int i;
|
int i;
|
||||||
Attribute *a;
|
Attribute *a;
|
||||||
char buf[] = "+9223372036854775807L";
|
static struct berval bv_ops = BER_BVC( "cn=operations" );
|
||||||
|
|
||||||
assert( mi );
|
assert( mi );
|
||||||
assert( e );
|
assert( e );
|
||||||
|
|
||||||
rdnvalue = e->e_dn + ( sizeof( "cn=" ) - 1 );
|
dnRdn( &e->e_nname, &rdn );
|
||||||
|
|
||||||
if ( strncmp( rdnvalue, SLAPD_MONITOR_OPS_NAME,
|
if ( dn_match( &rdn, &bv_ops ) ) {
|
||||||
sizeof( SLAPD_MONITOR_OPS_NAME ) - 1 ) == 0 )
|
#ifdef HAVE_GMP
|
||||||
{
|
mpz_init( nInitiated );
|
||||||
|
mpz_init( nCompleted );
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
|
||||||
|
ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex );
|
||||||
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
|
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
|
||||||
nInitiated += num_ops_initiated_[ i ];
|
#ifdef HAVE_GMP
|
||||||
nCompleted += num_ops_completed_[ i ];
|
mpz_add( nInitiated, nInitiated, slap_counters.sc_ops_initiated_[ i ] );
|
||||||
|
mpz_add( nCompleted, nCompleted, slap_counters.sc_ops_completed_[ i ] );
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
nInitiated += slap_counter.sc_ops_initiated_[ i ];
|
||||||
|
nCompleted += slap_counter.sc_ops_completed_[ i ];
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
}
|
}
|
||||||
|
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
|
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
|
||||||
if ( strncmp( rdnvalue, bv_op[ i ].bv_val,
|
if ( dn_match( &rdn, &monitor_op[ i ].nrdn ) )
|
||||||
bv_op[ i ].bv_len ) == 0 )
|
|
||||||
{
|
{
|
||||||
nInitiated = num_ops_initiated_[ i ];
|
ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex );
|
||||||
nCompleted = num_ops_completed_[ i ];
|
#ifdef HAVE_GMP
|
||||||
|
mpz_init_set( nInitiated, slap_counters.sc_ops_initiated_[ i ] );
|
||||||
|
mpz_init_set( nCompleted, slap_counters.sc_ops_completed_[ i ] );
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
nInitiated = slap_counter.sc_ops_initiated_[ i ];
|
||||||
|
nCompleted = slap_counter.sc_ops_completed_[ i ];
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -186,15 +213,45 @@ monitor_subsys_ops_update(
|
||||||
|
|
||||||
a = attr_find( e->e_attrs, mi->mi_ad_monitorOpInitiated );
|
a = attr_find( e->e_attrs, mi->mi_ad_monitorOpInitiated );
|
||||||
assert ( a != NULL );
|
assert ( a != NULL );
|
||||||
snprintf( buf, sizeof( buf ), "%ld", nInitiated );
|
|
||||||
free( a->a_vals[ 0 ].bv_val );
|
free( a->a_vals[ 0 ].bv_val );
|
||||||
|
#ifdef HAVE_GMP
|
||||||
|
/* NOTE: there should be no minus sign allowed in the counters... */
|
||||||
|
a->a_vals[ 0 ].bv_len = mpz_sizeinbase( nInitiated, 10 );
|
||||||
|
a->a_vals[ 0 ].bv_val = ber_memalloc( a->a_vals[ 0 ].bv_len + 1 );
|
||||||
|
(void)mpz_get_str( a->a_vals[ 0 ].bv_val, 10, nInitiated );
|
||||||
|
mpz_clear( nInitiated );
|
||||||
|
/* NOTE: according to the documentation, the result
|
||||||
|
* of mpz_sizeinbase() can exceed the length of the
|
||||||
|
* string representation of the number by 1
|
||||||
|
*/
|
||||||
|
if ( a->a_vals[ 0 ].bv_val[ a->a_vals[ 0 ].bv_len - 1 ] == '\0' ) {
|
||||||
|
a->a_vals[ 0 ].bv_len--;
|
||||||
|
}
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
snprintf( buf, sizeof( buf ), "%ld", nInitiated );
|
||||||
ber_str2bv( buf, 0, 1, &a->a_vals[ 0 ] );
|
ber_str2bv( buf, 0, 1, &a->a_vals[ 0 ] );
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
|
||||||
a = attr_find( e->e_attrs, mi->mi_ad_monitorOpCompleted );
|
a = attr_find( e->e_attrs, mi->mi_ad_monitorOpCompleted );
|
||||||
assert ( a != NULL );
|
assert ( a != NULL );
|
||||||
snprintf( buf, sizeof( buf ), "%ld", nCompleted );
|
|
||||||
free( a->a_vals[ 0 ].bv_val );
|
free( a->a_vals[ 0 ].bv_val );
|
||||||
|
#ifdef HAVE_GMP
|
||||||
|
/* NOTE: there should be no minus sign allowed in the counters... */
|
||||||
|
a->a_vals[ 0 ].bv_len = mpz_sizeinbase( nCompleted, 10 );
|
||||||
|
a->a_vals[ 0 ].bv_val = ber_memalloc( a->a_vals[ 0 ].bv_len + 1 );
|
||||||
|
(void)mpz_get_str( a->a_vals[ 0 ].bv_val, 10, nCompleted );
|
||||||
|
mpz_clear( nCompleted );
|
||||||
|
/* NOTE: according to the documentation, the result
|
||||||
|
* of mpz_sizeinbase() can exceed the length of the
|
||||||
|
* string representation of the number by 1
|
||||||
|
*/
|
||||||
|
if ( a->a_vals[ 0 ].bv_val[ a->a_vals[ 0 ].bv_len - 1 ] == '\0' ) {
|
||||||
|
a->a_vals[ 0 ].bv_len--;
|
||||||
|
}
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
snprintf( buf, sizeof( buf ), "%ld", nCompleted );
|
||||||
ber_str2bv( buf, 0, 1, &a->a_vals[ 0 ] );
|
ber_str2bv( buf, 0, 1, &a->a_vals[ 0 ] );
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,10 @@ struct monitor_sent_t {
|
||||||
struct berval rdn;
|
struct berval rdn;
|
||||||
struct berval nrdn;
|
struct berval nrdn;
|
||||||
} monitor_sent[] = {
|
} monitor_sent[] = {
|
||||||
|
{ BER_BVC("cn=Bytes"), BER_BVC("cn=bytes") },
|
||||||
|
{ BER_BVC("cn=PDU"), BER_BVC("cn=pdu") },
|
||||||
{ BER_BVC("cn=Entries"), BER_BVC("cn=entries") },
|
{ BER_BVC("cn=Entries"), BER_BVC("cn=entries") },
|
||||||
{ BER_BVC("cn=Referrals"), BER_BVC("cn=referrals") },
|
{ BER_BVC("cn=Referrals"), BER_BVC("cn=referrals") },
|
||||||
{ BER_BVC("cn=PDU"), BER_BVC("cn=pdu") },
|
|
||||||
{ BER_BVC("cn=Bytes"), BER_BVC("cn=bytes") },
|
|
||||||
{ BER_BVNULL, BER_BVNULL }
|
{ BER_BVNULL, BER_BVNULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -150,9 +150,15 @@ monitor_subsys_sent_update(
|
||||||
(struct monitorinfo *)op->o_bd->be_private;
|
(struct monitorinfo *)op->o_bd->be_private;
|
||||||
|
|
||||||
struct berval rdn;
|
struct berval rdn;
|
||||||
|
#ifdef HAVE_GMP
|
||||||
|
mpz_t n;
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
unsigned long n;
|
unsigned long n;
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
Attribute *a;
|
Attribute *a;
|
||||||
|
#ifndef HAVE_GMP
|
||||||
char buf[] = "+9223372036854775807L";
|
char buf[] = "+9223372036854775807L";
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
assert( mi );
|
assert( mi );
|
||||||
|
|
@ -170,37 +176,68 @@ monitor_subsys_sent_update(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ldap_pvt_thread_mutex_lock(&num_sent_mutex);
|
ldap_pvt_thread_mutex_lock(&slap_counters.sc_sent_mutex);
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
case MONITOR_SENT_ENTRIES:
|
case MONITOR_SENT_ENTRIES:
|
||||||
n = num_entries_sent;
|
#ifdef HAVE_GMP
|
||||||
|
mpz_init_set( n, slap_counters.sc_entries );
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
n = slap_counters.sc_entries;
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MONITOR_SENT_REFERRALS:
|
case MONITOR_SENT_REFERRALS:
|
||||||
n = num_refs_sent;
|
#ifdef HAVE_GMP
|
||||||
|
mpz_init_set( n, slap_counters.sc_refs );
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
n = slap_counters.sc_refs;
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MONITOR_SENT_PDU:
|
case MONITOR_SENT_PDU:
|
||||||
n = num_pdu_sent;
|
#ifdef HAVE_GMP
|
||||||
|
mpz_init_set( n, slap_counters.sc_pdu );
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
n = slap_counters.sc_pdu;
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MONITOR_SENT_BYTES:
|
case MONITOR_SENT_BYTES:
|
||||||
n = num_bytes_sent;
|
#ifdef HAVE_GMP
|
||||||
|
mpz_init_set( n, slap_counters.sc_bytes );
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
n = slap_counters.sc_bytes;
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
|
ldap_pvt_thread_mutex_unlock(&slap_counters.sc_sent_mutex);
|
||||||
|
|
||||||
a = attr_find( e->e_attrs, mi->mi_ad_monitorCounter );
|
a = attr_find( e->e_attrs, mi->mi_ad_monitorCounter );
|
||||||
if ( a == NULL ) {
|
if ( a == NULL ) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf( buf, sizeof( buf ), "%lu", n );
|
|
||||||
free( a->a_vals[ 0 ].bv_val );
|
free( a->a_vals[ 0 ].bv_val );
|
||||||
|
#ifdef HAVE_GMP
|
||||||
|
/* NOTE: there should be no minus sign allowed in the counters... */
|
||||||
|
a->a_vals[ 0 ].bv_len = mpz_sizeinbase( n, 10 );
|
||||||
|
a->a_vals[ 0 ].bv_val = ber_memalloc( a->a_vals[ 0 ].bv_len + 1 );
|
||||||
|
(void)mpz_get_str( a->a_vals[ 0 ].bv_val, 10, n );
|
||||||
|
mpz_clear( n );
|
||||||
|
/* NOTE: according to the documentation, the result
|
||||||
|
* of mpz_sizeinbase() can exceed the length of the
|
||||||
|
* string representation of the number by 1
|
||||||
|
*/
|
||||||
|
if ( a->a_vals[ 0 ].bv_val[ a->a_vals[ 0 ].bv_len - 1 ] == '\0' ) {
|
||||||
|
a->a_vals[ 0 ].bv_len--;
|
||||||
|
}
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
snprintf( buf, sizeof( buf ), "%lu", n );
|
||||||
ber_str2bv( buf, 0, 1, &a->a_vals[ 0 ] );
|
ber_str2bv( buf, 0, 1, &a->a_vals[ 0 ] );
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -865,14 +865,41 @@ void connection_done( Connection *c )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef SLAPD_MONITOR
|
#ifdef SLAPD_MONITOR
|
||||||
#define INCR_OP(var,index) \
|
#ifdef HAVE_GMP
|
||||||
|
#define INCR_OP_INITIATED(index) \
|
||||||
do { \
|
do { \
|
||||||
ldap_pvt_thread_mutex_lock( &num_ops_mutex ); \
|
ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); \
|
||||||
(var)[(index)]++; \
|
mpz_add_ui(slap_counters.sc_ops_initiated_[(index)], \
|
||||||
ldap_pvt_thread_mutex_unlock( &num_ops_mutex ); \
|
slap_counters.sc_ops_initiated_[(index)], 1); \
|
||||||
|
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#define INCR_OP_COMPLETED(index) \
|
||||||
|
do { \
|
||||||
|
ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); \
|
||||||
|
mpz_add_ui(slap_counters.sc_ops_completed, \
|
||||||
|
slap_counters.sc_ops_completed, 1); \
|
||||||
|
mpz_add_ui(slap_counters.sc_ops_completed_[(index)], \
|
||||||
|
slap_counters.sc_ops_completed_[(index)], 1); \
|
||||||
|
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); \
|
||||||
|
} while (0)
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
#define INCR_OP_INITIATED(index) \
|
||||||
|
do { \
|
||||||
|
ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); \
|
||||||
|
slap_counters.sc_ops_initiated_[(index)]++; \
|
||||||
|
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); \
|
||||||
|
} while (0)
|
||||||
|
#define INCR_OP_COMPLETED(index) \
|
||||||
|
do { \
|
||||||
|
ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); \
|
||||||
|
slap_counters.sc_ops_completed++; \
|
||||||
|
slap_counters.sc_ops_completed_[(index)]++; \
|
||||||
|
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); \
|
||||||
|
} while (0)
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
#else /* !SLAPD_MONITOR */
|
#else /* !SLAPD_MONITOR */
|
||||||
#define INCR_OP(var,index)
|
#define INCR_OP_INITIATED(index)
|
||||||
|
#define INCR_OP_COMPLETED(index)
|
||||||
#endif /* !SLAPD_MONITOR */
|
#endif /* !SLAPD_MONITOR */
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
|
@ -890,9 +917,13 @@ connection_operation( void *ctx, void *arg_v )
|
||||||
void *memctx_null = NULL;
|
void *memctx_null = NULL;
|
||||||
ber_len_t memsiz;
|
ber_len_t memsiz;
|
||||||
|
|
||||||
ldap_pvt_thread_mutex_lock( &num_ops_mutex );
|
ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex );
|
||||||
num_ops_initiated++;
|
#ifdef HAVE_GMP
|
||||||
ldap_pvt_thread_mutex_unlock( &num_ops_mutex );
|
mpz_add_ui(slap_counters.sc_ops_initiated, slap_counters.sc_ops_initiated, 1);
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
slap_counters.sc_ops_initiated++;
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex );
|
||||||
|
|
||||||
op->o_threadctx = ctx;
|
op->o_threadctx = ctx;
|
||||||
|
|
||||||
|
|
@ -952,52 +983,52 @@ connection_operation( void *ctx, void *arg_v )
|
||||||
|
|
||||||
switch ( tag ) {
|
switch ( tag ) {
|
||||||
case LDAP_REQ_BIND:
|
case LDAP_REQ_BIND:
|
||||||
INCR_OP(num_ops_initiated_, SLAP_OP_BIND);
|
INCR_OP_INITIATED(SLAP_OP_BIND);
|
||||||
rc = do_bind( op, &rs );
|
rc = do_bind( op, &rs );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LDAP_REQ_UNBIND:
|
case LDAP_REQ_UNBIND:
|
||||||
INCR_OP(num_ops_initiated_, SLAP_OP_UNBIND);
|
INCR_OP_INITIATED(SLAP_OP_UNBIND);
|
||||||
rc = do_unbind( op, &rs );
|
rc = do_unbind( op, &rs );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LDAP_REQ_ADD:
|
case LDAP_REQ_ADD:
|
||||||
INCR_OP(num_ops_initiated_, SLAP_OP_ADD);
|
INCR_OP_INITIATED(SLAP_OP_ADD);
|
||||||
rc = do_add( op, &rs );
|
rc = do_add( op, &rs );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LDAP_REQ_DELETE:
|
case LDAP_REQ_DELETE:
|
||||||
INCR_OP(num_ops_initiated_, SLAP_OP_DELETE);
|
INCR_OP_INITIATED(SLAP_OP_DELETE);
|
||||||
rc = do_delete( op, &rs );
|
rc = do_delete( op, &rs );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LDAP_REQ_MODRDN:
|
case LDAP_REQ_MODRDN:
|
||||||
INCR_OP(num_ops_initiated_, SLAP_OP_MODRDN);
|
INCR_OP_INITIATED(SLAP_OP_MODRDN);
|
||||||
rc = do_modrdn( op, &rs );
|
rc = do_modrdn( op, &rs );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LDAP_REQ_MODIFY:
|
case LDAP_REQ_MODIFY:
|
||||||
INCR_OP(num_ops_initiated_, SLAP_OP_MODIFY);
|
INCR_OP_INITIATED(SLAP_OP_MODIFY);
|
||||||
rc = do_modify( op, &rs );
|
rc = do_modify( op, &rs );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LDAP_REQ_COMPARE:
|
case LDAP_REQ_COMPARE:
|
||||||
INCR_OP(num_ops_initiated_, SLAP_OP_COMPARE);
|
INCR_OP_INITIATED(SLAP_OP_COMPARE);
|
||||||
rc = do_compare( op, &rs );
|
rc = do_compare( op, &rs );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LDAP_REQ_SEARCH:
|
case LDAP_REQ_SEARCH:
|
||||||
INCR_OP(num_ops_initiated_, SLAP_OP_SEARCH);
|
INCR_OP_INITIATED(SLAP_OP_SEARCH);
|
||||||
rc = do_search( op, &rs );
|
rc = do_search( op, &rs );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LDAP_REQ_ABANDON:
|
case LDAP_REQ_ABANDON:
|
||||||
INCR_OP(num_ops_initiated_, SLAP_OP_ABANDON);
|
INCR_OP_INITIATED(SLAP_OP_ABANDON);
|
||||||
rc = do_abandon( op, &rs );
|
rc = do_abandon( op, &rs );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LDAP_REQ_EXTENDED:
|
case LDAP_REQ_EXTENDED:
|
||||||
INCR_OP(num_ops_initiated_, SLAP_OP_EXTENDED);
|
INCR_OP_INITIATED(SLAP_OP_EXTENDED);
|
||||||
rc = do_extended( op, &rs );
|
rc = do_extended( op, &rs );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -1009,47 +1040,44 @@ connection_operation( void *ctx, void *arg_v )
|
||||||
operations_error:
|
operations_error:
|
||||||
if( rc == SLAPD_DISCONNECT ) tag = LBER_ERROR;
|
if( rc == SLAPD_DISCONNECT ) tag = LBER_ERROR;
|
||||||
|
|
||||||
ldap_pvt_thread_mutex_lock( &num_ops_mutex );
|
|
||||||
|
|
||||||
num_ops_completed++;
|
|
||||||
#ifdef SLAPD_MONITOR
|
#ifdef SLAPD_MONITOR
|
||||||
switch (oldtag) {
|
switch (oldtag) {
|
||||||
case LDAP_REQ_BIND:
|
case LDAP_REQ_BIND:
|
||||||
num_ops_completed_[SLAP_OP_BIND]++;
|
INCR_OP_COMPLETED(SLAP_OP_BIND);
|
||||||
break;
|
break;
|
||||||
case LDAP_REQ_UNBIND:
|
case LDAP_REQ_UNBIND:
|
||||||
num_ops_completed_[SLAP_OP_UNBIND]++;
|
INCR_OP_COMPLETED(SLAP_OP_UNBIND);
|
||||||
break;
|
break;
|
||||||
case LDAP_REQ_ADD:
|
case LDAP_REQ_ADD:
|
||||||
num_ops_completed_[SLAP_OP_ADD]++;
|
INCR_OP_COMPLETED(SLAP_OP_ADD);
|
||||||
break;
|
break;
|
||||||
case LDAP_REQ_DELETE:
|
case LDAP_REQ_DELETE:
|
||||||
num_ops_completed_[SLAP_OP_DELETE]++;
|
INCR_OP_COMPLETED(SLAP_OP_DELETE);
|
||||||
break;
|
break;
|
||||||
case LDAP_REQ_MODRDN:
|
case LDAP_REQ_MODRDN:
|
||||||
num_ops_completed_[SLAP_OP_MODRDN]++;
|
INCR_OP_COMPLETED(SLAP_OP_MODRDN);
|
||||||
break;
|
break;
|
||||||
case LDAP_REQ_MODIFY:
|
case LDAP_REQ_MODIFY:
|
||||||
num_ops_completed_[SLAP_OP_MODIFY]++;
|
INCR_OP_COMPLETED(SLAP_OP_MODIFY);
|
||||||
break;
|
break;
|
||||||
case LDAP_REQ_COMPARE:
|
case LDAP_REQ_COMPARE:
|
||||||
num_ops_completed_[SLAP_OP_COMPARE]++;
|
INCR_OP_COMPLETED(SLAP_OP_COMPARE);
|
||||||
break;
|
break;
|
||||||
case LDAP_REQ_SEARCH:
|
case LDAP_REQ_SEARCH:
|
||||||
num_ops_completed_[SLAP_OP_SEARCH]++;
|
INCR_OP_COMPLETED(SLAP_OP_SEARCH);
|
||||||
break;
|
break;
|
||||||
case LDAP_REQ_ABANDON:
|
case LDAP_REQ_ABANDON:
|
||||||
num_ops_completed_[SLAP_OP_ABANDON]++;
|
INCR_OP_COMPLETED(SLAP_OP_ABANDON);
|
||||||
break;
|
break;
|
||||||
case LDAP_REQ_EXTENDED:
|
case LDAP_REQ_EXTENDED:
|
||||||
num_ops_completed_[SLAP_OP_EXTENDED]++;
|
INCR_OP_COMPLETED(SLAP_OP_EXTENDED);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* not reachable */
|
/* not reachable */
|
||||||
assert( 0 );
|
assert( 0 );
|
||||||
}
|
}
|
||||||
#endif /* SLAPD_MONITOR */
|
#endif /* SLAPD_MONITOR */
|
||||||
ldap_pvt_thread_mutex_unlock( &num_ops_mutex );
|
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex );
|
||||||
|
|
||||||
if ( op->o_cancel == SLAP_CANCEL_REQ ) {
|
if ( op->o_cancel == SLAP_CANCEL_REQ ) {
|
||||||
op->o_cancel = LDAP_TOO_LATE;
|
op->o_cancel = LDAP_TOO_LATE;
|
||||||
|
|
|
||||||
|
|
@ -72,19 +72,8 @@ ldap_pvt_thread_mutex_t gmtime_mutex;
|
||||||
ldap_pvt_thread_mutex_t passwd_mutex;
|
ldap_pvt_thread_mutex_t passwd_mutex;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned long num_ops_initiated = 0;
|
slap_counters_t slap_counters;
|
||||||
unsigned long num_ops_completed = 0;
|
|
||||||
#ifdef SLAPD_MONITOR
|
|
||||||
unsigned long num_ops_initiated_[SLAP_OP_LAST];
|
|
||||||
unsigned long num_ops_completed_[SLAP_OP_LAST];
|
|
||||||
#endif /* SLAPD_MONITOR */
|
|
||||||
ldap_pvt_thread_mutex_t num_ops_mutex;
|
|
||||||
|
|
||||||
unsigned long num_entries_sent;
|
|
||||||
unsigned long num_refs_sent;
|
|
||||||
unsigned long num_bytes_sent;
|
|
||||||
unsigned long num_pdu_sent;
|
|
||||||
ldap_pvt_thread_mutex_t num_sent_mutex;
|
|
||||||
/*
|
/*
|
||||||
* these mutexes must be used when calling the entry2str()
|
* these mutexes must be used when calling the entry2str()
|
||||||
* routine since it returns a pointer to static data.
|
* routine since it returns a pointer to static data.
|
||||||
|
|
@ -99,6 +88,7 @@ int
|
||||||
slap_init( int mode, const char *name )
|
slap_init( int mode, const char *name )
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
int i;
|
||||||
|
|
||||||
assert( mode );
|
assert( mode );
|
||||||
|
|
||||||
|
|
@ -130,18 +120,39 @@ slap_init( int mode, const char *name )
|
||||||
|
|
||||||
ldap_pvt_thread_mutex_init( &entry2str_mutex );
|
ldap_pvt_thread_mutex_init( &entry2str_mutex );
|
||||||
ldap_pvt_thread_mutex_init( &replog_mutex );
|
ldap_pvt_thread_mutex_init( &replog_mutex );
|
||||||
ldap_pvt_thread_mutex_init( &num_ops_mutex );
|
|
||||||
ldap_pvt_thread_mutex_init( &num_sent_mutex );
|
ldap_pvt_thread_mutex_init( &slap_counters.sc_sent_mutex );
|
||||||
|
ldap_pvt_thread_mutex_init( &slap_counters.sc_ops_mutex );
|
||||||
|
#ifdef HAVE_GMP
|
||||||
|
mpz_init( slap_counters.sc_bytes );
|
||||||
|
mpz_init( slap_counters.sc_pdu );
|
||||||
|
mpz_init( slap_counters.sc_entries );
|
||||||
|
mpz_init( slap_counters.sc_refs );
|
||||||
|
|
||||||
|
mpz_init( slap_counters.sc_ops_completed );
|
||||||
|
mpz_init( slap_counters.sc_ops_initiated );
|
||||||
|
|
||||||
#ifdef SLAPD_MONITOR
|
#ifdef SLAPD_MONITOR
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
|
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
|
||||||
num_ops_initiated_[ i ] = 0;
|
mpz_init( slap_counters.sc_ops_initiated_[ i ] );
|
||||||
num_ops_completed_[ i ] = 0;
|
mpz_init( slap_counters.sc_ops_completed_[ i ] );
|
||||||
}
|
}
|
||||||
|
#endif /* SLAPD_MONITOR */
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
slap_counters.sc_bytes = 0;
|
||||||
|
slap_counters.sc_pdu = 0;
|
||||||
|
slap_counters.sc_entries = 0;
|
||||||
|
slap_counters.sc_refs = 0;
|
||||||
|
|
||||||
|
slap_counters.sc_ops_completed = 0;
|
||||||
|
slap_counters.sc_ops_initiated = 0;
|
||||||
|
#ifdef SLAPD_MONITOR
|
||||||
|
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
|
||||||
|
slap_counters.sc_ops_initiated_[ i ] = 0;
|
||||||
|
slap_counters.sc_ops_completed_[ i ] = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* SLAPD_MONITOR */
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
|
||||||
#ifndef HAVE_GMTIME_R
|
#ifndef HAVE_GMTIME_R
|
||||||
ldap_pvt_thread_mutex_init( &gmtime_mutex );
|
ldap_pvt_thread_mutex_init( &gmtime_mutex );
|
||||||
|
|
@ -220,6 +231,7 @@ int slap_shutdown( Backend *be )
|
||||||
int slap_destroy(void)
|
int slap_destroy(void)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
int i;
|
||||||
|
|
||||||
Debug( LDAP_DEBUG_TRACE,
|
Debug( LDAP_DEBUG_TRACE,
|
||||||
"%s destroy: freeing system resources.\n",
|
"%s destroy: freeing system resources.\n",
|
||||||
|
|
@ -232,6 +244,38 @@ int slap_destroy(void)
|
||||||
|
|
||||||
entry_destroy();
|
entry_destroy();
|
||||||
|
|
||||||
|
switch ( slapMode & SLAP_MODE ) {
|
||||||
|
case SLAP_SERVER_MODE:
|
||||||
|
case SLAP_TOOL_MODE:
|
||||||
|
|
||||||
|
ldap_pvt_thread_mutex_destroy( &slap_counters.sc_sent_mutex );
|
||||||
|
ldap_pvt_thread_mutex_destroy( &slap_counters.sc_ops_mutex );
|
||||||
|
#ifdef HAVE_GMP
|
||||||
|
mpz_clear( slap_counters.sc_bytes );
|
||||||
|
mpz_clear( slap_counters.sc_pdu );
|
||||||
|
mpz_clear( slap_counters.sc_entries );
|
||||||
|
mpz_clear( slap_counters.sc_refs );
|
||||||
|
mpz_clear( slap_counters.sc_ops_completed );
|
||||||
|
mpz_clear( slap_counters.sc_ops_initiated );
|
||||||
|
|
||||||
|
#ifdef SLAPD_MONITOR
|
||||||
|
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
|
||||||
|
mpz_clear( slap_counters.sc_ops_initiated_[ i ] );
|
||||||
|
mpz_clear( slap_counters.sc_ops_completed_[ i ] );
|
||||||
|
}
|
||||||
|
#endif /* SLAPD_MONITOR */
|
||||||
|
#endif /* HAVE_GMP */
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"slap_destroy(): undefined mode (%d).\n", slapMode, 0, 0 );
|
||||||
|
|
||||||
|
rc = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ldap_pvt_thread_destroy();
|
ldap_pvt_thread_destroy();
|
||||||
|
|
||||||
/* should destory the above mutex */
|
/* should destory the above mutex */
|
||||||
|
|
|
||||||
|
|
@ -640,6 +640,11 @@ LDAP_SLAPD_F (int) filter_escape_value LDAP_P(( struct berval *in,
|
||||||
|
|
||||||
LDAP_SLAPD_F (int) test_filter LDAP_P(( Operation *op, Entry *e, Filter *f ));
|
LDAP_SLAPD_F (int) test_filter LDAP_P(( Operation *op, Entry *e, Filter *f ));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* frontend.c
|
||||||
|
*/
|
||||||
|
LDAP_SLAPD_F (int) frontend_init LDAP_P(( void ));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* globals.c
|
* globals.c
|
||||||
*/
|
*/
|
||||||
|
|
@ -1317,19 +1322,7 @@ LDAP_SLAPD_V (int) ldap_syslog;
|
||||||
LDAP_SLAPD_V (struct berval) default_search_base;
|
LDAP_SLAPD_V (struct berval) default_search_base;
|
||||||
LDAP_SLAPD_V (struct berval) default_search_nbase;
|
LDAP_SLAPD_V (struct berval) default_search_nbase;
|
||||||
|
|
||||||
LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) num_sent_mutex;
|
LDAP_SLAPD_V (slap_counters_t) slap_counters;
|
||||||
LDAP_SLAPD_V (unsigned long) num_bytes_sent;
|
|
||||||
LDAP_SLAPD_V (unsigned long) num_pdu_sent;
|
|
||||||
LDAP_SLAPD_V (unsigned long) num_entries_sent;
|
|
||||||
LDAP_SLAPD_V (unsigned long) num_refs_sent;
|
|
||||||
|
|
||||||
LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) num_ops_mutex;
|
|
||||||
LDAP_SLAPD_V (unsigned long) num_ops_completed;
|
|
||||||
LDAP_SLAPD_V (unsigned long) num_ops_initiated;
|
|
||||||
#ifdef SLAPD_MONITOR
|
|
||||||
LDAP_SLAPD_V (unsigned long) num_ops_completed_[SLAP_OP_LAST];
|
|
||||||
LDAP_SLAPD_V (unsigned long) num_ops_initiated_[SLAP_OP_LAST];
|
|
||||||
#endif /* SLAPD_MONITOR */
|
|
||||||
|
|
||||||
LDAP_SLAPD_V (char *) slapd_pid_file;
|
LDAP_SLAPD_V (char *) slapd_pid_file;
|
||||||
LDAP_SLAPD_V (char *) slapd_args_file;
|
LDAP_SLAPD_V (char *) slapd_args_file;
|
||||||
|
|
|
||||||
|
|
@ -447,10 +447,15 @@ send_ldap_response(
|
||||||
}
|
}
|
||||||
#endif /* LDAP_SLAPI */
|
#endif /* LDAP_SLAPI */
|
||||||
|
|
||||||
ldap_pvt_thread_mutex_lock( &num_sent_mutex );
|
ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex );
|
||||||
num_bytes_sent += bytes;
|
#ifdef HAVE_GMP
|
||||||
num_pdu_sent++;
|
mpz_add_ui( slap_counters.sc_pdu, slap_counters.sc_pdu, 1 );
|
||||||
ldap_pvt_thread_mutex_unlock( &num_sent_mutex );
|
mpz_add_ui( slap_counters.sc_bytes, slap_counters.sc_bytes, bytes );
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
slap_counters.sc_bytes += bytes;
|
||||||
|
slap_counters.sc_pdu++;
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex );
|
||||||
|
|
||||||
cleanup:;
|
cleanup:;
|
||||||
/* Tell caller that we did this for real, as opposed to being
|
/* Tell caller that we did this for real, as opposed to being
|
||||||
|
|
@ -1175,11 +1180,17 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
|
||||||
}
|
}
|
||||||
rs->sr_nentries++;
|
rs->sr_nentries++;
|
||||||
|
|
||||||
ldap_pvt_thread_mutex_lock( &num_sent_mutex );
|
ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex );
|
||||||
num_bytes_sent += bytes;
|
#ifdef HAVE_GMP
|
||||||
num_entries_sent++;
|
mpz_add_ui( slap_counters.sc_bytes, slap_counters.sc_bytes, bytes );
|
||||||
num_pdu_sent++;
|
mpz_add_ui( slap_counters.sc_entries, slap_counters.sc_entries, 1 );
|
||||||
ldap_pvt_thread_mutex_unlock( &num_sent_mutex );
|
mpz_add_ui( slap_counters.sc_pdu, slap_counters.sc_pdu, 1 );
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
slap_counters.sc_bytes += bytes;
|
||||||
|
slap_counters.sc_entries++;
|
||||||
|
slap_counters.sc_pdu++;
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
Statslog( LDAP_DEBUG_STATS2, "conn=%lu op=%lu ENTRY dn=\"%s\"\n",
|
Statslog( LDAP_DEBUG_STATS2, "conn=%lu op=%lu ENTRY dn=\"%s\"\n",
|
||||||
|
|
@ -1364,11 +1375,17 @@ slap_send_search_reference( Operation *op, SlapReply *rs )
|
||||||
bytes = send_ldap_ber( op->o_conn, ber );
|
bytes = send_ldap_ber( op->o_conn, ber );
|
||||||
ber_free_buf( ber );
|
ber_free_buf( ber );
|
||||||
|
|
||||||
ldap_pvt_thread_mutex_lock( &num_sent_mutex );
|
ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex );
|
||||||
num_bytes_sent += bytes;
|
#ifdef HAVE_GMP
|
||||||
num_refs_sent++;
|
mpz_add_ui( slap_counters.sc_bytes, slap_counters.sc_bytes, bytes );
|
||||||
num_pdu_sent++;
|
mpz_add_ui( slap_counters.sc_refs, slap_counters.sc_refs, 1 );
|
||||||
ldap_pvt_thread_mutex_unlock( &num_sent_mutex );
|
mpz_add_ui( slap_counters.sc_pdu, slap_counters.sc_pdu, 1 );
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
slap_counters.sc_bytes += bytes;
|
||||||
|
slap_counters.sc_refs++;
|
||||||
|
slap_counters.sc_pdu++;
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex );
|
||||||
#ifdef LDAP_CONNECTIONLESS
|
#ifdef LDAP_CONNECTIONLESS
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,10 @@
|
||||||
|
|
||||||
#include "ldap_defaults.h"
|
#include "ldap_defaults.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_GMP
|
||||||
|
#include <gmp.h>
|
||||||
|
#endif /* HAVE_GMP */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ac/stdlib.h>
|
#include <ac/stdlib.h>
|
||||||
|
|
||||||
|
|
@ -2424,6 +2428,49 @@ enum {
|
||||||
};
|
};
|
||||||
#endif /* SLAPD_MONITOR */
|
#endif /* SLAPD_MONITOR */
|
||||||
|
|
||||||
|
typedef struct slap_counters_t {
|
||||||
|
ldap_pvt_thread_mutex_t sc_sent_mutex;
|
||||||
|
#ifdef HAVE_GMP
|
||||||
|
mpz_t sc_bytes;
|
||||||
|
mpz_t sc_pdu;
|
||||||
|
mpz_t sc_entries;
|
||||||
|
mpz_t sc_refs;
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
unsigned long sc_bytes;
|
||||||
|
unsigned long sc_pdu;
|
||||||
|
unsigned long sc_entries;
|
||||||
|
unsigned long sc_refs;
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
|
||||||
|
ldap_pvt_thread_mutex_t sc_ops_mutex;
|
||||||
|
#ifdef HAVE_GMP
|
||||||
|
mpz_t sc_ops_completed;
|
||||||
|
mpz_t sc_ops_initiated;
|
||||||
|
#ifdef SLAPD_MONITOR
|
||||||
|
mpz_t sc_ops_completed_[SLAP_OP_LAST];
|
||||||
|
mpz_t sc_ops_initiated_[SLAP_OP_LAST];
|
||||||
|
#endif /* SLAPD_MONITOR */
|
||||||
|
#else /* ! HAVE_GMP */
|
||||||
|
unsigned long sc_ops_completed;
|
||||||
|
unsigned long sc_ops_initiated;
|
||||||
|
#ifdef SLAPD_MONITOR
|
||||||
|
unsigned long sc_ops_completed_[SLAP_OP_LAST];
|
||||||
|
unsigned long sc_ops_initiated_[SLAP_OP_LAST];
|
||||||
|
#endif /* SLAPD_MONITOR */
|
||||||
|
#endif /* ! HAVE_GMP */
|
||||||
|
} slap_counters_t;
|
||||||
|
|
||||||
|
#define num_sent_mutex slap_counters.sc_sent_mutex
|
||||||
|
#define num_bytes_sent slap_counters.sc_bytes
|
||||||
|
#define num_pdu_sent slap_counters.sc_pdu
|
||||||
|
#define num_entries_sent slap_counters.sc_entries
|
||||||
|
#define num_refs_sent slap_counters.sc_refs
|
||||||
|
#define num_ops_mutex slap_counters.sc_ops_mutex
|
||||||
|
#define num_ops_completed slap_counters.sc_ops_completed
|
||||||
|
#define num_ops_initiated slap_counters.sc_ops_initiated
|
||||||
|
#define num_ops_completed_ slap_counters.sc_ops_completed_
|
||||||
|
#define num_ops_initiated_ slap_counters.sc_ops_initiated_
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Better know these all around slapd
|
* Better know these all around slapd
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue