aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-06-17 17:20:21 +0000
committerng0 <ng0@n0.is>2019-06-25 08:01:46 +0000
commit883c72f9a69ac3ccf591742327c3e425e47a8ea0 (patch)
tree0d821164a2531b8f8e7b4c892c5de41ad78529bc
parentb474adda0898c01194ed47c5d90b5caed99f7bf6 (diff)
downloadlibmicrohttpd-883c72f9a69ac3ccf591742327c3e425e47a8ea0.tar.gz
libmicrohttpd-883c72f9a69ac3ccf591742327c3e425e47a8ea0.zip
mhd_send: Move return_bytes related code into the right place.
-rw-r--r--src/microhttpd/mhd_send.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 1394aa70..4af5680c 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -260,7 +260,7 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
260 size_t buffer_size, 260 size_t buffer_size,
261 enum MHD_SendSocketOptions) 261 enum MHD_SendSocketOptions)
262{ 262{
263 int errno = 0; 263 int errno = 0;
264 MHD_socket s = connection->socket_fd; 264 MHD_socket s = connection->socket_fd;
265 // -- <pseudo> 265 // -- <pseudo>
266 // set socket := connect->MHD_socket 266 // set socket := connect->MHD_socket
@@ -286,40 +286,39 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
286 // return -1 286 // return -1
287 // return numBytes 287 // return numBytes
288 // -- </pseudo> 288 // -- </pseudo>
289#ifdef WRITEV
290 int iovcnt;
291 struct iovec vector[2];
292 vector[0].iov_base = header;
293 vector[0].iov_len = strlen (header);
294 vector[1].iov_base = buffer;
295 vector[1].iov_len = strlen (buffer);
296 iovcnt = sizeof (vector) / sizeof (struct iovec);
297 int i = writev (s, vector, iovcnt);
298 fprintf (stdout, "i=%d, errno=%d\n", i, errno);
299#else
300 // not available, send a combination of header + buffer.
301 size_t concatsize = header_size + buffer_size;
302 const char *concatbuffer;
303 concatbuffer = header + buffer;
304#ifdef MSG_MORE
305 num_bytes = send (s, concatbuffer, concatsize, MSG_MORE);
306#else
307 num_bytes = send (s, concatbuffer, concatsize);
308#endif
309#endif
310 struct tcp_info *tcp_; 289 struct tcp_info *tcp_;
311 size_t opt1, opt2, length; 290 size_t opt1, opt2, length;
312 switch (MHD_SendSocketOptions) 291 switch (MHD_SendSocketOptions)
313 { 292 {
314 case MHD_SSO_NO_CORK: 293 case MHD_SSO_NO_CORK:
315 /* No corking */ 294 /* No corking */
316 case MHD_SSO_MAY_CORK: 295 case MHD_SSO_MAY_CORK:
317 case MHD_SSO_HDR_CORK: 296 case MHD_SSO_HDR_CORK:
318 } 297 }
319if (MHD_SendSocketOptions == 1) 298 if (MHD_SendSocketOptions == 1)
320{ 299 {
321 // bla 300#ifdef WRITEV
322} 301 int iovcnt;
302 struct iovec vector[2];
303 vector[0].iov_base = header;
304 vector[0].iov_len = strlen (header);
305 vector[1].iov_base = buffer;
306 vector[1].iov_len = strlen (buffer);
307 iovcnt = sizeof (vector) / sizeof (struct iovec);
308 int i = writev (s, vector, iovcnt);
309 fprintf (stdout, "i=%d, errno=%d\n", i, errno);
310#else
311 // not available, send a combination of header + buffer.
312 //size_t concatsize = header_size + buffer_size;
313 //const char *concatbuffer;
314 //concatbuffer = header + buffer;
315#ifdef MSG_MORE
316 num_bytes = send (s, header, header_size, MSG_MORE);
317#else
318 num_bytes = send (s, header, header_size);
319#endif
320#endif
321 }
323 if (0 != errno) 322 if (0 != errno)
324 return -1; 323 return -1;
325 if (0 == errno) 324 if (0 == errno)