Rev 739: ensure the main daemon doesn't use a blocking lock on the freelist in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Tue Jan 8 11:31:49 GMT 2008


------------------------------------------------------------
revno: 739
revision-id:tridge at samba.org-20080108113148-wiggdhve4uskariz
parent: tridge at samba.org-20080108102842-xdxdvnk6jtg6336p
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge.stable
timestamp: Tue 2008-01-08 22:31:48 +1100
message:
  ensure the main daemon doesn't use a blocking lock on the freelist
modified:
  server/ctdb_recover.c          ctdb_recover.c-20070503002147-admmfgt1oj6gexfo-1
=== modified file 'server/ctdb_recover.c'
--- a/server/ctdb_recover.c	2008-01-08 06:23:27 +0000
+++ b/server/ctdb_recover.c	2008-01-08 11:31:48 +0000
@@ -647,6 +647,11 @@
 	struct ctdb_db_context *ctdb_db;
 	TDB_DATA key, data;
 	struct ctdb_ltdb_header *hdr, *hdr2;
+	
+	/* these are really internal tdb functions - but we need them here for
+	   non-blocking lock of the freelist */
+	int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype);
+	int tdb_unlock(struct tdb_context *tdb, int list, int ltype);
 
 	if (indata.dsize < sizeof(uint32_t) || indata.dsize != rec->length) {
 		DEBUG(0,(__location__ " Bad record size in ctdb_control_delete_record\n"));
@@ -688,8 +693,11 @@
 	}
 
 	if (data.dsize < sizeof(struct ctdb_ltdb_header)) {
-		tdb_delete(ctdb_db->ltdb->tdb, key);
-		DEBUG(0,(__location__ " Deleted corrupt record\n"));
+		if (tdb_lock_nonblock(ctdb_db->ltdb->tdb, -1, F_WRLCK) == 0) {
+			tdb_delete(ctdb_db->ltdb->tdb, key);
+			tdb_unlock(ctdb_db->ltdb->tdb, -1, F_WRLCK);
+			DEBUG(0,(__location__ " Deleted corrupt record\n"));
+		}
 		tdb_chainunlock(ctdb_db->ltdb->tdb, key);
 		free(data.dptr);
 		return 0;
@@ -712,13 +720,21 @@
 		return -1;				
 	}
 
+	if (tdb_lock_nonblock(ctdb_db->ltdb->tdb, -1, F_WRLCK) != 0) {
+		tdb_chainunlock(ctdb_db->ltdb->tdb, key);
+		free(data.dptr);
+		return -1;				
+	}
+
 	if (tdb_delete(ctdb_db->ltdb->tdb, key) != 0) {
+		tdb_unlock(ctdb_db->ltdb->tdb, -1, F_WRLCK);
 		tdb_chainunlock(ctdb_db->ltdb->tdb, key);
 		DEBUG(2,(__location__ " Failed to delete record\n"));
 		free(data.dptr);
 		return -1;						
 	}
 
+	tdb_unlock(ctdb_db->ltdb->tdb, -1, F_WRLCK);
 	tdb_chainunlock(ctdb_db->ltdb->tdb, key);
 	free(data.dptr);
 	return 0;	



More information about the samba-cvs mailing list