ldap/servers/slapd/entry.c | 2 +-
ldap/servers/slapd/pw.c | 2 +-
ldap/servers/slapd/slapi-plugin.h | 8 +++++++-
ldap/servers/slapd/slapi2nspr.c | 14 ++++++++++++++
4 files changed, 23 insertions(+), 3 deletions(-)
New commits:
commit dbb5ef5dae65aeab87c3287d6bac946d9e71f5aa
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Tue Feb 10 15:37:14 2015 -0800
Ticket #47728 - compilation failed with ' incomplete struct/union/enum' if not
set USE_POSIX_RWLOCKS
Description:
1) Slapi_RWLock is typedef'ed as follows without defining "struct
slapi_rwlock".
ifdef USE_POSIX_RWLOCKS
typedef pthread_rwlock_t Slapi_RWLock;
else
typedef struct slapi_rwlock Slapi_RWLock;
endif
According to the wrapper layer slapi2nspr.c, the "else" of
USE_POSIX_RWLOCKS
is supposed to handle PRRWLock. This patch replaces "struct slapi_rwlock"
with PRRWLock*.
2) In slapi_entry_size and pw_get_ext_size, the size of Slapi_RWLock is
added to the each object size. Unfortunately, the size of PRRWLock is not
provided by NSPR. This patch adds an API slapi_rwlock_get_size, in which
if not USE_POSIX_RWLOCKS, a rough estimate of the PRRWLock size is calculated
and returned. Note: "if USE_POSIX_RWLOCKS" is the default case and in the
case, the size is accurate.
https://fedorahosted.org/389/ticket/47728
Reviewed by mreynolds(a)redhat.com (Thank you, Mark!!)
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 203c742..981a02d 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -2094,7 +2094,7 @@ slapi_entry_size(Slapi_Entry *e)
if (e->e_uniqueid) size += strlen(e->e_uniqueid) + 1;
if (e->e_dncsnset) size += csnset_size(e->e_dncsnset);
if (e->e_maxcsn) size += sizeof( CSN );
- if (e->e_virtual_lock) size += sizeof(Slapi_RWLock);
+ if (e->e_virtual_lock) size += slapi_rwlock_get_size();
/* Slapi_DN and RDN are included in Slapi_Entry */
size += (slapi_sdn_get_size(&e->e_sdn) - sizeof(Slapi_DN));
size += (slapi_rdn_get_size(&e->e_srdn) - sizeof(Slapi_RDN));
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index 43a11c7..c781adc 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -2782,7 +2782,7 @@ pw_get_ext_size(Slapi_Entry *entry, size_t *size)
return LDAP_SUCCESS;
}
*size += sizeof(struct slapi_pw_entry_ext);
- *size += sizeof(Slapi_RWLock);
+ *size += slapi_rwlock_get_size();
if (LDAP_SUCCESS == slapi_pw_get_entry_ext(entry, &pw_entry_values)) {
Slapi_Value *cvalue;
int idx = valuearray_first_value(pw_entry_values, &cvalue);
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 41dd2c8..1148b3e 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -6100,7 +6100,7 @@ typedef struct slapi_condvar Slapi_CondVar;
#ifdef USE_POSIX_RWLOCKS
typedef pthread_rwlock_t Slapi_RWLock;
#else
-typedef struct slapi_rwlock Slapi_RWLock;
+typedef PRRWLock Slapi_RWLock;
#endif
Slapi_Mutex *slapi_new_mutex( void );
void slapi_destroy_mutex( Slapi_Mutex *mutex );
@@ -6169,6 +6169,12 @@ int slapi_rwlock_wrlock( Slapi_RWLock *rwlock );
*/
int slapi_rwlock_unlock( Slapi_RWLock *rwlock );
+/**
+ * Get the size of Slapi_RWLock
+ *
+ * \return the size of Slapi_RWLock
+ */
+int slapi_rwlock_get_size();
/*
* thread-safe LDAP connections
diff --git a/ldap/servers/slapd/slapi2nspr.c b/ldap/servers/slapd/slapi2nspr.c
index c734989..44b6d8e 100644
--- a/ldap/servers/slapd/slapi2nspr.c
+++ b/ldap/servers/slapd/slapi2nspr.c
@@ -289,3 +289,17 @@ slapi_rwlock_unlock( Slapi_RWLock *rwlock )
return ret;
}
+int
+slapi_rwlock_get_size()
+{
+#ifdef USE_POSIX_RWLOCKS
+ return sizeof(pthread_rwlock_t);
+#else
+ /*
+ * NSPR does not provide the size of PRRWLock.
+ * This is a rough estimate to maintain the entry size sane.
+ */
+ return sizeof("slapi_rwlock") + sizeof(void *) * 6;
+#endif
+}
+