This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ATHTTPD patch


Patch provided by Anthony Tonizzo to fix an issue with asserts enabled. Checked in.

Jifl
--
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
------["The best things in life aren't things."]------      Opinions==mine
diff -r -U 5 -N -x CVS -x '*~' -x '.#~' /home/atonizzo/ecos/clean/packages/net/athttpd/current/ChangeLog /home/atonizzo/ecos/devo/packages/net/athttpd/current/ChangeLog
--- /home/atonizzo/ecos/clean/packages/net/athttpd/current/ChangeLog	2006-07-19 07:53:33.000000000 -0700
+++ /home/atonizzo/ecos/devo/packages/net/athttpd/current/ChangeLog	2006-07-19 14:45:38.000000000 -0700
@@ -1,5 +1,11 @@
+2006-07-19  Anthony Tonizzo  <atonizzo@gmail.com>
+
+	* src/socket.c: Corrected a typo that generated an assertion.
+    Modified slightly the source of cyg_httpd_write and cyg_httpd_writev
+     to make the code more consistent as to when assertions are thrown.
+
 2006-07-19  Sergei Gavrikov  <w3sg@softhome.net>
 
 	* doc/athttpd.sgml: jade doesn't allow underscores in
 	id attributes, so fix.
 
diff -r -U 5 -N -x CVS -x '*~' -x '.#~' /home/atonizzo/ecos/clean/packages/net/athttpd/current/src/socket.c /home/atonizzo/ecos/devo/packages/net/athttpd/current/src/socket.c
--- /home/atonizzo/ecos/clean/packages/net/athttpd/current/src/socket.c	2006-07-18 09:37:24.000000000 -0700
+++ /home/atonizzo/ecos/devo/packages/net/athttpd/current/src/socket.c	2006-07-19 14:18:04.000000000 -0700
@@ -76,27 +76,33 @@
 cyg_uint8    cyg_httpd_thread_stack[CYG_HTTPD_DAEMON_STACK_SIZE]     
                                        __attribute__((__aligned__ (16)));
 CYG_HTTPD_STATE httpstate;
                                          
 __inline__ ssize_t
-cyg_httpd_write(char* buf, int len)
+cyg_httpd_write(char* buf, int buf_len)
 {
     // We are not going to write anything in case
     ssize_t sent = send(httpstate.sockets[httpstate.client_index].descriptor, 
                         buf, 
-                        len,
+                        buf_len,
                         0);
-    CYG_ASSERT(sent == len, "send() did not send out all bytes");
+    CYG_ASSERT(sent == buf_len, "send() did not send out all bytes");
     return sent;
 }
 
 __inline__ ssize_t
-cyg_httpd_writev(cyg_iovec *bufs, int count)
+cyg_httpd_writev(cyg_iovec *iovec_bufs, int count)
 {
-    return writev(httpstate.sockets[httpstate.client_index].descriptor, 
-                  bufs, 
-                  count);
+    int i;
+    ssize_t sent = writev(httpstate.sockets[httpstate.client_index].descriptor, 
+                          iovec_bufs, 
+                          count);
+    ssize_t buf_len = 0;
+    for (i = 0; i < count; i++)
+        buf_len += iovec_bufs[i].iov_len;
+    CYG_ASSERT(sent == buf_len, "writev() did not send out all bytes");
+    return sent;
 }
     
 // The need for chunked transfers arises from the fact that with dinamic
 //  pages it is not always possible to know the packet size upfront, and thus
 //  it is not possible to fill the Content-Length: field in the header.
@@ -139,16 +145,11 @@
     //  dynamic data we want them to be executed any every time they are 
     //  requested.
     httpstate.last_modified = -1;
     httpstate.mime_type = cyg_httpd_find_mime_string(extension);
     cyg_int32 header_length = cyg_httpd_format_header();
-    ssize_t sent = send(httpstate.sockets[httpstate.client_index].descriptor, 
-                        httpstate.outbuffer, 
-                        header_length,
-                        0);
-    CYG_ASSERT(sent == header_length, "Did not send out all header bytes");
-    return sent;
+    return cyg_httpd_write(httpstate.outbuffer, header_length);
 }
 
 ssize_t
 cyg_httpd_write_chunked(char* buf, int len)
 {
@@ -160,15 +161,11 @@
     iovec_bufs[1].iov_len = len;
     iovec_bufs[2].iov_len = 2;
     if (httpstate.mode & CYG_HTTPD_SEND_HEADER_ONLY)
         return (iovec_bufs[0].iov_len + iovec_bufs[1].iov_len + 
                                                   iovec_bufs[2].iov_len);
-    ssize_t sent = cyg_httpd_writev(iovec_bufs, 3);
-    CYG_ASSERT(sent == (iovec_bufs[0].iov_len + iovec_bufs[1].iov_len + 
-                                                       iovec_bufs[1].iov_len),
-                        "Writev did not send out all bytes");
-    return sent;
+    return cyg_httpd_writev(iovec_bufs, 3);
 }
 
 void
 cyg_httpd_end_chunked(void)
 {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]