From c3e58dfdbe61ddc19441a8251caa0cbc5a669a2e Mon Sep 17 00:00:00 2001 From: Andrew Bott Date: Fri, 16 Sep 2016 20:41:19 +0000 Subject: [PATCH] mount-points: fix matching of paths where there's also an entry with a common prefix e.g. with the following mount points /raw /raw/snapshot /raw/video _match() would not match /raw/video and /raw/snapshot correctly. https://bugzilla.gnome.org/show_bug.cgi?id=771555 --- gst/rtsp-server/rtsp-mount-points.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gst/rtsp-server/rtsp-mount-points.c b/gst/rtsp-server/rtsp-mount-points.c index c6a8c06dce..77d82ed471 100644 --- a/gst/rtsp-server/rtsp-mount-points.c +++ b/gst/rtsp-server/rtsp-mount-points.c @@ -248,6 +248,8 @@ gst_rtsp_mount_points_match (GstRTSPMountPoints * mounts, item.path = (gchar *) path; item.len = strlen (path); + GST_LOG ("Looking for mount point path %s", path); + g_mutex_lock (&priv->lock); if (priv->dirty) { g_sequence_sort (priv->mounts, data_item_compare, mounts); @@ -266,18 +268,17 @@ gst_rtsp_mount_points_match (GstRTSPMountPoints * mounts, data_item_dump (ritem, "inspect: "); - if (best == NULL) { - if (has_prefix (&item, ritem)) { + /* The sequence is sorted, so any prefix match is an improvement upon + * the previous best match, as '/abc' will always be before '/abcd' */ + if (has_prefix (&item, ritem)) { + if (best == NULL) { data_item_dump (ritem, "prefix: "); - best = iter; + } else { + data_item_dump (ritem, "new best: "); } - } else { - if (!has_prefix (&item, ritem)) - break; - best = iter; - data_item_dump (ritem, "new best: "); } + iter = g_sequence_iter_next (iter); } if (best) {