[PHP-CVS] cvs: php4 /sapi/thttpd thttpd.c
sas Tue Apr 24 23:42:24 2001 EDT Modified files: /php4/sapi/thttpd thttpd.c Log: Fix optimization -- we did not send out custom Response Status Lines. Index: php4/sapi/thttpd/thttpd.c diff -u php4/sapi/thttpd/thttpd.c:1.40 php4/sapi/thttpd/thttpd.c:1.41 --- php4/sapi/thttpd/thttpd.c:1.40 Sun Apr 22 07:22:40 2001 +++ php4/sapi/thttpd/thttpd.c Tue Apr 24 23:42:24 2001 @@ -77,17 +77,24 @@ int n = 0; zend_llist_position pos; sapi_header_struct *h; + size_t len; if (!SG(sapi_headers).http_status_line) { - size_t len; - snprintf(buf, 1023, HTTP/1.0 %d Something\r\n, SG(sapi_headers).http_response_code); len = strlen(buf); vec[n].iov_base = buf; - vec[n++].iov_len = len; - TG(hc)-status = SG(sapi_headers).http_response_code; - TG(hc)-bytes_sent += len; + vec[n].iov_len = len; + } else { + vec[n].iov_base = SG(sapi_headers).http_status_line; + len = strlen(vec[n].iov_base); + vec[n].iov_len = len; + vec[++n].iov_base = \r\n; + vec[n].iov_len = 2; + len += 2; } + TG(hc)-status = SG(sapi_headers).http_response_code; + TG(hc)-bytes_sent += len; + n++; h = zend_llist_get_first_ex(sapi_headers-headers, pos); while (h) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-CVS] cvs: php4 /sapi/thttpd thttpd.c
sas Tue Mar 13 09:14:47 2001 EDT Modified files: /php4/sapi/thttpd thttpd.c Log: Replace memcpy and sprintf with smart_strs. Index: php4/sapi/thttpd/thttpd.c diff -u php4/sapi/thttpd/thttpd.c:1.38 php4/sapi/thttpd/thttpd.c:1.39 --- php4/sapi/thttpd/thttpd.c:1.38 Fri Mar 2 09:01:52 2001 +++ php4/sapi/thttpd/thttpd.c Tue Mar 13 09:14:47 2001 @@ -24,6 +24,8 @@ #include "php_variables.h" #include "version.h" +#include "ext/standard/php_smart_str.h" + #include sys/uio.h typedef struct { @@ -257,30 +259,24 @@ static void thttpd_request_ctor(TLS_D SLS_DC) { - char *cp; - size_t cp_len; char buf[1024]; int offset; size_t filename_len; size_t cwd_len; - + smart_str s = {0}; SG(request_info).query_string = TG(hc)-query?strdup(TG(hc)-query):NULL; - - filename_len = strlen(TG(hc)-expnfilename); - cwd_len = strlen(TG(hc)-hs-cwd); - cp_len = cwd_len + filename_len; - cp = (char *) malloc(cp_len + 1); - /* cwd always ends in "/", so this is safe */ - memcpy(cp, TG(hc)-hs-cwd, cwd_len); - memcpy(cp + cwd_len, TG(hc)-expnfilename, filename_len); - cp[cp_len] = '\0'; - - SG(request_info).path_translated = cp; - - snprintf(buf, 1023, "/%s", TG(hc)-origfilename); - SG(request_info).request_uri = strdup(buf); + smart_str_appends_ex(s, TG(hc)-hs-cwd, 1); + smart_str_appends_ex(s, TG(hc)-expnfilename, 1); + smart_str_0(s); + SG(request_info).path_translated = s.c; + + s.c = NULL; + smart_str_appendc_ex(s, '/', 1); + smart_str_appends_ex(s, TG(hc)-origfilename, 1); + smart_str_0(s); + SG(request_info).request_uri = s.c; SG(request_info).request_method = httpd_method_str(TG(hc)-method); SG(sapi_headers).http_response_code = 200; SG(request_info).content_type = TG(hc)-contenttype; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-CVS] cvs: php4 /sapi/thttpd thttpd.c
sas Fri Mar 2 09:01:52 2001 EDT Modified files: /php4/sapi/thttpd thttpd.c Log: Combine all HTTP headers into a single writev Index: php4/sapi/thttpd/thttpd.c diff -u php4/sapi/thttpd/thttpd.c:1.37 php4/sapi/thttpd/thttpd.c:1.38 --- php4/sapi/thttpd/thttpd.c:1.37 Sun Feb 25 22:07:38 2001 +++ php4/sapi/thttpd/thttpd.c Fri Mar 2 09:01:52 2001 @@ -66,40 +66,51 @@ return sent; } +#define COMBINE_HEADERS 30 + static int sapi_thttpd_send_headers(sapi_headers_struct *sapi_headers SLS_DC) { char buf[1024]; - + struct iovec vec[COMBINE_HEADERS]; + int n = 0; + zend_llist_position pos; + sapi_header_struct *h; + if (!SG(sapi_headers).http_status_line) { size_t len; snprintf(buf, 1023, "HTTP/1.0 %d Something\r\n", SG(sapi_headers).http_response_code); len = strlen(buf); - send(TG(hc)-conn_fd, buf, len, 0); + vec[n].iov_base = buf; + vec[n++].iov_len = len; TG(hc)-status = SG(sapi_headers).http_response_code; TG(hc)-bytes += len; } - - return SAPI_HEADER_DO_SEND; -} - -static void sapi_thttpd_send_header(sapi_header_struct *sapi_header, void *server_context) -{ - struct iovec vec[2]; - int n = 0; - TLS_FETCH(); - if (sapi_header) { - vec[n].iov_base = sapi_header-header; - vec[n++].iov_len = sapi_header-header_len; - TG(hc)-bytes += sapi_header-header_len; + h = zend_llist_get_first_ex(sapi_headers-headers, pos); + while (h) { + vec[n].iov_base = h-header; + vec[n++].iov_len = h-header_len; + if (n = COMBINE_HEADERS - 1) { + if (writev(TG(hc)-conn_fd, vec, n) == -1 errno == EPIPE) + php_handle_aborted_connection(); + n = 0; + } + vec[n].iov_base = "\r\n"; + vec[n++].iov_len = 2; + + h = zend_llist_get_next_ex(sapi_headers-headers, pos); } + vec[n].iov_base = "\r\n"; vec[n++].iov_len = 2; - TG(hc)-bytes += 2; + + if (n) { + if (writev(TG(hc)-conn_fd, vec, n) == -1 errno == EPIPE) + php_handle_aborted_connection(); + } - if (writev(TG(hc)-conn_fd, vec, n) == -1 errno == EPIPE) - php_handle_aborted_connection(); + return SAPI_HEADER_SENT_SUCCESSFULLY; } static int sapi_thttpd_read_post(char *buffer, uint count_bytes SLS_DC) @@ -211,7 +222,7 @@ NULL, sapi_thttpd_send_headers, - sapi_thttpd_send_header, + NULL, sapi_thttpd_read_post, sapi_thttpd_read_cookies, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-CVS] cvs: php4 /sapi/thttpd thttpd.c
sas Mon Feb 19 02:28:08 2001 EDT Modified files: /php4/sapi/thttpd thttpd.c Log: Include sys/uio.h. Apparently, the header cleanup in glibc 2.2.2 caused that file to be included by accident. Index: php4/sapi/thttpd/thttpd.c diff -u php4/sapi/thttpd/thttpd.c:1.34 php4/sapi/thttpd/thttpd.c:1.35 --- php4/sapi/thttpd/thttpd.c:1.34 Sun Feb 18 11:03:36 2001 +++ php4/sapi/thttpd/thttpd.c Mon Feb 19 02:28:08 2001 @@ -24,6 +24,8 @@ #include "php_variables.h" #include "version.h" +#include sys/uio.h + typedef struct { httpd_conn *hc; int post_off; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-CVS] cvs: php4 /sapi/thttpd thttpd.c
sas Sun Feb 18 11:03:36 2001 EDT Modified files: /php4/sapi/thttpd thttpd.c Log: Save 50% of the syscalls when writing the HTTP header. Index: php4/sapi/thttpd/thttpd.c diff -u php4/sapi/thttpd/thttpd.c:1.33 php4/sapi/thttpd/thttpd.c:1.34 --- php4/sapi/thttpd/thttpd.c:1.33 Wed Jan 10 05:51:58 2001 +++ php4/sapi/thttpd/thttpd.c Sun Feb 18 11:03:36 2001 @@ -83,14 +83,20 @@ static void sapi_thttpd_send_header(sapi_header_struct *sapi_header, void *server_context) { + struct iovec vec[2]; + int n = 0; TLS_FETCH(); if (sapi_header) { - send(TG(hc)-conn_fd, sapi_header-header, sapi_header-header_len, 0); + vec[n].iov_base = sapi_header-header; + vec[n++].iov_len = sapi_header-header_len; TG(hc)-bytes += sapi_header-header_len; } - send(TG(hc)-conn_fd, "\r\n", sizeof("\r\n") - 1, 0); + vec[n].iov_base = "\r\n"; + vec[n++].iov_len = 2; TG(hc)-bytes += 2; + + writev(TG(hc)-conn_fd, vec, n); } static int sapi_thttpd_read_post(char *buffer, uint count_bytes SLS_DC) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]