From 8c3a2f11ab13c9629c05a396c1f888d6a8685bfb Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 17 Oct 2010 20:29:28 +0300 Subject: [PATCH] WPS: Separate local error from max queue length reached Drop subscription only if the max queue length has been reached; not based on any error. --- src/wps/wps_upnp.c | 10 ++++++---- src/wps/wps_upnp_event.c | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/wps/wps_upnp.c b/src/wps/wps_upnp.c index 01c2deee0..4c0a5c1c8 100644 --- a/src/wps/wps_upnp.c +++ b/src/wps/wps_upnp.c @@ -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) "\n"; const char *tail = "\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); diff --git a/src/wps/wps_upnp_event.c b/src/wps/wps_upnp_event.c index 9deca5259..31ce82492 100644 --- a/src/wps/wps_upnp_event.c +++ b/src/wps/wps_upnp_event.c @@ -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)