Signed-off-by: Christoph Hellwig <[email protected]>

---
 sheep/group.c      |    3 +++
 sheep/sheep.c      |    4 ++++
 sheep/sheep_priv.h |    8 ++++++++
 3 files changed, 15 insertions(+)

Index: sheepdog/sheep/group.c
===================================================================
--- sheepdog.orig/sheep/group.c 2012-05-08 15:49:44.000000000 +0200
+++ sheepdog/sheep/group.c      2012-05-08 15:50:07.260687070 +0200
@@ -175,6 +175,7 @@ struct vnode_info *grab_vnode_info(struc
  */
 struct vnode_info *get_vnode_info(void)
 {
+       assert(is_main_thread());
        assert(current_vnode_info);
 
        return grab_vnode_info(current_vnode_info);
@@ -187,6 +188,8 @@ struct vnode_info *get_vnode_info(void)
  */
 void put_vnode_info(struct vnode_info *vnode_info)
 {
+       assert(is_main_thread());
+
        if (vnode_info) {
                assert(uatomic_read(&vnode_info->refcnt) > 0);
 
Index: sheepdog/sheep/sheep.c
===================================================================
--- sheepdog.orig/sheep/sheep.c 2012-05-08 15:46:26.000000000 +0200
+++ sheepdog/sheep/sheep.c      2012-05-08 15:49:52.064687217 +0200
@@ -96,6 +96,8 @@ Available log levels:\n\
 static struct cluster_info __sys;
 struct cluster_info *sys = &__sys;
 
+pthread_t main_thread;
+
 int main(int argc, char **argv)
 {
        int ch, longindex;
@@ -110,6 +112,8 @@ int main(int argc, char **argv)
        char *p;
        struct cluster_driver *cdrv;
 
+       main_thread = pthread_self();
+
        signal(SIGPIPE, SIG_IGN);
 
        while ((ch = getopt_long(argc, argv, short_options, long_options,
Index: sheepdog/sheep/sheep_priv.h
===================================================================
--- sheepdog.orig/sheep/sheep_priv.h    2012-05-08 15:49:48.000000000 +0200
+++ sheepdog/sheep/sheep_priv.h 2012-05-08 15:49:52.064687217 +0200
@@ -12,6 +12,7 @@
 #define __SHEEP_PRIV_H__
 
 #include <inttypes.h>
+#include <pthread.h>
 
 #include "sheepdog_proto.h"
 #include "event.h"
@@ -219,6 +220,13 @@ extern mode_t def_fmode;
 extern mode_t def_dmode;
 extern struct objlist_cache obj_list_cache;
 
+extern pthread_t main_thread;
+
+static inline int is_main_thread(void)
+{
+       return pthread_equal(pthread_self(), main_thread);
+}
+
 int create_listen_port(int port, void *data);
 
 int init_store(const char *dir);

-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to