Merge remote-tracking branch 'razzfazz/renew_cleanup'

This commit is contained in:
Thomas Bernard 2015-12-12 08:28:48 +01:00
commit 2a654e0ef4
3 changed files with 11 additions and 9 deletions

View File

@ -143,8 +143,8 @@ upnpevents_addSubscriber(const char * eventurl,
} }
/* renew a subscription (update the timeout) */ /* renew a subscription (update the timeout) */
int const char *
renewSubscription(const char * sid, int sidlen, int timeout) upnpevents_renewSubscription(const char * sid, int sidlen, int timeout)
{ {
struct subscriber * sub; struct subscriber * sub;
for(sub = subscriberlist.lh_first; sub != NULL; sub = sub->entries.le_next) { for(sub = subscriberlist.lh_first; sub != NULL; sub = sub->entries.le_next) {
@ -155,10 +155,10 @@ renewSubscription(const char * sid, int sidlen, int timeout)
continue; continue;
#endif #endif
sub->timeout = (timeout ? time(NULL) + timeout : 0); sub->timeout = (timeout ? time(NULL) + timeout : 0);
return 0; return sub->uuid;
} }
} }
return -1; return NULL;
} }
int int

View File

@ -36,8 +36,8 @@ upnpevents_addSubscriber(const char * eventurl,
int int
upnpevents_removeSubscriber(const char * sid, int sidlen); upnpevents_removeSubscriber(const char * sid, int sidlen);
int const char *
renewSubscription(const char * sid, int sidlen, int timeout); upnpevents_renewSubscription(const char * sid, int sidlen, int timeout);
void upnpevents_selectfds(fd_set *readset, fd_set *writeset, int * max_fd); void upnpevents_selectfds(fd_set *readset, fd_set *writeset, int * max_fd);
void upnpevents_processfds(fd_set *readset, fd_set *writeset); void upnpevents_processfds(fd_set *readset, fd_set *writeset);

View File

@ -665,11 +665,13 @@ with HTTP error 412 Precondition Failed. */
BuildResp2_upnphttp(h, 400, "Incompatible header fields", 0, 0); BuildResp2_upnphttp(h, 400, "Incompatible header fields", 0, 0);
} else } else
#endif #endif
if(renewSubscription(h->req_buf + h->req_SIDOff, h->req_SIDLen, sid = upnpevents_renewSubscription(h->req_buf + h->req_SIDOff,
h->req_Timeout) < 0) { h->req_SIDLen, h->req_Timeout);
if(!sid) {
BuildResp2_upnphttp(h, 412, "Precondition Failed", 0, 0); BuildResp2_upnphttp(h, 412, "Precondition Failed", 0, 0);
} else { } else {
h->respflags = FLAG_TIMEOUT; h->respflags = FLAG_TIMEOUT | FLAG_SID;
h->res_SID = sid;
BuildResp_upnphttp(h, 0, 0); BuildResp_upnphttp(h, 0, 0);
} }
} }