From: Pierangelo Masarati Date: Sun, 26 Sep 2004 22:58:47 +0000 (+0000) Subject: multiple precision with BIGNUM/gmp/ulong X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~499 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=761f2879435deec0dc8369de98381557de416b89;p=openldap multiple precision with BIGNUM/gmp/ulong --- diff --git a/configure.in b/configure.in index db0cbaf7f4..9f1752049a 100644 --- a/configure.in +++ b/configure.in @@ -171,6 +171,10 @@ OL_ARG_WITH(tls,[ --with-tls with TLS/SSL support], auto, [auto ssleay openssl yes no] ) OL_ARG_WITH(yielding_select,[ --with-yielding-select with implicitly yielding select], auto, [auto yes no manual] ) +OL_ARG_WITH(multiple_precision,[ --with-multiple-precision + multiple precision support for statistics + auto|bignum|gmp], + auto, [auto bignum gmp yes no] ) dnl ---------------------------------------------------------------- dnl Server options @@ -1207,10 +1211,11 @@ fi dnl ---------------------------------------------------------------- dnl TLS/SSL + ol_link_tls=no if test $ol_with_tls != no ; then AC_CHECK_HEADERS(openssl/ssl.h ssl.h) - + if test $ac_cv_header_openssl_ssl_h = yes \ -o $ac_cv_header_ssl_h = yes ; then AC_CHECK_LIB(ssl, SSLeay_add_ssl_algorithms, @@ -2230,15 +2235,96 @@ if test $ol_enable_slp != no ; then fi dnl ---------------------------------------------------------------- -dnl Check for GMP API Library -AC_CHECK_HEADERS( gmp.h ) +dnl Check for multiple precision support +if test "$ol_with_multiple_precision" != "no" ; then + ol_have_bignum=no + ol_have_gmp=no + + AC_CHECK_HEADERS(openssl/bn.h bn.h) + AC_CHECK_HEADERS(openssl/crypto.h crypto.h) + AC_CHECK_HEADERS( gmp.h ) + + if test "$ol_with_tls" = "found" ; then + ol_have_bn_h=no + ol_have_crypto_h=no + + if test "$ac_cv_header_openssl_bn_h" = "yes" \ + -o "$ac_cv_header_bn_h" = "yes" ; then + ol_have_bn_h=yes + fi + + if test "$ac_cv_header_openssl_crypto_h" = "yes" \ + -o "$ac_cv_header_crypto_h" = "yes" ; then + ol_have_crypto_h=yes + fi + + if test "$ol_have_bn_h" = "yes" \ + -a "$ol_have_crypto_h" = "yes" ; then + ol_have_bignum=yes + fi + fi + + 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 + ol_have_gmp=yes + fi + fi -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_MSG_CHECKING([for multiple precision support]) + + ol_mp_support="none" + case "$ol_with_multiple_precision" in + auto) + dnl preferred sequence: + dnl - OpenSSL's BIGNUM (if libssl is already linked) + dnl - GNU's MP + dnl - unsigned long + if test "$ol_have_bignum" = "yes" ; then + ol_mp_support="bignum" + else + if test "$ol_have_gmp" = "yes" ; then + ol_mp_support="gmp" + fi + fi + ;; + bignum) + if test "$ol_have_bignum" != "yes" ; then + AC_MSG_ERROR([OpenSSL's BIGNUM not available]) + fi + ol_mp_support="bignum" + ;; + gmp) + if test "$ol_have_gmp" != "yes" ; then + AC_MSG_ERROR([GMP not available]) + fi + ol_mp_support="gmp" + ;; + yes) + if test "$ol_have_bignum" = "yes" ; then + ol_mp_support="bignum" + elif test "$ol_have_gmp" = "yes" ; then + ol_mp_support="gmp" + else + AC_MSG_ERROR([not available]) + fi + ;; + esac + + case "$ol_mp_support" in + bignum) + AC_DEFINE(HAVE_BIGNUM, 1, + [define if you have SSLeay or OpenSSL's BIGNUM]) + ;; + gmp) AC_DEFINE(HAVE_GMP, 1, [define if you have -lgmp]) SLAPD_GMP_LIBS=-lgmp - fi + ;; + none) + ;; + esac + + AC_MSG_RESULT($ol_mp_support) fi dnl ---------------------------------------------------------------- diff --git a/include/ldap_pvt.h b/include/ldap_pvt.h index f218223acf..ea73f3c539 100644 --- a/include/ldap_pvt.h +++ b/include/ldap_pvt.h @@ -249,7 +249,95 @@ LDAP_F (int) ldap_pvt_tls_get_strength LDAP_P(( void *ctx )); LDAP_END_DECL -#include "ldap_pvt_uc.h" +/* + * Multiple precision stuff + * + * May use OpenSSL's BIGNUM if built with TLS, + * or GNU's multiple precision library. + * + * If none is available, unsigned long data is used. + */ +#ifdef HAVE_BIGNUM +/* + * Use OpenSSL's BIGNUM + */ +#if defined(HAVE_OPENSSL_CRYPTO_H) +#include +#elif HAVE_CRYPTO_H +#include +#endif /* HAVE_OPENSSL_CRYPTO_H || HAVE_CRYPTO_H */ +#ifdef HAVE_OPENSSL_BN_H +#include +#elif HAVE_BN_H +#include +#endif /* HAVE_OPENSSL_BN_H || HAVE_BN_H */ + +typedef BIGNUM* ldap_pvt_mp_t; + +#define ldap_pvt_mp_init(mp) \ + do { (mp) = BN_new(); BN_init((mp)); } while (0) +/* FIXME: we rely on mpr being initialized */ +#define ldap_pvt_mp_init_set(mpr,mpv) \ + do { ldap_pvt_mp_init((mpr)); BN_add((mpr), (mpr), (mpv)); } while (0) + +#define ldap_pvt_mp_add(mpr,mpv) \ + BN_add((mpr), (mpr), (mpv)) + +#define ldap_pvt_mp_add_ulong(mp,v) \ + BN_add_word((mp), (v)) + +#define ldap_pvt_mp_clear(mp) \ + do { BN_free((mp)); (mp) = 0; } while (0) + +#elif defined(HAVE_GMP) +/* + * Use GNU's multiple precision library + */ +#ifdef HAVE_GMP_H +#include #endif +typedef mpz_t ldap_pvt_mp_t; +#define ldap_pvt_mp_init(mp) \ + mpz_init((mp)) + +#define ldap_pvt_mp_init_set(mpr,mpv) \ + mpz_init_set((mpr), (mpv)) + +#define ldap_pvt_mp_add(mpr,mpv) \ + mpz_add((mpr), (mpr), (mpv)) + +#define ldap_pvt_mp_add_ulong(mp,v) \ + mpz_add_ui((mp), (mp), (v)) + +#define ldap_pvt_mp_clear(mp) \ + mpz_clear((mp)) + +#else /* ! HAVE_BIGNUM && ! HAVE_GMP */ +/* + * Use unsigned long + */ + +typedef unsigned long ldap_pvt_mp_t; + +#define ldap_pvt_mp_init(mp) \ + (mp) = 0 + +#define ldap_pvt_mp_init_set(mpr,mpv) \ + (mpr) = (mpv) + +#define ldap_pvt_mp_add(mpr,mpv) \ + (mpr) += (mpv) + +#define ldap_pvt_mp_add_ulong(mp,v) \ + (mp) += (v) + +#define ldap_pvt_mp_clear(mp) \ + (mp) = 0 + +#endif /* ! HAVE_BIGNUM && ! HAVE_GMP */ + +#include "ldap_pvt_uc.h" + +#endif diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index 9b5805363e..5b26440975 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -24,7 +24,6 @@ #include #include -#include "ldap_pvt.h" #include "slap.h" #include "lutil.h" @@ -793,6 +792,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr ) } an = ch_realloc( an, ( i + j + 1 ) * sizeof( AttributeName ) ); + BER_BVZERO( &an[i + j].an_name ); anew = an + i; for ( s = ldap_pvt_strtok( str, brkstr, &lasts ); s != NULL; diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 086efa4ba7..1c3a5f2766 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -30,7 +30,6 @@ #include #include -#include "ldap_pvt.h" #include "slap.h" #ifdef LDAP_SLAPI diff --git a/servers/slapd/at.c b/servers/slapd/at.c index 740a2b7ef5..bc3d12f53e 100644 --- a/servers/slapd/at.c +++ b/servers/slapd/at.c @@ -24,7 +24,6 @@ #include #include -#include "ldap_pvt.h" #include "slap.h" diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index 87bfb97a5b..70600c4eb9 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -38,7 +38,6 @@ #include #include -#include "ldap_pvt.h" #include "slap.h" void diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index b3266084a4..a399805a7c 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -31,7 +31,6 @@ #include "slap.h" #include "../back-ldap/back-ldap.h" #include "back-meta.h" -#include "ldap_pvt.h" #undef ldap_debug /* silence a warning in ldap-int.h */ #include "ldap_log.h" #include "../../../libraries/libldap/ldap-int.h" diff --git a/servers/slapd/back-monitor/operation.c b/servers/slapd/back-monitor/operation.c index a04aab28d0..96c635bdba 100644 --- a/servers/slapd/back-monitor/operation.c +++ b/servers/slapd/back-monitor/operation.c @@ -159,13 +159,8 @@ monitor_subsys_ops_update( struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private; -#ifdef HAVE_GMP - mpz_t nInitiated, + ldap_pvt_mp_t nInitiated, nCompleted; -#else /* ! HAVE_GMP */ - unsigned long nInitiated = 0, - nCompleted = 0; -#endif /* ! HAVE_GMP */ struct berval rdn; int i; Attribute *a; @@ -177,20 +172,13 @@ monitor_subsys_ops_update( dnRdn( &e->e_nname, &rdn ); if ( dn_match( &rdn, &bv_ops ) ) { -#ifdef HAVE_GMP - mpz_init( nInitiated ); - mpz_init( nCompleted ); -#endif /* HAVE_GMP */ + ldap_pvt_mp_init( nInitiated ); + ldap_pvt_mp_init( nCompleted ); ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); for ( i = 0; i < SLAP_OP_LAST; i++ ) { -#ifdef HAVE_GMP - 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_counters.sc_ops_initiated_[ i ]; - nCompleted += slap_counters.sc_ops_completed_[ i ]; -#endif /* ! HAVE_GMP */ + ldap_pvt_mp_add( nInitiated, slap_counters.sc_ops_initiated_[ i ] ); + ldap_pvt_mp_add( nCompleted, slap_counters.sc_ops_completed_[ i ] ); } ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); @@ -199,13 +187,8 @@ monitor_subsys_ops_update( if ( dn_match( &rdn, &monitor_op[ i ].nrdn ) ) { ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); -#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_counters.sc_ops_initiated_[ i ]; - nCompleted = slap_counters.sc_ops_completed_[ i ]; -#endif /* ! HAVE_GMP */ + ldap_pvt_mp_init_set( nInitiated, slap_counters.sc_ops_initiated_[ i ] ); + ldap_pvt_mp_init_set( nCompleted, slap_counters.sc_ops_completed_[ i ] ); ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); break; } @@ -222,18 +205,14 @@ monitor_subsys_ops_update( /* NOTE: no minus sign is allowed in the counters... */ UI2BV( &a->a_vals[ 0 ], nInitiated ); -#ifdef HAVE_GMP - mpz_clear( nInitiated ); -#endif /* HAVE_GMP */ + ldap_pvt_mp_clear( nInitiated ); a = attr_find( e->e_attrs, mi->mi_ad_monitorOpCompleted ); assert ( a != NULL ); /* NOTE: no minus sign is allowed in the counters... */ UI2BV( &a->a_vals[ 0 ], nCompleted ); -#ifdef HAVE_GMP - mpz_clear( nCompleted ); -#endif /* HAVE_GMP */ + ldap_pvt_mp_clear( nCompleted ); return( 0 ); } diff --git a/servers/slapd/back-monitor/proto-back-monitor.h b/servers/slapd/back-monitor/proto-back-monitor.h index cfda44b07b..f1643e924b 100644 --- a/servers/slapd/back-monitor/proto-back-monitor.h +++ b/servers/slapd/back-monitor/proto-back-monitor.h @@ -99,7 +99,26 @@ int monitor_subsys_time_update LDAP_P(( Operation *op, Entry *e )); /* NOTE: this macro assumes that bv has been allocated * by ber_* malloc functions or is { 0L, NULL } */ -#ifdef HAVE_GMP +#if defined(HAVE_BIGNUM) +#define UI2BV(bv,ui) \ + do { \ + char *val; \ + ber_len_t len; \ + val = BN_bn2dec(ui); \ + if (val) { \ + len = strlen(val); \ + if ( len > (bv)->bv_len ) { \ + (bv)->bv_val = ber_memrealloc( (bv)->bv_val, len + 1 ); \ + } \ + AC_MEMCPY((bv)->bv_val, val, len + 1); \ + (bv)->bv_len = len; \ + OPENSSL_free(val); \ + } else { \ + ber_memfree( (bv)->bv_val ); \ + BER_BVZERO( (bv) ); \ + } \ + } while ( 0 ) +#elif defined(HAVE_GMP) /* NOTE: according to the documentation, the result * of mpz_sizeinbase() can exceed the length of the * string representation of the number by 1 @@ -116,7 +135,7 @@ int monitor_subsys_time_update LDAP_P(( Operation *op, Entry *e )); } \ (bv)->bv_len = len; \ } while ( 0 ) -#else /* ! HAVE_GMP */ +#else /* ! HAVE_BIGNUM && ! HAVE_GMP */ #define UI2BV(bv,ui) \ do { \ char buf[] = "+9223372036854775807L"; \ diff --git a/servers/slapd/back-monitor/rww.c b/servers/slapd/back-monitor/rww.c index 60ad9f468d..6a4c70d540 100644 --- a/servers/slapd/back-monitor/rww.c +++ b/servers/slapd/back-monitor/rww.c @@ -28,6 +28,22 @@ #include "lutil.h" #include "back-monitor.h" +enum { + MONITOR_RWW_READ = 0, + MONITOR_RWW_WRITE, + + MONITOR_RWW_LAST +}; + +struct monitor_rww_t { + struct berval rdn; + struct berval nrdn; +} monitor_rww[] = { + { BER_BVC("cn=Read"), BER_BVNULL }, + { BER_BVC("cn=Write"), BER_BVNULL }, + { BER_BVNULL, BER_BVNULL } +}; + int monitor_subsys_rww_init( BackendDB *be @@ -35,10 +51,9 @@ monitor_subsys_rww_init( { struct monitorinfo *mi; - Entry *e, **ep, *e_conn; + Entry **ep, *e_conn; struct monitorentrypriv *mp; - char buf[ BACKMONITOR_BUFSIZE ]; - struct berval bv; + int i; assert( be != NULL ); @@ -57,109 +72,66 @@ monitor_subsys_rww_init( mp->mp_children = NULL; ep = &mp->mp_children; - /* - * Total conns - */ - snprintf( buf, sizeof( buf ), - "dn: cn=Read,%s\n" - "objectClass: %s\n" - "structuralObjectClass: %s\n" - "cn: Read\n" - "creatorsName: %s\n" - "modifiersName: %s\n" - "createTimestamp: %s\n" - "modifyTimestamp: %s\n", - monitor_subsys[SLAPD_MONITOR_RWW].mss_dn.bv_val, - mi->mi_oc_monitorCounterObject->soc_cname.bv_val, - mi->mi_oc_monitorCounterObject->soc_cname.bv_val, - mi->mi_creatorsName.bv_val, - mi->mi_creatorsName.bv_val, - mi->mi_startTime.bv_val, - mi->mi_startTime.bv_val ); - - e = str2entry( buf ); - if ( e == NULL ) { - Debug( LDAP_DEBUG_ANY, - "monitor_subsys_rww_init: " - "unable to create entry \"cn=Read,%s\"\n", - monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn.bv_val, 0, 0 ); - return( -1 ); - } - - bv.bv_val = "0"; - bv.bv_len = 1; - attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL ); - - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); - e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; - mp->mp_info = &monitor_subsys[SLAPD_MONITOR_RWW]; - mp->mp_flags = monitor_subsys[SLAPD_MONITOR_RWW].mss_flags \ - | MONITOR_F_SUB | MONITOR_F_PERSISTENT; - - if ( monitor_cache_add( mi, e ) ) { - Debug( LDAP_DEBUG_ANY, - "monitor_subsys_rww_init: " - "unable to add entry \"cn=Read,%s\"\n", - monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn.bv_val, 0, 0 ); - return( -1 ); - } - - *ep = e; - ep = &mp->mp_next; - - /* - * Current conns - */ - snprintf( buf, sizeof( buf ), - "dn: cn=Write,%s\n" + for ( i = 0; i < MONITOR_RWW_LAST; i++ ) { + char buf[ BACKMONITOR_BUFSIZE ]; + struct berval nrdn, bv; + Entry *e; + + snprintf( buf, sizeof( buf ), + "dn: %s,%s\n" "objectClass: %s\n" "structuralObjectClass: %s\n" - "cn: Write\n" + "cn: %s\n" "creatorsName: %s\n" "modifiersName: %s\n" "createTimestamp: %s\n" "modifyTimestamp: %s\n", + monitor_rww[i].rdn.bv_val, monitor_subsys[SLAPD_MONITOR_RWW].mss_dn.bv_val, mi->mi_oc_monitorCounterObject->soc_cname.bv_val, mi->mi_oc_monitorCounterObject->soc_cname.bv_val, + &monitor_rww[i].rdn.bv_val[STRLENOF("cn")], mi->mi_creatorsName.bv_val, mi->mi_creatorsName.bv_val, mi->mi_startTime.bv_val, mi->mi_startTime.bv_val ); - e = str2entry( buf ); - if ( e == NULL ) { - Debug( LDAP_DEBUG_ANY, - "monitor_subsys_rww_init: " - "unable to create entry \"cn=Write,%s\"\n", - monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn.bv_val, 0, 0 ); - return( -1 ); - } + e = str2entry( buf ); + if ( e == NULL ) { + Debug( LDAP_DEBUG_ANY, + "monitor_subsys_rww_init: " + "unable to create entry \"cn=Read,%s\"\n", + monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn.bv_val, 0, 0 ); + return( -1 ); + } + + /* steal normalized RDN */ + dnRdn( &e->e_nname, &nrdn ); + ber_dupbv( &monitor_rww[i].nrdn, &nrdn ); - bv.bv_val = "0"; - bv.bv_len = 1; - attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL ); + BER_BVSTR( &bv, "0" ); + attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL ); - mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); - e->e_private = ( void * )mp; - mp->mp_next = NULL; - mp->mp_children = NULL; - mp->mp_info = &monitor_subsys[SLAPD_MONITOR_RWW]; - mp->mp_flags = monitor_subsys[SLAPD_MONITOR_RWW].mss_flags \ - | MONITOR_F_SUB | MONITOR_F_PERSISTENT; - - if ( monitor_cache_add( mi, e ) ) { - Debug( LDAP_DEBUG_ANY, - "monitor_subsys_rww_init: " - "unable to add entry \"cn=Write,%s\"\n", - monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn.bv_val, 0, 0 ); - return( -1 ); - } + mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); + e->e_private = ( void * )mp; + mp->mp_next = NULL; + mp->mp_children = NULL; + mp->mp_info = &monitor_subsys[SLAPD_MONITOR_RWW]; + mp->mp_flags = monitor_subsys[SLAPD_MONITOR_RWW].mss_flags \ + | MONITOR_F_SUB | MONITOR_F_PERSISTENT; + + if ( monitor_cache_add( mi, e ) ) { + Debug( LDAP_DEBUG_ANY, + "monitor_subsys_rww_init: " + "unable to add entry \"%s,%s\"\n", + monitor_rww[i].rdn.bv_val, + monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn.bv_val, 0 ); + return( -1 ); + } - *ep = e; - ep = &mp->mp_next; + *ep = e; + ep = &mp->mp_next; + } monitor_cache_release( mi, e_conn ); @@ -177,49 +149,51 @@ monitor_subsys_rww_update( int connindex; long nconns, nwritewaiters, nreadwaiters; -#define RWW_NONE 0 -#define RWW_READ 1 -#define RWW_WRITE 2 - int type = RWW_NONE; - + int i; + struct berval nrdn; + Attribute *a; char buf[] = "+9223372036854775807L"; long num = 0; + ber_len_t len; assert( mi != NULL ); assert( e != NULL ); - - if ( strncasecmp( e->e_ndn, "cn=read", - sizeof("cn=read")-1 ) == 0 ) { - type = RWW_READ; - } else if ( strncasecmp( e->e_ndn, "cn=write", - sizeof("cn=write")-1 ) == 0 ) { - type = RWW_WRITE; + dnRdn( &e->e_nname, &nrdn ); + + for ( i = 0; !BER_BVISNULL( &monitor_rww[i].nrdn ); i++ ) { + if ( dn_match( &nrdn, &monitor_rww[i].nrdn ) ) { + break; + } + } - } else { - return( 0 ); + if ( i == MONITOR_RWW_LAST ) { + return 0; } nconns = nwritewaiters = nreadwaiters = 0; for ( c = connection_first( &connindex ); c != NULL; - c = connection_next( c, &connindex ), nconns++ ) { + c = connection_next( c, &connindex ), nconns++ ) + { if ( c->c_writewaiter ) { nwritewaiters++; } + + /* FIXME: ?!? */ if ( c->c_currentber != NULL ) { nreadwaiters++; } } connection_done(c); - switch ( type ) { - case RWW_READ: + switch ( i ) { + case MONITOR_RWW_READ: num = nreadwaiters; break; - case RWW_WRITE: + case MONITOR_RWW_WRITE: num = nwritewaiters; break; @@ -231,8 +205,16 @@ monitor_subsys_rww_update( a = attr_find( e->e_attrs, mi->mi_ad_monitorCounter ); assert( a ); - free( a->a_vals[0].bv_val ); - ber_str2bv( buf, 0, 1, &a->a_vals[ 0 ] ); + len = strlen( buf ); + if ( len > a->a_vals[0].bv_len ) { + a->a_vals[0].bv_val = ber_memrealloc( a->a_vals[0].bv_val, len + 1 ); + if ( a->a_vals[0].bv_val == NULL ) { + BER_BVZERO( &a->a_vals[0] ); + return( 0 ); + } + } + AC_MEMCPY( a->a_vals[0].bv_val, buf, len + 1 ); + a->a_vals[ 0 ].bv_len = len; return( 0 ); } diff --git a/servers/slapd/back-monitor/sent.c b/servers/slapd/back-monitor/sent.c index f996f9ec55..9f3df46618 100644 --- a/servers/slapd/back-monitor/sent.c +++ b/servers/slapd/back-monitor/sent.c @@ -77,7 +77,7 @@ monitor_subsys_sent_init( for ( i = 0; i < MONITOR_SENT_LAST; i++ ) { char buf[ BACKMONITOR_BUFSIZE ]; - struct berval rdn, bv; + struct berval nrdn, bv; Entry *e; snprintf( buf, sizeof( buf ), @@ -110,8 +110,8 @@ monitor_subsys_sent_init( } /* steal normalized RDN */ - dnRdn( &e->e_nname, &rdn ); - ber_dupbv( &monitor_sent[i].nrdn, &rdn ); + dnRdn( &e->e_nname, &nrdn ); + ber_dupbv( &monitor_sent[i].nrdn, &nrdn ); BER_BVSTR( &bv, "0" ); attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL ); @@ -151,22 +151,18 @@ monitor_subsys_sent_update( struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private; - struct berval rdn; -#ifdef HAVE_GMP - mpz_t n; -#else /* ! HAVE_GMP */ - unsigned long n; -#endif /* ! HAVE_GMP */ + struct berval nrdn; + ldap_pvt_mp_t n; Attribute *a; int i; assert( mi ); assert( e ); - dnRdn( &e->e_nname, &rdn ); + dnRdn( &e->e_nname, &nrdn ); for ( i = 0; i < MONITOR_SENT_LAST; i++ ) { - if ( dn_match( &rdn, &monitor_sent[i].nrdn ) ) { + if ( dn_match( &nrdn, &monitor_sent[i].nrdn ) ) { break; } } @@ -178,35 +174,19 @@ monitor_subsys_sent_update( ldap_pvt_thread_mutex_lock(&slap_counters.sc_sent_mutex); switch ( i ) { case MONITOR_SENT_ENTRIES: -#ifdef HAVE_GMP - mpz_init_set( n, slap_counters.sc_entries ); -#else /* ! HAVE_GMP */ - n = slap_counters.sc_entries; -#endif /* ! HAVE_GMP */ + ldap_pvt_mp_init_set( n, slap_counters.sc_entries ); break; case MONITOR_SENT_REFERRALS: -#ifdef HAVE_GMP - mpz_init_set( n, slap_counters.sc_refs ); -#else /* ! HAVE_GMP */ - n = slap_counters.sc_refs; -#endif /* ! HAVE_GMP */ + ldap_pvt_mp_init_set( n, slap_counters.sc_refs ); break; case MONITOR_SENT_PDU: -#ifdef HAVE_GMP - mpz_init_set( n, slap_counters.sc_pdu ); -#else /* ! HAVE_GMP */ - n = slap_counters.sc_pdu; -#endif /* ! HAVE_GMP */ + ldap_pvt_mp_init_set( n, slap_counters.sc_pdu ); break; case MONITOR_SENT_BYTES: -#ifdef HAVE_GMP - mpz_init_set( n, slap_counters.sc_bytes ); -#else /* ! HAVE_GMP */ - n = slap_counters.sc_bytes; -#endif /* ! HAVE_GMP */ + ldap_pvt_mp_init_set( n, slap_counters.sc_bytes ); break; default: @@ -219,9 +199,7 @@ monitor_subsys_sent_update( /* NOTE: no minus sign is allowed in the counters... */ UI2BV( &a->a_vals[ 0 ], n ); -#ifdef HAVE_GMP - mpz_clear( n ); -#endif /* HAVE_GMP */ + ldap_pvt_mp_clear( n ); return 0; } diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index 1317459fd5..239a1ba67b 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -45,7 +45,6 @@ #include "slap.h" #include "back-passwd.h" -#include static void pw_start( Backend *be ); diff --git a/servers/slapd/back-sql/add.c b/servers/slapd/back-sql/add.c index c0918b8ccf..bf733ff08d 100644 --- a/servers/slapd/back-sql/add.c +++ b/servers/slapd/back-sql/add.c @@ -27,7 +27,6 @@ #include "ac/string.h" #include "slap.h" -#include "ldap_pvt.h" #include "proto-sql.h" /* diff --git a/servers/slapd/back-sql/api.c b/servers/slapd/back-sql/api.c index 431a94495a..715e22b63b 100644 --- a/servers/slapd/back-sql/api.c +++ b/servers/slapd/back-sql/api.c @@ -26,8 +26,6 @@ #include "ac/string.h" #include "slap.h" -#include "lber_pvt.h" -#include "ldap_pvt.h" #include "proto-sql.h" static backsql_api *backsqlapi; diff --git a/servers/slapd/back-sql/delete.c b/servers/slapd/back-sql/delete.c index 29e58c0742..f0f5b58b5f 100644 --- a/servers/slapd/back-sql/delete.c +++ b/servers/slapd/back-sql/delete.c @@ -27,7 +27,6 @@ #include "ac/string.h" #include "slap.h" -#include "ldap_pvt.h" #include "proto-sql.h" typedef struct backsql_delete_attr_t { diff --git a/servers/slapd/back-sql/entry-id.c b/servers/slapd/back-sql/entry-id.c index 0b422d223a..b53384a9aa 100644 --- a/servers/slapd/back-sql/entry-id.c +++ b/servers/slapd/back-sql/entry-id.c @@ -26,8 +26,6 @@ #include #include "ac/string.h" -#include "lber_pvt.h" -#include "ldap_pvt.h" #include "slap.h" #include "proto-sql.h" diff --git a/servers/slapd/back-sql/init.c b/servers/slapd/back-sql/init.c index 9924349930..24d6d201f6 100644 --- a/servers/slapd/back-sql/init.c +++ b/servers/slapd/back-sql/init.c @@ -27,7 +27,6 @@ #include "ac/string.h" #include "slap.h" -#include "ldap_pvt.h" #include "proto-sql.h" #if SLAPD_SQL == SLAPD_MOD_DYNAMIC diff --git a/servers/slapd/back-sql/modify.c b/servers/slapd/back-sql/modify.c index 1a528091d8..2e43e13c12 100644 --- a/servers/slapd/back-sql/modify.c +++ b/servers/slapd/back-sql/modify.c @@ -27,7 +27,6 @@ #include "ac/string.h" #include "slap.h" -#include "ldap_pvt.h" #include "proto-sql.h" int diff --git a/servers/slapd/back-sql/modrdn.c b/servers/slapd/back-sql/modrdn.c index 83fd4ee0c4..698daed1c7 100644 --- a/servers/slapd/back-sql/modrdn.c +++ b/servers/slapd/back-sql/modrdn.c @@ -27,7 +27,6 @@ #include "ac/string.h" #include "slap.h" -#include "ldap_pvt.h" #include "proto-sql.h" int diff --git a/servers/slapd/back-sql/schema-map.c b/servers/slapd/back-sql/schema-map.c index 8b2d8f678f..fd524e721f 100644 --- a/servers/slapd/back-sql/schema-map.c +++ b/servers/slapd/back-sql/schema-map.c @@ -27,8 +27,6 @@ #include "ac/string.h" #include "slap.h" -#include "lber_pvt.h" -#include "ldap_pvt.h" #include "proto-sql.h" #define BACKSQL_DUPLICATE (-1) diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index 7b1f960e03..f3951734bb 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -28,8 +28,6 @@ #include "ac/ctype.h" #include "slap.h" -#include "lber_pvt.h" -#include "ldap_pvt.h" #include "proto-sql.h" static int backsql_process_filter( backsql_srch_info *bsi, Filter *f ); diff --git a/servers/slapd/back-sql/sql-wrap.c b/servers/slapd/back-sql/sql-wrap.c index ff0fa3d941..f6337fe31e 100644 --- a/servers/slapd/back-sql/sql-wrap.c +++ b/servers/slapd/back-sql/sql-wrap.c @@ -27,7 +27,6 @@ #include #include "slap.h" -#include "ldap_pvt.h" #include "proto-sql.h" #define MAX_ATTR_LEN 16384 diff --git a/servers/slapd/back-sql/util.c b/servers/slapd/back-sql/util.c index 16084ef4ef..41f099ce18 100644 --- a/servers/slapd/back-sql/util.c +++ b/servers/slapd/back-sql/util.c @@ -29,8 +29,6 @@ #include "ac/stdarg.h" #include "slap.h" -#include "lber_pvt.h" -#include "ldap_pvt.h" #include "proto-sql.h" #define BACKSQL_MAX(a,b) ((a)>(b)?(a):(b)) diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index c9d200bfba..55c9e8bb47 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -31,7 +31,6 @@ #include #include -#include "ldap_pvt.h" #include "slap.h" #ifdef LDAP_SLAPI #include "slapi/slapi.h" diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 0ade75a500..6a7d1d47aa 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -29,7 +29,6 @@ #include #include -#include "ldap_pvt.h" #include "slap.h" #ifdef LDAP_SLAPI #include "slapi/slapi.h" diff --git a/servers/slapd/component.c b/servers/slapd/component.c index d0b7e0af61..46559c760c 100644 --- a/servers/slapd/component.c +++ b/servers/slapd/component.c @@ -20,7 +20,6 @@ #include #include -#include "ldap_pvt.h" #include "lutil.h" #include #include "slap.h" diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 0b65dd33df..d44ad0005f 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -34,7 +34,6 @@ #include #include -#include "ldap_pvt.h" #include "slap.h" #ifdef LDAP_SLAPI #include "slapi/slapi.h" diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index d01e907d07..baab32cb15 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -34,7 +34,6 @@ #include #include -#include "ldap_pvt.h" #include "lutil.h" #include "slap.h" @@ -863,38 +862,20 @@ void connection_done( Connection *c ) */ #ifdef SLAPD_MONITOR -#ifdef HAVE_GMP +/* FIXME: returns 0 in case of failure */ #define INCR_OP_INITIATED(index) \ do { \ ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); \ - mpz_add_ui(slap_counters.sc_ops_initiated_[(index)], \ - slap_counters.sc_ops_initiated_[(index)], 1); \ + ldap_pvt_mp_add_ulong(slap_counters.sc_ops_initiated_[(index)], 1); \ 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 ); \ - 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_mp_add_ulong(slap_counters.sc_ops_completed, 1); \ + ldap_pvt_mp_add_ulong(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 */ #define INCR_OP_INITIATED(index) #define INCR_OP_COMPLETED(index) @@ -916,11 +897,8 @@ connection_operation( void *ctx, void *arg_v ) ber_len_t memsiz; ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); -#ifdef HAVE_GMP - 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 */ + /* FIXME: returns 0 in case of failure */ + ldap_pvt_mp_add_ulong(slap_counters.sc_ops_initiated, 1); ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); op->o_threadctx = ctx; diff --git a/servers/slapd/cr.c b/servers/slapd/cr.c index f69c321cb9..4280b740e6 100644 --- a/servers/slapd/cr.c +++ b/servers/slapd/cr.c @@ -23,7 +23,6 @@ #include #include "slap.h" -#include "ldap_pvt.h" struct cindexrec { struct berval cir_name; diff --git a/servers/slapd/ctxcsn.c b/servers/slapd/ctxcsn.c index b67fc7dff9..3080ea312a 100644 --- a/servers/slapd/ctxcsn.c +++ b/servers/slapd/ctxcsn.c @@ -22,7 +22,6 @@ #include #include -#include "ldap_pvt.h" #include "lutil.h" #include "slap.h" #include "lutil_ldap.h" diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index c3e98eb0b2..bd91a1a350 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -35,7 +35,6 @@ #include #include "slap.h" -#include "ldap_pvt.h" #include "ldap_pvt_thread.h" #include "lutil.h" diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index bc502ebf0e..3ee66eac7d 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -30,7 +30,6 @@ #include #include -#include "ldap_pvt.h" #include "slap.h" #include "lutil.h" diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 7f3a34537f..151d6d35ce 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -34,7 +34,6 @@ #include #include "slap.h" -#include "ldap_pvt.h" /* must be after slap.h, to get ldap_bv2dn_x() & co */ #include "lutil.h" /* diff --git a/servers/slapd/init.c b/servers/slapd/init.c index c20bb4bbd6..b7a3fc3bac 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -121,36 +121,20 @@ slap_init( int mode, const char *name ) 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 ); + ldap_pvt_mp_init( slap_counters.sc_bytes ); + ldap_pvt_mp_init( slap_counters.sc_pdu ); + ldap_pvt_mp_init( slap_counters.sc_entries ); + ldap_pvt_mp_init( slap_counters.sc_refs ); - mpz_init( slap_counters.sc_ops_completed ); - mpz_init( slap_counters.sc_ops_initiated ); + ldap_pvt_mp_init( slap_counters.sc_ops_completed ); + ldap_pvt_mp_init( slap_counters.sc_ops_initiated ); #ifdef SLAPD_MONITOR for ( i = 0; i < SLAP_OP_LAST; i++ ) { - mpz_init( slap_counters.sc_ops_initiated_[ i ] ); - mpz_init( slap_counters.sc_ops_completed_[ i ] ); + ldap_pvt_mp_init( slap_counters.sc_ops_initiated_[ i ] ); + ldap_pvt_mp_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 /* SLAPD_MONITOR */ -#endif /* ! HAVE_GMP */ #ifndef HAVE_GMTIME_R ldap_pvt_thread_mutex_init( &gmtime_mutex ); @@ -251,21 +235,19 @@ int slap_destroy(void) 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 ); + ldap_pvt_mp_clear( slap_counters.sc_bytes ); + ldap_pvt_mp_clear( slap_counters.sc_pdu ); + ldap_pvt_mp_clear( slap_counters.sc_entries ); + ldap_pvt_mp_clear( slap_counters.sc_refs ); + ldap_pvt_mp_clear( slap_counters.sc_ops_completed ); + ldap_pvt_mp_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 ] ); + ldap_pvt_mp_clear( slap_counters.sc_ops_initiated_[ i ] ); + ldap_pvt_mp_clear( slap_counters.sc_ops_completed_[ i ] ); } #endif /* SLAPD_MONITOR */ -#endif /* HAVE_GMP */ break; default: diff --git a/servers/slapd/ldapsync.c b/servers/slapd/ldapsync.c index 19c74eb6b5..c0b9161936 100644 --- a/servers/slapd/ldapsync.c +++ b/servers/slapd/ldapsync.c @@ -22,7 +22,6 @@ #include #include -#include "ldap_pvt.h" #include "lutil.h" #include "slap.h" #include "../../libraries/liblber/lber-int.h" /* get ber_strndup() */ diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 01fbf316af..3f5f835d0e 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -34,8 +34,6 @@ #include #include -#include "ldap_pvt.h" - #include "slap.h" #include "lutil.h" #include "ldif.h" diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 1b707e175f..f7dbeb026e 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -31,7 +31,6 @@ #include #include -#include "ldap_pvt.h" #include "slap.h" #ifdef LDAP_SLAPI #include "slapi/slapi.h" diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index f5c8a33bf0..6446a311af 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -38,7 +38,6 @@ #include #include -#include "ldap_pvt.h" #include "slap.h" #ifdef LDAP_SLAPI #include "slapi/slapi.h" diff --git a/servers/slapd/mr.c b/servers/slapd/mr.c index ea1c9bd415..e810c37648 100644 --- a/servers/slapd/mr.c +++ b/servers/slapd/mr.c @@ -23,7 +23,6 @@ #include #include "slap.h" -#include "ldap_pvt.h" struct mindexrec { struct berval mir_name; diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index b31defeaef..fcefc34449 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -23,7 +23,6 @@ #include #include "slap.h" -#include "ldap_pvt.h" int is_object_subclass( ObjectClass *sup, diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index b631a58efd..3b667e5380 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -29,7 +29,6 @@ #include #include "slap.h" -#include "ldap_pvt.h" #include "lutil.h" #include "ldap_rq.h" diff --git a/servers/slapd/referral.c b/servers/slapd/referral.c index 91db896f1c..039e1957f3 100644 --- a/servers/slapd/referral.c +++ b/servers/slapd/referral.c @@ -25,8 +25,6 @@ #include #include -#include - #include "slap.h" /* diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 1f87393182..b2f611c4eb 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -448,13 +448,8 @@ send_ldap_response( #endif /* LDAP_SLAPI */ ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex ); -#ifdef HAVE_GMP - mpz_add_ui( slap_counters.sc_pdu, slap_counters.sc_pdu, 1 ); - 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_mp_add_ulong( slap_counters.sc_pdu, 1 ); + ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, bytes ); ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex ); cleanup:; @@ -1181,15 +1176,9 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) rs->sr_nentries++; ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex ); -#ifdef HAVE_GMP - mpz_add_ui( slap_counters.sc_bytes, slap_counters.sc_bytes, bytes ); - mpz_add_ui( slap_counters.sc_entries, slap_counters.sc_entries, 1 ); - 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_mp_add_ulong( slap_counters.sc_bytes, bytes ); + ldap_pvt_mp_add_ulong( slap_counters.sc_entries, 1 ); + ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 ); ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex ); } @@ -1376,15 +1365,9 @@ slap_send_search_reference( Operation *op, SlapReply *rs ) ber_free_buf( ber ); ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex ); -#ifdef HAVE_GMP - mpz_add_ui( slap_counters.sc_bytes, slap_counters.sc_bytes, bytes ); - mpz_add_ui( slap_counters.sc_refs, slap_counters.sc_refs, 1 ); - 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_mp_add_ulong( slap_counters.sc_bytes, bytes ); + ldap_pvt_mp_add_ulong( slap_counters.sc_refs, 1 ); + ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 ); ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex ); #ifdef LDAP_CONNECTIONLESS } diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index f00d0ab6b8..3363294e01 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -60,8 +60,6 @@ typedef struct sasl_ctx { #endif -#include "ldap_pvt.h" -#include "lber_pvt.h" #include static struct berval ext_bv = BER_BVC( "EXTERNAL" ); diff --git a/servers/slapd/saslauthz.c b/servers/slapd/saslauthz.c index 7b61f06e0c..28044d6993 100644 --- a/servers/slapd/saslauthz.c +++ b/servers/slapd/saslauthz.c @@ -26,7 +26,6 @@ #include -#include #include "lutil.h" #define SASLREGEX_REPLACE 10 diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c index 8f6f2af619..69d243b04d 100644 --- a/servers/slapd/schema.c +++ b/servers/slapd/schema.c @@ -23,7 +23,6 @@ #include #include "slap.h" -#include "ldap_pvt.h" #include "lutil.h" diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index 1a11a0b011..0da634d812 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -23,7 +23,6 @@ #include #include "slap.h" -#include "ldap_pvt.h" static char * oc_check_required( Entry *e, diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index a0e5fe6a06..4390130435 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -25,8 +25,6 @@ #include #include "slap.h" -#include "ldap_pvt.h" -#include "lber_pvt.h" #include "ldap_utf8.h" diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index a368e51e31..e81009a57b 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -23,8 +23,6 @@ #include #include "slap.h" -#include "ldap_pvt.h" -#include "ldap_pvt_uc.h" #define OCDEBUG 0 diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 30532922b9..805e5a180f 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -30,7 +30,6 @@ #include #include -#include "ldap_pvt.h" #include "lutil.h" #include "slap.h" diff --git a/servers/slapd/sessionlog.c b/servers/slapd/sessionlog.c index 2e9bbfca16..a573be6830 100644 --- a/servers/slapd/sessionlog.c +++ b/servers/slapd/sessionlog.c @@ -22,7 +22,6 @@ #include #include -#include "ldap_pvt.h" #include "lutil.h" #include "slap.h" #include "lutil_ldap.h" diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 7234f15db7..e973c363db 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -40,10 +40,6 @@ #include #include -#ifdef HAVE_GMP -#include -#endif /* HAVE_GMP */ - #include "avl.h" #ifndef ldap_debug @@ -56,6 +52,7 @@ #include #include "lber_pvt.h" +#include "ldap_pvt.h" #include "ldap_pvt_thread.h" #include "ldap_queue.h" @@ -2434,47 +2431,20 @@ enum { 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_mp_t sc_bytes; + ldap_pvt_mp_t sc_pdu; + ldap_pvt_mp_t sc_entries; + ldap_pvt_mp_t sc_refs; 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; + ldap_pvt_mp_t sc_ops_completed; + ldap_pvt_mp_t sc_ops_initiated; #ifdef SLAPD_MONITOR - unsigned long sc_ops_completed_[SLAP_OP_LAST]; - unsigned long sc_ops_initiated_[SLAP_OP_LAST]; + ldap_pvt_mp_t sc_ops_completed_[SLAP_OP_LAST]; + ldap_pvt_mp_t 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 */ diff --git a/servers/slapd/slapi/slapi_ext.c b/servers/slapd/slapi/slapi_ext.c index 0bc87bb80f..d83b77a2a8 100644 --- a/servers/slapd/slapi/slapi_ext.c +++ b/servers/slapd/slapi/slapi_ext.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index a4f177246d..7209e43e98 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/servers/slapd/starttls.c b/servers/slapd/starttls.c index 5ed9c5b5ac..cc47ee736d 100644 --- a/servers/slapd/starttls.c +++ b/servers/slapd/starttls.c @@ -18,8 +18,6 @@ #include #include -#include - #include "slap.h" #ifdef HAVE_TLS diff --git a/servers/slapd/str2filter.c b/servers/slapd/str2filter.c index f8b9cfcdf3..39fa95eaec 100644 --- a/servers/slapd/str2filter.c +++ b/servers/slapd/str2filter.c @@ -33,7 +33,6 @@ #include #include "slap.h" -#include #if 0 /* unused */ static char *find_matching_paren( const char *s ); diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 7346da5cd3..696101ab64 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -23,7 +23,6 @@ #include #include -#include "ldap_pvt.h" #include "lutil.h" #include "slap.h" #include "lutil_ldap.h" diff --git a/servers/slapd/syntax.c b/servers/slapd/syntax.c index 711ed6171c..92c1e0681f 100644 --- a/servers/slapd/syntax.c +++ b/servers/slapd/syntax.c @@ -23,7 +23,6 @@ #include #include "slap.h" -#include "ldap_pvt.h" struct sindexrec { char *sir_name;