diff options
author | SVN Migration <svn@php.net> | 2001-09-20 15:50:12 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2001-09-20 15:50:12 +0000 |
commit | 6b900b344974360925bf80f70c48d04034e552b6 (patch) | |
tree | 7b922971c30eac156e465c88af7a52e8fc397c2e /sapi/thttpd | |
parent | d58240d0f57fcf9f6d66ad77a240479c38937d80 (diff) | |
download | php-git-6b900b344974360925bf80f70c48d04034e552b6.tar.gz |
This commit was manufactured by cvs2svn to create branch
'NAMESPACES_BRANCH'.
Diffstat (limited to 'sapi/thttpd')
-rw-r--r-- | sapi/thttpd/CREDITS | 2 | ||||
-rw-r--r-- | sapi/thttpd/Makefile.in | 5 | ||||
-rw-r--r-- | sapi/thttpd/README | 59 | ||||
-rw-r--r-- | sapi/thttpd/config.m4 | 24 | ||||
-rw-r--r-- | sapi/thttpd/php.sym | 3 | ||||
-rw-r--r-- | sapi/thttpd/php_thttpd.h | 35 | ||||
-rw-r--r-- | sapi/thttpd/stub.c | 0 | ||||
-rw-r--r-- | sapi/thttpd/thttpd.c | 566 | ||||
-rw-r--r-- | sapi/thttpd/thttpd_patch | 206 |
9 files changed, 0 insertions, 900 deletions
diff --git a/sapi/thttpd/CREDITS b/sapi/thttpd/CREDITS deleted file mode 100644 index 8f02f36f4f..0000000000 --- a/sapi/thttpd/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -thttpd -Sascha Schumann diff --git a/sapi/thttpd/Makefile.in b/sapi/thttpd/Makefile.in deleted file mode 100644 index a18d0f8d18..0000000000 --- a/sapi/thttpd/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = stub.c - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/thttpd/README b/sapi/thttpd/README deleted file mode 100644 index b46c4dea5c..0000000000 --- a/sapi/thttpd/README +++ /dev/null @@ -1,59 +0,0 @@ -README FOR THTTPD MODULE (by Sascha Schumann) -($Date$) - - This is a SAPI module for PHP 4.0 supporting thttpd, the tiny, - turbo, throttling HTTP server by Jef Poskanzer. - - The module contains a patch against version 2.19 of thttpd. The patch - adds hooks to thttpd to call PHP, if a filename matches *.php. This - patch will be applied when you install PHP. - - This is a functional and stable module (it runs a large application - like IMP 2.2.0 without any problems). Its original intention was to - demonstrate the ability of PHP to work in every web server environment. - - NOTE: All requests will be serialized. That means, one long running - script will block all other requests. Choose another web-server, - if you want to execute arbitrary scripts. - -REQUIRED DOWNLOADS - - 1. thttpd 2.xx - - Full Distribution: - http://www.acme.com/software/thttpd/ - - 2. PHP 4.0.x - - Download: - http://www.php.net/ - - Snapshots from CVS: - http://snaps.php.net/ - - -BUILD INSTRUCTIONS - - 1. Extract software packages - - $ gunzip -c thttpd-2.xx.tar.gz | tar xf - - $ gunzip -c php-*.tar.gz | tar xf - - - 2. Prepare PHP - - $ cd php-* - $ ./configure \ - --with-thttpd=../thttpd-2.xx \ - <further PHP options> - $ make install - $ cd .. - - You can see the list of valid PHP options by executing - - $ ./configure --help - - 3. Configure, compile, install thttpd - - Now follow the thttpd instructions. The Makefile template of - thttpd was changed to automatically use the components - required by PHP. diff --git a/sapi/thttpd/config.m4 b/sapi/thttpd/config.m4 deleted file mode 100644 index a96c5299fc..0000000000 --- a/sapi/thttpd/config.m4 +++ /dev/null @@ -1,24 +0,0 @@ -AC_ARG_WITH(thttpd, -[ --with-thttpd=SRCDIR Build PHP as thttpd module],[ - test -d $withval || AC_MSG_RESULT(thttpd directory does not exist ($withval)) - egrep thttpd.2.21b $withval/version.h >/dev/null || AC_MSG_RESULT([This version only supports thttpd-2.21b]) - PHP_EXPAND_PATH($withval, THTTPD) - PHP_TARGET_RDYNAMIC - INSTALL_IT="\ - echo 'PHP_LIBS = -L. -lphp4 \$(PHP_LIBS) \$(EXTRA_LIBS)' > $THTTPD/php_makefile; \ - echo 'PHP_LDFLAGS = \$(NATIVE_RPATHS) \$(PHP_LDFLAGS)' >> $THTTPD/php_makefile; \ - echo 'PHP_CFLAGS = \$(COMMON_FLAGS) \$(CFLAGS_CLEAN) \$(CPPFLAGS) \$(EXTRA_CFLAGS)' >> $THTTPD/php_makefile; \ - \$(LN_S) $abs_srcdir/sapi/thttpd/thttpd.c $THTTPD/php_thttpd.c; \ - \$(LN_S) $abs_srcdir/sapi/thttpd/php_thttpd.h $abs_builddir/$SAPI_STATIC $THTTPD/;\ - test -f $THTTPD/php_patched || \ - (cd $THTTPD && patch < $abs_srcdir/sapi/thttpd/thttpd_patch && touch php_patched)" - PHP_THTTPD="yes, using $THTTPD" - PHP_ADD_INCLUDE($THTTPD) - PHP_BUILD_STATIC - PHP_SAPI=thttpd -],[ - PHP_THTTPD=no -]) - -AC_MSG_CHECKING(for thttpd) -AC_MSG_RESULT($PHP_THTTPD) diff --git a/sapi/thttpd/php.sym b/sapi/thttpd/php.sym deleted file mode 100644 index 2214d3964d..0000000000 --- a/sapi/thttpd/php.sym +++ /dev/null @@ -1,3 +0,0 @@ -thttpd_php_request -thttpd_php_init -thttpd_php_shutdown diff --git a/sapi/thttpd/php_thttpd.h b/sapi/thttpd/php_thttpd.h deleted file mode 100644 index a5ebf13cb2..0000000000 --- a/sapi/thttpd/php_thttpd.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ -*/ - -#ifndef PHP_THTTPD_H -#define PHP_THTTPD_H - -#include <sys/types.h> -#include <sys/stat.h> -#include <libhttpd.h> - -void thttpd_php_shutdown(void); -void thttpd_php_init(void); -off_t thttpd_php_request(httpd_conn *hc); - -void thttpd_register_on_close(void (*)(int)); -void thttpd_closed_conn(int fd); -int thttpd_get_fd(void); -void thttpd_set_dont_close(void); - -#endif diff --git a/sapi/thttpd/stub.c b/sapi/thttpd/stub.c deleted file mode 100644 index e69de29bb2..0000000000 --- a/sapi/thttpd/stub.c +++ /dev/null diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c deleted file mode 100644 index ddb531a644..0000000000 --- a/sapi/thttpd/thttpd.c +++ /dev/null @@ -1,566 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ -*/ - - -#include "php.h" -#include "SAPI.h" -#include "php_main.h" -#include "php_thttpd.h" -#include "php_variables.h" -#include "version.h" - -#include "ext/standard/php_smart_str.h" - -#include <sys/uio.h> - -typedef struct { - httpd_conn *hc; - int post_off; - void (*on_close)(int); -} php_thttpd_globals; - - -#ifdef ZTS -static int thttpd_globals_id; -#define TG(v) TSRMG(thttpd_globals_id, php_thttpd_globals *, v) -#else -static php_thttpd_globals thttpd_globals; -#define TG(v) (thttpd_globals.v) -#endif - -static int sapi_thttpd_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - int n; - uint sent = 0; - - while (str_length > 0) { - n = send(TG(hc)->conn_fd, str, str_length, 0); - - if (n == -1 && errno == EPIPE) - php_handle_aborted_connection(); - if (n == -1 && errno == EAGAIN) - continue; - if (n <= 0) - return n; - - TG(hc)->bytes_sent += n; - str += n; - sent += n; - str_length -= n; - } - - return sent; -} - -#define COMBINE_HEADERS 30 - -static int sapi_thttpd_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - char buf[1024]; - struct iovec vec[COMBINE_HEADERS]; - int n = 0; - zend_llist_position pos; - sapi_header_struct *h; - size_t len; - - if (!SG(sapi_headers).http_status_line) { - 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; - } 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++; - -#define DEF_CONTENT_TYPE_LINE "Content-Type: text/html\r\n" - if (SG(sapi_headers).send_default_content_type) { - vec[n].iov_base = DEF_CONTENT_TYPE_LINE; - vec[n].iov_len = sizeof(DEF_CONTENT_TYPE_LINE) - 1; - n++; - } - - 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; - - if (n) { - 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 TSRMLS_DC) -{ - size_t read_bytes = 0, tmp; - int c; - - /* to understand this, read cgi_interpose_input() in libhttpd.c */ - c = TG(hc)->read_idx - TG(hc)->checked_idx; - if (c > 0) { - read_bytes = MIN(c, count_bytes); - memcpy(buffer, TG(hc)->read_buf + TG(hc)->checked_idx, read_bytes); - TG(hc)->checked_idx += read_bytes; - count_bytes -= read_bytes; - } - - count_bytes = MIN(count_bytes, - SG(request_info).content_length - SG(read_post_bytes) - TG(post_off)); - - while (read_bytes < count_bytes) { - tmp = recv(TG(hc)->conn_fd, buffer + read_bytes, - count_bytes - read_bytes, 0); - if (tmp <= 0) - break; - read_bytes += tmp; - } - - return read_bytes; -} - -static char *sapi_thttpd_read_cookies(TSRMLS_D) -{ - return TG(hc)->cookie; -} - -#define BUF_SIZE 512 -#define ADD_STRING(name) \ - php_register_variable(name, buf, track_vars_array TSRMLS_CC) - -static void sapi_thttpd_register_variables(zval *track_vars_array TSRMLS_DC) -{ - char buf[BUF_SIZE + 1]; - char *p; - - php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array TSRMLS_CC); - php_register_variable("SERVER_SOFTWARE", SERVER_SOFTWARE, track_vars_array TSRMLS_CC); - php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", track_vars_array TSRMLS_CC); - php_register_variable("REQUEST_METHOD", (char *) SG(request_info).request_method, track_vars_array TSRMLS_CC); - php_register_variable("REQUEST_URI", SG(request_info).request_uri, track_vars_array TSRMLS_CC); - php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated, track_vars_array TSRMLS_CC); - - p = inet_ntoa(TG(hc)->client_addr.sa_in.sin_addr); - /* string representation of IPs are never larger than 512 bytes */ - if (p) { - memcpy(buf, p, strlen(p) + 1); - ADD_STRING("REMOTE_ADDR"); - ADD_STRING("REMOTE_HOST"); - } - - snprintf(buf, BUF_SIZE, "%d", TG(hc)->hs->port); - ADD_STRING("SERVER_PORT"); - - snprintf(buf, BUF_SIZE, "/%s", TG(hc)->pathinfo); - ADD_STRING("PATH_INFO"); - - snprintf(buf, BUF_SIZE, "/%s", TG(hc)->origfilename); - ADD_STRING("SCRIPT_NAME"); - -#define CONDADD(name, field) \ - if (TG(hc)->field[0]) { \ - php_register_variable(#name, TG(hc)->field, track_vars_array TSRMLS_CC); \ - } - - CONDADD(HTTP_REFERER, referer); - CONDADD(HTTP_USER_AGENT, useragent); - CONDADD(HTTP_ACCEPT, accept); - CONDADD(HTTP_ACCEPT_ENCODING, accepte); - CONDADD(HTTP_COOKIE, cookie); - CONDADD(CONTENT_TYPE, contenttype); - CONDADD(REMOTE_USER, remoteuser); - CONDADD(SERVER_PROTOCOL, protocol); - - if (TG(hc)->contentlength != -1) { - sprintf(buf, "%ld", (long) TG(hc)->contentlength); - ADD_STRING("CONTENT_LENGTH"); - } - - if (TG(hc)->authorization[0]) - php_register_variable("AUTH_TYPE", "Basic", track_vars_array TSRMLS_CC); -} - -static sapi_module_struct thttpd_sapi_module = { - "thttpd", - "thttpd", - - php_module_startup, - php_module_shutdown_wrapper, - - NULL, /* activate */ - NULL, /* deactivate */ - - sapi_thttpd_ub_write, - NULL, - NULL, /* get uid */ - NULL, /* getenv */ - - php_error, - - NULL, - sapi_thttpd_send_headers, - NULL, - sapi_thttpd_read_post, - sapi_thttpd_read_cookies, - - sapi_thttpd_register_variables, - NULL, /* Log message */ - - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - -static void thttpd_module_main(TSRMLS_D) -{ - zend_file_handle file_handle; - - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = SG(request_info).path_translated; - file_handle.free_filename = 0; - file_handle.opened_path = NULL; - - if (php_request_startup(TSRMLS_C) == FAILURE) { - return; - } - - php_execute_script(&file_handle TSRMLS_CC); - php_request_shutdown(NULL); -} - -static void thttpd_request_ctor(TSRMLS_D) -{ - int offset; - smart_str s = {0}; - - SG(request_info).query_string = TG(hc)->query?strdup(TG(hc)->query):NULL; - - 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; - SG(request_info).content_length = TG(hc)->contentlength; - - php_handle_auth_data(TG(hc)->authorization TSRMLS_CC); - - TG(post_off) = TG(hc)->read_idx - TG(hc)->checked_idx; - - /* avoid feeding \r\n from POST data to SAPI */ - offset = TG(post_off) - SG(request_info).content_length; - - if (offset > 0) { - TG(post_off) -= offset; - TG(hc)->read_idx -= offset; - } -} - -static void thttpd_request_dtor(TSRMLS_D) -{ - if (SG(request_info).query_string) - free(SG(request_info).query_string); - free(SG(request_info).request_uri); - free(SG(request_info).path_translated); -} - -#ifdef ZTS - -#ifdef TSRM_ST -#define thread_create_simple_detached(n) st_thread_create(n, NULL, 0, 0) -#define thread_usleep(n) st_usleep(n) -#define thread_exit() st_thread_exit(NULL) -/* No preemption, simple operations are safe */ -#define thread_atomic_inc(n) (++n) -#define thread_atomic_dec(n) (--n) -#else -#error No thread primitives available -#endif - -/* We might want to replace this with a STAILQ */ -typedef struct qreq { - httpd_conn *hc; - struct qreq *next; -} qreq_t; - -static MUTEX_T qr_lock; -static qreq_t *queued_requests; -static qreq_t *last_qr; -static int nr_free_threads; -static int nr_threads; -static int max_threads = 50; - -#define HANDLE_STRINGS() { \ - HANDLE_STR(encodedurl); \ - HANDLE_STR(decodedurl); \ - HANDLE_STR(origfilename); \ - HANDLE_STR(expnfilename); \ - HANDLE_STR(pathinfo); \ - HANDLE_STR(query); \ - HANDLE_STR(referer); \ - HANDLE_STR(useragent); \ - HANDLE_STR(accept); \ - HANDLE_STR(accepte); \ - HANDLE_STR(acceptl); \ - HANDLE_STR(cookie); \ - HANDLE_STR(contenttype); \ - HANDLE_STR(authorization); \ - HANDLE_STR(remoteuser); \ - } - -static httpd_conn *duplicate_conn(httpd_conn *hc, httpd_conn *nhc) -{ - memcpy(nhc, hc, sizeof(*nhc)); - -#define HANDLE_STR(m) nhc->m = nhc->m ? strdup(nhc->m) : NULL - HANDLE_STRINGS(); -#undef HANDLE_STR - - return nhc; -} - -static void destroy_conn(httpd_conn *hc) -{ -#define HANDLE_STR(m) if (hc->m) free(hc->m) - HANDLE_STRINGS(); -#undef HANDLE_STR -} - -static httpd_conn *dequeue_request(void) -{ - httpd_conn *ret = NULL; - qreq_t *m; - - tsrm_mutex_lock(qr_lock); - if (queued_requests) { - m = queued_requests; - ret = m->hc; - if (!(queued_requests = m->next)) - last_qr = NULL; - free(m); - } - tsrm_mutex_unlock(qr_lock); - - return ret; -} - -static void *worker_thread(void *); - -static void queue_request(httpd_conn *hc) -{ - qreq_t *m; - httpd_conn *nhc; - - /* Mark as long-running request */ - hc->file_address = (char *) 1; - - /* - * We cannot synchronously revoke accesses to hc in the worker - * thread, so we need to pass a copy of hc to the worker thread. - */ - nhc = malloc(sizeof *nhc); - duplicate_conn(hc, nhc); - - /* Allocate request queue container */ - m = malloc(sizeof *m); - m->hc = nhc; - m->next = NULL; - - tsrm_mutex_lock(qr_lock); - /* Create new threads when reaching a certain threshhold */ - if (nr_threads < max_threads && nr_free_threads < 2) { - nr_threads++; /* protected by qr_lock */ - - thread_atomic_inc(nr_free_threads); - thread_create_simple_detached(worker_thread); - } - /* Insert container into request queue */ - if (queued_requests) - last_qr->next = m; - else - queued_requests = m; - last_qr = m; - tsrm_mutex_unlock(qr_lock); -} - -static off_t thttpd_real_php_request(httpd_conn *hc TSRMLS_DC); - -static void *worker_thread(void *dummy) -{ - int do_work = 50; - httpd_conn *hc; - - while (do_work) { - hc = dequeue_request(); - - if (!hc) { -/* do_work--; */ - thread_usleep(500000); - continue; - } -/* do_work = 50; */ - - thread_atomic_dec(nr_free_threads); - - thttpd_real_php_request(hc TSRMLS_CC); - shutdown(hc->conn_fd, 0); - destroy_conn(hc); - free(hc); - - thread_atomic_inc(nr_free_threads); - } - thread_atomic_dec(nr_free_threads); - thread_atomic_dec(nr_threads); - thread_exit(); -} - -static void remove_dead_conn(int fd) -{ - qreq_t *m, *prev = NULL; - - tsrm_mutex_lock(qr_lock); - m = queued_requests; - while (m) { - if (m->hc->conn_fd == fd) { - if (prev) - if (!(prev->next = m->next)) - last_qr = prev; - else - if (!(queued_requests = m->next)) - last_qr = NULL; - destroy_conn(m->hc); - free(m->hc); - free(m); - break; - } - prev = m; - m = m->next; - } - tsrm_mutex_unlock(qr_lock); -} - -#endif - -static off_t thttpd_real_php_request(httpd_conn *hc TSRMLS_DC) -{ - TG(hc) = hc; - hc->bytes_sent = 0; - - thttpd_request_ctor(TSRMLS_C); - - thttpd_module_main(TSRMLS_C); - - thttpd_request_dtor(TSRMLS_C); - - return 0; -} - -off_t thttpd_php_request(httpd_conn *hc) -{ -#ifdef ZTS - queue_request(hc); -#else - TSRMLS_FETCH(); - return thttpd_real_php_request(hc TSRMLS_CC); -#endif -} - -void thttpd_register_on_close(void (*arg)(int)) -{ - TSRMLS_FETCH(); - TG(on_close) = arg; -} - -void thttpd_closed_conn(int fd) -{ - TSRMLS_FETCH(); - if (TG(on_close)) TG(on_close)(fd); -} - -int thttpd_get_fd(void) -{ - TSRMLS_FETCH(); - return TG(hc)->conn_fd; -} - -void thttpd_set_dont_close(void) -{ - TSRMLS_FETCH(); - TG(hc)->file_address = (char *) 1; -} - - -void thttpd_php_init(void) -{ -#ifdef ZTS - tsrm_startup(1, 1, 0, NULL); - ts_allocate_id(&thttpd_globals_id, sizeof(php_thttpd_globals), NULL, NULL); - qr_lock = tsrm_mutex_alloc(); - thttpd_register_on_close(remove_dead_conn); -#endif - sapi_startup(&thttpd_sapi_module); - thttpd_sapi_module.startup(&thttpd_sapi_module); - { - TSRMLS_FETCH(); - - SG(server_context) = (void *) 1; - } -} - -void thttpd_php_shutdown(void) -{ - TSRMLS_FETCH(); - - if (SG(server_context) != NULL) { - thttpd_sapi_module.shutdown(&thttpd_sapi_module); - sapi_shutdown(); -#ifdef ZTS - tsrm_shutdown(); -#endif - } -} diff --git a/sapi/thttpd/thttpd_patch b/sapi/thttpd/thttpd_patch deleted file mode 100644 index 1a058c7aaa..0000000000 --- a/sapi/thttpd/thttpd_patch +++ /dev/null @@ -1,206 +0,0 @@ -diff -ur thttpd-2.21b-orig/Makefile.in thttpd-2.21b/Makefile.in ---- thttpd-2.21b-orig/Makefile.in Thu Mar 29 20:36:21 2001 -+++ thttpd-2.21b/Makefile.in Mon Aug 13 23:50:27 2001 -@@ -46,13 +46,15 @@ - - # You shouldn't need to edit anything below here. - -+include php_makefile -+ - CC = @CC@ - CCOPT = @V_CCOPT@ - DEFS = @DEFS@ - INCLS = -I. - CFLAGS = $(CCOPT) $(DEFS) $(INCLS) --LDFLAGS = @LDFLAGS@ --LIBS = @LIBS@ -+LDFLAGS = @LDFLAGS@ $(PHP_LDFLAGS) -+LIBS = @LIBS@ $(PHP_LIBS) - NETLIBS = @V_NETLIBS@ - INSTALL = @INSTALL@ - -@@ -62,7 +64,7 @@ - @rm -f $@ - $(CC) $(CFLAGS) -c $*.c - --SRC = thttpd.c libhttpd.c fdwatch.c mmc.c timers.c match.c tdate_parse.c syslog.c -+SRC = thttpd.c libhttpd.c fdwatch.c mmc.c timers.c match.c tdate_parse.c syslog.c php_thttpd.c - - OBJ = $(SRC:.c=.o) @LIBOBJS@ - -@@ -151,6 +153,9 @@ - - tags: - ctags -wtd *.c *.h -+ -+php_thttpd.o: php_thttpd.c -+ $(CC) $(PHP_CFLAGS) $(CFLAGS) -c php_thttpd.c - - tar: - @name=`sed -n -e '/SERVER_SOFTWARE/!d' -e 's,.*thttpd/,thttpd-,' -e 's, .*,,p' version.h` ; \ -diff -ur thttpd-2.21b-orig/config.h thttpd-2.21b/config.h ---- thttpd-2.21b-orig/config.h Mon Apr 9 23:57:36 2001 -+++ thttpd-2.21b/config.h Mon Aug 13 23:51:00 2001 -@@ -316,7 +316,7 @@ - /* CONFIGURE: A list of index filenames to check. The files are searched - ** for in this order. - */ --#define INDEX_NAMES "index.html", "index.htm", "Default.htm", "index.cgi" -+#define INDEX_NAMES "index.php", "index.html", "index.htm", "Default.htm", "index.cgi" - - /* CONFIGURE: If this is defined then thttpd will automatically generate - ** index pages for directories that don't have an explicit index file. -diff -ur thttpd-2.21b-orig/fdwatch.c thttpd-2.21b/fdwatch.c ---- thttpd-2.21b-orig/fdwatch.c Fri Apr 13 07:36:08 2001 -+++ thttpd-2.21b/fdwatch.c Tue Aug 14 00:00:10 2001 -@@ -460,7 +460,7 @@ - - ridx = 0; - for ( i = 0; i < npollfds; ++i ) -- if ( pollfds[i].revents & ( POLLIN | POLLOUT ) ) -+ if ( pollfds[i].revents & ( POLLIN | POLLOUT | POLLERR | POLLHUP | POLLNVAL ) ) - poll_rfdidx[ridx++] = pollfds[i].fd; - - return r; -@@ -472,8 +472,8 @@ - { - switch ( fd_rw[fd] ) - { -- case FDW_READ: return pollfds[poll_fdidx[fd]].revents & POLLIN; -- case FDW_WRITE: return pollfds[poll_fdidx[fd]].revents & POLLOUT; -+ case FDW_READ: return pollfds[poll_fdidx[fd]].revents & ( POLLIN | POLLERR | POLLHUP | POLLNVAL ); -+ case FDW_WRITE: return pollfds[poll_fdidx[fd]].revents & ( POLLOUT | POLLERR | POLLHUP | POLLNVAL ); - default: return 0; - } - } -diff -ur thttpd-2.21b-orig/libhttpd.c thttpd-2.21b/libhttpd.c ---- thttpd-2.21b-orig/libhttpd.c Tue Apr 24 00:42:40 2001 -+++ thttpd-2.21b/libhttpd.c Tue Aug 14 00:00:07 2001 -@@ -85,6 +85,8 @@ - #include "match.h" - #include "tdate_parse.h" - -+#include "php_thttpd.h" -+ - #ifndef STDIN_FILENO - #define STDIN_FILENO 0 - #endif -@@ -242,6 +244,8 @@ - free( (void*) hs->cwd ); - if ( hs->cgi_pattern != (char*) 0 ) - free( (void*) hs->cgi_pattern ); -+ if ( hs->php_pattern != (char*) 0 ) -+ free( (void*) hs->php_pattern ); - if ( hs->charset != (char*) 0 ) - free( (void*) hs->charset ); - if ( hs->url_pattern != (char*) 0 ) -@@ -249,6 +253,7 @@ - if ( hs->local_pattern != (char*) 0 ) - free( (void*) hs->local_pattern ); - free( (void*) hs ); -+ thttpd_php_shutdown(); - } - - -@@ -312,6 +317,7 @@ - } - - hs->port = port; -+ hs->php_pattern = strdup("**.php"); - if ( cgi_pattern == (char*) 0 ) - hs->cgi_pattern = (char*) 0; - else -@@ -385,6 +391,8 @@ - return (httpd_server*) 0; - } - -+ thttpd_php_init(); -+ - /* Done initializing. */ - if ( hs->binding_hostname == (char*) 0 ) - syslog( LOG_INFO, "%.80s starting on port %d", SERVER_SOFTWARE, hs->port ); -@@ -2353,7 +2361,10 @@ - { - make_log_entry( hc, nowP ); - -- if ( hc->file_address != (char*) 0 ) -+ if ( hc->file_address == (char*) 1 ) -+ { -+ thttpd_closed_conn(hc->conn_fd); -+ } else if ( hc->file_address != (char*) 0 ) - { - mmc_unmap( hc->file_address, &(hc->sb), nowP ); - hc->file_address = (char*) 0; -@@ -3026,11 +3037,9 @@ - post_post_garbage_hack( httpd_conn* hc ) - { - char buf[2]; -- int r; - -- r = recv( hc->conn_fd, buf, sizeof(buf), MSG_PEEK ); -- if ( r > 0 ) -- (void) read( hc->conn_fd, buf, r ); -+ fcntl(hc->conn_fd, F_SETFL, O_NONBLOCK); -+ (void) read( hc->conn_fd, buf, 2 ); - } - - -@@ -3560,6 +3569,11 @@ - ( hc->sb.st_mode & S_IXOTH ) && - match( hc->hs->cgi_pattern, hc->expnfilename ) ) - return cgi( hc ); -+ -+ if ( hc->hs->php_pattern != (char*) 0 && -+ match( hc->hs->php_pattern, hc->expnfilename)) { -+ return thttpd_php_request( hc ); -+ } - - /* It's not CGI. If it's executable or there's pathinfo, someone's - ** trying to either serve or run a non-CGI file as CGI. Either case -Only in thttpd-2.21b: libhttpd.c~ -diff -ur thttpd-2.21b-orig/libhttpd.h thttpd-2.21b/libhttpd.h ---- thttpd-2.21b-orig/libhttpd.h Tue Apr 24 00:36:50 2001 -+++ thttpd-2.21b/libhttpd.h Mon Aug 13 23:50:27 2001 -@@ -69,6 +69,7 @@ - char* server_hostname; - int port; - char* cgi_pattern; -+ char* php_pattern; - char* charset; - char* cwd; - int listen4_fd, listen6_fd; -diff -ur thttpd-2.21b-orig/thttpd.c thttpd-2.21b/thttpd.c ---- thttpd-2.21b-orig/thttpd.c Tue Apr 24 00:41:57 2001 -+++ thttpd-2.21b/thttpd.c Mon Aug 13 23:50:27 2001 -@@ -1333,7 +1333,7 @@ - clear_connection( c, tvP ); - return; - } -- hc->read_idx += sz; -+ if (sz > 0) hc->read_idx += sz; - - /* Do we have a complete request yet? */ - switch ( httpd_got_request( hc ) ) -@@ -1387,6 +1387,12 @@ - clear_connection( c, tvP ); - return; - } -+ if (hc->file_address == (char *) 1) { -+ tmr_cancel( c->idle_read_timer ); -+ c->idle_read_timer = (Timer*) 0; -+ c->wouldblock_delay = 0; -+ return; -+ } - if ( c->bytes_sent >= c->bytes_to_send ) - { - /* There's nothing to send. */ -@@ -1500,7 +1506,7 @@ - { - /* Yes; move the unwritten part to the front of the buffer. */ - int newlen = hc->responselen - sz; -- (void) memcpy( hc->response, &(hc->response[sz]), newlen ); -+ (void) memmove( hc->response, &(hc->response[sz]), newlen ); - hc->responselen = newlen; - sz = 0; - } -Only in thttpd-2.21b: thttpd.c~ |