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
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,
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 ----------------------------------------------------------------
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 <openssl/crypto.h>
+#elif HAVE_CRYPTO_H
+#include <crypto.h>
+#endif /* HAVE_OPENSSL_CRYPTO_H || HAVE_CRYPTO_H */
+#ifdef HAVE_OPENSSL_BN_H
+#include <openssl/bn.h>
+#elif HAVE_BN_H
+#include <bn.h>
+#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 <gmp.h>
#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
#include <ac/string.h>
#include <ac/time.h>
-#include "ldap_pvt.h"
#include "slap.h"
#include "lutil.h"
}
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;
#include <ac/time.h>
#include <ac/socket.h>
-#include "ldap_pvt.h"
#include "slap.h"
#ifdef LDAP_SLAPI
#include <ac/string.h>
#include <ac/time.h>
-#include "ldap_pvt.h"
#include "slap.h"
#include <ac/string.h>
#include <ac/time.h>
-#include "ldap_pvt.h"
#include "slap.h"
void
#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"
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;
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 );
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;
}
/* 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 );
}
/* 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
} \
(bv)->bv_len = len; \
} while ( 0 )
-#else /* ! HAVE_GMP */
+#else /* ! HAVE_BIGNUM && ! HAVE_GMP */
#define UI2BV(bv,ui) \
do { \
char buf[] = "+9223372036854775807L"; \
#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
{
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 );
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 );
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;
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 );
}
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 ),
}
/* 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 );
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;
}
}
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:
/* 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;
}
#include "slap.h"
#include "back-passwd.h"
-#include <ldap_pvt.h>
static void pw_start( Backend *be );
#include "ac/string.h"
#include "slap.h"
-#include "ldap_pvt.h"
#include "proto-sql.h"
/*
#include "ac/string.h"
#include "slap.h"
-#include "lber_pvt.h"
-#include "ldap_pvt.h"
#include "proto-sql.h"
static backsql_api *backsqlapi;
#include "ac/string.h"
#include "slap.h"
-#include "ldap_pvt.h"
#include "proto-sql.h"
typedef struct backsql_delete_attr_t {
#include <sys/types.h>
#include "ac/string.h"
-#include "lber_pvt.h"
-#include "ldap_pvt.h"
#include "slap.h"
#include "proto-sql.h"
#include "ac/string.h"
#include "slap.h"
-#include "ldap_pvt.h"
#include "proto-sql.h"
#if SLAPD_SQL == SLAPD_MOD_DYNAMIC
#include "ac/string.h"
#include "slap.h"
-#include "ldap_pvt.h"
#include "proto-sql.h"
int
#include "ac/string.h"
#include "slap.h"
-#include "ldap_pvt.h"
#include "proto-sql.h"
int
#include "ac/string.h"
#include "slap.h"
-#include "lber_pvt.h"
-#include "ldap_pvt.h"
#include "proto-sql.h"
#define BACKSQL_DUPLICATE (-1)
#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 );
#include <sys/types.h>
#include "slap.h"
-#include "ldap_pvt.h"
#include "proto-sql.h"
#define MAX_ATTR_LEN 16384
#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))
#include <ac/string.h>
#include <ac/socket.h>
-#include "ldap_pvt.h"
#include "slap.h"
#ifdef LDAP_SLAPI
#include "slapi/slapi.h"
#include <ac/socket.h>
#include <ac/string.h>
-#include "ldap_pvt.h"
#include "slap.h"
#ifdef LDAP_SLAPI
#include "slapi/slapi.h"
#include <ac/string.h>
#include <ac/socket.h>
-#include "ldap_pvt.h"
#include "lutil.h"
#include <ldap.h>
#include "slap.h"
#include <ac/socket.h>
#include <ac/errno.h>
-#include "ldap_pvt.h"
#include "slap.h"
#ifdef LDAP_SLAPI
#include "slapi/slapi.h"
#include <ac/time.h>
#include <ac/unistd.h>
-#include "ldap_pvt.h"
#include "lutil.h"
#include "slap.h"
*/
#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)
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;
#include <ac/socket.h>
#include "slap.h"
-#include "ldap_pvt.h"
struct cindexrec {
struct berval cir_name;
#include <ac/string.h>
#include <ac/socket.h>
-#include "ldap_pvt.h"
#include "lutil.h"
#include "slap.h"
#include "lutil_ldap.h"
#include <ac/unistd.h>
#include "slap.h"
-#include "ldap_pvt.h"
#include "ldap_pvt_thread.h"
#include "lutil.h"
#include <ac/string.h>
#include <ac/socket.h>
-#include "ldap_pvt.h"
#include "slap.h"
#include "lutil.h"
#include <ac/time.h>
#include "slap.h"
-#include "ldap_pvt.h" /* must be after slap.h, to get ldap_bv2dn_x() & co */
#include "lutil.h"
/*
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 );
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:
#include <ac/string.h>
#include <ac/socket.h>
-#include "ldap_pvt.h"
#include "lutil.h"
#include "slap.h"
#include "../../libraries/liblber/lber-int.h" /* get ber_strndup() */
#include <ac/wait.h>
#include <ac/errno.h>
-#include "ldap_pvt.h"
-
#include "slap.h"
#include "lutil.h"
#include "ldif.h"
#include <ac/string.h>
#include <ac/time.h>
-#include "ldap_pvt.h"
#include "slap.h"
#ifdef LDAP_SLAPI
#include "slapi/slapi.h"
#include <ac/socket.h>
#include <ac/string.h>
-#include "ldap_pvt.h"
#include "slap.h"
#ifdef LDAP_SLAPI
#include "slapi/slapi.h"
#include <ac/socket.h>
#include "slap.h"
-#include "ldap_pvt.h"
struct mindexrec {
struct berval mir_name;
#include <ac/socket.h>
#include "slap.h"
-#include "ldap_pvt.h"
int is_object_subclass(
ObjectClass *sup,
#include <ac/time.h>
#include "slap.h"
-#include "ldap_pvt.h"
#include "lutil.h"
#include "ldap_rq.h"
#include <ac/time.h>
#include <ac/unistd.h>
-#include <ldap_pvt.h>
-
#include "slap.h"
/*
#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:;
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 );
}
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
}
#endif
-#include "ldap_pvt.h"
-#include "lber_pvt.h"
#include <lutil.h>
static struct berval ext_bv = BER_BVC( "EXTERNAL" );
#include <limits.h>
-#include <ldap_pvt.h>
#include "lutil.h"
#define SASLREGEX_REPLACE 10
#include <ac/socket.h>
#include "slap.h"
-#include "ldap_pvt.h"
#include "lutil.h"
#include <ac/socket.h>
#include "slap.h"
-#include "ldap_pvt.h"
static char * oc_check_required(
Entry *e,
#include <ac/socket.h>
#include "slap.h"
-#include "ldap_pvt.h"
-#include "lber_pvt.h"
#include "ldap_utf8.h"
#include <ac/socket.h>
#include "slap.h"
-#include "ldap_pvt.h"
-#include "ldap_pvt_uc.h"
#define OCDEBUG 0
#include <ac/string.h>
#include <ac/socket.h>
-#include "ldap_pvt.h"
#include "lutil.h"
#include "slap.h"
#include <ac/string.h>
#include <ac/socket.h>
-#include "ldap_pvt.h"
#include "lutil.h"
#include "slap.h"
#include "lutil_ldap.h"
#include <ac/time.h>
#include <ac/param.h>
-#ifdef HAVE_GMP
-#include <gmp.h>
-#endif /* HAVE_GMP */
-
#include "avl.h"
#ifndef ldap_debug
#include <ldap_schema.h>
#include "lber_pvt.h"
+#include "ldap_pvt.h"
#include "ldap_pvt_thread.h"
#include "ldap_queue.h"
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
*/
#include <ac/stdarg.h>
#include <ac/ctype.h>
#include <ac/unistd.h>
-#include <ldap_pvt.h>
#include <slap.h>
#include <slapi.h>
#include <ac/stdarg.h>
#include <ac/ctype.h>
#include <ac/unistd.h>
-#include <ldap_pvt.h>
#include <slap.h>
#include <slapi.h>
#include <stdio.h>
#include <ac/socket.h>
-#include <ldap_pvt.h>
-
#include "slap.h"
#ifdef HAVE_TLS
#include <ac/socket.h>
#include "slap.h"
-#include <ldap_pvt.h>
#if 0 /* unused */
static char *find_matching_paren( const char *s );
#include <ac/string.h>
#include <ac/socket.h>
-#include "ldap_pvt.h"
#include "lutil.h"
#include "slap.h"
#include "lutil_ldap.h"
#include <ac/socket.h>
#include "slap.h"
-#include "ldap_pvt.h"
struct sindexrec {
char *sir_name;