Skip to content
Snippets Groups Projects
Commit 47e503cb authored by François-Simon Fauteux-Chapleau's avatar François-Simon Fauteux-Chapleau
Browse files

upnp: fix bug in poll.patch

This commit fixes a bug in poll.patch that prevented UPnP search
messages from being sent.

GitLab: #1054
Change-Id: Ied2329d98ac45f4ccfa88f8eaaccba82327cfdd4
parent 860fa521
No related branches found
No related tags found
No related merge requests found
upnp/src/genlib/net/http/httpreadwrite.c | 89 +++++++++++++++------------------------- upnp/src/genlib/net/http/httpreadwrite.c | 89 +++++++-----------
upnp/src/genlib/net/sock.c | 103 ++++++++++++++++++---------------------------- upnp/src/genlib/net/sock.c | 103 ++++++++-------------
upnp/src/ssdp/ssdp_ctrlpt.c | 155 +++++++++++++++++++++++++-------------------------------------------- upnp/src/ssdp/ssdp_ctrlpt.c | 152 +++++++++++--------------------
3 files changed, 129 insertions(+), 218 deletions(-) 3 files changed, 125 insertions(+), 219 deletions(-)
diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c
index 27e9c3a5..69eb0a1f 100644 index 27e9c3a5..69eb0a1f 100644
...@@ -247,7 +247,7 @@ index 396c692a..b8a980f0 100644 ...@@ -247,7 +247,7 @@ index 396c692a..b8a980f0 100644
if (info->ssl) { if (info->ssl) {
num_written = SSL_write(info->ssl, num_written = SSL_write(info->ssl,
diff --git a/upnp/src/ssdp/ssdp_ctrlpt.c b/upnp/src/ssdp/ssdp_ctrlpt.c diff --git a/upnp/src/ssdp/ssdp_ctrlpt.c b/upnp/src/ssdp/ssdp_ctrlpt.c
index 8644c746..050b4916 100644 index 8644c746..714c5b14 100644
--- a/upnp/src/ssdp/ssdp_ctrlpt.c --- a/upnp/src/ssdp/ssdp_ctrlpt.c
+++ b/upnp/src/ssdp/ssdp_ctrlpt.c +++ b/upnp/src/ssdp/ssdp_ctrlpt.c
@@ -40,6 +40,7 @@ @@ -40,6 +40,7 @@
...@@ -258,15 +258,23 @@ index 8644c746..050b4916 100644 ...@@ -258,15 +258,23 @@ index 8644c746..050b4916 100644
#ifdef INCLUDE_CLIENT_APIS #ifdef INCLUDE_CLIENT_APIS
#if EXCLUDE_SSDP == 0 #if EXCLUDE_SSDP == 0
@@ -597,6 +598,7 @@ int SearchByTarget(int Hnd, int Mx, char *St, void *Cookie) @@ -588,7 +589,6 @@ int SearchByTarget(int Hnd, int Mx, char *St, void *Cookie)
#ifdef UPNP_ENABLE_IPV6
struct sockaddr_in6 *destAddr6 = (struct sockaddr_in6 *)&__ss_v6;
#endif
- fd_set wrSet;
SsdpSearchArg *newArg = NULL;
SsdpSearchExpArg *expArg = NULL;
int timeTillRead = 0;
@@ -597,6 +597,7 @@ int SearchByTarget(int Hnd, int Mx, char *St, void *Cookie)
struct in_addr addrv4; struct in_addr addrv4;
SOCKET max_fd = 0; SOCKET max_fd = 0;
int retVal; int retVal;
+ int numCopies = 0; + int numCopies;
/*ThreadData *ThData; */ /*ThreadData *ThData; */
ThreadPoolJob job; ThreadPoolJob job;
@@ -674,105 +676,60 @@ int SearchByTarget(int Hnd, int Mx, char *St, void *Cookie) @@ -674,105 +675,56 @@ int SearchByTarget(int Hnd, int Mx, char *St, void *Cookie)
HandleUnlock(); HandleUnlock();
/* End of lock */ /* End of lock */
...@@ -397,28 +405,24 @@ index 8644c746..050b4916 100644 ...@@ -397,28 +405,24 @@ index 8644c746..050b4916 100644
+ return UPNP_E_INTERNAL_ERROR; + return UPNP_E_INTERNAL_ERROR;
+ } + }
+#ifdef UPNP_ENABLE_IPV6 +#ifdef UPNP_ENABLE_IPV6
+ if (gSsdpReqSocket6 != INVALID_SOCKET && FD_ISSET(gSsdpReqSocket6, &wrSet)) { + if (gSsdpReqSocket6 != INVALID_SOCKET && (fds[nfds - 1].revents & POLLOUT)) {
+ while (numCopies < NUM_SSDP_COPY) { + for (numCopies = 0; numCopies < NUM_SSDP_COPY; numCopies++) {
+ UpnpPrintf(UPNP_INFO, SSDP, __FILE__, __LINE__, ">>> SSDP SEND M-SEARCH >>>\n%s\n", ReqBufv6UlaGua); + UpnpPrintf(UPNP_INFO, SSDP, __FILE__, __LINE__, ">>> SSDP SEND M-SEARCH >>>\n%s\n", ReqBufv6UlaGua);
+ sendto(gSsdpReqSocket6, ReqBufv6UlaGua, (int)strlen(ReqBufv6UlaGua), 0, (struct sockaddr *)&__ss_v6, sizeof(struct sockaddr_in6)); + sendto(gSsdpReqSocket6, ReqBufv6UlaGua, (int)strlen(ReqBufv6UlaGua), 0, (struct sockaddr *)&__ss_v6, sizeof(struct sockaddr_in6));
+ numCopies++;
+ imillisleep(SSDP_PAUSE); + imillisleep(SSDP_PAUSE);
+ } + }
+ numCopies = 0;
+ inet_pton(AF_INET6, SSDP_IPV6_LINKLOCAL, &destAddr6->sin6_addr); + inet_pton(AF_INET6, SSDP_IPV6_LINKLOCAL, &destAddr6->sin6_addr);
+ while (numCopies < NUM_SSDP_COPY) { + for (numCopies = 0; numCopies < NUM_SSDP_COPY; numCopies++) {
+ UpnpPrintf(UPNP_INFO, SSDP, __FILE__, __LINE__, ">>> SSDP SEND M-SEARCH >>>\n%s\n", ReqBufv6); + UpnpPrintf(UPNP_INFO, SSDP, __FILE__, __LINE__, ">>> SSDP SEND M-SEARCH >>>\n%s\n", ReqBufv6);
+ sendto(gSsdpReqSocket6, ReqBufv6, (int)strlen(ReqBufv6), 0, (struct sockaddr *)&__ss_v6, sizeof(struct sockaddr_in6)); + sendto(gSsdpReqSocket6, ReqBufv6, (int)strlen(ReqBufv6), 0, (struct sockaddr *)&__ss_v6, sizeof(struct sockaddr_in6));
+ numCopies++;
+ imillisleep(SSDP_PAUSE); + imillisleep(SSDP_PAUSE);
+ } + }
+ } + }
+#endif /* IPv6 */ +#endif /* IPv6 */
+ if (gSsdpReqSocket4 != INVALID_SOCKET && FD_ISSET(gSsdpReqSocket4, &wrSet)) { + if (gSsdpReqSocket4 != INVALID_SOCKET && (fds[0].revents & POLLOUT)) {
+ while (numCopies < NUM_SSDP_COPY) { + for (numCopies = 0; numCopies < NUM_SSDP_COPY; numCopies++) {
+ UpnpPrintf(UPNP_INFO, SSDP, __FILE__, __LINE__, ">>> SSDP SEND M-SEARCH >>>\n%s\n", ReqBufv4); + UpnpPrintf(UPNP_INFO, SSDP, __FILE__, __LINE__, ">>> SSDP SEND M-SEARCH >>>\n%s\n", ReqBufv4);
+ sendto(gSsdpReqSocket4, ReqBufv4, (int)strlen(ReqBufv4), 0, (struct sockaddr *)&__ss_v4, sizeof(struct sockaddr_in)); + sendto(gSsdpReqSocket4, ReqBufv4, (int)strlen(ReqBufv4), 0, (struct sockaddr *)&__ss_v4, sizeof(struct sockaddr_in));
+ numCopies++;
+ imillisleep(SSDP_PAUSE); + imillisleep(SSDP_PAUSE);
+ } + }
+ } + }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment