------------------------------------------------------------
revno: 1450
committer: James Hunt <[email protected]>
branch nick: upstart-file-bridge
timestamp: Fri 2013-03-15 12:44:29 +0000
message:
  * extra/man/file-event.7: Simplify language.
  * extra/upstart-file-bridge.c:
    - skip_slashes(): New macro to make path matching more reliable.
    - file_filter(): Call skip_slashes().
    - create_handler(): Call skip_slashes().
    - modify_handler(): Call skip_slashes().
    - delete_handler(): Call skip_slashes().
    - watched_dir_new(): Special case watching the root directory.
modified:
  ChangeLog
  extra/man/file-event.7
  extra/upstart-file-bridge.c


--
lp:upstart
https://code.launchpad.net/~upstart-devel/upstart/trunk

Your team Upstart Reviewers is subscribed to branch lp:upstart.
To unsubscribe from this branch go to 
https://code.launchpad.net/~upstart-devel/upstart/trunk/+edit-subscription
=== modified file 'ChangeLog'
--- ChangeLog	2013-03-11 20:02:18 +0000
+++ ChangeLog	2013-03-15 12:44:29 +0000
@@ -1,3 +1,14 @@
+2013-03-15  James Hunt  <[email protected]>
+
+	* extra/man/file-event.7: Simplify language.
+	* extra/upstart-file-bridge.c:
+	  - skip_slashes(): New macro to make path matching more reliable.
+	  - file_filter(): Call skip_slashes().
+	  - create_handler(): Call skip_slashes().
+	  - modify_handler(): Call skip_slashes().
+	  - delete_handler(): Call skip_slashes().
+	  - watched_dir_new(): Special case watching the root directory.
+
 2013-03-11  James Hunt  <[email protected]>
 
 	* extra/Makefile.am: Add file bridge and conf file.

=== modified file 'extra/man/file-event.7'
--- extra/man/file-event.7	2013-03-11 20:02:18 +0000
+++ extra/man/file-event.7	2013-03-15 12:44:29 +0000
@@ -61,7 +61,7 @@
 .BR FMATCH ", "
 ensure that
 .B FPATH
-does not contain multiple contiguous runs of slashes since otherwise
+does not contain multiple consecutive runs of slashes since otherwise
 your job will find it difficult to perform such a match.
 .\"
 .SH EXAMPLES

=== modified file 'extra/upstart-file-bridge.c'
--- extra/upstart-file-bridge.c	2013-03-11 20:02:18 +0000
+++ extra/upstart-file-bridge.c	2013-03-15 12:44:29 +0000
@@ -188,6 +188,17 @@
 	 (file->original ? file->original : file->path)
 
 /**
+ * skip_slashes:
+ *
+ * @path: pointer to path string.
+ *
+ * Increment @path to skip over multiple leading slashes.
+ **/
+#define skip_slashes(path) \
+	while (*(path) == '/' && (path)+1 && *((path)+1) == '/') \
+		(path)++
+
+/**
  * Job:
  *
  * @entry: list header,
@@ -658,7 +669,6 @@
 	}
 
 	nih_message ("Job got added %s", job_path);
-
 }
 
 /**
@@ -874,6 +884,8 @@
 	nih_assert (dir);
 	nih_assert (path);
 
+	skip_slashes (path);
+
 	NIH_HASH_FOREACH_SAFE (dir->files, iter) {
 		WatchedFile *file = (WatchedFile *)iter;
 
@@ -928,6 +940,8 @@
 	nih_assert (path);
 	nih_assert (statbuf);
 
+	skip_slashes (path);
+
 	/* path should be a file below the WatchedDir */
 	nih_assert (strstr (path, dir->path) == path);
 
@@ -1049,6 +1063,8 @@
 	/* path should be a file below the WatchedDir */
 	nih_assert (strstr (path, dir->path) == path);
 
+	skip_slashes (path);
+
 	handled = NIH_MUST (nih_hash_string_new (NULL, 0));
 
 	NIH_HASH_FOREACH_SAFE (dir->files, iter) {
@@ -1120,6 +1136,8 @@
 	/* path should be a file below the WatchedDir */
 	nih_assert (strstr (path, dir->path) == path);
 
+	skip_slashes (path);
+
 	nih_list_init (&entries);
 	handled = NIH_MUST (nih_hash_string_new (NULL, 0));
 
@@ -1420,14 +1438,17 @@
 	strcpy (watched_path, path);
 	len = strlen (watched_path);
 
-	if (watched_path[len-1] == '/') {
+	if (len > 1 && watched_path[len-1] == '/') {
 		/* Better to remove a trailing slash before handing to
 		 * inotify since although all works as expected, the
 		 * path handed to inotify also gets given to the
 		 * create/modify/delete handlers which can then lead to
-		 * multiple contiguous slashes which could result in
+		 * multiple consecutive slashes which could result in
 		 * jobs failing to start as they would not expect FMATCH
 		 * to contain such values.
+		 *
+		 * Note that we do not (cannot) do this if @path is
+		 * the root directory.
 		 */
 		watched_path[len-1] = '\0';
 	}

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to