]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Make sure replies to subscribe and unsubscribe methods arrive before any
authorAndreas Öman <andreas@lonelycoder.com>
Sat, 28 Feb 2009 17:45:52 +0000 (17:45 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Sat, 28 Feb 2009 17:45:52 +0000 (17:45 +0000)
other action is taken.

htsp.c

diff --git a/htsp.c b/htsp.c
index 15eb5450ac1bf8e9f1ae0bcdf35f0c4617dd2edf..1b7a3bdc641714f02cbe32542e43171e550a8d54 100644 (file)
--- a/htsp.c
+++ b/htsp.c
@@ -414,11 +414,18 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in)
   if((ch = channel_find_by_identifier(chid)) == NULL)
     return htsp_error("Requested channel does not exist");
 
+
+  /*
+   * We send the reply here or the user will get the 'subscriptionStart'
+   * async message before the reply to 'subscribe'.
+   */
+  htsp_reply(htsp, in, htsmsg_create());
+
   s = subscription_create_from_channel(ch, 500, "htsp",
                                       htsp_subscription_callback, htsp, sid);
 
   LIST_INSERT_HEAD(&htsp->htsp_subscriptions, s, ths_subscriber_link);
-  return htsmsg_create();
+  return NULL;
 }
 
 
@@ -438,12 +445,18 @@ htsp_method_unsubscribe(htsp_connection_t *htsp, htsmsg_t *in)
     if(s->ths_u32 == sid)
       break;
 
+  /*
+   * We send the reply here or the user will get the 'subscriptionStart'
+   * async message before the reply to 'subscribe'.
+   */
+  htsp_reply(htsp, in, htsmsg_create());
+
   if(s == NULL)
-    return htsmsg_create(); /* Just say ok */
+    return NULL; /* Subscription did not exist, but we don't really care */
 
   LIST_REMOVE(s, ths_subscriber_link);
   subscription_unsubscribe(s);
-  return htsmsg_create();
+  return NULL;
 }