summaryrefslogtreecommitdiff
blob: 3dd51c2195126bdc62607a746c934cb2e60aaddb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
diff -urN gamin-0.0.6/server/gam_server.c gamin-0.0.6.az/server/gam_server.c
--- gamin-0.0.6/server/gam_server.c	2004-08-19 12:54:45.000000000 +0200
+++ gamin-0.0.6.az/server/gam_server.c	2004-08-23 00:22:48.136493880 +0200
@@ -41,6 +41,7 @@
 #endif
 
 static const char *session;
+static int gam_backend;
 
 /**
  * gam_shutdown:
@@ -63,13 +64,36 @@
 gboolean
 gam_init_subscriptions(void)
 {
+    gboolean ret;
+
+    gam_backend = 0;
+
 #ifdef USE_INOTIFY
-    return (gam_inotify_init());
-#elif linux
-    return (gam_dnotify_init());
-#else
-    return (gam_poll_init());
+    if ((!gam_backend) && (ret = gam_inotify_init())) {
+	gam_backend = BACKEND_INOTIFY;
+	gam_debug(DEBUG_INFO, "Using INotify as backend\n");
+	return ret;
+    }
 #endif
+#ifdef linux
+    if ((!gam_backend) && (ret = gam_dnotify_init())) {
+	gam_backend = BACKEND_DNOTIFY;
+	gam_debug(DEBUG_INFO, "Using DNotify as backend\n");
+	return ret;
+    }
+#endif
+    if (!gam_backend) {
+	ret = gam_poll_init();
+	if (ret) {
+	    gam_backend = BACKEND_POLL;
+	    gam_debug(DEBUG_INFO, "Using Poll as backend\n");
+	}
+	return ret;
+    }
+
+    gam_debug(DEBUG_INFO, "Cannot initialize any backend\n");
+
+    return FALSE;
 }
 
 /**
@@ -113,13 +137,21 @@
 	return (gam_poll_add_subscription(sub));
     }
  ***/
+    switch (gam_backend) {
 #ifdef USE_INOTIFY
-    return (gam_inotify_add_subscription(sub));
-#elif linux
-    return (gam_dnotify_add_subscription(sub));
-#else
-    return (gam_poll_add_subscription(sub));
+    case BACKEND_INOTIFY:
+	return (gam_inotify_add_subscription(sub));
+	break;
 #endif
+#ifdef linux
+    case BACKEND_DNOTIFY:
+	return (gam_dnotify_add_subscription(sub));
+	break;
+#endif
+    case BACKEND_POLL:
+	return (gam_poll_add_subscription(sub));
+	break;
+    }
 }
 
 /**
@@ -132,13 +164,21 @@
 gboolean
 gam_remove_subscription(GamSubscription * sub)
 {
+    switch (gam_backend) {
 #ifdef USE_INOTIFY
-    return (gam_inotify_remove_subscription(sub));
-#elif linux
-    return (gam_dnotify_remove_subscription(sub));
-#else
-    return (gam_poll_remove_subscription(sub));
+    case BACKEND_INOTIFY:
+	return (gam_inotify_remove_subscription(sub));
+	break;
+#endif
+#ifdef linux
+    case BACKEND_DNOTIFY:
+	return (gam_dnotify_remove_subscription(sub));
+	break;
 #endif
+    case BACKEND_POLL:
+	return (gam_poll_remove_subscription(sub));
+	break;
+    }
 }
 
 /**
diff -urN gamin-0.0.6/server/gam_server.h gamin-0.0.6.az/server/gam_server.h
--- gamin-0.0.6/server/gam_server.h	2004-08-19 12:51:57.000000000 +0200
+++ gamin-0.0.6.az/server/gam_server.h	2004-08-23 00:20:01.420838512 +0200
@@ -9,6 +9,10 @@
 extern "C" {
 #endif
 
+#define BACKEND_INOTIFY	1
+#define BACKEND_DNOTIFY	2
+#define BACKEND_POLL	3
+
 gboolean        gam_init_subscriptions          (void);
 gboolean        gam_add_subscription            (GamSubscription *sub);
 gboolean        gam_remove_subscription         (GamSubscription *sub);