[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm vlv.c, 1.6.2.2, 1.6.2.3

Noriko Hosoi (nhosoi) fedora-directory-commits at redhat.com
Fri Jan 11 01:02:54 UTC 2008


Author: nhosoi

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31508

Modified Files:
      Tag: Directory71RtmBranch
	vlv.c 
Log Message:
Resolves: #171081
Summary: ldapsearch hung at browsing index creation
Description: applied the patch to Directory71RtmBranch



Index: vlv.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/vlv.c,v
retrieving revision 1.6.2.2
retrieving revision 1.6.2.3
diff -u -r1.6.2.2 -r1.6.2.3
--- vlv.c	10 Jan 2008 19:44:21 -0000	1.6.2.2
+++ vlv.c	11 Jan 2008 01:02:52 -0000	1.6.2.3
@@ -111,18 +111,28 @@
 int vlv_DeleteSearchEntry(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg)
 {
     struct vlvSearch* p=NULL;
-	backend *be= ((ldbm_instance*)arg)->inst_be;
-	
+    ldbm_instance *inst = (ldbm_instance*)arg;
+    backend *be= inst->inst_be;
+
+    if (instance_set_busy(inst) != 0)
+    {
+        LDAPDebug( LDAP_DEBUG_ANY,
+            "Backend instance: '%s' is already in the middle of "
+            "another task and cannot be disturbed.\n",
+            inst->inst_name, 0, 0);
+        return SLAPI_DSE_CALLBACK_ERROR;
+    }
     /* vlvSearchList is modified; need Wlock */
-	PR_RWLock_Wlock(be->vlvSearchList_lock);
-	p = vlvSearch_finddn((struct vlvSearch *)be->vlvSearchList, slapi_entry_get_sdn(entryBefore));
+    PR_RWLock_Wlock(be->vlvSearchList_lock);
+    p = vlvSearch_finddn((struct vlvSearch *)be->vlvSearchList, slapi_entry_get_sdn(entryBefore));
     if(p!=NULL)
-    {	
-		LDAPDebug( LDAP_DEBUG_ANY, "Deleted Virtual List View Search (%s).\n", p->vlv_name, 0, 0);
-		vlvSearch_removefromlist((struct vlvSearch **)&be->vlvSearchList,p->vlv_dn);
-		vlvSearch_delete(&p);
+    {
+        LDAPDebug( LDAP_DEBUG_ANY, "Deleted Virtual List View Search (%s).\n", p->vlv_name, 0, 0);
+        vlvSearch_removefromlist((struct vlvSearch **)&be->vlvSearchList,p->vlv_dn);
+        vlvSearch_delete(&p);
     }
-	PR_RWLock_Unlock(be->vlvSearchList_lock);
+    PR_RWLock_Unlock(be->vlvSearchList_lock);
+    instance_set_not_busy(inst);
     return SLAPI_DSE_CALLBACK_OK;
 }
 
@@ -131,8 +141,18 @@
  
 int vlv_DeleteIndexEntry(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg)
 {
-   	LDAPDebug( LDAP_DEBUG_ANY, "Deleted Virtual List View Index.\n", 0, 0, 0);
-    return SLAPI_DSE_CALLBACK_OK;
+    ldbm_instance *inst = (ldbm_instance*)arg;
+    if (inst && (inst->inst_flags & INST_FLAG_BUSY)) {
+        LDAPDebug( LDAP_DEBUG_ANY,
+                       "Backend instance: '%s' is already in the middle of "
+                       "another task and cannot be disturbed.\n",
+                       inst->inst_name, 0, 0);
+        return SLAPI_DSE_CALLBACK_ERROR;
+    } else {
+        LDAPDebug( LDAP_DEBUG_ANY, 
+                       "Deleted Virtual List View Index.\n", 0, 0, 0);
+        return SLAPI_DSE_CALLBACK_OK;
+    }
 }
 
 
@@ -1492,11 +1512,12 @@
         }
         id= candidates->b_ids[current];
         e = id2entry( be, id, NULL, &err );
-    	if ( e == NULL )
-    	{
+        if ( e == NULL )
+        {
             int rval;
-    	    LDAPDebug( LDAP_DEBUG_ANY, "vlv_trim_candidates_byvalue: Candidate ID %lu not found err=%d\n", (u_long)id, err, 0 );
-            rval = idl_delete(&candidates, id);
+            LDAPDebug( LDAP_DEBUG_ANY, "vlv_trim_candidates_byvalue: "
+                     "Candidate ID %lu not found err=%d\n", (u_long)id, err, 0 );
+            rval = idl_delete((IDList **)&candidates, id);
             if (0 == rval || 1 == rval || 2 == rval) {
                 goto retry;
             } else {
@@ -1953,6 +1974,14 @@
 	const char *dn= slapi_sdn_get_dn(&e->e_sdn);
 	backend *be= inst->inst_be;
 
+	if (instance_set_busy(inst) != 0)
+	{
+		LDAPDebug( LDAP_DEBUG_ANY,
+			"Backend instance: '%s' is already in the middle of "
+			"another task and cannot be disturbed.\n",
+			inst->inst_name, 0, 0);
+		return LDAP_OPERATIONS_ERROR;
+	}
 	tag1=create_vlv_search_tag(dn);
 	buf=slapi_ch_smprintf("%s%s%s%s%s","cn=MCC ",tag1,", cn=",inst->inst_name,LDBM_PLUGIN_ROOT);
 	newdn=slapi_sdn_new_dn_byval(buf);
@@ -1991,6 +2020,7 @@
     } else {
 		PR_RWLock_Unlock(be->vlvSearchList_lock);
 	}
+	instance_set_not_busy(inst);
 	slapi_ch_free((void **)&tag1);
 	slapi_ch_free((void **)&buf);
 	slapi_sdn_free(&newdn);




More information about the Fedora-directory-commits mailing list