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.
This commit is contained in:
Jouni Malinen 2010-10-17 20:29:28 +03:00
parent dd50c2d425
commit 8c3a2f11ab
2 changed files with 9 additions and 7 deletions

View 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);

View 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)