Fossil SCM

Fix the socket_receive() function so that it compiles on systems that lack the MSG_DONTWAIT macro (Windows). Such systems lose non-blocking capabilities, but they work otherwise.

drh 2018-07-11 19:46 smtp
Commit 31d274d02ea8944c6e2400228a8dba9366baed2fe12c30af1a36fdda8cf277e5
1 file changed +4 -1
--- src/http_socket.c
+++ src/http_socket.c
@@ -215,11 +215,14 @@
215215
** have been read.
216216
*/
217217
size_t socket_receive(void *NotUsed, void *pContent, size_t N, int bDontBlock){
218218
ssize_t got;
219219
size_t total = 0;
220
- int flags = bDontBlock ? MSG_DONTWAIT : 0;
220
+ int flags = 0;
221
+#ifdef MSG_DONTWAIT
222
+ if( bDontBlock ) flags |= MSG_DONTWAIT;
223
+#endif
221224
while( N>0 ){
222225
/* WinXP fails for large values of N. So limit it to 64KiB. */
223226
got = recv(iSocket, pContent, N>65536 ? 65536 : N, flags);
224227
if( got<=0 ) break;
225228
total += (size_t)got;
226229
--- src/http_socket.c
+++ src/http_socket.c
@@ -215,11 +215,14 @@
215 ** have been read.
216 */
217 size_t socket_receive(void *NotUsed, void *pContent, size_t N, int bDontBlock){
218 ssize_t got;
219 size_t total = 0;
220 int flags = bDontBlock ? MSG_DONTWAIT : 0;
 
 
 
221 while( N>0 ){
222 /* WinXP fails for large values of N. So limit it to 64KiB. */
223 got = recv(iSocket, pContent, N>65536 ? 65536 : N, flags);
224 if( got<=0 ) break;
225 total += (size_t)got;
226
--- src/http_socket.c
+++ src/http_socket.c
@@ -215,11 +215,14 @@
215 ** have been read.
216 */
217 size_t socket_receive(void *NotUsed, void *pContent, size_t N, int bDontBlock){
218 ssize_t got;
219 size_t total = 0;
220 int flags = 0;
221 #ifdef MSG_DONTWAIT
222 if( bDontBlock ) flags |= MSG_DONTWAIT;
223 #endif
224 while( N>0 ){
225 /* WinXP fails for large values of N. So limit it to 64KiB. */
226 got = recv(iSocket, pContent, N>65536 ? 65536 : N, flags);
227 if( got<=0 ) break;
228 total += (size_t)got;
229

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button