From 460e5bf6423f0746414bc766bc06ec70a2a6f419 Mon Sep 17 00:00:00 2001 From: William Brown Date: Fri, 30 Jun 2017 12:21:19 +1000 Subject: [PATCH] Ticket 49305 - Improve atomic behaviours in 389-ds Bug Description: Previously our usage of atomics has ranged from "okay" with PR_Atomic, to dangerous with atomic's only being partially used. Notablp, PR_Atomic is much slower than gcc's __atomic_* operations, especially given the barrier options avaliable in gcc for thread sync. Fix Description: This replaces most calles to PR_Atomic with the correct __atomic types. Importantly, this also changes the slapi_counter types to __ATOMIC_RELAXED, which removes thread ordering constraints, and allows just "atomics" to function. https://pagure.io/389-ds-base/issue/49305 Author: wibrown Review by: ??? --- ldap/servers/slapd/attrsyntax.c | 8 +- ldap/servers/slapd/back-ldbm/back-ldbm.h | 2 +- ldap/servers/slapd/back-ldbm/dblayer.c | 8 +- ldap/servers/slapd/daemon.c | 4 +- ldap/servers/slapd/entry.c | 16 +- ldap/servers/slapd/libglobs.c | 962 ++++++++--------------- ldap/servers/slapd/log.c | 12 +- ldap/servers/slapd/log.h | 2 +- ldap/servers/slapd/object.c | 10 +- ldap/servers/slapd/proto-slap.h | 2 +- ldap/servers/slapd/psearch.c | 8 +- ldap/servers/slapd/slap.h | 31 +- ldap/servers/slapd/slapi_counter.c | 13 +- src/nunc-stans/test/test_nuncstans_stress_core.c | 2 +- 14 files changed, 364 insertions(+), 716 deletions(-) diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c index 9e836b6..13ae31a 100644 --- a/ldap/servers/slapd/attrsyntax.c +++ b/ldap/servers/slapd/attrsyntax.c @@ -262,7 +262,7 @@ attr_syntax_get_by_oid_locking_optional( const char *oid, PRBool use_lock, PRUin asi = (struct asyntaxinfo *)PL_HashTableLookup_const(ht, oid); if (asi) { - PR_AtomicIncrement( &asi->asi_refcnt ); + __atomic_add_fetch_8(&(asi->asi_refcnt), 1, __ATOMIC_RELEASE); } if ( use_lock ) { AS_UNLOCK_READ(oid2asi_lock); @@ -359,7 +359,7 @@ attr_syntax_get_by_name_locking_optional(const char *name, PRBool use_lock, PRUi } asi = (struct asyntaxinfo *)PL_HashTableLookup_const(ht, name); if ( NULL != asi ) { - PR_AtomicIncrement( &asi->asi_refcnt ); + __atomic_add_fetch_8(&(asi->asi_refcnt), 1, __ATOMIC_RELEASE); } if ( use_lock ) { AS_UNLOCK_READ(name2asi_lock); @@ -394,7 +394,7 @@ attr_syntax_return_locking_optional(struct asyntaxinfo *asi, PRBool use_lock) } if ( NULL != asi ) { PRBool delete_it = PR_FALSE; - if ( 0 == PR_AtomicDecrement( &asi->asi_refcnt )) { + if ( 0 == __atomic_sub_fetch_8(&(asi->asi_refcnt), 1, __ATOMIC_ACQ_REL)) { delete_it = asi->asi_marked_for_delete; } @@ -527,7 +527,7 @@ attr_syntax_delete_no_lock( struct asyntaxinfo *asi, PL_HashTableRemove(ht, asi->asi_aliases[i]); } } - if ( asi->asi_refcnt > 0 ) { + if ( __atomic_load_8(&(asi->asi_refcnt), __ATOMIC_ACQUIRE) > 0 ) { asi->asi_marked_for_delete = PR_TRUE; } else { /* This is ok, but the correct thing is to call delete first, diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h index 4568ba7..299eb70 100644 --- a/ldap/servers/slapd/back-ldbm/back-ldbm.h +++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h @@ -452,7 +452,7 @@ struct attrinfo { #define IS_INDEXED( a ) ( a & INDEX_ANY ) char **ai_index_rules; /* matching rule OIDs */ void *ai_dblayer; /* private data used by the dblayer code */ - PRInt32 ai_dblayer_count; /* used by the dblayer code */ + uint64_t ai_dblayer_count; /* used by the dblayer code */ idl_private *ai_idl; /* private data used by the IDL code (eg locking the IDLs) */ attrcrypt_private *ai_attrcrypt; /* private data used by the attribute encryption code (eg is it enabled or not) */ value_compare_fn_type ai_key_cmp_fn; /* function used to compare two index keys - diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c index 0e81643..3290052 100644 --- a/ldap/servers/slapd/back-ldbm/dblayer.c +++ b/ldap/servers/slapd/back-ldbm/dblayer.c @@ -2917,7 +2917,7 @@ int dblayer_get_index_file(backend *be, struct attrinfo *a, DB** ppDB, int open_ /* it's like a semaphore -- when count > 0, any file handle that's in * the attrinfo will remain valid from here on. */ - PR_AtomicIncrement(&a->ai_dblayer_count); + __atomic_add_fetch_8(&(a->ai_dblayer_count), 1, __ATOMIC_RELEASE); if (a->ai_dblayer && ((dblayer_handle*)(a->ai_dblayer))->dblayer_dbp) { /* This means that the pointer is valid, so we should return it. */ @@ -2981,7 +2981,7 @@ int dblayer_get_index_file(backend *be, struct attrinfo *a, DB** ppDB, int open_ /* some sort of error -- we didn't open a handle at all. * decrement the refcount back to where it was. */ - PR_AtomicDecrement(&a->ai_dblayer_count); + __atomic_sub_fetch_8(&(a->ai_dblayer_count), 1, __ATOMIC_RELEASE); } return return_value; @@ -2992,7 +2992,7 @@ int dblayer_get_index_file(backend *be, struct attrinfo *a, DB** ppDB, int open_ */ int dblayer_release_index_file(backend *be __attribute__((unused)), struct attrinfo *a, DB* pDB __attribute__((unused))) { - PR_AtomicDecrement(&a->ai_dblayer_count); + __atomic_sub_fetch_8(&(a->ai_dblayer_count), 1, __ATOMIC_RELEASE); return 0; } @@ -3094,7 +3094,7 @@ int dblayer_erase_index_file_ex(backend *be, struct attrinfo *a, dblayer_release_index_file(be, a, db); - while (a->ai_dblayer_count > 0) { + while (__atomic_load_8(&(a->ai_dblayer_count), __ATOMIC_ACQUIRE) > 0) { /* someone is using this index file */ /* ASSUMPTION: you have already set the INDEX_OFFLINE flag, because * you intend to mess with this index. therefore no new requests diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index e63c26a..50ab0c9 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -922,7 +922,7 @@ void slapd_daemon( daemon_ports_t *ports, ns_thrpool_t *tp ) PRIntn num_poll = 0; PRIntervalTime pr_timeout = PR_MillisecondsToInterval(slapd_wakeup_timer); PRThread *time_thread_p; - int threads; + uint64_t threads; int in_referral_mode = config_check_referral_mode(); int connection_table_size = get_configured_connection_table_size(); the_connection_table= connection_table_new(connection_table_size); @@ -1574,7 +1574,7 @@ handle_timeout( void ) if ( difftime(curtime, prevtime) >= slapd_housekeeping_timer ) { - int num_active_threads; + uint64_t num_active_threads; snmp_collator_update(); diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c index 4d57277..05dc607 100644 --- a/ldap/servers/slapd/entry.c +++ b/ldap/servers/slapd/entry.c @@ -2376,29 +2376,29 @@ slapi_entry_attr_find( const Slapi_Entry *e, const char *type, Slapi_Attr **a ) /* the following functions control virtual attribute cache invalidation */ -static PRInt32 g_virtual_watermark = -1; /* good enough to init */ +static uint32_t g_virtual_watermark = 0; /* good enough to init */ int slapi_entry_vattrcache_watermark_isvalid(const Slapi_Entry *e) { - return e->e_virtual_watermark == g_virtual_watermark; + return e->e_virtual_watermark == __atomic_load_4(&g_virtual_watermark, __ATOMIC_ACQUIRE); } void slapi_entry_vattrcache_watermark_set(Slapi_Entry *e) { - e->e_virtual_watermark = g_virtual_watermark; + e->e_virtual_watermark = __atomic_load_4(&g_virtual_watermark, __ATOMIC_ACQUIRE); } void slapi_entry_vattrcache_watermark_invalidate(Slapi_Entry *e) { - e->e_virtual_watermark = 0; + e->e_virtual_watermark = 0; } void slapi_entrycache_vattrcache_watermark_invalidate() { - PR_AtomicIncrement(&g_virtual_watermark); - if (g_virtual_watermark == 0) { - PR_AtomicIncrement(&g_virtual_watermark); - } + /* Make sure the value is never 0 */ + if (__atomic_add_fetch_4(&g_virtual_watermark, 1, __ATOMIC_RELEASE) == 0) { + __atomic_add_fetch_4(&g_virtual_watermark, 1, __ATOMIC_RELEASE); + } } /* The following functions control the virtual attribute cache diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index 6f9bcdc..77da741 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -162,8 +162,8 @@ typedef enum { CONFIG_SPECIAL_UNHASHED_PW_SWITCH /* unhashed pw: on/off/nolog */ } ConfigVarType; -static int config_set_onoff( const char *attrname, char *value, - int *configvalue, char *errorbuf, int apply ); +static int32_t config_set_onoff( const char *attrname, char *value, + int32_t *configvalue, char *errorbuf, int apply ); static int config_set_schemareplace ( const char *attrname, char *value, char *errorbuf, int apply ); static void remove_commas(char *str); @@ -1334,24 +1334,24 @@ strarray2bervalarray(const char **strarray) /* * counter for active threads */ -static PRInt32 active_threads = 0; +static uint64_t active_threads = 0; void g_incr_active_threadcnt(void) { - PR_AtomicIncrement(&active_threads); + __atomic_add_fetch_8(&active_threads, 1, __ATOMIC_RELEASE); } void g_decr_active_threadcnt(void) { - PR_AtomicDecrement(&active_threads); + __atomic_sub_fetch_8(&active_threads, 1, __ATOMIC_RELEASE); } -int +uint64_t g_get_active_threadcnt(void) { - return (int)active_threads; + return __atomic_load_8(&active_threads, __ATOMIC_ACQUIRE); } /* @@ -1724,11 +1724,11 @@ get_entry_point( int ep_name, caddr_t *ep_addr ) return rc; } -int +int32_t config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbuf, int apply) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->auditlog_logging_hide_unhashed_pw), errorbuf, apply); @@ -1740,11 +1740,11 @@ config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbu return retVal; } -int +int32_t config_set_auditfaillog_unhashed_pw(const char *attrname, char *value, char *errorbuf, int apply) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->auditfaillog_logging_hide_unhashed_pw), errorbuf, apply); @@ -1757,11 +1757,11 @@ config_set_auditfaillog_unhashed_pw(const char *attrname, char *value, char *err } #ifdef HAVE_CLOCK_GETTIME -int +int32_t config_set_logging_hr_timestamps(const char *attrname, char *value, char *errorbuf, int apply) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->logging_hr_timestamps), errorbuf, apply); @@ -1796,33 +1796,33 @@ config_value_is_null( const char *attrname, const char *value, char *errorbuf, return 0; } -int +int32_t config_set_ignore_vattrs (const char *attrname, char *value, char *errorbuf, int apply ) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->ignore_vattrs), errorbuf, apply); return retVal; } -int +int32_t config_set_sasl_mapping_fallback (const char *attrname, char *value, char *errorbuf, int apply ) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->sasl_mapping_fallback), errorbuf, apply); return retVal; } -int +int32_t config_set_disk_monitoring( const char *attrname, char *value, char *errorbuf, int apply ) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->disk_monitoring), errorbuf, apply); @@ -1860,11 +1860,11 @@ config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, in return retVal; } -int +int32_t config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply ) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->disk_logging_critical), errorbuf, apply); @@ -1900,11 +1900,11 @@ config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf, return retVal; } -int +int32_t config_set_ndn_cache_enabled(const char *attrname, char *value, char *errorbuf, int apply ) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; + int32_t retVal; retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->ndn_cache_enabled), errorbuf, apply); @@ -1974,11 +1974,11 @@ config_set_sasl_maxbufsize(const char *attrname, char *value, char *errorbuf, in return retVal; } -int +int32_t config_set_return_orig_type_switch(const char *attrname, char *value, char *errorbuf, int apply) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; + int32_t retVal; retVal = config_set_onoff(attrname, value, &(slapdFrontendConfig->return_orig_type), errorbuf, apply); @@ -2094,11 +2094,11 @@ config_set_SSLclientAuth( const char *attrname, char *value, char *errorbuf, int } -int +int32_t config_set_ssl_check_hostname(const char *attrname, char *value, char *errorbuf, int apply) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, @@ -2199,9 +2199,9 @@ config_set_ldapi_filename( const char *attrname, char *value, char *errorbuf, in return retVal; } -int +int32_t config_set_ldapi_switch( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, @@ -2213,9 +2213,10 @@ config_set_ldapi_switch( const char *attrname, char *value, char *errorbuf, int return retVal; } -int config_set_ldapi_bind_switch( const char *attrname, char *value, char *errorbuf, int apply ) +int32_t +config_set_ldapi_bind_switch( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, @@ -2246,9 +2247,10 @@ int config_set_ldapi_root_dn( const char *attrname, char *value, char *errorbuf, return retVal; } -int config_set_ldapi_map_entries( const char *attrname, char *value, char *errorbuf, int apply ) +int32_t +config_set_ldapi_map_entries( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, @@ -2364,9 +2366,10 @@ int config_set_anon_limits_dn( const char *attrname, char *value, char *errorbuf * incremented. Note: counters which are necessary for the server's running * are not disabled. */ -int config_set_slapi_counters( const char *attrname, char *value, char *errorbuf, int apply ) +int32_t +config_set_slapi_counters( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, value, @@ -2559,9 +2562,9 @@ config_set_pw_storagescheme( const char *attrname, char *value, char *errorbuf, } -int +int32_t config_set_pw_change( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -2574,9 +2577,9 @@ config_set_pw_change( const char *attrname, char *value, char *errorbuf, int app } -int +int32_t config_set_pw_history( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -2589,9 +2592,9 @@ config_set_pw_history( const char *attrname, char *value, char *errorbuf, int ap } -int +int32_t config_set_pw_must_change( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -2604,9 +2607,9 @@ config_set_pw_must_change( const char *attrname, char *value, char *errorbuf, in } -int +int32_t config_set_pwpolicy_local( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -2619,10 +2622,10 @@ config_set_pwpolicy_local( const char *attrname, char *value, char *errorbuf, in } -int +int32_t config_set_pwpolicy_inherit_global(const char *attrname, char *value, char *errorbuf, int apply) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff (attrname, @@ -2635,9 +2638,9 @@ config_set_pwpolicy_inherit_global(const char *attrname, char *value, char *erro } -int +int32_t config_set_allow_hashed_pw( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -2649,9 +2652,9 @@ config_set_allow_hashed_pw( const char *attrname, char *value, char *errorbuf, i return retVal; } -int +int32_t config_set_pw_syntax( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3130,9 +3133,9 @@ config_set_pw_resetfailurecount( const char *attrname, char *value, char *errorb return retVal; } -int +int32_t config_set_pw_is_global_policy( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3144,9 +3147,9 @@ config_set_pw_is_global_policy( const char *attrname, char *value, char *errorbu return retVal; } -int +int32_t config_set_pw_is_legacy_policy( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3172,9 +3175,9 @@ config_set_pw_admin_dn( const char *attrname __attribute__((unused)), char *valu return retVal; } -int +int32_t config_set_pw_track_last_update_time( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3186,9 +3189,9 @@ config_set_pw_track_last_update_time( const char *attrname, char *value, char *e return retVal; } -int +int32_t config_set_pw_exp( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3200,9 +3203,9 @@ config_set_pw_exp( const char *attrname, char *value, char *errorbuf, int apply return retVal; } -int +int32_t config_set_pw_send_expiring( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3214,9 +3217,9 @@ config_set_pw_send_expiring( const char *attrname, char *value, char *errorbuf, return retVal; } -int +int32_t config_set_pw_unlock( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3229,9 +3232,9 @@ config_set_pw_unlock( const char *attrname, char *value, char *errorbuf, int app } -int +int32_t config_set_pw_lockout( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3279,9 +3282,9 @@ config_set_pw_gracelimit( const char *attrname, char *value, char *errorbuf, int } -int +int32_t config_set_lastmod( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; Slapi_Backend *be = NULL; char *cookie; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); @@ -3312,9 +3315,9 @@ config_set_lastmod( const char *attrname, char *value, char *errorbuf, int apply } -int +int32_t config_set_nagle( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3327,9 +3330,9 @@ config_set_nagle( const char *attrname, char *value, char *errorbuf, int apply ) } -int +int32_t config_set_accesscontrol( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3343,9 +3346,9 @@ config_set_accesscontrol( const char *attrname, char *value, char *errorbuf, int -int +int32_t config_set_return_exact_case( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3358,9 +3361,9 @@ config_set_return_exact_case( const char *attrname, char *value, char *errorbuf, } -int +int32_t config_set_result_tweak( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3372,9 +3375,9 @@ config_set_result_tweak( const char *attrname, char *value, char *errorbuf, int return retVal; } -int +int32_t config_set_plugin_tracking( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3386,9 +3389,9 @@ config_set_plugin_tracking( const char *attrname, char *value, char *errorbuf, i return retVal; } -int +int32_t config_set_moddn_aci( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3400,9 +3403,9 @@ config_set_moddn_aci( const char *attrname, char *value, char *errorbuf, int app return retVal; } -int +int32_t config_set_dynamic_plugins( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3414,22 +3417,16 @@ config_set_dynamic_plugins( const char *attrname, char *value, char *errorbuf, i return retVal; } -int +int32_t config_get_dynamic_plugins(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->dynamic_plugins; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->dynamic_plugins), __ATOMIC_ACQUIRE); } -int +int32_t config_set_cn_uses_dn_syntax_in_dns(const char *attrname, char *value, char *errorbuf, int apply) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3441,22 +3438,16 @@ config_set_cn_uses_dn_syntax_in_dns(const char *attrname, char *value, char *err return retVal; } -int +int32_t config_get_cn_uses_dn_syntax_in_dns() { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->cn_uses_dn_syntax_in_dns; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->cn_uses_dn_syntax_in_dns), __ATOMIC_ACQUIRE); } -int +int32_t config_set_security( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3468,50 +3459,41 @@ config_set_security( const char *attrname, char *value, char *errorbuf, int appl return retVal; } -static int -config_set_onoff(const char *attrname, char *value, int *configvalue, char *errorbuf, int apply) +static int32_t +config_set_onoff(const char *attrname, char *value, int32_t *configvalue, char *errorbuf, int apply) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapi_onoff_t newval = -1; -#ifndef ATOMIC_GETSET_ONOFF - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); -#endif - + if ( config_value_is_null( attrname, value, errorbuf, 1 )) { return LDAP_OPERATIONS_ERROR; } - - CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig); + if (strcasecmp(value, "on") && strcasecmp(value, "off")) { slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\". Valid values are \"on\" or \"off\".", attrname, value); retVal = LDAP_OPERATIONS_ERROR; } - + if ( !apply ) { /* we can return now if we aren't applying the changes */ return retVal; } - + if ( strcasecmp ( value, "on" ) == 0 ) { newval = LDAP_ON; } else if ( strcasecmp ( value, "off" ) == 0 ) { newval = LDAP_OFF; } - -#ifdef ATOMIC_GETSET_ONOFF - PR_AtomicSet(configvalue, newval); -#else - *configvalue = newval; -#endif - CFG_ONOFF_UNLOCK_WRITE(slapdFrontendConfig); + + __atomic_store_4(configvalue, newval, __ATOMIC_RELEASE); return retVal; } - -int + +int32_t config_set_readonly( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3523,9 +3505,9 @@ config_set_readonly( const char *attrname, char *value, char *errorbuf, int appl return retVal; } -int +int32_t config_set_schemacheck( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3537,9 +3519,9 @@ config_set_schemacheck( const char *attrname, char *value, char *errorbuf, int a return retVal; } -int +int32_t config_set_schemamod( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3551,9 +3533,9 @@ config_set_schemamod( const char *attrname, char *value, char *errorbuf, int app return retVal; } -int +int32_t config_set_syntaxcheck( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3565,9 +3547,9 @@ config_set_syntaxcheck( const char *attrname, char *value, char *errorbuf, int a return retVal; } -int +int32_t config_set_syntaxlogging( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3579,9 +3561,9 @@ config_set_syntaxlogging( const char *attrname, char *value, char *errorbuf, int return retVal; } -int +int32_t config_set_dn_validate_strict( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3593,9 +3575,9 @@ config_set_dn_validate_strict( const char *attrname, char *value, char *errorbuf return retVal; } -int +int32_t config_set_ds4_compatible_schema( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3608,10 +3590,10 @@ config_set_ds4_compatible_schema( const char *attrname, char *value, char *error } -int +int32_t config_set_schema_ignore_trailing_spaces( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3624,9 +3606,9 @@ config_set_schema_ignore_trailing_spaces( const char *attrname, char *value, } -int +int32_t config_set_enquote_sup_oc( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -3891,13 +3873,7 @@ config_set_maxthreadsperconn( const char *attrname, char *value, char *errorbuf, } if (apply) { -#ifdef ATOMIC_GETSET_MAXTHREADSPERCONN - PR_AtomicSet(&slapdFrontendConfig->maxthreadsperconn, (slapi_int_t)maxthreadnum); -#else - CFG_LOCK_WRITE(slapdFrontendConfig); - slapdFrontendConfig->maxthreadsperconn = maxthreadnum; - CFG_UNLOCK_WRITE(slapdFrontendConfig); -#endif + __atomic_store_4(&(slapdFrontendConfig->maxthreadsperconn), maxthreadnum, __ATOMIC_RELEASE); } return retVal; } @@ -4051,13 +4027,7 @@ config_set_ioblocktimeout( const char *attrname, char *value, char *errorbuf, in } if ( apply ) { -#ifdef ATOMIC_GETSET_IOBLOCKTIMEOUT - PR_AtomicSet(&slapdFrontendConfig->ioblocktimeout, (PRInt32)nValue); -#else - CFG_LOCK_WRITE(slapdFrontendConfig); - slapdFrontendConfig->ioblocktimeout = nValue; - CFG_UNLOCK_WRITE(slapdFrontendConfig); -#endif + __atomic_store_4(&(slapdFrontendConfig->ioblocktimeout), nValue, __ATOMIC_RELEASE); } return retVal; @@ -4559,41 +4529,23 @@ config_get_ignore_vattrs() return (int)slapdFrontendConfig->ignore_vattrs; } -int +int32_t config_get_sasl_mapping_fallback() { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->sasl_mapping_fallback; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->sasl_mapping_fallback), __ATOMIC_ACQUIRE); } -int +int32_t config_get_disk_monitoring(){ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->disk_monitoring; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->disk_monitoring), __ATOMIC_ACQUIRE); } -int +int32_t config_get_disk_logging_critical(){ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->disk_logging_critical; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->disk_logging_critical), __ATOMIC_ACQUIRE); } int @@ -4633,24 +4585,16 @@ config_get_ldapi_filename(){ } -int config_get_ldapi_switch(){ - int retVal; - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->ldapi_switch; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; +int32_t +config_get_ldapi_switch() { + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->ldapi_switch), __ATOMIC_ACQUIRE); } -int config_get_ldapi_bind_switch(){ - int retVal; - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->ldapi_bind_switch; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; +int32_t +config_get_ldapi_bind_switch() { + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->ldapi_bind_switch), __ATOMIC_ACQUIRE); } char *config_get_ldapi_root_dn(){ @@ -4664,13 +4608,8 @@ char *config_get_ldapi_root_dn(){ } int config_get_ldapi_map_entries(){ - int retVal; - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->ldapi_map_entries; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->ldapi_map_entries), __ATOMIC_ACQUIRE); } char *config_get_ldapi_uidnumber_type(){ @@ -4726,15 +4665,11 @@ char *config_get_anon_limits_dn(){ return retVal; } -int config_get_slapi_counters() -{ - int retVal; - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->slapi_counters; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; +int32_t +config_get_slapi_counters() +{ + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->slapi_counters), __ATOMIC_ACQUIRE); } char * @@ -4903,68 +4838,38 @@ config_get_pw_storagescheme(void) { } -int +int32_t config_get_pw_change(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->pw_policy.pw_change; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->pw_policy.pw_change), __ATOMIC_ACQUIRE); } -int +int32_t config_get_pw_history(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->pw_policy.pw_history; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->pw_policy.pw_history), __ATOMIC_ACQUIRE); } -int +int32_t config_get_pw_must_change(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->pw_policy.pw_must_change; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->pw_policy.pw_must_change), __ATOMIC_ACQUIRE); } -int +int32_t config_get_allow_hashed_pw(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->allow_hashed_pw; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->allow_hashed_pw), __ATOMIC_ACQUIRE); } -int +int32_t config_get_pw_syntax(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->pw_policy.pw_syntax; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->pw_policy.pw_syntax), __ATOMIC_ACQUIRE); } @@ -5138,65 +5043,35 @@ config_get_pw_resetfailurecount(void) { return retVal; } -int +int32_t config_get_pw_is_global_policy(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->pw_is_global_policy; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->pw_is_global_policy), __ATOMIC_ACQUIRE); } -int +int32_t config_get_pw_is_legacy_policy(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->pw_policy.pw_is_legacy; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->pw_policy.pw_is_legacy), __ATOMIC_ACQUIRE); } -int +int32_t config_get_pw_exp(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->pw_policy.pw_exp; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->pw_policy.pw_exp), __ATOMIC_ACQUIRE); } -int +int32_t config_get_pw_unlock(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->pw_policy.pw_unlock; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->pw_policy.pw_unlock), __ATOMIC_ACQUIRE); } -int +int32_t config_get_pw_lockout(){ - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->pw_policy.pw_lockout; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->pw_policy.pw_lockout), __ATOMIC_ACQUIRE); } int @@ -5212,193 +5087,100 @@ config_get_pw_gracelimit(void) { } -int +int32_t config_get_lastmod(){ - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->lastmod; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->lastmod), __ATOMIC_ACQUIRE); } -int +int32_t config_get_enquote_sup_oc(){ - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->enquote_sup_oc; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->enquote_sup_oc), __ATOMIC_ACQUIRE); } -int +int32_t config_get_nagle(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->nagle; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->nagle), __ATOMIC_ACQUIRE); } -int +int32_t config_get_accesscontrol(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->accesscontrol; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->accesscontrol), __ATOMIC_ACQUIRE); } -int +int32_t config_get_return_exact_case(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - retVal = (int)slapdFrontendConfig->return_exact_case; - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->return_exact_case), __ATOMIC_ACQUIRE); } -int +int32_t config_get_result_tweak(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->result_tweak; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->result_tweak), __ATOMIC_ACQUIRE); } -int +int32_t config_get_moddn_aci(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->moddn_aci; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->moddn_aci), __ATOMIC_ACQUIRE); } -int +int32_t config_get_security(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->security; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->security), __ATOMIC_ACQUIRE); } - -int -slapi_config_get_readonly(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->readonly; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - return retVal; +int32_t +slapi_config_get_readonly(void) { + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->readonly), __ATOMIC_ACQUIRE); } -int +int32_t config_get_schemacheck(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->schemacheck; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->schemacheck), __ATOMIC_ACQUIRE); } -int +int32_t config_get_schemamod(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->schemamod; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->schemamod), __ATOMIC_ACQUIRE); } -int +int32_t config_get_syntaxcheck(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->syntaxcheck; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->syntaxcheck), __ATOMIC_ACQUIRE); } -int +int32_t config_get_syntaxlogging(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->syntaxlogging; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->syntaxlogging), __ATOMIC_ACQUIRE); } -int +int32_t config_get_dn_validate_strict(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->dn_validate_strict; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->dn_validate_strict), __ATOMIC_ACQUIRE); } -int +int32_t config_get_ds4_compatible_schema(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->ds4_compatible_schema; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->ds4_compatible_schema), __ATOMIC_ACQUIRE); } -int +int32_t config_get_schema_ignore_trailing_spaces(void) { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->schema_ignore_trailing_spaces; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->schema_ignore_trailing_spaces), __ATOMIC_ACQUIRE); } char * @@ -5490,18 +5272,10 @@ config_get_threadnumber(void) { return retVal; } -int +int32_t config_get_maxthreadsperconn(){ - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; -#ifdef ATOMIC_GETSET_MAXTHREADSPERCONN - retVal = (int)slapdFrontendConfig->maxthreadsperconn; -#else - CFG_LOCK_READ(slapdFrontendConfig); - retVal = slapdFrontendConfig->maxthreadsperconn; - CFG_UNLOCK_READ(slapdFrontendConfig); -#endif - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->maxthreadsperconn), __ATOMIC_ACQUIRE); } int @@ -5527,20 +5301,10 @@ config_get_reservedescriptors(){ return retVal; } -int +int32_t config_get_ioblocktimeout(){ - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - -#ifndef ATOMIC_GETSET_IOBLOCKTIMEOUT - CFG_LOCK_READ(slapdFrontendConfig); -#endif - retVal = (int)slapdFrontendConfig->ioblocktimeout; -#ifndef ATOMIC_GETSET_IOBLOCKTIMEOUT - CFG_UNLOCK_READ(slapdFrontendConfig); -#endif - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->ioblocktimeout), __ATOMIC_ACQUIRE); } int @@ -5833,39 +5597,25 @@ config_get_outbound_ldap_io_timeout(void) return retVal; } -int +int32_t config_get_unauth_binds_switch(void) { - int retVal; - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->allow_unauth_binds; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->allow_unauth_binds), __ATOMIC_ACQUIRE); } -int +int32_t config_get_require_secure_binds(void) { - int retVal; - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->require_secure_binds; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->require_secure_binds), __ATOMIC_ACQUIRE); } -int +int32_t config_get_anon_access_switch(void) { - int retVal = 0; - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->allow_anon_access; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->allow_anon_access), __ATOMIC_ACQUIRE); } int @@ -6066,11 +5816,11 @@ config_set_minssf( const char *attrname, char *value, char *errorbuf, int apply return retVal; } -int +int32_t config_set_minssf_exclude_rootdse( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff ( attrname, @@ -6104,16 +5854,11 @@ config_get_minssf() return minssf; } -int +int32_t config_get_minssf_exclude_rootdse() { - int retVal; - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->minssf_exclude_rootdse; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->minssf_exclude_rootdse), __ATOMIC_ACQUIRE); } int @@ -6138,33 +5883,18 @@ config_set_max_filter_nest_level( const char *attrname, char *value, } if ( !apply ) { - return retVal; + return retVal; } -#ifdef ATOMIC_GETSET_FILTER_NEST_LEVEL - PR_AtomicSet(&slapdFrontendConfig->max_filter_nest_level, level); -#else - CFG_LOCK_WRITE(slapdFrontendConfig); - slapdFrontendConfig->max_filter_nest_level = level; - CFG_UNLOCK_WRITE(slapdFrontendConfig); -#endif + __atomic_store_4(&(slapdFrontendConfig->max_filter_nest_level), level, __ATOMIC_RELEASE); return retVal; } -int +int32_t config_get_max_filter_nest_level() { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - -#ifndef ATOMIC_GETSET_FILTER_NEST_LEVEL - CFG_LOCK_READ(slapdFrontendConfig); -#endif - retVal = (int)slapdFrontendConfig->max_filter_nest_level; -#ifndef ATOMIC_GETSET_FILTER_NEST_LEVEL - CFG_UNLOCK_READ(slapdFrontendConfig); -#endif - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->max_filter_nest_level), __ATOMIC_ACQUIRE); } size_t @@ -6178,27 +5908,17 @@ config_get_ndn_cache_size(){ return retVal; } -int +int32_t config_get_ndn_cache_enabled(){ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->ndn_cache_enabled; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->ndn_cache_enabled), __ATOMIC_ACQUIRE); } -int +int32_t config_get_return_orig_type_switch() { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal; - - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->return_orig_type; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->return_orig_type), __ATOMIC_ACQUIRE); } char * @@ -6620,10 +6340,10 @@ config_get_auditfaillog_list() return log_get_loglist(SLAPD_AUDITFAIL_LOG); } -int +int32_t config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, int apply) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, @@ -6635,10 +6355,10 @@ config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, return retVal; } -int +int32_t config_set_csnlogging(const char *attrname, char *value, char *errorbuf, int apply) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, @@ -6657,10 +6377,10 @@ config_get_csnlogging() return (int)slapdFrontendConfig->csnlogging; } -int +int32_t config_set_attrname_exceptions(const char *attrname, char *value, char *errorbuf, int apply) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, @@ -6679,11 +6399,11 @@ config_get_attrname_exceptions() return (int)slapdFrontendConfig->attrname_exceptions; } -int +int32_t config_set_hash_filters(const char *attrname, char *value, char *errorbuf, int apply) { - int val = 0; - int retVal = LDAP_SUCCESS; + int32_t val = 0; + int32_t retVal = LDAP_SUCCESS; retVal = config_set_onoff(attrname, value, @@ -6704,10 +6424,10 @@ config_get_hash_filters() return 0; /* for now */ } -int +int32_t config_set_rewrite_rfc1274(const char *attrname, char *value, char *errorbuf, int apply) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, @@ -6793,11 +6513,11 @@ config_set_outbound_ldap_io_timeout( const char *attrname, char *value, } -int +int32_t config_set_unauth_binds_switch( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, @@ -6809,11 +6529,11 @@ config_set_unauth_binds_switch( const char *attrname, char *value, return retVal; } -int +int32_t config_set_require_secure_binds( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, @@ -6899,23 +6619,18 @@ config_set_validate_cert_switch( const char *attrname, char *value, return retVal; } -int +int32_t config_get_force_sasl_external(void) { - int retVal; - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->force_sasl_external; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return __atomic_load_4(&(slapdFrontendConfig->force_sasl_external), __ATOMIC_ACQUIRE); } -int +int32_t config_set_force_sasl_external( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, @@ -6927,23 +6642,18 @@ config_set_force_sasl_external( const char *attrname, char *value, return retVal; } -int +int32_t config_get_entryusn_global(void) { - int retVal; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->entryusn_global; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->entryusn_global), __ATOMIC_ACQUIRE); } -int +int32_t config_set_entryusn_global( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, value, @@ -7168,89 +6878,59 @@ config_set_unhashed_pw_switch(const char *attrname, char *value, return retVal; } -int +int32_t config_get_enable_turbo_mode(void) { - int retVal; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->enable_turbo_mode; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->enable_turbo_mode), __ATOMIC_ACQUIRE); } -int +int32_t config_get_connection_nocanon(void) { - int retVal; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->connection_nocanon; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->connection_nocanon), __ATOMIC_ACQUIRE); } -int +int32_t config_get_plugin_logging(void) { - int retVal; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_ONOFF_LOCK_READ(slapdFrontendConfig); - retVal = (int)slapdFrontendConfig->plugin_logging; - CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->plugin_logging), __ATOMIC_ACQUIRE); } -int +int32_t slapi_config_get_unhashed_pw_switch() { return config_get_unhashed_pw_switch(); } -int +int32_t config_get_unhashed_pw_switch() { - int retVal = 0; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_LOCK_READ(slapdFrontendConfig); - retVal = slapdFrontendConfig->unhashed_pw_switch; - CFG_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->unhashed_pw_switch), __ATOMIC_ACQUIRE); } -int +int32_t config_get_ignore_time_skew(void) { - int retVal; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_LOCK_READ(slapdFrontendConfig); - retVal = slapdFrontendConfig->ignore_time_skew; - CFG_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->ignore_time_skew), __ATOMIC_ACQUIRE); } -int +int32_t config_get_global_backend_lock() { - int retVal; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - CFG_LOCK_READ(slapdFrontendConfig); - retVal = slapdFrontendConfig->global_backend_lock; - CFG_UNLOCK_READ(slapdFrontendConfig); - - return retVal; + return __atomic_load_4(&(slapdFrontendConfig->global_backend_lock), __ATOMIC_ACQUIRE); } -int +int32_t config_set_enable_turbo_mode( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, value, @@ -7259,11 +6939,11 @@ config_set_enable_turbo_mode( const char *attrname, char *value, return retVal; } -int +int32_t config_set_connection_nocanon( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, value, @@ -7272,11 +6952,11 @@ config_set_connection_nocanon( const char *attrname, char *value, return retVal; } -int +int32_t config_set_ignore_time_skew( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, value, @@ -7285,11 +6965,11 @@ config_set_ignore_time_skew( const char *attrname, char *value, return retVal; } -int +int32_t config_set_global_backend_lock( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, value, @@ -7298,11 +6978,11 @@ config_set_global_backend_lock( const char *attrname, char *value, return retVal; } -int +int32_t config_set_plugin_logging( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, value, @@ -7343,7 +7023,7 @@ config_set_connection_buffer( const char *attrname, char *value, return retVal; } - PR_AtomicSet(&slapdFrontendConfig->connection_buffer, atoi(value)); + __atomic_store_4(&(slapdFrontendConfig->connection_buffer), atoi(value), __ATOMIC_RELEASE); return retVal; } @@ -7367,7 +7047,7 @@ config_set_listen_backlog_size( const char *attrname, char *value, } if ( apply ) { - PR_AtomicSet(&slapdFrontendConfig->listen_backlog_size, size); + __atomic_store_4(&(slapdFrontendConfig->listen_backlog_size), size, __ATOMIC_RELEASE); } return LDAP_SUCCESS; } @@ -7394,11 +7074,11 @@ config_get_enable_nunc_stans() return retVal; } -int +int32_t config_set_enable_nunc_stans( const char *attrname, char *value, char *errorbuf, int apply ) { - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); retVal = config_set_onoff(attrname, value, @@ -7790,17 +7470,15 @@ config_set_accesslog_enabled(int value) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE]; - errorbuf[0] = '\0'; + errorbuf[0] = '\0'; - CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig); - slapdFrontendConfig->accesslog_logging_enabled = (int)value; + __atomic_store_4(&(slapdFrontendConfig->accesslog_logging_enabled), value, __ATOMIC_RELEASE); if(value){ log_set_logging(CONFIG_ACCESSLOG_LOGGING_ENABLED_ATTRIBUTE, "on", SLAPD_ACCESS_LOG, errorbuf, CONFIG_APPLY); } else { log_set_logging(CONFIG_ACCESSLOG_LOGGING_ENABLED_ATTRIBUTE, "off", SLAPD_ACCESS_LOG, errorbuf, CONFIG_APPLY); } - CFG_ONOFF_UNLOCK_WRITE(slapdFrontendConfig); - if (errorbuf[0] != '\0') { + if (errorbuf[0] != '\0') { slapi_log_err(SLAPI_LOG_ERR, "config_set_accesslog_enabled", "%s\n", errorbuf); } } @@ -7809,17 +7487,15 @@ void config_set_auditlog_enabled(int value){ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE]; - errorbuf[0] = '\0'; + errorbuf[0] = '\0'; - CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig); - slapdFrontendConfig->auditlog_logging_enabled = (int)value; + __atomic_store_4(&(slapdFrontendConfig->auditlog_logging_enabled), value, __ATOMIC_RELEASE); if(value){ log_set_logging(CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, "on", SLAPD_AUDIT_LOG, errorbuf, CONFIG_APPLY); } else { log_set_logging(CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, "off", SLAPD_AUDIT_LOG, errorbuf, CONFIG_APPLY); } - CFG_ONOFF_UNLOCK_WRITE(slapdFrontendConfig); - if (errorbuf[0] != '\0') { + if (errorbuf[0] != '\0') { slapi_log_err(SLAPI_LOG_ERR, "config_set_auditlog_enabled", "%s\n", errorbuf); } } @@ -7828,17 +7504,15 @@ void config_set_auditfaillog_enabled(int value){ slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE]; - errorbuf[0] = '\0'; + errorbuf[0] = '\0'; - CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig); - slapdFrontendConfig->auditfaillog_logging_enabled = (int)value; + __atomic_store_4(&(slapdFrontendConfig->auditfaillog_logging_enabled), value, __ATOMIC_RELEASE); if(value){ log_set_logging(CONFIG_AUDITFAILLOG_LOGGING_ENABLED_ATTRIBUTE, "on", SLAPD_AUDITFAIL_LOG, errorbuf, CONFIG_APPLY); } else { log_set_logging(CONFIG_AUDITFAILLOG_LOGGING_ENABLED_ATTRIBUTE, "off", SLAPD_AUDITFAIL_LOG, errorbuf, CONFIG_APPLY); } - CFG_ONOFF_UNLOCK_WRITE(slapdFrontendConfig); - if (errorbuf[0] != '\0') { + if (errorbuf[0] != '\0') { slapi_log_err(SLAPI_LOG_ERR, "config_set_auditlog_enabled", "%s\n", errorbuf); } } @@ -7884,11 +7558,11 @@ config_get_maxsimplepaged_per_conn() return retVal; } -int +int32_t config_set_extract_pem(const char *attrname, char *value, char *errorbuf, int apply) { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - int retVal = LDAP_SUCCESS; + int32_t retVal = LDAP_SUCCESS; retVal = config_set_onoff(attrname, value, &(slapdFrontendConfig->extract_pem), errorbuf, apply); return retVal; @@ -7923,9 +7597,7 @@ config_set_malloc_mxfast(const char *attrname, char *value, char *errorbuf, int value, CONFIG_MALLOC_MXFAST, max); return LDAP_OPERATIONS_ERROR; } - CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig); - slapdFrontendConfig->malloc_mxfast = mxfast; - CFG_ONOFF_UNLOCK_WRITE(slapdFrontendConfig); + __atomic_store_4(&(slapdFrontendConfig->malloc_mxfast), mxfast, __ATOMIC_RELEASE); if ((mxfast >= 0) && (mxfast <= max)) { mallopt(M_MXFAST, mxfast); @@ -7965,9 +7637,7 @@ config_set_malloc_trim_threshold(const char *attrname, char *value, char *errorb return LDAP_OPERATIONS_ERROR; } - CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig); - slapdFrontendConfig->malloc_trim_threshold = trim_threshold; - CFG_ONOFF_UNLOCK_WRITE(slapdFrontendConfig); + __atomic_store_4(&(slapdFrontendConfig->malloc_trim_threshold), trim_threshold, __ATOMIC_RELEASE); if (trim_threshold >= -1) { mallopt(M_TRIM_THRESHOLD, trim_threshold); @@ -8014,9 +7684,7 @@ config_set_malloc_mmap_threshold(const char *attrname, char *value, char *errorb return LDAP_OPERATIONS_ERROR; } - CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig); - slapdFrontendConfig->malloc_mmap_threshold = mmap_threshold; - CFG_ONOFF_UNLOCK_WRITE(slapdFrontendConfig); + __atomic_store_4(&(slapdFrontendConfig->malloc_mmap_threshold), mmap_threshold, __ATOMIC_RELEASE); if ((mmap_threshold >= 0) && (mmap_threshold <= max)) { mallopt(M_MMAP_THRESHOLD, mmap_threshold); diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c index 199496a..3b4e672 100644 --- a/ldap/servers/slapd/log.c +++ b/ldap/servers/slapd/log.c @@ -4914,14 +4914,14 @@ log__open_auditfaillogfile(int logfile_state, int locked) static LogBufferInfo *log_create_buffer(size_t sz) { LogBufferInfo *lbi; - + lbi = (LogBufferInfo *) slapi_ch_malloc(sizeof(LogBufferInfo)); lbi->top = (char *) slapi_ch_malloc(sz); lbi->current = lbi->top; lbi->maxsize = sz; - lbi->refcount = 0; + __atomic_store_8(&(lbi->refcount), 0, __ATOMIC_RELEASE); return lbi; -} +} #if 0 /* for some reason, we never call this. */ @@ -4981,7 +4981,7 @@ static void log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_ insert_point = lbi->current; lbi->current += size; /* Increment the copy refcount */ - PR_AtomicIncrement(&(lbi->refcount)); + __atomic_add_fetch_8(&(lbi->refcount), 1, __ATOMIC_RELEASE); PR_Unlock(lbi->lock); /* Now we can copy without holding the lock */ @@ -4989,7 +4989,7 @@ static void log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_ memcpy(insert_point + size1, msg2, size2); /* Decrement the copy refcount */ - PR_AtomicDecrement(&(lbi->refcount)); + __atomic_sub_fetch_8(&(lbi->refcount), 1, __ATOMIC_RELEASE); /* If we are asked to sync to disk immediately, do so */ if (!slapdFrontendConfig->accesslogbuffering) { @@ -5009,7 +5009,7 @@ static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now) if (type == SLAPD_ACCESS_LOG) { /* It is only safe to flush once any other threads which are copying are finished */ - while (lbi->refcount > 0) { + while (__atomic_load_8(&(lbi->refcount), __ATOMIC_ACQUIRE) > 0) { /* It's ok to sleep for a while because we only flush every second or so */ DS_Sleep (PR_MillisecondsToInterval(1)); } diff --git a/ldap/servers/slapd/log.h b/ldap/servers/slapd/log.h index 948fdb0..401a1a1 100644 --- a/ldap/servers/slapd/log.h +++ b/ldap/servers/slapd/log.h @@ -95,7 +95,7 @@ struct logbufinfo { char *current; /* current pointer into buffer */ size_t maxsize; /* size of buffer */ PRLock *lock; /* lock for access logging */ - PRInt32 refcount; /* Reference count for buffer copies */ + uint64_t refcount; /* Reference count for buffer copies */ }; typedef struct logbufinfo LogBufferInfo; diff --git a/ldap/servers/slapd/object.c b/ldap/servers/slapd/object.c index 1db9a90..4c40beb 100644 --- a/ldap/servers/slapd/object.c +++ b/ldap/servers/slapd/object.c @@ -23,7 +23,7 @@ typedef struct object { - PRInt32 refcnt; /* reference count for the object */ + uint64_t refcnt; /* reference count for the object */ FNFree destructor; /* Destructor for the object */ void *data; /* pointer to actual node data */ } object; @@ -44,9 +44,9 @@ object_new(void *user_data, FNFree destructor) { Object *o; o = (object *)slapi_ch_malloc(sizeof(object)); - o->refcnt = 1; o->destructor = destructor; o->data = user_data; + __atomic_store_8(&(o->refcnt), 1, __ATOMIC_RELEASE); return o; } @@ -60,7 +60,7 @@ void object_acquire(Object *o) { PR_ASSERT(NULL != o); - PR_AtomicIncrement(&o->refcnt); + __atomic_add_fetch_8(&(o->refcnt), 1, __ATOMIC_RELEASE); } @@ -75,8 +75,7 @@ object_release(Object *o) PRInt32 refcnt_after_release; PR_ASSERT(NULL != o); - refcnt_after_release = PR_AtomicDecrement(&o->refcnt); - PR_ASSERT(refcnt_after_release >= 0); + refcnt_after_release = __atomic_sub_fetch_8(&(o->refcnt), 1, __ATOMIC_ACQ_REL); if (refcnt_after_release == 0) { /* Object can be destroyed */ @@ -85,7 +84,6 @@ object_release(Object *o) /* Make it harder to reuse a dangling pointer */ o->data = NULL; o->destructor = NULL; - o->refcnt = -9999; slapi_ch_free((void **)&o); } } diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 8e054d1..1a3ca5a 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -207,7 +207,7 @@ void be_unbindall( Connection *conn, Operation *op); int be_nbackends_public(void); void g_incr_active_threadcnt(void); void g_decr_active_threadcnt(void); -int g_get_active_threadcnt(void); +uint64_t g_get_active_threadcnt(void); /* * bind.c diff --git a/ldap/servers/slapd/psearch.c b/ldap/servers/slapd/psearch.c index 7398fd8..3de7f74 100644 --- a/ldap/servers/slapd/psearch.c +++ b/ldap/servers/slapd/psearch.c @@ -43,7 +43,7 @@ typedef struct _ps_entry_queue_node { typedef struct _psearch { Slapi_PBlock *ps_pblock; PRLock *ps_lock; - PRInt32 ps_complete; + uint64_t ps_complete; PSEQNode *ps_eq_head; PSEQNode *ps_eq_tail; time_t ps_lasttime; @@ -134,7 +134,7 @@ ps_stop_psearch_system() if ( PS_IS_INITIALIZED()) { PSL_LOCK_WRITE(); for ( ps = psearch_list->pl_head; NULL != ps; ps = ps->ps_next ) { - PR_AtomicIncrement( &ps->ps_complete ); + __atomic_add_fetch_8(&(ps->ps_complete), 1, __ATOMIC_RELEASE); } PSL_UNLOCK_WRITE(); ps_wakeup_all(); @@ -286,7 +286,7 @@ ps_send_results( void *arg ) PR_Lock( psearch_list->pl_cvarlock ); - while ( (conn_acq_flag == 0) && !ps->ps_complete ) { + while ( (conn_acq_flag == 0) && __atomic_load_8(&(ps->ps_complete), __ATOMIC_ACQUIRE) == 0) { /* Check for an abandoned operation */ if ( pb_op == NULL || slapi_op_abandoned( ps->ps_pblock ) ) { slapi_log_err(SLAPI_LOG_CONNS, "ps_send_results", @@ -440,7 +440,7 @@ psearch_alloc(void) slapi_ch_free((void **)&ps); return( NULL ); } - ps->ps_complete = 0; + __atomic_store_8(&(ps->ps_complete), 0, __ATOMIC_RELEASE); ps->ps_eq_head = ps->ps_eq_tail = (PSEQNode *) NULL; ps->ps_lasttime = (time_t) 0L; ps->ps_next = NULL; diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 0dddb70..5edaf43 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -435,19 +435,8 @@ typedef void (*VFPV)(); /* takes undefined arguments */ #define SLAPD_VALIDATE_CERT_ON 1 #define SLAPD_VALIDATE_CERT_WARN 2 -/* if the use of atomic get/set for config parameters is enabled, enable the use for the specific parameters defined below */ -#define USE_ATOMIC_GETSET 1 -#ifdef USE_ATOMIC_GETSET -#define ATOMIC_GETSET_MAXTHREADSPERCONN 1 -#define ATOMIC_GETSET_IOBLOCKTIMEOUT 1 -#define ATOMIC_GETSET_FILTER_NEST_LEVEL 1 -#define ATOMIC_GETSET_ONOFF 1 -typedef PRInt32 slapi_onoff_t; -typedef PRInt32 slapi_int_t; -#else -typedef int slapi_onoff_t; -typedef int slapi_int_t; -#endif +typedef int32_t slapi_onoff_t; +typedef int32_t slapi_int_t; struct subfilt { char *sf_type; @@ -619,7 +608,7 @@ typedef struct asyntaxinfo { char *asi_syntax_oid; /* syntax oid */ unsigned long asi_flags; /* SLAPI_ATTR_FLAG_... */ int asi_syntaxlength; /* length associated w/syntax */ - int asi_refcnt; /* outstanding references */ + uint64_t asi_refcnt; /* outstanding references */ PRBool asi_marked_for_delete; /* delete at next opportunity */ struct slapdplugin *asi_mr_eq_plugin; /* EQUALITY matching rule plugin */ struct slapdplugin *asi_mr_sub_plugin; /* SUBSTR matching rule plugin */ @@ -772,7 +761,7 @@ struct slapi_entry { Slapi_Attr *e_attrs; /* list of attributes and values */ Slapi_Attr *e_deleted_attrs; /* deleted list of attributes and values */ Slapi_Vattr *e_virtual_attrs; /* cache of virtual attributes */ - time_t e_virtual_watermark; /* indicates cache consistency when compared + uint32_t e_virtual_watermark; /* indicates cache consistency when compared to global watermark */ Slapi_RWLock *e_virtual_lock; /* for access to cached vattrs */ void *e_extension; /* A list of entry object extensions */ @@ -2179,18 +2168,6 @@ typedef struct _slapdEntryPoints { #define CFG_UNLOCK_WRITE(cfg) slapi_rwlock_unlock(cfg->cfg_rwlock) #endif -#ifdef ATOMIC_GETSET_ONOFF -#define CFG_ONOFF_LOCK_READ(cfg) -#define CFG_ONOFF_UNLOCK_READ(cfg) -#define CFG_ONOFF_LOCK_WRITE(cfg) -#define CFG_ONOFF_UNLOCK_WRITE(cfg) -#else -#define CFG_ONOFF_LOCK_READ(cfg) CFG_LOCK_READ(cfg) -#define CFG_ONOFF_UNLOCK_READ(cfg) CFG_UNLOCK_READ(cfg) -#define CFG_ONOFF_LOCK_WRITE(cfg) CFG_LOCK_WRITE(cfg) -#define CFG_ONOFF_UNLOCK_WRITE(cfg) CFG_UNLOCK_WRITE(cfg) -#endif - #define REFER_MODE_OFF 0 #define REFER_MODE_ON 1 diff --git a/ldap/servers/slapd/slapi_counter.c b/ldap/servers/slapd/slapi_counter.c index 9904fe9..e757292 100644 --- a/ldap/servers/slapd/slapi_counter.c +++ b/ldap/servers/slapd/slapi_counter.c @@ -6,6 +6,11 @@ * See LICENSE for details. * END COPYRIGHT BLOCK **/ +/* + * !!!!!!!!!!!! IMPORTANT !!!!!!!!!!!!!!! + * You must read https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html + */ + #ifdef HAVE_CONFIG_H # include #endif @@ -115,7 +120,7 @@ uint64_t slapi_counter_add(Slapi_Counter *counter, uint64_t addvalue) return newvalue; } #ifdef ATOMIC_64BIT_OPERATIONS - newvalue = __atomic_add_fetch_8(&(counter->value), addvalue, __ATOMIC_SEQ_CST); + newvalue = __atomic_add_fetch_8(&(counter->value), addvalue, __ATOMIC_RELAXED); #else #ifdef HPUX uint64_t prev = 0; @@ -168,7 +173,7 @@ uint64_t slapi_counter_subtract(Slapi_Counter *counter, uint64_t subvalue) } #ifdef ATOMIC_64BIT_OPERATIONS - newvalue = __atomic_sub_fetch_8(&(counter->value), subvalue, __ATOMIC_SEQ_CST); + newvalue = __atomic_sub_fetch_8(&(counter->value), subvalue, __ATOMIC_RELAXED); #else #ifdef HPUX uint64_t prev = 0; @@ -220,7 +225,7 @@ uint64_t slapi_counter_set_value(Slapi_Counter *counter, uint64_t newvalue) } #ifdef ATOMIC_64BIT_OPERATIONS - __atomic_store_8(&(counter->value), newvalue, __ATOMIC_SEQ_CST); + __atomic_store_8(&(counter->value), newvalue, __ATOMIC_RELAXED); #else /* HPUX */ #ifdef HPUX do { @@ -251,7 +256,7 @@ uint64_t slapi_counter_get_value(Slapi_Counter *counter) } #ifdef ATOMIC_64BIT_OPERATIONS - value = __atomic_load_8(&(counter->value), __ATOMIC_SEQ_CST); + value = __atomic_load_8(&(counter->value), __ATOMIC_RELAXED); #else /* HPUX */ #ifdef HPUX do { diff --git a/src/nunc-stans/test/test_nuncstans_stress_core.c b/src/nunc-stans/test/test_nuncstans_stress_core.c index ca4e45d..87883d6 100644 --- a/src/nunc-stans/test/test_nuncstans_stress_core.c +++ b/src/nunc-stans/test/test_nuncstans_stress_core.c @@ -355,7 +355,7 @@ client_initiate_connection_cb(struct ns_job_t *job) char *err = NULL; PR_GetErrorText(err); do_logging(LOG_ERR, "FAIL: Socket failed, %d -> %s\n", PR_GetError(), err); - PR_AtomicAdd(&client_fail_count, 1); + __atomic_add_fetch(&client_fail_count, 1, __ATOMIC_SEQ_CST); goto done; } -- 1.8.3.1