aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-server.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-05-07 18:20:07 +0200
committerMattias Andrée <maandree@operamail.com>2014-05-07 18:20:07 +0200
commit9cf460de884ff1a7f2fd3fb9d8df3e1bd5691b3a (patch)
tree8fde4526f9e4e410ca748497d36f949cecb237bc /src/mds-server.c
parentget multicast recipients (diff)
downloadmds-9cf460de884ff1a7f2fd3fb9d8df3e1bd5691b3a.tar.gz
mds-9cf460de884ff1a7f2fd3fb9d8df3e1bd5691b3a.tar.bz2
mds-9cf460de884ff1a7f2fd3fb9d8df3e1bd5691b3a.tar.xz
sort interceptors by priority
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/mds-server.c')
-rw-r--r--src/mds-server.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mds-server.c b/src/mds-server.c
index 9145033..8f0e8fe 100644
--- a/src/mds-server.c
+++ b/src/mds-server.c
@@ -909,6 +909,22 @@ void add_intercept_condition(client_t* client, char* condition, int64_t priority
/**
+ * Compare two queued interceptors by priority
+ *
+ * @param a:const queued_interception_t* One of the interceptors
+ * @param b:const queued_interception_t* The other of the two interceptors
+ * @return Negative if a before b, positive if a after b, otherwise zero
+ */
+static int cmp_queued_interception(const void* a, const void* b)
+{
+ const queued_interception_t* p = b; /* Highest first, so swap them. */
+ const queued_interception_t* q = a;
+ int64_t diff = p->priority - q->priority;
+ return diff < 0 ? -1 : diff > 0 ? 1 : 0;
+}
+
+
+/**
* Multicast a message
*
* @param message The message
@@ -1027,6 +1043,8 @@ void multicast_message(char* message, size_t length)
goto fail;
/* Sort interceptors. */
+ qsort(interceptions, interceptions_count, sizeof(queued_interception_t), cmp_queued_interception);
+
/* TODO */
errno = 0;