|
|
74ca47 |
From be621fcd9f2215bba4c9190fd63815dc395814d8 Mon Sep 17 00:00:00 2001
|
|
|
74ca47 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
74ca47 |
Date: Tue, 28 Mar 2017 11:39:16 -0400
|
|
|
74ca47 |
Subject: [PATCH] Issue 48989 - Integer overflow
|
|
|
74ca47 |
|
|
|
74ca47 |
Redo slapi_counters and monitors
|
|
|
74ca47 |
---
|
|
|
74ca47 |
Makefile.am | 4 +-
|
|
|
74ca47 |
configure.ac | 74 +++--
|
|
|
74ca47 |
ldap/servers/plugins/dna/dna.c | 20 +-
|
|
|
74ca47 |
ldap/servers/plugins/posix-winsync/posix-winsync.c | 12 +-
|
|
|
74ca47 |
ldap/servers/plugins/replication/repl5_init.c | 2 +-
|
|
|
74ca47 |
ldap/servers/plugins/replication/repl_extop.c | 2 +-
|
|
|
74ca47 |
ldap/servers/plugins/usn/usn.c | 16 +-
|
|
|
74ca47 |
ldap/servers/slapd/back-ldbm/monitor.c | 4 +-
|
|
|
74ca47 |
ldap/servers/slapd/back-ldbm/perfctrs.c | 12 +-
|
|
|
74ca47 |
ldap/servers/slapd/back-ldbm/perfctrs.h | 74 ++---
|
|
|
74ca47 |
ldap/servers/slapd/back-ldbm/vlv_srch.h | 2 +-
|
|
|
74ca47 |
ldap/servers/slapd/conntable.c | 14 +-
|
|
|
74ca47 |
ldap/servers/slapd/entry.c | 4 +-
|
|
|
74ca47 |
ldap/servers/slapd/log.c | 13 +-
|
|
|
74ca47 |
ldap/servers/slapd/monitor.c | 14 +-
|
|
|
74ca47 |
ldap/servers/slapd/slapi-plugin.h | 14 +-
|
|
|
74ca47 |
ldap/servers/slapd/slapi_counter.c | 333 ++++-----------------
|
|
|
74ca47 |
ldap/servers/slapd/slapi_counter_sunos_sparcv9.S | 105 -------
|
|
|
74ca47 |
ldap/servers/slapd/snmp_collator.c | 2 +-
|
|
|
74ca47 |
test/libslapd/test.c | 2 +
|
|
|
74ca47 |
test/test_slapd.h | 4 +
|
|
|
74ca47 |
21 files changed, 205 insertions(+), 522 deletions(-)
|
|
|
74ca47 |
delete mode 100644 ldap/servers/slapd/slapi_counter_sunos_sparcv9.S
|
|
|
74ca47 |
|
|
|
74ca47 |
diff --git a/Makefile.am b/Makefile.am
|
|
|
74ca47 |
index df4a037..982dd28 100644
|
|
|
74ca47 |
--- a/Makefile.am
|
|
|
74ca47 |
+++ b/Makefile.am
|
|
|
74ca47 |
@@ -1222,9 +1222,6 @@ libslapd_la_SOURCES = ldap/servers/slapd/add.c \
|
|
|
74ca47 |
$(libavl_a_SOURCES)
|
|
|
74ca47 |
|
|
|
74ca47 |
libslapd_la_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) $(SASL_INCLUDES) @db_inc@ $(SVRCORE_INCLUDES) @kerberos_inc@ @pcre_inc@
|
|
|
74ca47 |
-if SPARC
|
|
|
74ca47 |
-libslapd_la_SOURCES += ldap/servers/slapd/slapi_counter_sunos_sparcv9.S
|
|
|
74ca47 |
-endif
|
|
|
74ca47 |
libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(SVRCORE_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LINK) $(PCRE_LINK) $(THREADLIB) $(SYSTEMD_LINK)
|
|
|
74ca47 |
libslapd_la_LDFLAGS = $(AM_LDFLAGS) $(SLAPD_LDFLAGS)
|
|
|
74ca47 |
|
|
|
74ca47 |
@@ -2004,6 +2001,7 @@ TESTS = test_slapd \
|
|
|
74ca47 |
|
|
|
74ca47 |
test_slapd_SOURCES = test/main.c \
|
|
|
74ca47 |
test/libslapd/test.c \
|
|
|
74ca47 |
+ test/libslapd/counters/atomic.c \
|
|
|
74ca47 |
test/libslapd/pblock/analytics.c \
|
|
|
74ca47 |
test/libslapd/pblock/v3_compat.c \
|
|
|
74ca47 |
test/libslapd/operation/v3_compat.c
|
|
|
74ca47 |
diff --git a/configure.ac b/configure.ac
|
|
|
74ca47 |
index 3f2aa75..8172bab 100644
|
|
|
74ca47 |
--- a/configure.ac
|
|
|
74ca47 |
+++ b/configure.ac
|
|
|
74ca47 |
@@ -555,7 +555,6 @@ case $host in
|
|
|
74ca47 |
case $host in
|
|
|
74ca47 |
i*86-*-linux*)
|
|
|
74ca47 |
AC_DEFINE([CPU_x86], [], [cpu type x86])
|
|
|
74ca47 |
- AC_DEFINE([ATOMIC_64BIT_OPERATIONS], [1], [enabling atomic counter])
|
|
|
74ca47 |
;;
|
|
|
74ca47 |
x86_64-*-linux*)
|
|
|
74ca47 |
with_xsixfour="yes"
|
|
|
74ca47 |
@@ -565,23 +564,6 @@ case $host in
|
|
|
74ca47 |
# wibrown -- 2017-02-21 disabled temporarily
|
|
|
74ca47 |
# with_atomic_queue="yes"
|
|
|
74ca47 |
# AC_DEFINE([ATOMIC_QUEUE_OPERATIONS], [1], [enabling atomic queue operations])
|
|
|
74ca47 |
- AC_DEFINE([ATOMIC_64BIT_OPERATIONS], [1], [enabling atomic counter])
|
|
|
74ca47 |
-
|
|
|
74ca47 |
- AC_MSG_CHECKING([for SSE4.2 features ...])
|
|
|
74ca47 |
- save_CFLAGS="$CFLAGS"
|
|
|
74ca47 |
- CFLAGS="$CFLAGS -msse4.2"
|
|
|
74ca47 |
- AC_TRY_COMPILE(
|
|
|
74ca47 |
- [],
|
|
|
74ca47 |
- [return 0;],
|
|
|
74ca47 |
- [
|
|
|
74ca47 |
- AC_DEFINE([HAVE_SSE4_2], [1], [Have sss4.2 on this platform arch])
|
|
|
74ca47 |
- AC_MSG_RESULT([SSE4.2 avaliable on this platform])
|
|
|
74ca47 |
- ],
|
|
|
74ca47 |
- [
|
|
|
74ca47 |
- AC_MSG_RESULT([SSE4.2 not avaliable on this platform])
|
|
|
74ca47 |
- ]
|
|
|
74ca47 |
- )
|
|
|
74ca47 |
- CFLAGS="$save_CFLAGS"
|
|
|
74ca47 |
;;
|
|
|
74ca47 |
aarch64-*-linux*)
|
|
|
74ca47 |
AC_DEFINE([CPU_arm], [], [cpu type arm])
|
|
|
74ca47 |
@@ -600,17 +582,6 @@ case $host in
|
|
|
74ca47 |
s390x-*-linux*)
|
|
|
74ca47 |
;;
|
|
|
74ca47 |
esac
|
|
|
74ca47 |
- AC_MSG_CHECKING([for GCC provided 64-bit atomic bool cas function ...])
|
|
|
74ca47 |
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
|
|
|
74ca47 |
- [[long long ptrval = 0, val = 0, newval = 1; (void)__sync_bool_compare_and_swap_8(&ptrval, val, newval);]])],
|
|
|
74ca47 |
- [AC_DEFINE([HAVE_64BIT_ATOMIC_CAS_FUNC], [1], [have 64-bit atomic bool compare and swap function provided by gcc])AC_MSG_RESULT([yes])],
|
|
|
74ca47 |
- [AC_MSG_RESULT([no])])
|
|
|
74ca47 |
- AC_MSG_CHECKING([for GCC provided 64-bit atomic ops functions ...])
|
|
|
74ca47 |
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
|
|
|
74ca47 |
- [[long long ptrval = 0, val = 0; (void)__sync_add_and_fetch_8(&ptrval, val);]])],
|
|
|
74ca47 |
- [AC_DEFINE([HAVE_64BIT_ATOMIC_OP_FUNCS], [1], [have 64-bit atomic operation functions provided by gcc])AC_MSG_RESULT([yes])],
|
|
|
74ca47 |
- [AC_MSG_RESULT([no])])
|
|
|
74ca47 |
-
|
|
|
74ca47 |
# some programs use the native thread library directly
|
|
|
74ca47 |
THREADLIB=-lpthread
|
|
|
74ca47 |
AC_SUBST([THREADLIB], [$THREADLIB])
|
|
|
74ca47 |
@@ -654,7 +625,6 @@ case $host in
|
|
|
74ca47 |
AC_DEFINE([_POSIX_C_SOURCE], [199506L], [POSIX revision])
|
|
|
74ca47 |
AC_DEFINE([_HPUX_SOURCE], [1], [Source namespace])
|
|
|
74ca47 |
AC_DEFINE([_INCLUDE_STDC__SOURCE_199901], [1], [to pick up all of the printf format macros in inttypes.h])
|
|
|
74ca47 |
- AC_DEFINE([ATOMIC_64BIT_OPERATIONS], [1], [enabling atomic counter])
|
|
|
74ca47 |
# assume 64 bit
|
|
|
74ca47 |
initconfigdir="/$PACKAGE_NAME/config"
|
|
|
74ca47 |
perlexec='/opt/perl_64/bin/perl'
|
|
|
74ca47 |
@@ -689,12 +659,11 @@ dnl Cstd and Crun are required to link any C++ related code
|
|
|
74ca47 |
initdir='$(sysconfdir)/init.d'
|
|
|
74ca47 |
case $host in
|
|
|
74ca47 |
i?86-*-solaris2.1[[0-9]]*)
|
|
|
74ca47 |
-dnl I dont know why i386 need this explicit
|
|
|
74ca47 |
+ dnl I dont know why i386 need this explicit
|
|
|
74ca47 |
AC_DEFINE([HAVE_GETPEERUCRED], [1], [have getpeerucred])
|
|
|
74ca47 |
;;
|
|
|
74ca47 |
sparc-*-solaris*)
|
|
|
74ca47 |
-dnl includes some assembler stuff in counter.o
|
|
|
74ca47 |
- AC_DEFINE([ATOMIC_64BIT_OPERATIONS], [1], [enabling atomic counter])
|
|
|
74ca47 |
+ dnl includes some assembler stuff in counter.o
|
|
|
74ca47 |
AC_DEFINE([CPU_sparc], [], [cpu type sparc])
|
|
|
74ca47 |
TARGET='SPARC'
|
|
|
74ca47 |
;;
|
|
|
74ca47 |
@@ -705,6 +674,45 @@ dnl includes some assembler stuff in counter.o
|
|
|
74ca47 |
;;
|
|
|
74ca47 |
esac
|
|
|
74ca47 |
|
|
|
74ca47 |
+AC_MSG_CHECKING([for SSE4.2 features ...])
|
|
|
74ca47 |
+save_CFLAGS="$CFLAGS"
|
|
|
74ca47 |
+CFLAGS="$CFLAGS -msse4.2"
|
|
|
74ca47 |
+AC_TRY_COMPILE(
|
|
|
74ca47 |
+ [],
|
|
|
74ca47 |
+ [return 0;],
|
|
|
74ca47 |
+ [
|
|
|
74ca47 |
+ AC_DEFINE([HAVE_SSE4_2], [1], [Have sss4.2 on this platform arch])
|
|
|
74ca47 |
+ AC_MSG_RESULT([SSE4.2 avaliable on this platform])
|
|
|
74ca47 |
+ ],
|
|
|
74ca47 |
+ [
|
|
|
74ca47 |
+ AC_MSG_RESULT([SSE4.2 not avaliable on this platform])
|
|
|
74ca47 |
+ ]
|
|
|
74ca47 |
+)
|
|
|
74ca47 |
+CFLAGS="$save_CFLAGS"
|
|
|
74ca47 |
+
|
|
|
74ca47 |
+AC_MSG_CHECKING([for GCC provided 64-bit atomic operations])
|
|
|
74ca47 |
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
|
74ca47 |
+ #include <inttypes.h>
|
|
|
74ca47 |
+ ]],
|
|
|
74ca47 |
+ [[
|
|
|
74ca47 |
+ uint64_t t_counter = 0;
|
|
|
74ca47 |
+ uint64_t t_oldval = 0;
|
|
|
74ca47 |
+ uint64_t t_newval = 1;
|
|
|
74ca47 |
+
|
|
|
74ca47 |
+ __atomic_compare_exchange_8(&t_counter, &t_oldval, t_newval, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
|
|
74ca47 |
+ __atomic_add_fetch_8(&t_counter, t_newval, __ATOMIC_SEQ_CST);
|
|
|
74ca47 |
+ __atomic_sub_fetch_8(&t_counter, t_newval, __ATOMIC_SEQ_CST);
|
|
|
74ca47 |
+ __atomic_load(&t_counter, &t_oldval, __ATOMIC_SEQ_CST);
|
|
|
74ca47 |
+ return 0;
|
|
|
74ca47 |
+ ]])],
|
|
|
74ca47 |
+ [
|
|
|
74ca47 |
+ AC_DEFINE([ATOMIC_64BIT_OPERATIONS], [1], [have 64-bit atomic operation functions provided by gcc])
|
|
|
74ca47 |
+ AC_MSG_RESULT([yes])
|
|
|
74ca47 |
+ ],
|
|
|
74ca47 |
+ [
|
|
|
74ca47 |
+ AC_MSG_RESULT([no])
|
|
|
74ca47 |
+ ]
|
|
|
74ca47 |
+)
|
|
|
74ca47 |
|
|
|
74ca47 |
# cmd line overrides default setting above
|
|
|
74ca47 |
if test -n "$with_initddir" ; then
|
|
|
74ca47 |
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
|
|
|
74ca47 |
index 54bbe86..34011b9 100644
|
|
|
74ca47 |
--- a/ldap/servers/plugins/dna/dna.c
|
|
|
74ca47 |
+++ b/ldap/servers/plugins/dna/dna.c
|
|
|
74ca47 |
@@ -2497,7 +2497,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
|
|
|
74ca47 |
if ((config_entry->maxval == -1) ||
|
|
|
74ca47 |
(nextval <= (config_entry->maxval + config_entry->interval))) {
|
|
|
74ca47 |
/* try to set the new next value in the config entry */
|
|
|
74ca47 |
- PR_snprintf(next_value, sizeof(next_value),"%" NSPRIu64, nextval);
|
|
|
74ca47 |
+ snprintf(next_value, sizeof(next_value),"%" NSPRIu64, nextval);
|
|
|
74ca47 |
|
|
|
74ca47 |
/* set up our replace modify operation */
|
|
|
74ca47 |
replace_val[0] = next_value;
|
|
|
74ca47 |
@@ -2565,13 +2565,13 @@ dna_get_shared_config_attr_val(struct configEntry *config_entry, char *attr, cha
|
|
|
74ca47 |
if(slapi_sdn_compare(server->sdn, server_sdn) == 0){
|
|
|
74ca47 |
if(strcmp(attr, DNA_REMOTE_BIND_METHOD) == 0){
|
|
|
74ca47 |
if (server->remote_bind_method) {
|
|
|
74ca47 |
- PR_snprintf(value, DNA_REMOTE_BUFSIZ, "%s", server->remote_bind_method);
|
|
|
74ca47 |
+ snprintf(value, DNA_REMOTE_BUFSIZ, "%s", server->remote_bind_method);
|
|
|
74ca47 |
found = 1;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
break;
|
|
|
74ca47 |
} else if(strcmp(attr, DNA_REMOTE_CONN_PROT) == 0){
|
|
|
74ca47 |
if (server->remote_conn_prot) {
|
|
|
74ca47 |
- PR_snprintf(value, DNA_REMOTE_BUFSIZ, "%s", server->remote_conn_prot);
|
|
|
74ca47 |
+ snprintf(value, DNA_REMOTE_BUFSIZ, "%s", server->remote_conn_prot);
|
|
|
74ca47 |
found = 1;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
break;
|
|
|
74ca47 |
@@ -2609,7 +2609,7 @@ dna_update_shared_config(struct configEntry *config_entry)
|
|
|
74ca47 |
|
|
|
74ca47 |
/* We store the number of remaining assigned values
|
|
|
74ca47 |
* in the shared config entry. */
|
|
|
74ca47 |
- PR_snprintf(remaining_vals, sizeof(remaining_vals),"%" NSPRIu64,
|
|
|
74ca47 |
+ snprintf(remaining_vals, sizeof(remaining_vals),"%" NSPRIu64,
|
|
|
74ca47 |
config_entry->remaining);
|
|
|
74ca47 |
|
|
|
74ca47 |
/* set up our replace modify operation */
|
|
|
74ca47 |
@@ -2709,7 +2709,7 @@ dna_update_next_range(struct configEntry *config_entry,
|
|
|
74ca47 |
int ret = 0;
|
|
|
74ca47 |
|
|
|
74ca47 |
/* Try to set the new next range in the config entry. */
|
|
|
74ca47 |
- PR_snprintf(nextrange_value, sizeof(nextrange_value), "%" NSPRIu64 "-%" NSPRIu64,
|
|
|
74ca47 |
+ snprintf(nextrange_value, sizeof(nextrange_value), "%" NSPRIu64 "-%" NSPRIu64,
|
|
|
74ca47 |
lower, upper);
|
|
|
74ca47 |
|
|
|
74ca47 |
/* set up our replace modify operation */
|
|
|
74ca47 |
@@ -2778,8 +2778,8 @@ dna_activate_next_range(struct configEntry *config_entry)
|
|
|
74ca47 |
int ret = 0;
|
|
|
74ca47 |
|
|
|
74ca47 |
/* Setup the modify operation for the config entry */
|
|
|
74ca47 |
- PR_snprintf(maxval_val, sizeof(maxval_val),"%" NSPRIu64, config_entry->next_range_upper);
|
|
|
74ca47 |
- PR_snprintf(nextval_val, sizeof(nextval_val),"%" NSPRIu64, config_entry->next_range_lower);
|
|
|
74ca47 |
+ snprintf(maxval_val, sizeof(maxval_val),"%" NSPRIu64, config_entry->next_range_upper);
|
|
|
74ca47 |
+ snprintf(nextval_val, sizeof(nextval_val),"%" NSPRIu64, config_entry->next_range_lower);
|
|
|
74ca47 |
|
|
|
74ca47 |
maxval_vals[0] = maxval_val;
|
|
|
74ca47 |
maxval_vals[1] = 0;
|
|
|
74ca47 |
@@ -4411,8 +4411,8 @@ static int dna_extend_exop(Slapi_PBlock *pb)
|
|
|
74ca47 |
char highstr[16];
|
|
|
74ca47 |
|
|
|
74ca47 |
/* Create the exop response */
|
|
|
74ca47 |
- PR_snprintf(lowstr, sizeof(lowstr), "%" NSPRIu64, lower);
|
|
|
74ca47 |
- PR_snprintf(highstr, sizeof(highstr), "%" NSPRIu64, upper);
|
|
|
74ca47 |
+ snprintf(lowstr, sizeof(lowstr), "%" NSPRIu64, lower);
|
|
|
74ca47 |
+ snprintf(highstr, sizeof(highstr), "%" NSPRIu64, upper);
|
|
|
74ca47 |
range_low.bv_val = lowstr;
|
|
|
74ca47 |
range_low.bv_len = strlen(range_low.bv_val);
|
|
|
74ca47 |
range_high.bv_val = highstr;
|
|
|
74ca47 |
@@ -4588,7 +4588,7 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
|
|
|
74ca47 |
*lower = *upper - release + 1;
|
|
|
74ca47 |
|
|
|
74ca47 |
/* try to set the new maxval in the config entry */
|
|
|
74ca47 |
- PR_snprintf(max_value, sizeof(max_value),"%" NSPRIu64, (*lower - 1));
|
|
|
74ca47 |
+ snprintf(max_value, sizeof(max_value),"%" NSPRIu64, (*lower - 1));
|
|
|
74ca47 |
|
|
|
74ca47 |
/* set up our replace modify operation */
|
|
|
74ca47 |
replace_val[0] = max_value;
|
|
|
74ca47 |
diff --git a/ldap/servers/plugins/posix-winsync/posix-winsync.c b/ldap/servers/plugins/posix-winsync/posix-winsync.c
|
|
|
74ca47 |
index a7e024d..63444e5 100644
|
|
|
74ca47 |
--- a/ldap/servers/plugins/posix-winsync/posix-winsync.c
|
|
|
74ca47 |
+++ b/ldap/servers/plugins/posix-winsync/posix-winsync.c
|
|
|
74ca47 |
@@ -234,7 +234,7 @@ sync_acct_disable(void *cbdata, /* the usual domain config data */
|
|
|
74ca47 |
{
|
|
|
74ca47 |
int ds_is_enabled = 1; /* default to true */
|
|
|
74ca47 |
int ad_is_enabled = 1; /* default to true */
|
|
|
74ca47 |
- unsigned long adval = 0; /* raw account val from ad entry */
|
|
|
74ca47 |
+ uint64_t adval = 0; /* raw account val from ad entry */
|
|
|
74ca47 |
int isvirt = 0;
|
|
|
74ca47 |
|
|
|
74ca47 |
/* get the account lock state of the ds entry */
|
|
|
74ca47 |
@@ -270,9 +270,8 @@ sync_acct_disable(void *cbdata, /* the usual domain config data */
|
|
|
74ca47 |
if (update_entry) {
|
|
|
74ca47 |
slapi_entry_attr_set_ulong(update_entry, "userAccountControl", adval);
|
|
|
74ca47 |
slapi_log_err(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name,
|
|
|
74ca47 |
- "<-- sync_acct_disable - %s AD account [%s] - "
|
|
|
74ca47 |
- "new value is [%ld]\n", (ds_is_enabled) ? "enabled" : "disabled",
|
|
|
74ca47 |
- slapi_entry_get_dn_const(update_entry), adval);
|
|
|
74ca47 |
+ "<-- sync_acct_disable - %s AD account [%s] - new value is [%" NSPRIu64 "]\n",
|
|
|
74ca47 |
+ (ds_is_enabled) ? "enabled" : "disabled", slapi_entry_get_dn_const(update_entry), adval);
|
|
|
74ca47 |
} else {
|
|
|
74ca47 |
/* iterate through the mods - if there is already a mod
|
|
|
74ca47 |
for userAccountControl, change it - otherwise, add it */
|
|
|
74ca47 |
@@ -327,9 +326,8 @@ sync_acct_disable(void *cbdata, /* the usual domain config data */
|
|
|
74ca47 |
mod_bval->bv_len = strlen(acctvalstr);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
slapi_log_err(SLAPI_LOG_PLUGIN, posix_winsync_plugin_name,
|
|
|
74ca47 |
- "<-- sync_acct_disable - %s AD account [%s] - "
|
|
|
74ca47 |
- "new value is [%ld]\n", (ds_is_enabled) ? "enabled" : "disabled",
|
|
|
74ca47 |
- slapi_entry_get_dn_const(ad_entry), adval);
|
|
|
74ca47 |
+ "<-- sync_acct_disable - %s AD account [%s] - new value is [%" NSPRIu64 "]\n",
|
|
|
74ca47 |
+ (ds_is_enabled) ? "enabled" : "disabled", slapi_entry_get_dn_const(ad_entry), adval);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
diff --git a/ldap/servers/plugins/replication/repl5_init.c b/ldap/servers/plugins/replication/repl5_init.c
|
|
|
74ca47 |
index 0945f7b..9549dcf 100644
|
|
|
74ca47 |
--- a/ldap/servers/plugins/replication/repl5_init.c
|
|
|
74ca47 |
+++ b/ldap/servers/plugins/replication/repl5_init.c
|
|
|
74ca47 |
@@ -208,7 +208,7 @@ get_repl_session_id (Slapi_PBlock *pb, char *idstr, CSN **csn)
|
|
|
74ca47 |
/* Avoid "Connection is NULL and hence cannot access SLAPI_CONN_ID" */
|
|
|
74ca47 |
if (opid) {
|
|
|
74ca47 |
slapi_pblock_get (pb, SLAPI_CONN_ID, &connid);
|
|
|
74ca47 |
- PR_snprintf (idstr, REPL_SESSION_ID_SIZE, "conn=%" NSPRIu64 " op=%d",
|
|
|
74ca47 |
+ snprintf (idstr, REPL_SESSION_ID_SIZE, "conn=%" NSPRIu64 " op=%d",
|
|
|
74ca47 |
connid, opid);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c
|
|
|
74ca47 |
index 948f38d..80580f9 100644
|
|
|
74ca47 |
--- a/ldap/servers/plugins/replication/repl_extop.c
|
|
|
74ca47 |
+++ b/ldap/servers/plugins/replication/repl_extop.c
|
|
|
74ca47 |
@@ -865,7 +865,7 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
|
|
|
74ca47 |
* the session's conn id and op id to identify the the supplier.
|
|
|
74ca47 |
*/
|
|
|
74ca47 |
/* junkrc = ruv_get_first_id_and_purl(supplier_ruv, &junkrid, &locking_purl); */
|
|
|
74ca47 |
- PR_snprintf(locking_session, sizeof(locking_session), "conn=%" NSPRIu64 " id=%d",
|
|
|
74ca47 |
+ snprintf(locking_session, sizeof(locking_session), "conn=%" NSPRIu64 " id=%d",
|
|
|
74ca47 |
connid, opid);
|
|
|
74ca47 |
locking_purl = &locking_session[0];
|
|
|
74ca47 |
if (replica_get_exclusive_access(replica, &isInc, connid, opid,
|
|
|
74ca47 |
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
|
|
|
74ca47 |
index 6fe8d2e..5e67e0a 100644
|
|
|
74ca47 |
--- a/ldap/servers/plugins/usn/usn.c
|
|
|
74ca47 |
+++ b/ldap/servers/plugins/usn/usn.c
|
|
|
74ca47 |
@@ -360,7 +360,7 @@ _usn_mod_next_usn(LDAPMod ***mods, Slapi_Backend *be)
|
|
|
74ca47 |
|
|
|
74ca47 |
/* add next USN to the mods; "be" contains the usn counter */
|
|
|
74ca47 |
usn_berval.bv_val = counter_buf;
|
|
|
74ca47 |
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
|
|
|
74ca47 |
+ snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
|
|
|
74ca47 |
slapi_counter_get_value(be->be_usn_counter));
|
|
|
74ca47 |
usn_berval.bv_len = strlen(usn_berval.bv_val);
|
|
|
74ca47 |
bvals[0] = &usn_berval;
|
|
|
74ca47 |
@@ -670,7 +670,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
|
|
|
74ca47 |
/* nsslapd-entryusn-global: on*/
|
|
|
74ca47 |
/* root dse shows ...
|
|
|
74ca47 |
* lastusn: <num> */
|
|
|
74ca47 |
- PR_snprintf(attr, USN_LAST_USN_ATTR_CORE_LEN + 1, "%s", USN_LAST_USN);
|
|
|
74ca47 |
+ snprintf(attr, USN_LAST_USN_ATTR_CORE_LEN + 1, "%s", USN_LAST_USN);
|
|
|
74ca47 |
for (be = slapi_get_first_backend(&cookie); be;
|
|
|
74ca47 |
be = slapi_get_next_backend(cookie)) {
|
|
|
74ca47 |
if (be->be_usn_counter) {
|
|
|
74ca47 |
@@ -681,10 +681,10 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
|
|
|
74ca47 |
/* get a next USN counter from be_usn_counter;
|
|
|
74ca47 |
* then minus 1 from it (except if be_usn_counter has value 0) */
|
|
|
74ca47 |
if (slapi_counter_get_value(be->be_usn_counter)) {
|
|
|
74ca47 |
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
|
|
|
74ca47 |
+ snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
|
|
|
74ca47 |
slapi_counter_get_value(be->be_usn_counter)-1);
|
|
|
74ca47 |
} else {
|
|
|
74ca47 |
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "-1");
|
|
|
74ca47 |
+ snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "-1");
|
|
|
74ca47 |
}
|
|
|
74ca47 |
usn_berval.bv_len = strlen(usn_berval.bv_val);
|
|
|
74ca47 |
slapi_entry_attr_replace(e, attr, vals);
|
|
|
74ca47 |
@@ -693,7 +693,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
|
|
|
74ca47 |
/* nsslapd-entryusn-global: off (default) */
|
|
|
74ca47 |
/* root dse shows ...
|
|
|
74ca47 |
* lastusn;<backend>: <num> */
|
|
|
74ca47 |
- PR_snprintf(attr, USN_LAST_USN_ATTR_CORE_LEN + 2, "%s;", USN_LAST_USN);
|
|
|
74ca47 |
+ snprintf(attr, USN_LAST_USN_ATTR_CORE_LEN + 2, "%s;", USN_LAST_USN);
|
|
|
74ca47 |
attr_subp = attr + USN_LAST_USN_ATTR_CORE_LEN + 1;
|
|
|
74ca47 |
for (be = slapi_get_first_backend(&cookie); be;
|
|
|
74ca47 |
be = slapi_get_next_backend(cookie)) {
|
|
|
74ca47 |
@@ -704,10 +704,10 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
|
|
|
74ca47 |
/* get a next USN counter from be_usn_counter;
|
|
|
74ca47 |
* then minus 1 from it (except if be_usn_counter has value 0) */
|
|
|
74ca47 |
if (slapi_counter_get_value(be->be_usn_counter)) {
|
|
|
74ca47 |
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
|
|
|
74ca47 |
+ snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
|
|
|
74ca47 |
slapi_counter_get_value(be->be_usn_counter)-1);
|
|
|
74ca47 |
} else {
|
|
|
74ca47 |
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "-1");
|
|
|
74ca47 |
+ snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "-1");
|
|
|
74ca47 |
}
|
|
|
74ca47 |
usn_berval.bv_len = strlen(usn_berval.bv_val);
|
|
|
74ca47 |
|
|
|
74ca47 |
@@ -716,7 +716,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
|
|
|
74ca47 |
attr = (char *)slapi_ch_realloc(attr, attr_len);
|
|
|
74ca47 |
attr_subp = attr + USN_LAST_USN_ATTR_CORE_LEN;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
- PR_snprintf(attr_subp, attr_len - USN_LAST_USN_ATTR_CORE_LEN,
|
|
|
74ca47 |
+ snprintf(attr_subp, attr_len - USN_LAST_USN_ATTR_CORE_LEN,
|
|
|
74ca47 |
"%s", be->be_name);
|
|
|
74ca47 |
slapi_entry_attr_replace(e, attr, vals);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
|
|
|
74ca47 |
index dfcc735..757792b 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/back-ldbm/monitor.c
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
|
|
|
74ca47 |
@@ -26,7 +26,7 @@
|
|
|
74ca47 |
|
|
|
74ca47 |
#define MSETF(_attr, _x) do { \
|
|
|
74ca47 |
char tmp_atype[37]; \
|
|
|
74ca47 |
- PR_snprintf(tmp_atype, sizeof(tmp_atype), _attr, _x); \
|
|
|
74ca47 |
+ snprintf(tmp_atype, sizeof(tmp_atype), _attr, _x); \
|
|
|
74ca47 |
MSET(tmp_atype); \
|
|
|
74ca47 |
} while (0)
|
|
|
74ca47 |
|
|
|
74ca47 |
@@ -86,7 +86,7 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
|
|
|
74ca47 |
MSET("entryCacheHits");
|
|
|
74ca47 |
sprintf(buf, "%lu", (long unsigned int)tries);
|
|
|
74ca47 |
MSET("entryCacheTries");
|
|
|
74ca47 |
- sprintf(buf, "%lu", (unsigned long)(100.0*(double)hits / (double)(tries > 0 ? tries : 1)));
|
|
|
74ca47 |
+ sprintf(buf, "%lu", (long unsigned int)(100.0*(double)hits / (double)(tries > 0 ? tries : 1)));
|
|
|
74ca47 |
MSET("entryCacheHitRatio");
|
|
|
74ca47 |
sprintf(buf, "%lu", (long unsigned int)size);
|
|
|
74ca47 |
MSET("currentEntryCacheSize");
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/back-ldbm/perfctrs.c b/ldap/servers/slapd/back-ldbm/perfctrs.c
|
|
|
74ca47 |
index 2bd18bd..5929dea 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/back-ldbm/perfctrs.c
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/back-ldbm/perfctrs.c
|
|
|
74ca47 |
@@ -49,7 +49,7 @@
|
|
|
74ca47 |
|
|
|
74ca47 |
static void perfctrs_update(perfctrs_private *priv, DB_ENV *db_env);
|
|
|
74ca47 |
static void perfctr_add_to_entry( Slapi_Entry *e, char *type,
|
|
|
74ca47 |
- PRUint32 countervalue );
|
|
|
74ca47 |
+ uint64_t countervalue );
|
|
|
74ca47 |
|
|
|
74ca47 |
/* Init perf ctrs */
|
|
|
74ca47 |
void perfctrs_init(struct ldbminfo *li, perfctrs_private **ret_priv)
|
|
|
74ca47 |
@@ -304,17 +304,13 @@ perfctrs_as_entry( Slapi_Entry *e, perfctrs_private *priv, DB_ENV *db_env )
|
|
|
74ca47 |
*/
|
|
|
74ca47 |
for ( i = 0; i < SLAPI_LDBM_PERFCTR_AT_MAP_COUNT; ++i ) {
|
|
|
74ca47 |
perfctr_add_to_entry( e, perfctr_at_map[i].pam_type,
|
|
|
74ca47 |
- *((PRUint32 *)((char *)perf + perfctr_at_map[i].pam_offset)));
|
|
|
74ca47 |
+ *((uint64_t *)((char *)perf + perfctr_at_map[i].pam_offset)));
|
|
|
74ca47 |
}
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
|
|
|
74ca47 |
static void
|
|
|
74ca47 |
-perfctr_add_to_entry( Slapi_Entry *e, char *type, PRUint32 countervalue )
|
|
|
74ca47 |
+perfctr_add_to_entry( Slapi_Entry *e, char *type, uint64_t countervalue )
|
|
|
74ca47 |
{
|
|
|
74ca47 |
- /*
|
|
|
74ca47 |
- * XXXmcs: the following line assumes that long's are 32 bits or larger,
|
|
|
74ca47 |
- * which we assume in other places too I am sure.
|
|
|
74ca47 |
- */
|
|
|
74ca47 |
- slapi_entry_attr_set_ulong( e, type, (unsigned long)countervalue );
|
|
|
74ca47 |
+ slapi_entry_attr_set_ulong( e, type, countervalue );
|
|
|
74ca47 |
}
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/back-ldbm/perfctrs.h b/ldap/servers/slapd/back-ldbm/perfctrs.h
|
|
|
74ca47 |
index 65a7850..57be1d1 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/back-ldbm/perfctrs.h
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/back-ldbm/perfctrs.h
|
|
|
74ca47 |
@@ -11,46 +11,48 @@
|
|
|
74ca47 |
# include <config.h>
|
|
|
74ca47 |
#endif
|
|
|
74ca47 |
|
|
|
74ca47 |
+#include <inttypes.h>
|
|
|
74ca47 |
+
|
|
|
74ca47 |
/* Structure definition for performance data */
|
|
|
74ca47 |
/* This stuff goes in shared memory, so make sure the packing is consistent */
|
|
|
74ca47 |
|
|
|
74ca47 |
struct _performance_counters {
|
|
|
74ca47 |
- PRUint32 sequence_number;
|
|
|
74ca47 |
- PRUint32 lock_region_wait_rate;
|
|
|
74ca47 |
- PRUint32 deadlock_rate;
|
|
|
74ca47 |
- PRUint32 configured_locks;
|
|
|
74ca47 |
- PRUint32 current_locks;
|
|
|
74ca47 |
- PRUint32 max_locks;
|
|
|
74ca47 |
- PRUint32 lockers;
|
|
|
74ca47 |
- PRUint32 current_lock_objects;
|
|
|
74ca47 |
- PRUint32 max_lock_objects;
|
|
|
74ca47 |
- PRUint32 lock_conflicts;
|
|
|
74ca47 |
- PRUint32 lock_request_rate;
|
|
|
74ca47 |
- PRUint32 log_region_wait_rate;
|
|
|
74ca47 |
- PRUint32 log_write_rate;
|
|
|
74ca47 |
- PRUint32 log_bytes_since_checkpoint;
|
|
|
74ca47 |
- PRUint32 cache_size_bytes;
|
|
|
74ca47 |
- PRUint32 page_access_rate;
|
|
|
74ca47 |
- PRUint32 cache_hit;
|
|
|
74ca47 |
- PRUint32 cache_try;
|
|
|
74ca47 |
- PRUint32 page_create_rate;
|
|
|
74ca47 |
- PRUint32 page_read_rate;
|
|
|
74ca47 |
- PRUint32 page_write_rate;
|
|
|
74ca47 |
- PRUint32 page_ro_evict_rate;
|
|
|
74ca47 |
- PRUint32 page_rw_evict_rate;
|
|
|
74ca47 |
- PRUint32 hash_buckets;
|
|
|
74ca47 |
- PRUint32 hash_search_rate;
|
|
|
74ca47 |
- PRUint32 longest_chain_length;
|
|
|
74ca47 |
- PRUint32 hash_elements_examine_rate;
|
|
|
74ca47 |
- PRUint32 pages_in_use;
|
|
|
74ca47 |
- PRUint32 dirty_pages;
|
|
|
74ca47 |
- PRUint32 clean_pages;
|
|
|
74ca47 |
- PRUint32 page_trickle_rate;
|
|
|
74ca47 |
- PRUint32 cache_region_wait_rate;
|
|
|
74ca47 |
- PRUint32 active_txns;
|
|
|
74ca47 |
- PRUint32 commit_rate;
|
|
|
74ca47 |
- PRUint32 abort_rate;
|
|
|
74ca47 |
- PRUint32 txn_region_wait_rate;
|
|
|
74ca47 |
+ uint64_t sequence_number;
|
|
|
74ca47 |
+ uint64_t lock_region_wait_rate;
|
|
|
74ca47 |
+ uint64_t deadlock_rate;
|
|
|
74ca47 |
+ uint64_t configured_locks;
|
|
|
74ca47 |
+ uint64_t current_locks;
|
|
|
74ca47 |
+ uint64_t max_locks;
|
|
|
74ca47 |
+ uint64_t lockers;
|
|
|
74ca47 |
+ uint64_t current_lock_objects;
|
|
|
74ca47 |
+ uint64_t max_lock_objects;
|
|
|
74ca47 |
+ uint64_t lock_conflicts;
|
|
|
74ca47 |
+ uint64_t lock_request_rate;
|
|
|
74ca47 |
+ uint64_t log_region_wait_rate;
|
|
|
74ca47 |
+ uint64_t log_write_rate;
|
|
|
74ca47 |
+ uint64_t log_bytes_since_checkpoint;
|
|
|
74ca47 |
+ uint64_t cache_size_bytes;
|
|
|
74ca47 |
+ uint64_t page_access_rate;
|
|
|
74ca47 |
+ uint64_t cache_hit;
|
|
|
74ca47 |
+ uint64_t cache_try;
|
|
|
74ca47 |
+ uint64_t page_create_rate;
|
|
|
74ca47 |
+ uint64_t page_read_rate;
|
|
|
74ca47 |
+ uint64_t page_write_rate;
|
|
|
74ca47 |
+ uint64_t page_ro_evict_rate;
|
|
|
74ca47 |
+ uint64_t page_rw_evict_rate;
|
|
|
74ca47 |
+ uint64_t hash_buckets;
|
|
|
74ca47 |
+ uint64_t hash_search_rate;
|
|
|
74ca47 |
+ uint64_t longest_chain_length;
|
|
|
74ca47 |
+ uint64_t hash_elements_examine_rate;
|
|
|
74ca47 |
+ uint64_t pages_in_use;
|
|
|
74ca47 |
+ uint64_t dirty_pages;
|
|
|
74ca47 |
+ uint64_t clean_pages;
|
|
|
74ca47 |
+ uint64_t page_trickle_rate;
|
|
|
74ca47 |
+ uint64_t cache_region_wait_rate;
|
|
|
74ca47 |
+ uint64_t active_txns;
|
|
|
74ca47 |
+ uint64_t commit_rate;
|
|
|
74ca47 |
+ uint64_t abort_rate;
|
|
|
74ca47 |
+ uint64_t txn_region_wait_rate;
|
|
|
74ca47 |
};
|
|
|
74ca47 |
typedef struct _performance_counters performance_counters;
|
|
|
74ca47 |
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/back-ldbm/vlv_srch.h b/ldap/servers/slapd/back-ldbm/vlv_srch.h
|
|
|
74ca47 |
index d1eba08..6322f80 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/back-ldbm/vlv_srch.h
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/back-ldbm/vlv_srch.h
|
|
|
74ca47 |
@@ -92,7 +92,7 @@ struct vlvIndex
|
|
|
74ca47 |
time_t vlv_lastchecked;
|
|
|
74ca47 |
|
|
|
74ca47 |
/* The number of uses this search has received since start up */
|
|
|
74ca47 |
- PRUint32 vlv_uses;
|
|
|
74ca47 |
+ uint64_t vlv_uses;
|
|
|
74ca47 |
|
|
|
74ca47 |
struct backend* vlv_be; /* need backend to remove the index when done */
|
|
|
74ca47 |
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
|
|
|
74ca47 |
index 004aeae..bcafa4e 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/conntable.c
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/conntable.c
|
|
|
74ca47 |
@@ -395,7 +395,7 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
|
|
|
74ca47 |
* 3 = The number of operations attempted that were blocked
|
|
|
74ca47 |
* by max threads.
|
|
|
74ca47 |
*/
|
|
|
74ca47 |
- PR_snprintf(maxthreadbuf, sizeof(maxthreadbuf), "%d:%"NSPRIu64":%"NSPRIu64"",
|
|
|
74ca47 |
+ snprintf(maxthreadbuf, sizeof(maxthreadbuf), "%d:%"NSPRIu64":%"NSPRIu64"",
|
|
|
74ca47 |
maxthreadstate, ct->c[i].c_maxthreadscount,
|
|
|
74ca47 |
ct->c[i].c_maxthreadsblocked);
|
|
|
74ca47 |
|
|
|
74ca47 |
@@ -426,32 +426,32 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
|
|
|
74ca47 |
PR_ExitMonitor(ct->c[i].c_mutex);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
- PR_snprintf( buf, sizeof(buf), "%d", nconns );
|
|
|
74ca47 |
+ snprintf( buf, sizeof(buf), "%d", nconns );
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
val.bv_len = strlen( buf );
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "currentconnections", vals );
|
|
|
74ca47 |
|
|
|
74ca47 |
- PR_snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(num_conns));
|
|
|
74ca47 |
+ snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(num_conns));
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
val.bv_len = strlen( buf );
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "totalconnections", vals );
|
|
|
74ca47 |
|
|
|
74ca47 |
- PR_snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(conns_in_maxthreads));
|
|
|
74ca47 |
+ snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(conns_in_maxthreads));
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
val.bv_len = strlen( buf );
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "currentconnectionsatmaxthreads", vals );
|
|
|
74ca47 |
|
|
|
74ca47 |
- PR_snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(max_threads_count));
|
|
|
74ca47 |
+ snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(max_threads_count));
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
val.bv_len = strlen( buf );
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "maxthreadsperconnhits", vals );
|
|
|
74ca47 |
|
|
|
74ca47 |
- PR_snprintf( buf, sizeof(buf), "%d", (ct!=NULL?ct->size:0) );
|
|
|
74ca47 |
+ snprintf( buf, sizeof(buf), "%d", (ct!=NULL?ct->size:0) );
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
val.bv_len = strlen( buf );
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "dtablesize", vals );
|
|
|
74ca47 |
|
|
|
74ca47 |
- PR_snprintf( buf, sizeof(buf), "%d", nreadwaiters );
|
|
|
74ca47 |
+ snprintf( buf, sizeof(buf), "%d", nreadwaiters );
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
val.bv_len = strlen( buf );
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "readwaiters", vals );
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
|
|
|
74ca47 |
index 7bbd2f4..abacc57 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/entry.c
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/entry.c
|
|
|
74ca47 |
@@ -3088,14 +3088,14 @@ slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l)
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
void
|
|
|
74ca47 |
-slapi_entry_attr_set_ulong( Slapi_Entry* e, const char *type, unsigned long l)
|
|
|
74ca47 |
+slapi_entry_attr_set_ulong( Slapi_Entry* e, const char *type, uint64_t l)
|
|
|
74ca47 |
{
|
|
|
74ca47 |
char value[16];
|
|
|
74ca47 |
struct berval bv;
|
|
|
74ca47 |
struct berval *bvals[2];
|
|
|
74ca47 |
bvals[0] = &bv;
|
|
|
74ca47 |
bvals[1] = NULL;
|
|
|
74ca47 |
- sprintf(value,"%lu",l);
|
|
|
74ca47 |
+ sprintf(value,"%" NSPRIu64, l);
|
|
|
74ca47 |
bv.bv_val = value;
|
|
|
74ca47 |
bv.bv_len = strlen( value );
|
|
|
74ca47 |
slapi_entry_attr_replace( e, type, bvals );
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
|
|
|
74ca47 |
index 2f43a98..afedd5b 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/log.c
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/log.c
|
|
|
74ca47 |
@@ -2327,11 +2327,11 @@ vslapd_log_error(
|
|
|
74ca47 |
char buffer[SLAPI_LOG_BUFSIZ];
|
|
|
74ca47 |
char sev_name[10];
|
|
|
74ca47 |
int blen = TBUFSIZE;
|
|
|
74ca47 |
- char *vbuf;
|
|
|
74ca47 |
+ char *vbuf = NULL;
|
|
|
74ca47 |
int header_len = 0;
|
|
|
74ca47 |
int err = 0;
|
|
|
74ca47 |
|
|
|
74ca47 |
- if ((vbuf = PR_vsmprintf(fmt, ap)) == NULL) {
|
|
|
74ca47 |
+ if (vasprintf(&vbuf, fmt, ap) == -1) {
|
|
|
74ca47 |
log__error_emergency("CRITICAL: vslapd_log_error, Unable to format message", 1 , locked);
|
|
|
74ca47 |
return -1;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
@@ -2381,10 +2381,10 @@ vslapd_log_error(
|
|
|
74ca47 |
/* blen = strlen(buffer); */
|
|
|
74ca47 |
/* This truncates again .... But we have the nice smprintf above! */
|
|
|
74ca47 |
if (subsystem == NULL) {
|
|
|
74ca47 |
- PR_snprintf (buffer+blen, sizeof(buffer)-blen, "- %s - %s",
|
|
|
74ca47 |
+ snprintf (buffer+blen, sizeof(buffer)-blen, "- %s - %s",
|
|
|
74ca47 |
get_log_sev_name(sev_level, sev_name), vbuf);
|
|
|
74ca47 |
} else {
|
|
|
74ca47 |
- PR_snprintf (buffer+blen, sizeof(buffer)-blen, "- %s - %s - %s",
|
|
|
74ca47 |
+ snprintf (buffer+blen, sizeof(buffer)-blen, "- %s - %s - %s",
|
|
|
74ca47 |
get_log_sev_name(sev_level, sev_name), subsystem, vbuf);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
@@ -2418,7 +2418,7 @@ vslapd_log_error(
|
|
|
74ca47 |
g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
- PR_smprintf_free (vbuf);
|
|
|
74ca47 |
+ slapi_ch_free_string(&vbuf);
|
|
|
74ca47 |
return( 0 );
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
@@ -2520,8 +2520,7 @@ static int vslapd_log_access(char *fmt, va_list ap)
|
|
|
74ca47 |
time_t tnl;
|
|
|
74ca47 |
|
|
|
74ca47 |
/* We do this sooner, because that we we can use the message in other calls */
|
|
|
74ca47 |
- vlen = PR_vsnprintf(vbuf, SLAPI_LOG_BUFSIZ, fmt, ap);
|
|
|
74ca47 |
- if (! vlen) {
|
|
|
74ca47 |
+ if ((vlen = vsnprintf(vbuf, SLAPI_LOG_BUFSIZ, fmt, ap)) == -1){
|
|
|
74ca47 |
log__error_emergency("CRITICAL: vslapd_log_access, Unable to format message", 1 ,0);
|
|
|
74ca47 |
return -1;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/monitor.c b/ldap/servers/slapd/monitor.c
|
|
|
74ca47 |
index 0917bc8..f1fb38f 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/monitor.c
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/monitor.c
|
|
|
74ca47 |
@@ -54,25 +54,25 @@ monitor_info(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *ret
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "version", vals );
|
|
|
74ca47 |
slapi_ch_free( (void **) &val.bv_val );
|
|
|
74ca47 |
|
|
|
74ca47 |
- val.bv_len = PR_snprintf( buf, sizeof(buf), "%d", g_get_active_threadcnt() );
|
|
|
74ca47 |
+ val.bv_len = snprintf( buf, sizeof(buf), "%d", g_get_active_threadcnt() );
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "threads", vals );
|
|
|
74ca47 |
|
|
|
74ca47 |
connection_table_as_entry(the_connection_table, e);
|
|
|
74ca47 |
|
|
|
74ca47 |
- val.bv_len = PR_snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(ops_initiated) );
|
|
|
74ca47 |
+ val.bv_len = snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(ops_initiated) );
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "opsinitiated", vals );
|
|
|
74ca47 |
|
|
|
74ca47 |
- val.bv_len = PR_snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(ops_completed) );
|
|
|
74ca47 |
+ val.bv_len = snprintf( buf, sizeof(buf), "%" NSPRIu64, slapi_counter_get_value(ops_completed) );
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "opscompleted", vals );
|
|
|
74ca47 |
|
|
|
74ca47 |
- val.bv_len = PR_snprintf ( buf, sizeof(buf), "%" NSPRIu64, g_get_num_entries_sent() );
|
|
|
74ca47 |
+ val.bv_len = snprintf ( buf, sizeof(buf), "%" NSPRIu64, g_get_num_entries_sent() );
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "entriessent", vals );
|
|
|
74ca47 |
|
|
|
74ca47 |
- val.bv_len = PR_snprintf ( buf, sizeof(buf), "%" NSPRIu64, g_get_num_bytes_sent() );
|
|
|
74ca47 |
+ val.bv_len = snprintf ( buf, sizeof(buf), "%" NSPRIu64, g_get_num_bytes_sent() );
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "bytessent", vals );
|
|
|
74ca47 |
|
|
|
74ca47 |
@@ -88,12 +88,12 @@ monitor_info(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *ret
|
|
|
74ca47 |
val.bv_len = strlen( buf );
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "starttime", vals );
|
|
|
74ca47 |
|
|
|
74ca47 |
- val.bv_len = PR_snprintf( buf, sizeof(buf), "%d", be_nbackends_public() );
|
|
|
74ca47 |
+ val.bv_len = snprintf( buf, sizeof(buf), "%d", be_nbackends_public() );
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "nbackends", vals );
|
|
|
74ca47 |
|
|
|
74ca47 |
#ifdef THREAD_SUNOS5_LWP
|
|
|
74ca47 |
- val.bv_len = PR_snprintf( buf, sizeof(buf), "%d", thr_getconcurrency() );
|
|
|
74ca47 |
+ val.bv_len = snprintf( buf, sizeof(buf), "%d", thr_getconcurrency() );
|
|
|
74ca47 |
val.bv_val = buf;
|
|
|
74ca47 |
attrlist_replace( &e->e_attrs, "concurrency", vals );
|
|
|
74ca47 |
#endif
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
|
|
|
74ca47 |
index 1bd8fc8..725fa1c 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/slapi-plugin.h
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/slapi-plugin.h
|
|
|
74ca47 |
@@ -1954,7 +1954,7 @@ void slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long
|
|
|
74ca47 |
* \param type Attribute type in which you want to set the value.
|
|
|
74ca47 |
* \param l Unsigned long value that you want to assign to the attribute.
|
|
|
74ca47 |
*/
|
|
|
74ca47 |
-void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l);
|
|
|
74ca47 |
+void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, uint64_t l);
|
|
|
74ca47 |
|
|
|
74ca47 |
/**
|
|
|
74ca47 |
* Check if an attribute is set in the entry
|
|
|
74ca47 |
@@ -6746,12 +6746,12 @@ void slapi_destroy_task(void *arg);
|
|
|
74ca47 |
Slapi_Counter *slapi_counter_new(void);
|
|
|
74ca47 |
void slapi_counter_init(Slapi_Counter *counter);
|
|
|
74ca47 |
void slapi_counter_destroy(Slapi_Counter **counter);
|
|
|
74ca47 |
-PRUint64 slapi_counter_increment(Slapi_Counter *counter);
|
|
|
74ca47 |
-PRUint64 slapi_counter_decrement(Slapi_Counter *counter);
|
|
|
74ca47 |
-PRUint64 slapi_counter_add(Slapi_Counter *counter, PRUint64 addvalue);
|
|
|
74ca47 |
-PRUint64 slapi_counter_subtract(Slapi_Counter *counter, PRUint64 subvalue);
|
|
|
74ca47 |
-PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64 newvalue);
|
|
|
74ca47 |
-PRUint64 slapi_counter_get_value(Slapi_Counter *counter);
|
|
|
74ca47 |
+uint64_t slapi_counter_increment(Slapi_Counter *counter);
|
|
|
74ca47 |
+uint64_t slapi_counter_decrement(Slapi_Counter *counter);
|
|
|
74ca47 |
+uint64_t slapi_counter_add(Slapi_Counter *counter, uint64_t addvalue);
|
|
|
74ca47 |
+uint64_t slapi_counter_subtract(Slapi_Counter *counter, uint64_t subvalue);
|
|
|
74ca47 |
+uint64_t slapi_counter_set_value(Slapi_Counter *counter, uint64_t newvalue);
|
|
|
74ca47 |
+uint64_t slapi_counter_get_value(Slapi_Counter *counter);
|
|
|
74ca47 |
|
|
|
74ca47 |
/* Binder-based (connection centric) resource limits */
|
|
|
74ca47 |
/*
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/slapi_counter.c b/ldap/servers/slapd/slapi_counter.c
|
|
|
74ca47 |
index c3ac846..9904fe9 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/slapi_counter.c
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/slapi_counter.c
|
|
|
74ca47 |
@@ -12,37 +12,21 @@
|
|
|
74ca47 |
|
|
|
74ca47 |
#include "slap.h"
|
|
|
74ca47 |
|
|
|
74ca47 |
-#ifdef SOLARIS
|
|
|
74ca47 |
-PRUint64 _sparcv9_AtomicSet(PRUint64 *address, PRUint64 newval);
|
|
|
74ca47 |
-PRUint64 _sparcv9_AtomicAdd(PRUint64 *address, PRUint64 val);
|
|
|
74ca47 |
-PRUint64 _sparcv9_AtomicSub(PRUint64 *address, PRUint64 val);
|
|
|
74ca47 |
+#ifndef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
+#include <pthread.h>
|
|
|
74ca47 |
#endif
|
|
|
74ca47 |
|
|
|
74ca47 |
#ifdef HPUX
|
|
|
74ca47 |
-#ifdef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
#include <machine/sys/inline.h>
|
|
|
74ca47 |
#endif
|
|
|
74ca47 |
-#endif
|
|
|
74ca47 |
-
|
|
|
74ca47 |
-#ifdef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
-#if defined(LINUX) && !HAVE_64BIT_ATOMIC_OP_FUNCS
|
|
|
74ca47 |
-/* On systems that don't have the 64-bit GCC atomic builtins, we need to
|
|
|
74ca47 |
- * implement our own atomic functions using inline assembly code. */
|
|
|
74ca47 |
-PRUint64 __sync_add_and_fetch_8(PRUint64 *ptr, PRUint64 addval);
|
|
|
74ca47 |
-PRUint64 __sync_sub_and_fetch_8(PRUint64 *ptr, PRUint64 subval);
|
|
|
74ca47 |
-#define __sync_add_and_fetch __sync_add_and_fetch_8
|
|
|
74ca47 |
-#define __sync_sub_and_fetch __sync_sub_and_fetch_8
|
|
|
74ca47 |
-#endif
|
|
|
74ca47 |
-#endif /* ATOMIC_64BIT_OPERATIONS */
|
|
|
74ca47 |
-
|
|
|
74ca47 |
|
|
|
74ca47 |
/*
|
|
|
74ca47 |
* Counter Structure
|
|
|
74ca47 |
*/
|
|
|
74ca47 |
typedef struct slapi_counter {
|
|
|
74ca47 |
- PRUint64 value;
|
|
|
74ca47 |
+ uint64_t value;
|
|
|
74ca47 |
#ifndef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
- Slapi_Mutex *lock;
|
|
|
74ca47 |
+ pthread_mutex_t _lock;
|
|
|
74ca47 |
#endif
|
|
|
74ca47 |
} slapi_counter;
|
|
|
74ca47 |
|
|
|
74ca47 |
@@ -72,15 +56,11 @@ Slapi_Counter *slapi_counter_new()
|
|
|
74ca47 |
void slapi_counter_init(Slapi_Counter *counter)
|
|
|
74ca47 |
{
|
|
|
74ca47 |
if (counter != NULL) {
|
|
|
74ca47 |
-#ifndef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
- /* Create the lock if necessary. */
|
|
|
74ca47 |
- if (counter->lock == NULL) {
|
|
|
74ca47 |
- counter->lock = slapi_new_mutex();
|
|
|
74ca47 |
- }
|
|
|
74ca47 |
-#endif
|
|
|
74ca47 |
-
|
|
|
74ca47 |
/* Set the value to 0. */
|
|
|
74ca47 |
slapi_counter_set_value(counter, 0);
|
|
|
74ca47 |
+#ifndef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
+ pthread_mutex_init(&(counter->_lock), NULL);
|
|
|
74ca47 |
+#endif
|
|
|
74ca47 |
}
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
@@ -94,7 +74,7 @@ void slapi_counter_destroy(Slapi_Counter **counter)
|
|
|
74ca47 |
{
|
|
|
74ca47 |
if ((counter != NULL) && (*counter != NULL)) {
|
|
|
74ca47 |
#ifndef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
- slapi_destroy_mutex((*counter)->lock);
|
|
|
74ca47 |
+ pthread_mutex_destroy(&((*counter)->_lock));
|
|
|
74ca47 |
#endif
|
|
|
74ca47 |
slapi_ch_free((void **)counter);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
@@ -105,7 +85,7 @@ void slapi_counter_destroy(Slapi_Counter **counter)
|
|
|
74ca47 |
*
|
|
|
74ca47 |
* Atomically increments a Slapi_Counter.
|
|
|
74ca47 |
*/
|
|
|
74ca47 |
-PRUint64 slapi_counter_increment(Slapi_Counter *counter)
|
|
|
74ca47 |
+uint64_t slapi_counter_increment(Slapi_Counter *counter)
|
|
|
74ca47 |
{
|
|
|
74ca47 |
return slapi_counter_add(counter, 1);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
@@ -117,7 +97,7 @@ PRUint64 slapi_counter_increment(Slapi_Counter *counter)
|
|
|
74ca47 |
* that this will not prevent you from wrapping
|
|
|
74ca47 |
* around 0.
|
|
|
74ca47 |
*/
|
|
|
74ca47 |
-PRUint64 slapi_counter_decrement(Slapi_Counter *counter)
|
|
|
74ca47 |
+uint64_t slapi_counter_decrement(Slapi_Counter *counter)
|
|
|
74ca47 |
{
|
|
|
74ca47 |
return slapi_counter_subtract(counter, 1);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
@@ -127,28 +107,18 @@ PRUint64 slapi_counter_decrement(Slapi_Counter *counter)
|
|
|
74ca47 |
*
|
|
|
74ca47 |
* Atomically add a value to a Slapi_Counter.
|
|
|
74ca47 |
*/
|
|
|
74ca47 |
-PRUint64 slapi_counter_add(Slapi_Counter *counter, PRUint64 addvalue)
|
|
|
74ca47 |
+uint64_t slapi_counter_add(Slapi_Counter *counter, uint64_t addvalue)
|
|
|
74ca47 |
{
|
|
|
74ca47 |
- PRUint64 newvalue = 0;
|
|
|
74ca47 |
-#ifdef HPUX
|
|
|
74ca47 |
- PRUint64 prev = 0;
|
|
|
74ca47 |
-#endif
|
|
|
74ca47 |
+ uint64_t newvalue = 0;
|
|
|
74ca47 |
|
|
|
74ca47 |
if (counter == NULL) {
|
|
|
74ca47 |
return newvalue;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
-
|
|
|
74ca47 |
-#ifndef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
- slapi_lock_mutex(counter->lock);
|
|
|
74ca47 |
- counter->value += addvalue;
|
|
|
74ca47 |
- newvalue = counter->value;
|
|
|
74ca47 |
- slapi_unlock_mutex(counter->lock);
|
|
|
74ca47 |
+#ifdef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
+ newvalue = __atomic_add_fetch_8(&(counter->value), addvalue, __ATOMIC_SEQ_CST);
|
|
|
74ca47 |
#else
|
|
|
74ca47 |
-#ifdef LINUX
|
|
|
74ca47 |
- newvalue = __sync_add_and_fetch(&(counter->value), addvalue);
|
|
|
74ca47 |
-#elif defined(SOLARIS)
|
|
|
74ca47 |
- newvalue = _sparcv9_AtomicAdd(&(counter->value), addvalue);
|
|
|
74ca47 |
-#elif defined(HPUX)
|
|
|
74ca47 |
+#ifdef HPUX
|
|
|
74ca47 |
+ uint64_t prev = 0;
|
|
|
74ca47 |
/* fetchadd only works with values of 1, 4, 8, and 16. In addition, it requires
|
|
|
74ca47 |
* it's argument to be an integer constant. */
|
|
|
74ca47 |
if (addvalue == 1) {
|
|
|
74ca47 |
@@ -172,8 +142,13 @@ PRUint64 slapi_counter_add(Slapi_Counter *counter, PRUint64 addvalue)
|
|
|
74ca47 |
_Asm_mov_to_ar(_AREG_CCV, prev);
|
|
|
74ca47 |
} while (prev != _Asm_cmpxchg(_FASZ_D, _SEM_ACQ, &(counter->value), newvalue, _LDHINT_NONE));
|
|
|
74ca47 |
}
|
|
|
74ca47 |
+#else
|
|
|
74ca47 |
+ pthread_mutex_lock(&(counter->_lock));
|
|
|
74ca47 |
+ counter->value += addvalue;
|
|
|
74ca47 |
+ newvalue = counter->value;
|
|
|
74ca47 |
+ pthread_mutex_unlock(&(counter->_lock));
|
|
|
74ca47 |
+#endif
|
|
|
74ca47 |
#endif
|
|
|
74ca47 |
-#endif /* ATOMIC_64BIT_OPERATIONS */
|
|
|
74ca47 |
|
|
|
74ca47 |
return newvalue;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
@@ -184,28 +159,19 @@ PRUint64 slapi_counter_add(Slapi_Counter *counter, PRUint64 addvalue)
|
|
|
74ca47 |
* Atomically subtract a value from a Slapi_Counter. Note
|
|
|
74ca47 |
* that this will not prevent you from wrapping around 0.
|
|
|
74ca47 |
*/
|
|
|
74ca47 |
-PRUint64 slapi_counter_subtract(Slapi_Counter *counter, PRUint64 subvalue)
|
|
|
74ca47 |
+uint64_t slapi_counter_subtract(Slapi_Counter *counter, uint64_t subvalue)
|
|
|
74ca47 |
{
|
|
|
74ca47 |
- PRUint64 newvalue = 0;
|
|
|
74ca47 |
-#ifdef HPUX
|
|
|
74ca47 |
- PRUint64 prev = 0;
|
|
|
74ca47 |
-#endif
|
|
|
74ca47 |
+ uint64_t newvalue = 0;
|
|
|
74ca47 |
|
|
|
74ca47 |
if (counter == NULL) {
|
|
|
74ca47 |
return newvalue;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
-#ifndef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
- slapi_lock_mutex(counter->lock);
|
|
|
74ca47 |
- counter->value -= subvalue;
|
|
|
74ca47 |
- newvalue = counter->value;
|
|
|
74ca47 |
- slapi_unlock_mutex(counter->lock);
|
|
|
74ca47 |
+#ifdef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
+ newvalue = __atomic_sub_fetch_8(&(counter->value), subvalue, __ATOMIC_SEQ_CST);
|
|
|
74ca47 |
#else
|
|
|
74ca47 |
-#ifdef LINUX
|
|
|
74ca47 |
- newvalue = __sync_sub_and_fetch(&(counter->value), subvalue);
|
|
|
74ca47 |
-#elif defined(SOLARIS)
|
|
|
74ca47 |
- newvalue = _sparcv9_AtomicSub(&(counter->value), subvalue);
|
|
|
74ca47 |
-#elif defined(HPUX)
|
|
|
74ca47 |
+#ifdef HPUX
|
|
|
74ca47 |
+ uint64_t prev = 0;
|
|
|
74ca47 |
/* fetchadd only works with values of -1, -4, -8, and -16. In addition, it requires
|
|
|
74ca47 |
* it's argument to be an integer constant. */
|
|
|
74ca47 |
if (subvalue == 1) {
|
|
|
74ca47 |
@@ -229,8 +195,13 @@ PRUint64 slapi_counter_subtract(Slapi_Counter *counter, PRUint64 subvalue)
|
|
|
74ca47 |
_Asm_mov_to_ar(_AREG_CCV, prev);
|
|
|
74ca47 |
} while (prev != _Asm_cmpxchg(_FASZ_D, _SEM_ACQ, &(counter->value), newvalue, _LDHINT_NONE));
|
|
|
74ca47 |
}
|
|
|
74ca47 |
+#else
|
|
|
74ca47 |
+ pthread_mutex_lock(&(counter->_lock));
|
|
|
74ca47 |
+ counter->value -= subvalue;
|
|
|
74ca47 |
+ newvalue = counter->value;
|
|
|
74ca47 |
+ pthread_mutex_unlock(&(counter->_lock));
|
|
|
74ca47 |
+#endif
|
|
|
74ca47 |
#endif
|
|
|
74ca47 |
-#endif /* ATOMIC_64BIT_OPERATIONS */
|
|
|
74ca47 |
|
|
|
74ca47 |
return newvalue;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
@@ -240,76 +211,30 @@ PRUint64 slapi_counter_subtract(Slapi_Counter *counter, PRUint64 subvalue)
|
|
|
74ca47 |
*
|
|
|
74ca47 |
* Atomically sets the value of a Slapi_Counter.
|
|
|
74ca47 |
*/
|
|
|
74ca47 |
-PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64 newvalue)
|
|
|
74ca47 |
+uint64_t slapi_counter_set_value(Slapi_Counter *counter, uint64_t newvalue)
|
|
|
74ca47 |
{
|
|
|
74ca47 |
- PRUint64 value = 0;
|
|
|
74ca47 |
+ uint64_t value = 0;
|
|
|
74ca47 |
|
|
|
74ca47 |
if (counter == NULL) {
|
|
|
74ca47 |
return value;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
-#ifndef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
- slapi_lock_mutex(counter->lock);
|
|
|
74ca47 |
- counter->value = newvalue;
|
|
|
74ca47 |
- slapi_unlock_mutex(counter->lock);
|
|
|
74ca47 |
- return newvalue;
|
|
|
74ca47 |
-#else
|
|
|
74ca47 |
-#ifdef LINUX
|
|
|
74ca47 |
-/* Use our own inline assembly for an atomic set if
|
|
|
74ca47 |
- * the builtins aren't available. */
|
|
|
74ca47 |
-#if !HAVE_64BIT_ATOMIC_CAS_FUNC
|
|
|
74ca47 |
- /*
|
|
|
74ca47 |
- * %0 = counter->value
|
|
|
74ca47 |
- * %1 = newvalue
|
|
|
74ca47 |
- */
|
|
|
74ca47 |
- __asm__ __volatile__(
|
|
|
74ca47 |
-#ifdef CPU_x86
|
|
|
74ca47 |
- /* Save the PIC register */
|
|
|
74ca47 |
- " pushl %%ebx;"
|
|
|
74ca47 |
-#endif /* CPU_x86 */
|
|
|
74ca47 |
- /* Put value of counter->value in EDX:EAX */
|
|
|
74ca47 |
- "retryset: movl %0, %%eax;"
|
|
|
74ca47 |
- " movl 4%0, %%edx;"
|
|
|
74ca47 |
- /* Put newval in ECX:EBX */
|
|
|
74ca47 |
- " movl %1, %%ebx;"
|
|
|
74ca47 |
- " movl 4+%1, %%ecx;"
|
|
|
74ca47 |
- /* If EDX:EAX and counter-> are the same,
|
|
|
74ca47 |
- * replace *ptr with ECX:EBX */
|
|
|
74ca47 |
- " lock; cmpxchg8b %0;"
|
|
|
74ca47 |
- " jnz retryset;"
|
|
|
74ca47 |
-#ifdef CPU_x86
|
|
|
74ca47 |
- /* Restore the PIC register */
|
|
|
74ca47 |
- " popl %%ebx"
|
|
|
74ca47 |
-#endif /* CPU_x86 */
|
|
|
74ca47 |
- : "+o" (counter->value)
|
|
|
74ca47 |
- : "m" (newvalue)
|
|
|
74ca47 |
-#ifdef CPU_x86
|
|
|
74ca47 |
- : "memory", "eax", "ecx", "edx", "cc");
|
|
|
74ca47 |
-#else
|
|
|
74ca47 |
- : "memory", "eax", "ebx", "ecx", "edx", "cc");
|
|
|
74ca47 |
-#endif
|
|
|
74ca47 |
-
|
|
|
74ca47 |
- return newvalue;
|
|
|
74ca47 |
-#else
|
|
|
74ca47 |
- while (1) {
|
|
|
74ca47 |
- value = counter->value;
|
|
|
74ca47 |
- if (__sync_bool_compare_and_swap(&(counter->value), value, newvalue)) {
|
|
|
74ca47 |
- return newvalue;
|
|
|
74ca47 |
- }
|
|
|
74ca47 |
- }
|
|
|
74ca47 |
-#endif /* CPU_x86 || !HAVE_DECL___SYNC_ADD_AND_FETCH */
|
|
|
74ca47 |
-#elif defined(SOLARIS)
|
|
|
74ca47 |
- _sparcv9_AtomicSet(&(counter->value), newvalue);
|
|
|
74ca47 |
- return newvalue;
|
|
|
74ca47 |
-#elif defined(HPUX)
|
|
|
74ca47 |
+#ifdef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
+ __atomic_store_8(&(counter->value), newvalue, __ATOMIC_SEQ_CST);
|
|
|
74ca47 |
+#else /* HPUX */
|
|
|
74ca47 |
+#ifdef HPUX
|
|
|
74ca47 |
do {
|
|
|
74ca47 |
value = counter->value;
|
|
|
74ca47 |
/* Put value in a register for cmpxchg to compare against */
|
|
|
74ca47 |
_Asm_mov_to_ar(_AREG_CCV, value);
|
|
|
74ca47 |
} while (value != _Asm_cmpxchg(_FASZ_D, _SEM_ACQ, &(counter->value), newvalue, _LDHINT_NONE));
|
|
|
74ca47 |
- return newvalue;
|
|
|
74ca47 |
+#else
|
|
|
74ca47 |
+ pthread_mutex_lock(&(counter->_lock));
|
|
|
74ca47 |
+ counter->value = newvalue;
|
|
|
74ca47 |
+ pthread_mutex_unlock(&(counter->_lock));
|
|
|
74ca47 |
+#endif
|
|
|
74ca47 |
#endif
|
|
|
74ca47 |
-#endif /* ATOMIC_64BIT_OPERATIONS */
|
|
|
74ca47 |
+ return newvalue;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
/*
|
|
|
74ca47 |
@@ -317,174 +242,30 @@ PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64 newvalue)
|
|
|
74ca47 |
*
|
|
|
74ca47 |
* Returns the value of a Slapi_Counter.
|
|
|
74ca47 |
*/
|
|
|
74ca47 |
-PRUint64 slapi_counter_get_value(Slapi_Counter *counter)
|
|
|
74ca47 |
+uint64_t slapi_counter_get_value(Slapi_Counter *counter)
|
|
|
74ca47 |
{
|
|
|
74ca47 |
- PRUint64 value = 0;
|
|
|
74ca47 |
+ uint64_t value = 0;
|
|
|
74ca47 |
|
|
|
74ca47 |
if (counter == NULL) {
|
|
|
74ca47 |
return value;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
-#ifndef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
- slapi_lock_mutex(counter->lock);
|
|
|
74ca47 |
- value = counter->value;
|
|
|
74ca47 |
- slapi_unlock_mutex(counter->lock);
|
|
|
74ca47 |
-#else
|
|
|
74ca47 |
-#ifdef LINUX
|
|
|
74ca47 |
-/* Use our own inline assembly for an atomic get if
|
|
|
74ca47 |
- * the builtins aren't available. */
|
|
|
74ca47 |
-#if !HAVE_64BIT_ATOMIC_CAS_FUNC
|
|
|
74ca47 |
- /*
|
|
|
74ca47 |
- * %0 = counter->value
|
|
|
74ca47 |
- * %1 = value
|
|
|
74ca47 |
- */
|
|
|
74ca47 |
- __asm__ __volatile__(
|
|
|
74ca47 |
-#ifdef CPU_x86
|
|
|
74ca47 |
- /* Save the PIC register */
|
|
|
74ca47 |
- " pushl %%ebx;"
|
|
|
74ca47 |
-#endif /* CPU_x86 */
|
|
|
74ca47 |
- /* Put value of counter->value in EDX:EAX */
|
|
|
74ca47 |
- "retryget: movl %0, %%eax;"
|
|
|
74ca47 |
- " movl 4%0, %%edx;"
|
|
|
74ca47 |
- /* Copy EDX:EAX to ECX:EBX */
|
|
|
74ca47 |
- " movl %%eax, %%ebx;"
|
|
|
74ca47 |
- " movl %%edx, %%ecx;"
|
|
|
74ca47 |
- /* If EDX:EAX and counter->value are the same,
|
|
|
74ca47 |
- * replace *ptr with ECX:EBX */
|
|
|
74ca47 |
- " lock; cmpxchg8b %0;"
|
|
|
74ca47 |
- " jnz retryget;"
|
|
|
74ca47 |
- /* Put retrieved value into value */
|
|
|
74ca47 |
- " movl %%ebx, %1;"
|
|
|
74ca47 |
- " movl %%ecx, 4%1;"
|
|
|
74ca47 |
-#ifdef CPU_x86
|
|
|
74ca47 |
- /* Restore the PIC register */
|
|
|
74ca47 |
- " popl %%ebx"
|
|
|
74ca47 |
-#endif /* CPU_x86 */
|
|
|
74ca47 |
- : "+o" (counter->value), "=m" (value)
|
|
|
74ca47 |
- :
|
|
|
74ca47 |
-#ifdef CPU_x86
|
|
|
74ca47 |
- : "memory", "eax", "ecx", "edx", "cc");
|
|
|
74ca47 |
-#else
|
|
|
74ca47 |
- : "memory", "eax", "ebx", "ecx", "edx", "cc");
|
|
|
74ca47 |
-#endif
|
|
|
74ca47 |
-#else
|
|
|
74ca47 |
- while (1) {
|
|
|
74ca47 |
- value = counter->value;
|
|
|
74ca47 |
- if (__sync_bool_compare_and_swap(&(counter->value), value, value)) {
|
|
|
74ca47 |
- break;
|
|
|
74ca47 |
- }
|
|
|
74ca47 |
- }
|
|
|
74ca47 |
-#endif /* CPU_x86 || !HAVE_DECL___SYNC_ADD_AND_FETCH */
|
|
|
74ca47 |
-#elif defined(SOLARIS)
|
|
|
74ca47 |
- while (1) {
|
|
|
74ca47 |
- value = counter->value;
|
|
|
74ca47 |
- if (value == _sparcv9_AtomicSet(&(counter->value), value)) {
|
|
|
74ca47 |
- break;
|
|
|
74ca47 |
- }
|
|
|
74ca47 |
- }
|
|
|
74ca47 |
-#elif defined(HPUX)
|
|
|
74ca47 |
+#ifdef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
+ value = __atomic_load_8(&(counter->value), __ATOMIC_SEQ_CST);
|
|
|
74ca47 |
+#else /* HPUX */
|
|
|
74ca47 |
+#ifdef HPUX
|
|
|
74ca47 |
do {
|
|
|
74ca47 |
value = counter->value;
|
|
|
74ca47 |
/* Put value in a register for cmpxchg to compare against */
|
|
|
74ca47 |
_Asm_mov_to_ar(_AREG_CCV, value);
|
|
|
74ca47 |
} while (value != _Asm_cmpxchg(_FASZ_D, _SEM_ACQ, &(counter->value), value, _LDHINT_NONE));
|
|
|
74ca47 |
-#endif
|
|
|
74ca47 |
-#endif /* ATOMIC_64BIT_OPERATIONS */
|
|
|
74ca47 |
-
|
|
|
74ca47 |
- return value;
|
|
|
74ca47 |
-}
|
|
|
74ca47 |
-
|
|
|
74ca47 |
-#ifdef ATOMIC_64BIT_OPERATIONS
|
|
|
74ca47 |
-#if defined(LINUX) && !HAVE_64BIT_ATOMIC_OP_FUNCS
|
|
|
74ca47 |
-/* On systems that don't have the 64-bit GCC atomic builtins, we need to
|
|
|
74ca47 |
- * implement our own atomic add and subtract functions using inline
|
|
|
74ca47 |
- * assembly code. */
|
|
|
74ca47 |
-PRUint64 __sync_add_and_fetch_8(PRUint64 *ptr, PRUint64 addval)
|
|
|
74ca47 |
-{
|
|
|
74ca47 |
- PRUint64 retval = 0;
|
|
|
74ca47 |
-
|
|
|
74ca47 |
- /*
|
|
|
74ca47 |
- * %0 = *ptr
|
|
|
74ca47 |
- * %1 = retval
|
|
|
74ca47 |
- * %2 = addval
|
|
|
74ca47 |
- */
|
|
|
74ca47 |
- __asm__ __volatile__(
|
|
|
74ca47 |
-#ifdef CPU_x86
|
|
|
74ca47 |
- /* Save the PIC register */
|
|
|
74ca47 |
- " pushl %%ebx;"
|
|
|
74ca47 |
-#endif /* CPU_x86 */
|
|
|
74ca47 |
- /* Put value of *ptr in EDX:EAX */
|
|
|
74ca47 |
- "retryadd: movl %0, %%eax;"
|
|
|
74ca47 |
- " movl 4%0, %%edx;"
|
|
|
74ca47 |
- /* Put addval in ECX:EBX */
|
|
|
74ca47 |
- " movl %2, %%ebx;"
|
|
|
74ca47 |
- " movl 4+%2, %%ecx;"
|
|
|
74ca47 |
- /* Add value from EDX:EAX to value in ECX:EBX */
|
|
|
74ca47 |
- " addl %%eax, %%ebx;"
|
|
|
74ca47 |
- " adcl %%edx, %%ecx;"
|
|
|
74ca47 |
- /* If EDX:EAX and *ptr are the same, replace ptr with ECX:EBX */
|
|
|
74ca47 |
- " lock; cmpxchg8b %0;"
|
|
|
74ca47 |
- " jnz retryadd;"
|
|
|
74ca47 |
- /* Put new value into retval */
|
|
|
74ca47 |
- " movl %%ebx, %1;"
|
|
|
74ca47 |
- " movl %%ecx, 4%1;"
|
|
|
74ca47 |
-#ifdef CPU_x86
|
|
|
74ca47 |
- /* Restore the PIC register */
|
|
|
74ca47 |
- " popl %%ebx"
|
|
|
74ca47 |
-#endif /* CPU_x86 */
|
|
|
74ca47 |
- : "+o" (*ptr), "=m" (retval)
|
|
|
74ca47 |
- : "m" (addval)
|
|
|
74ca47 |
-#ifdef CPU_x86
|
|
|
74ca47 |
- : "memory", "eax", "ecx", "edx", "cc");
|
|
|
74ca47 |
#else
|
|
|
74ca47 |
- : "memory", "eax", "ebx", "ecx", "edx", "cc");
|
|
|
74ca47 |
+ pthread_mutex_lock(&(counter->_lock));
|
|
|
74ca47 |
+ value = counter->value;
|
|
|
74ca47 |
+ pthread_mutex_unlock(&(counter->_lock));
|
|
|
74ca47 |
#endif
|
|
|
74ca47 |
-
|
|
|
74ca47 |
- return retval;
|
|
|
74ca47 |
-}
|
|
|
74ca47 |
-
|
|
|
74ca47 |
-PRUint64 __sync_sub_and_fetch_8(PRUint64 *ptr, PRUint64 subval)
|
|
|
74ca47 |
-{
|
|
|
74ca47 |
- PRUint64 retval = 0;
|
|
|
74ca47 |
-
|
|
|
74ca47 |
- /*
|
|
|
74ca47 |
- * %0 = *ptr
|
|
|
74ca47 |
- * %1 = retval
|
|
|
74ca47 |
- * %2 = subval
|
|
|
74ca47 |
- */
|
|
|
74ca47 |
- __asm__ __volatile__(
|
|
|
74ca47 |
-#ifdef CPU_x86
|
|
|
74ca47 |
- /* Save the PIC register */
|
|
|
74ca47 |
- " pushl %%ebx;"
|
|
|
74ca47 |
-#endif /* CPU_x86 */
|
|
|
74ca47 |
- /* Put value of *ptr in EDX:EAX */
|
|
|
74ca47 |
- "retrysub: movl %0, %%eax;"
|
|
|
74ca47 |
- " movl 4%0, %%edx;"
|
|
|
74ca47 |
- /* Copy EDX:EAX to ECX:EBX */
|
|
|
74ca47 |
- " movl %%eax, %%ebx;"
|
|
|
74ca47 |
- " movl %%edx, %%ecx;"
|
|
|
74ca47 |
- /* Subtract subval from value in ECX:EBX */
|
|
|
74ca47 |
- " subl %2, %%ebx;"
|
|
|
74ca47 |
- " sbbl 4+%2, %%ecx;"
|
|
|
74ca47 |
- /* If EDX:EAX and ptr are the same, replace *ptr with ECX:EBX */
|
|
|
74ca47 |
- " lock; cmpxchg8b %0;"
|
|
|
74ca47 |
- " jnz retrysub;"
|
|
|
74ca47 |
- /* Put new value into retval */
|
|
|
74ca47 |
- " movl %%ebx, %1;"
|
|
|
74ca47 |
- " movl %%ecx, 4%1;"
|
|
|
74ca47 |
-#ifdef CPU_x86
|
|
|
74ca47 |
- /* Restore the PIC register */
|
|
|
74ca47 |
- " popl %%ebx"
|
|
|
74ca47 |
-#endif /* CPU_x86 */
|
|
|
74ca47 |
- : "+o" (*ptr), "=m" (retval)
|
|
|
74ca47 |
- : "m" (subval)
|
|
|
74ca47 |
-#ifdef CPU_x86
|
|
|
74ca47 |
- : "memory", "eax", "ecx", "edx", "cc");
|
|
|
74ca47 |
-#else
|
|
|
74ca47 |
- : "memory", "eax", "ebx", "ecx", "edx", "cc");
|
|
|
74ca47 |
#endif
|
|
|
74ca47 |
|
|
|
74ca47 |
- return retval;
|
|
|
74ca47 |
+ return value;
|
|
|
74ca47 |
}
|
|
|
74ca47 |
-#endif /* LINUX && !HAVE_64BIT_ATOMIC_OP_FUNCS */
|
|
|
74ca47 |
-#endif /* ATOMIC_64BIT_OPERATIONS */
|
|
|
74ca47 |
+
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/slapi_counter_sunos_sparcv9.S b/ldap/servers/slapd/slapi_counter_sunos_sparcv9.S
|
|
|
74ca47 |
deleted file mode 100644
|
|
|
74ca47 |
index e582c2a..0000000
|
|
|
74ca47 |
--- a/ldap/servers/slapd/slapi_counter_sunos_sparcv9.S
|
|
|
74ca47 |
+++ /dev/null
|
|
|
74ca47 |
@@ -1,105 +0,0 @@
|
|
|
74ca47 |
-! BEGIN COPYRIGHT BLOCK
|
|
|
74ca47 |
-! The Original Code is the Netscape Portable Runtime (NSPR).
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! The Initial Developer of the Original Code is
|
|
|
74ca47 |
-! Netscape Communications Corporation.
|
|
|
74ca47 |
-! Portions created by the Initial Developer are Copyright (C) 1998-2000
|
|
|
74ca47 |
-! the Initial Developer. All Rights Reserved.
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! The original code has been modified to support 64-bit atomic increments by
|
|
|
74ca47 |
-! Red Hat, Inc. These portions are Copyright (C) 2008 Red Hat, Inc. All Rights
|
|
|
74ca47 |
-! reserved.
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! License: GPL (version 3 or any later version).
|
|
|
74ca47 |
-! See LICENSE for details.
|
|
|
74ca47 |
-! END COPYRIGHT BLOCK
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-
|
|
|
74ca47 |
-#define _ASM 1 /* force to set an assembler code macro _ASM */
|
|
|
74ca47 |
-#include <sys/asm_linkage.h>
|
|
|
74ca47 |
-
|
|
|
74ca47 |
-! ======================================================================
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! Perform the sequence a = b atomically with respect to other
|
|
|
74ca47 |
-! fetch-and-stores to location a in a wait-free fashion.
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! usage : old_val = PR_AtomicSet(address, newval)
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! -----------------------
|
|
|
74ca47 |
-! Note on REGISTER USAGE:
|
|
|
74ca47 |
-! as this is a LEAF procedure, a new stack frame is not created;
|
|
|
74ca47 |
-! we use the caller's stack frame so what would normally be %i (input)
|
|
|
74ca47 |
-! registers are actually %o (output registers). Also, we must not
|
|
|
74ca47 |
-! overwrite the contents of %l (local) registers as they are not
|
|
|
74ca47 |
-! assumed to be volatile during calls.
|
|
|
74ca47 |
-! -----------------------
|
|
|
74ca47 |
-
|
|
|
74ca47 |
- ENTRY(_sparcv9_AtomicSet) ! standard assembler/ELF prologue
|
|
|
74ca47 |
-
|
|
|
74ca47 |
-retryAS:
|
|
|
74ca47 |
- ldx [%o0], %o2 ! set o2 to the current value
|
|
|
74ca47 |
- mov %o1, %o3 ! set up the new value
|
|
|
74ca47 |
- casx [%o0], %o2, %o3 ! atomically set if o0 hasn't changed
|
|
|
74ca47 |
- cmp %o2, %o3 ! see if we set the value
|
|
|
74ca47 |
- bne retryAS ! if not, try again
|
|
|
74ca47 |
- nop ! empty out the branch pipeline
|
|
|
74ca47 |
- retl ! return back to the caller
|
|
|
74ca47 |
- mov %o3, %o0 ! set the return code to the prev value
|
|
|
74ca47 |
-
|
|
|
74ca47 |
- SET_SIZE(_sparcv9_AtomicSet) ! standard assembler/ELF epilogue
|
|
|
74ca47 |
-
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! end
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! ======================================================================
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! Perform the sequence a = a + b atomically with respect to other
|
|
|
74ca47 |
-! fetch-and-adds to location a in a wait-free fashion.
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! usage : newval = PR_AtomicAdd(address, val)
|
|
|
74ca47 |
-! return: the value after addition
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
- ENTRY(_sparcv9_AtomicAdd) ! standard assembler/ELF prologue
|
|
|
74ca47 |
-
|
|
|
74ca47 |
-retryAA:
|
|
|
74ca47 |
- ldx [%o0], %o2 ! set o2 to the current value
|
|
|
74ca47 |
- addx %o2, %o1, %o3 ! calc the new value
|
|
|
74ca47 |
- mov %o3, %o4 ! save the return value
|
|
|
74ca47 |
- casx [%o0], %o2, %o3 ! atomically set if o0 hasn't changed
|
|
|
74ca47 |
- cmp %o2, %o3 ! see if we set the value
|
|
|
74ca47 |
- bne retryAA ! if not, try again
|
|
|
74ca47 |
- nop ! empty out the branch pipeline
|
|
|
74ca47 |
- retl ! return back to the caller
|
|
|
74ca47 |
- mov %o4, %o0 ! set the return code to the new value
|
|
|
74ca47 |
-
|
|
|
74ca47 |
- SET_SIZE(_sparcv9_AtomicAdd) ! standard assembler/ELF epilogue
|
|
|
74ca47 |
-
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! end
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! ======================================================================
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! Perform the sequence a = a - b atomically with respect to other
|
|
|
74ca47 |
-! fetch-and-subs to location a in a wait-free fashion.
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! usage : newval = PR_AtomicSub(address, val)
|
|
|
74ca47 |
-! return: the value after addition
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
- ENTRY(_sparcv9_AtomicSub) ! standard assembler/ELF prologue
|
|
|
74ca47 |
-
|
|
|
74ca47 |
-retryAU:
|
|
|
74ca47 |
- ldx [%o0], %o2 ! set o2 to the current value
|
|
|
74ca47 |
- subx %o2, %o1, %o3 ! calc the new value
|
|
|
74ca47 |
- mov %o3, %o4 ! save the return value
|
|
|
74ca47 |
- casx [%o0], %o2, %o3 ! atomically set if o0 hasn't changed
|
|
|
74ca47 |
- cmp %o2, %o3 ! see if we set the value
|
|
|
74ca47 |
- bne retryAU ! if not, try again
|
|
|
74ca47 |
- nop ! empty out the branch pipeline
|
|
|
74ca47 |
- retl ! return back to the caller
|
|
|
74ca47 |
- mov %o4, %o0 ! set the return code to the new value
|
|
|
74ca47 |
-
|
|
|
74ca47 |
- SET_SIZE(_sparcv9_AtomicSub) ! standard assembler/ELF epilogue
|
|
|
74ca47 |
-
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
-! end
|
|
|
74ca47 |
-!
|
|
|
74ca47 |
diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c
|
|
|
74ca47 |
index 841922f..b0c873d 100644
|
|
|
74ca47 |
--- a/ldap/servers/slapd/snmp_collator.c
|
|
|
74ca47 |
+++ b/ldap/servers/slapd/snmp_collator.c
|
|
|
74ca47 |
@@ -711,7 +711,7 @@ static void
|
|
|
74ca47 |
add_counter_to_value(Slapi_Entry *e, const char *type, PRUint64 countervalue)
|
|
|
74ca47 |
{
|
|
|
74ca47 |
char value[40];
|
|
|
74ca47 |
- PR_snprintf(value,sizeof(value),"%" NSPRIu64, countervalue);
|
|
|
74ca47 |
+ snprintf(value,sizeof(value),"%" NSPRIu64, countervalue);
|
|
|
74ca47 |
slapi_entry_attr_set_charptr( e, type, value);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
|
|
|
74ca47 |
diff --git a/test/libslapd/test.c b/test/libslapd/test.c
|
|
|
74ca47 |
index 37d5543..6e1171a 100644
|
|
|
74ca47 |
--- a/test/libslapd/test.c
|
|
|
74ca47 |
+++ b/test/libslapd/test.c
|
|
|
74ca47 |
@@ -24,6 +24,8 @@ run_libslapd_tests (void) {
|
|
|
74ca47 |
cmocka_unit_test(test_libslapd_pblock_v3c_original_target_dn),
|
|
|
74ca47 |
cmocka_unit_test(test_libslapd_pblock_v3c_target_uniqueid),
|
|
|
74ca47 |
cmocka_unit_test(test_libslapd_operation_v3c_target_spec),
|
|
|
74ca47 |
+ cmocka_unit_test(test_libslapd_counters_atomic_usage),
|
|
|
74ca47 |
+ cmocka_unit_test(test_libslapd_counters_atomic_overflow),
|
|
|
74ca47 |
};
|
|
|
74ca47 |
return cmocka_run_group_tests(tests, NULL, NULL);
|
|
|
74ca47 |
}
|
|
|
74ca47 |
diff --git a/test/test_slapd.h b/test/test_slapd.h
|
|
|
74ca47 |
index 02eefdd..b8f1aba 100644
|
|
|
74ca47 |
--- a/test/test_slapd.h
|
|
|
74ca47 |
+++ b/test/test_slapd.h
|
|
|
74ca47 |
@@ -37,4 +37,8 @@ void test_libslapd_pblock_v3c_target_uniqueid(void **state);
|
|
|
74ca47 |
/* libslapd-operation-v3_compat */
|
|
|
74ca47 |
void test_libslapd_operation_v3c_target_spec(void **state);
|
|
|
74ca47 |
|
|
|
74ca47 |
+/* libslapd-counters-atomic */
|
|
|
74ca47 |
+
|
|
|
74ca47 |
+void test_libslapd_counters_atomic_usage(void **state);
|
|
|
74ca47 |
+void test_libslapd_counters_atomic_overflow(void **state);
|
|
|
74ca47 |
|
|
|
74ca47 |
--
|
|
|
74ca47 |
2.9.3
|
|
|
74ca47 |
|