Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for compiling with lwIP #3155

Closed
wants to merge 2 commits into from
Closed

Fix for compiling with lwIP #3155

wants to merge 2 commits into from

Conversation

gvanem
Copy link
Contributor

@gvanem gvanem commented Oct 22, 2018

Compiling on Windows (_WIN32) with USE_LWIPSOCK, causes this error:

  curl_rtmp.c(223,3):  error: use of undeclared identifier 'setsockopt'
    setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO,
    ^
  curl_rtmp.c(41,32):  note: expanded from macro 'setsockopt'
  #define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
                                 ^  

(from with clang-cl).
Since setsockopt() is really lwip_setsockopt() in <LWIP_ROOT>/src/include/lwip\sockets.h, do not redefine it.

Compiling on _WIN32 and with USE_LWIPSOCK, causes this error:
  curl_rtmp.c(223,3):  error: use of undeclared identifier 'setsockopt'
    setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO,
    ^
  curl_rtmp.c(41,32):  note: expanded from macro 'setsockopt'
  #define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
                                 ^  
(from with clang-cl). 
Since 'setsockopt()'  is really 'lwip_setsockopt()' in '<LWIP_ROOT>/src/include/lwip\sockets.h', do not redefine it.
@jay
Copy link
Member

jay commented Oct 23, 2018

lwIP will take an int for rcvtime if it was built with LWIP_SO_SNDRCVTIMEO_NONSTANDARD. It doesn't say in the doc what causes that to be set. For example, is it set by default on Windows? (The only place where it would make any sense IMO). I searched the source but I don't see that it is actually turned on anywhere for any reason. Even if it was I don't know how we would determine that unless it was placed in a conf file? Just to be safe I propose we do this instead:

diff --git a/lib/curl_rtmp.c b/lib/curl_rtmp.c
index 9743064..d962127 100644
--- a/lib/curl_rtmp.c
+++ b/lib/curl_rtmp.c
@@ -37,8 +37,12 @@
 /* The last #include file should be: */
 #include "memdebug.h"

-#ifdef _WIN32
+#ifdef WIN32
 #define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
+#endif
+
+#if (defined(WIN32) && !defined(USE_LWIPSOCK)) || \
+    defined(LWIP_SO_SNDRCVTIMEO_NONSTANDARD)
 #define SET_RCVTIMEO(tv,s)   int tv = s*1000
 #else
 #define SET_RCVTIMEO(tv,s)   struct timeval tv = {s,0}

@jay
Copy link
Member

jay commented Oct 23, 2018

hm I see what you mean.. ok how about this:

diff --git a/lib/curl_rtmp.c b/lib/curl_rtmp.c
index 9743064..109f2b1 100644
--- a/lib/curl_rtmp.c
+++ b/lib/curl_rtmp.c
@@ -37,9 +37,11 @@
 /* The last #include file should be: */
 #include "memdebug.h"

-#ifdef _WIN32
+#if (defined(WIN32) && !defined(USE_LWIPSOCK))
 #define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
 #define SET_RCVTIMEO(tv,s)   int tv = s*1000
+#elif defined(LWIP_SO_SNDRCVTIMEO_NONSTANDARD)
+#define SET_RCVTIMEO(tv,s)   int tv = s*1000
 #else
 #define SET_RCVTIMEO(tv,s)   struct timeval tv = {s,0}
 #endif

@gvanem
Copy link
Contributor Author

gvanem commented Oct 23, 2018

LWIP_SO_SNDRCVTIMEO_NONSTANDARD is 0 by default. Your last patch seems okay.

Per Jay Satiros comment, adapt for the case when 'LWIP_SO_SNDRCVTIMEO_NONSTANDARD = 1'
@bagder bagder closed this in 639d052 Oct 25, 2018
@bagder
Copy link
Member

bagder commented Oct 25, 2018

I took the liberty of merging this. Thanks @gvanem !

@bagder bagder deleted the lwip-patch branch October 25, 2018 22:04
@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants