1
0
Эх сурвалжийг харах

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 [email protected] (Thank you, Mark!!)
Noriko Hosoi 10 жил өмнө
parent
commit
dbb5ef5dae

+ 1 - 1
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));

+ 1 - 1
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);

+ 7 - 1
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

+ 14 - 0
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
+}
+