[gamin] FAMCancelMonitor patch
- From: Carlos Romero <kidcrash freedesktop org>
- To: gamin-list gnome org
- Subject: [gamin] FAMCancelMonitor patch
- Date: Sun, 25 Jul 2004 12:39:25 -0400
diff -ruN gamin-0.0.2/libgamin/gam_api.c
gamin-0.0.2.new/libgamin/gam_api.c
--- gamin-0.0.2/libgamin/gam_api.c 2004-07-16 05:50:00.000000000 -0400
+++ gamin-0.0.2.new/libgamin/gam_api.c 2004-07-25 11:06:36.000000000 -0400
@@ -293,6 +293,7 @@
reqnum = gamin_data_get_reqnum(data, filename, (int) type, userData);
if (reqnum < 0)
return (-1);
+ fr->reqnum = reqnum;
} else {
len = strlen(filename);
if (len > MAXPATHLEN)
diff -ruN gamin-0.0.2/server/gam_connection.c gamin-0.0.2.new/server/gam_connection.c
--- gamin-0.0.2/server/gam_connection.c 2004-06-16 08:06:53.000000000 -0400
+++ gamin-0.0.2.new/server/gam_connection.c 2004-07-25 11:19:28.000000000 -0400
@@ -314,16 +314,16 @@
break;
case GAM_REQ_CANCEL:
sub =
- gam_listener_get_subscription(conn->listener,
- &req->path[0]);
+ gam_listener_get_subscription_by_reqno(conn->listener,
+ req->seq);
if (sub == NULL) {
gam_debug(DEBUG_INFO,
- "Cancel: subscription for %s not found\n",
- &req->path[0]);
+ "Cancel: subscription for (%d) not found\n",
+ req->seq);
goto error;
}
- gam_debug(DEBUG_INFO, "Cancelling subscription for %s\n",
- &req->path[0]);
+ gam_debug(DEBUG_INFO, "Cancelling subscription for (%d)\n",
+ req->seq);
gam_remove_subscription(sub);
gam_listener_remove_subscription(conn->listener, sub);
break;
@@ -390,12 +390,14 @@
req->version);
return (-1);
}
- /* double check pathlen and total length */
- if ((req->pathlen <= 0) || (req->pathlen > MAXPATHLEN)) {
- gam_debug(DEBUG_INFO, "invalid path length %d\n\n",
- req->pathlen);
- return (-1);
- }
+ if (GAM_REQ_CANCEL != req->type) {
+ /* double check pathlen and total length */
+ if ((req->pathlen <= 0) || (req->pathlen > MAXPATHLEN)) {
+ gam_debug(DEBUG_INFO, "invalid path length %d\n\n",
+ req->pathlen);
+ return (-1);
+ }
+ }
if (req->pathlen + GAM_PACKET_HEADER_LEN != req->len) {
gam_debug(DEBUG_INFO, "invalid packet sizes: %d %d\n",
req->len, req->pathlen);
diff -ruN gamin-0.0.2/server/gam_listener.c gamin-0.0.2.new/server/gam_listener.c
--- gamin-0.0.2/server/gam_listener.c 2004-06-15 15:30:48.000000000 -0400
+++ gamin-0.0.2.new/server/gam_listener.c 2004-07-25 11:11:02.000000000 -0400
@@ -143,6 +143,28 @@
}
/**
+ * Gets the subscription represented by the given reqno
+ *
+ * @param listener the listener
+ * @param reqno a subscription request number
+ * @returns a #GamSubscription, or NULL if it wasn't found
+ */
+GamSubscription *
+gam_listener_get_subscription_by_reqno(GamListener * listener, int reqno)
+{
+ GList *l;
+
+ for (l = listener->subs; l; l = l->next) {
+ GamSubscription *sub = l->data;
+
+ if (gam_subscription_get_reqno(sub) == reqno)
+ return sub;
+ }
+
+ return NULL;
+}
+
+/**
* Tells if a given #GamListener is subscribed to a file/directory
*
* @param listener the listener
diff -ruN gamin-0.0.2/server/gam_listener.h gamin-0.0.2.new/server/gam_listener.h
--- gamin-0.0.2/server/gam_listener.h 2004-06-15 15:30:48.000000000 -0400
+++ gamin-0.0.2.new/server/gam_listener.h 2004-07-25 11:11:49.000000000 -0400
@@ -28,6 +28,9 @@
GamSubscription *gam_listener_get_subscription (GamListener *listener,
const char *path);
+GamSubscription *gam_listener_get_subscription_by_reqno (GamListener *listener,
+ int reqno);
+
GList *gam_listener_get_subscriptions (GamListener *listener);
gboolean gam_listener_is_subscribed (GamListener *listener,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]