Re: [PATCH] objdb: Fix lock/unlock incorrect issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Xia,
patch looks sane, but ... this part of code was very hard to implement correctly, because of deadlocks (objdb can call notifications resulting in calling objdb resulting in notifications in different thread, ...). Honestly touching objdb code is like playing with fire.

So can you please describe me what are you trying to fix (test case)? Are really all locks/unlocks you've implemented needed? How did you tested patch? Didn't deadlock happened?

Regards,
  Honza

xia li napsal(a):
patch for v1.4.7

Signed-off-by: xia li <xli@xxxxxxxx>
---
  exec/objdb.c | 16 +++++++++++++---
  1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/exec/objdb.c b/exec/objdb.c
index 5d7c124..1a0b2fb 100644
--- a/exec/objdb.c
+++ b/exec/objdb.c
@@ -1412,7 +1412,7 @@ static int object_priv_get (
  	int res;
  	struct object_instance *object_instance;

-	objdb_unlock();
+	objdb_lock();
  	res = hdb_handle_get (&object_instance_database,
  		object_handle, (void *)&object_instance);
  	if (res != 0) {
@@ -1723,9 +1723,12 @@ static int object_track_start(hdb_handle_t object_handle,
  	unsigned int res;
  	struct object_tracker * tracker_pt;

+	objdb_lock();
+
  	res = hdb_handle_get (&object_instance_database,
  		object_handle, (void *)&instance);
  	if (res != 0) {
+		objdb_unlock();
  		return (res);
  	}
  	tracker_pt = malloc(sizeof(struct object_tracker));
@@ -1746,6 +1749,7 @@ static int object_track_start(hdb_handle_t object_handle,

  	hdb_handle_put (&object_instance_database, object_handle);

+	objdb_unlock();
  	return (res);
  }

@@ -1762,6 +1766,8 @@ static void object_track_stop(object_key_change_notify_fn_t key_change_notify_fn
  	struct list_head *obj_list, *tmp_obj_list;
  	unsigned int res;

+	objdb_lock();
+
  	/* go through the global list and find all the trackers to stop */
  	for (list = objdb_trackers_head.next, tmp_list = list->next;
  		list != &objdb_trackers_head; list = tmp_list, tmp_list = tmp_list->next) {
@@ -1796,6 +1802,7 @@ static void object_track_stop(object_key_change_notify_fn_t key_change_notify_fn
  			free(tracker_pt);
  		}
  	}
+	objdb_unlock();
  }

  static int object_dump(hdb_handle_t object_handle,
@@ -1852,10 +1859,11 @@ static int object_reload_config(int flush, const char **error_string)
  	int res;

  	main_get_config_modules(&modules, &num_modules);
-	object_reload_notification(OBJDB_RELOAD_NOTIFY_START, flush);

  	objdb_lock();

+	object_reload_notification(OBJDB_RELOAD_NOTIFY_START, flush);
+
  	for (i=0; i<num_modules; i++) {
  		if (modules[i]->config_reloadconfig) {
  			res = modules[i]->config_reloadconfig(&objdb_iface, flush, error_string);
@@ -1866,8 +1874,10 @@ static int object_reload_config(int flush, const char **error_string)
  			}
  		}
  	}
-	objdb_unlock();
+
  	object_reload_notification(OBJDB_RELOAD_NOTIFY_END, flush);
+
+	objdb_unlock();
  	return 0;
  }



_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss




[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux