WPS: Separate local error from max queue length reached
authorJouni Malinen <j@w1.fi>
Sun, 17 Oct 2010 17:29:28 +0000 (20:29 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 17 Oct 2010 17:29:28 +0000 (20:29 +0300)
Drop subscription only if the max queue length has been reached;
not based on any error.

src/wps/wps_upnp.c
src/wps/wps_upnp_event.c

index 01c2dee..4c0a5c1 100644 (file)
@@ -499,7 +499,7 @@ static void upnp_wps_device_send_event(struct upnp_wps_device_sm *sm)
 
        dl_list_for_each_safe(s, tmp, &sm->subscriptions, struct subscription,
                              list) {
-               if (event_add(s, buf)) {
+               if (event_add(s, buf) == 1) {
                        wpa_printf(MSG_INFO, "WPS UPnP: Dropping "
                                   "subscriber %p due to event backlog", s);
                        dl_list_del(&s->list);
@@ -608,6 +608,7 @@ static int subscription_first_event(struct subscription *s)
                "<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n";
        const char *tail = "</e:propertyset>\n";
        char txt[10];
+       int ret;
 
        if (s->sm->wlanevent == NULL) {
                /*
@@ -639,7 +640,7 @@ static int subscription_first_event(struct subscription *s)
        }
        buf = wpabuf_alloc(500 + os_strlen(wlan_event));
        if (buf == NULL)
-               return 1;
+               return -1;
 
        wpabuf_put_str(buf, head);
        wpabuf_put_property(buf, "STAStatus", "1");
@@ -649,9 +650,10 @@ static int subscription_first_event(struct subscription *s)
                wpabuf_put_property(buf, "WLANEvent", wlan_event);
        wpabuf_put_str(buf, tail);
 
-       if (event_add(s, buf)) {
+       ret = event_add(s, buf);
+       if (ret) {
                wpabuf_free(buf);
-               return 1;
+               return ret;
        }
        wpabuf_free(buf);
 
index 9deca52..31ce824 100644 (file)
@@ -365,7 +365,7 @@ void event_send_stop_all(struct upnp_wps_device_sm *sm)
  * event_add - Add a new event to a queue
  * @s: Subscription
  * @data: Event data (is copied; caller retains ownership)
- * Returns: 0 on success, 1 on error
+ * Returns: 0 on success, -1 on error, 1 on max event queue limit reached
  */
 int event_add(struct subscription *s, const struct wpabuf *data)
 {
@@ -381,13 +381,13 @@ int event_add(struct subscription *s, const struct wpabuf *data)
 
        e = os_zalloc(sizeof(*e));
        if (e == NULL)
-               return 1;
+               return -1;
        dl_list_init(&e->list);
        e->s = s;
        e->data = wpabuf_dup(data);
        if (e->data == NULL) {
                os_free(e);
-               return 1;
+               return -1;
        }
        e->subscriber_sequence = s->next_subscriber_sequence++;
        if (s->next_subscriber_sequence == 0)