SOURCES: lighttpd-mod_deflate.patch (NEW) - from http://trac.light...
paszczus
paszczus at pld-linux.org
Sun Feb 19 10:51:24 CET 2006
Author: paszczus Date: Sun Feb 19 09:51:24 2006 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- from http://trac.lighttpd.net/trac/wiki/Release-1.4.10-patches
---- Files affected:
SOURCES:
lighttpd-mod_deflate.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/lighttpd-mod_deflate.patch
diff -u /dev/null SOURCES/lighttpd-mod_deflate.patch:1.1
--- /dev/null Sun Feb 19 10:51:24 2006
+++ SOURCES/lighttpd-mod_deflate.patch Sun Feb 19 10:51:19 2006
@@ -0,0 +1,1945 @@
+diff -Naur lighttpd-1.4.10.orig/src/Makefile.am lighttpd-1.4.10/src/Makefile.am
+--- lighttpd-1.4.10.orig/src/Makefile.am 2006-01-04 06:08:03.000000000 -0800
++++ lighttpd-1.4.10/src/Makefile.am 2006-02-16 22:25:16.504347041 -0800
+@@ -28,7 +28,7 @@
+ mod_ssi_expr.c: mod_ssi_exprparser.h
+
+ common_src=buffer.c log.c \
+- keyvalue.c chunk.c \
++ keyvalue.c chunk.c chunk_encode.c \
+ http_chunk.c stream.c fdevent.c \
+ stat_cache.c plugin.c joblist.c etag.c array.c \
+ data_string.c data_count.c data_array.c \
+@@ -222,9 +222,14 @@
+ mod_accesslog_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
+ mod_accesslog_la_LIBADD = $(common_libadd)
+
++lib_LTLIBRARIES += mod_deflate.la
++mod_deflate_la_SOURCES = mod_deflate.c
++mod_deflate_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
++mod_deflate_la_LIBADD = $(Z_LIB) $(BZ_LIB) $(common_libadd)
++
+
+ hdr = server.h buffer.h network.h log.h keyvalue.h \
+- response.h request.h fastcgi.h chunk.h \
++ response.h request.h fastcgi.h chunk.h chunk_encode.h \
+ settings.h http_chunk.h http_auth_digest.h \
+ md5.h http_auth.h stream.h \
+ fdevent.h connections.h base.h stat_cache.h \
+diff -Naur lighttpd-1.4.10.orig/src/base.h lighttpd-1.4.10/src/base.h
+--- lighttpd-1.4.10.orig/src/base.h 2006-01-11 06:51:04.000000000 -0800
++++ lighttpd-1.4.10/src/base.h 2006-02-16 22:25:16.504347041 -0800
+@@ -345,8 +345,10 @@
+
+ int file_started;
+ int file_finished;
++ int end_chunk; /* used for chunked transfer encoding. */
+
+- chunkqueue *write_queue; /* a large queue for low-level write ( HTTP response ) [ file, mem ] */
++ chunkqueue *write_queue; /* a large queue for HTTP response content [ file, mem ] */
++ chunkqueue *output_queue; /* a large queue for low-level write ( HTTP response ) [ file, mem ] */
+ chunkqueue *read_queue; /* a small queue for low-level read ( HTTP request ) [ mem ] */
+ chunkqueue *request_content_queue; /* takes request-content into tempfile if necessary [ tempfile, mem ]*/
+
+@@ -570,6 +572,7 @@
+
+ connections *conns;
+ connections *joblist;
++ connections *joblist_prev;
+ connections *fdwaitqueue;
+
+ stat_cache *stat_cache;
+diff -Naur lighttpd-1.4.10.orig/src/chunk.c lighttpd-1.4.10/src/chunk.c
+--- lighttpd-1.4.10.orig/src/chunk.c 2005-11-18 05:18:19.000000000 -0800
++++ lighttpd-1.4.10/src/chunk.c 2006-02-16 22:25:16.505346873 -0800
+@@ -224,6 +224,16 @@
+ return 0;
+ }
+
++int chunkqueue_append_chunkqueue(chunkqueue *cq, chunkqueue *src) {
++ if(src == NULL) return 0;
++ chunkqueue_append_chunk(cq, src->first);
++ cq->last = src->last;
++ src->first = NULL;
++ src->last = NULL;
++
++ return 0;
++}
++
+ buffer * chunkqueue_get_prepend_buffer(chunkqueue *cq) {
+ chunk *c;
+
+diff -Naur lighttpd-1.4.10.orig/src/chunk.h lighttpd-1.4.10/src/chunk.h
+--- lighttpd-1.4.10.orig/src/chunk.h 2005-10-31 23:32:21.000000000 -0800
++++ lighttpd-1.4.10/src/chunk.h 2006-02-16 22:25:16.505346873 -0800
+@@ -51,6 +51,7 @@
+ int chunkqueue_append_file(chunkqueue *c, buffer *fn, off_t offset, off_t len);
+ int chunkqueue_append_mem(chunkqueue *c, const char *mem, size_t len);
+ int chunkqueue_append_buffer(chunkqueue *c, buffer *mem);
++int chunkqueue_append_chunkqueue(chunkqueue *cq, chunkqueue *src);
+ int chunkqueue_prepend_buffer(chunkqueue *c, buffer *mem);
+
+ buffer * chunkqueue_get_append_buffer(chunkqueue *c);
+diff -Naur lighttpd-1.4.10.orig/src/chunk_encode.c lighttpd-1.4.10/src/chunk_encode.c
+--- lighttpd-1.4.10.orig/src/chunk_encode.c 1969-12-31 16:00:00.000000000 -0800
++++ lighttpd-1.4.10/src/chunk_encode.c 2006-02-16 22:25:16.505346873 -0800
+@@ -0,0 +1,117 @@
++/**
++ * the HTTP chunk-API
++ *
++ *
++ */
++
++#include <sys/types.h>
++#include <sys/stat.h>
++
++#include <stdlib.h>
++#include <fcntl.h>
++#include <unistd.h>
++
++#include <stdio.h>
++#include <errno.h>
++#include <string.h>
++
++#include "server.h"
++#include "chunk.h"
++#include "chunk_encode.h"
++#include "log.h"
++
++static int chunk_encode_append_len(chunkqueue *cq, size_t len) {
++ size_t i, olen = len, j;
++ buffer *b;
++
++ /*b = srv->tmp_chunk_len;*/
++ /*b = buffer_init();*/
++ b = chunkqueue_get_append_buffer(cq);
++
++ if (len == 0) {
++ buffer_copy_string(b, "0");
++ } else {
++ for (i = 0; i < 8 && len; i++) {
++ len >>= 4;
++ }
++
++ /* i is the number of hex digits we have */
++ buffer_prepare_copy(b, i + 1);
++
++ for (j = i-1, len = olen; j+1 > 0; j--) {
++ b->ptr[j] = (len & 0xf) + (((len & 0xf) <= 9) ? '0' : 'a' - 10);
++ len >>= 4;
++ }
++ b->used = i;
++ b->ptr[b->used++] = '\0';
++ }
++
++ buffer_append_string(b, "\r\n");
++ /*
++ chunkqueue_append_buffer(cq, b);
++ buffer_free(b);
++ */
++
++ return 0;
++}
++
++
++int chunk_encode_append_file(chunkqueue *cq, buffer *fn, off_t offset, off_t len) {
++ if (!cq) return -1;
++ if (len == 0) return 0;
++
++ chunk_encode_append_len(cq, len);
++
++ chunkqueue_append_file(cq, fn, offset, len);
++
++ chunkqueue_append_mem(cq, "\r\n", 2 + 1);
++
++ return 0;
++}
++
++int chunk_encode_append_buffer(chunkqueue *cq, buffer *mem) {
++ if (!cq) return -1;
++ if (mem->used <= 1) return 0;
++
++ chunk_encode_append_len(cq, mem->used - 1);
++
++ chunkqueue_append_buffer(cq, mem);
++
++ chunkqueue_append_mem(cq, "\r\n", 2 + 1);
++
++ return 0;
++}
++
++int chunk_encode_append_mem(chunkqueue *cq, const char * mem, size_t len) {
++ if (!cq) return -1;
++ if (len <= 1) return 0;
++
++ chunk_encode_append_len(cq, len - 1);
++
++ chunkqueue_append_mem(cq, mem, len);
++
++ chunkqueue_append_mem(cq, "\r\n", 2 + 1);
++
++ return 0;
++}
++
++int chunk_encode_append_queue(chunkqueue *cq, chunkqueue *src) {
++ int len = chunkqueue_length(src);
++ if (!cq) return -1;
++ if (len == 0) return 0;
++
++ chunk_encode_append_len(cq, len);
++
++ chunkqueue_append_chunkqueue(cq, src);
++
++ chunkqueue_append_mem(cq, "\r\n", 2 + 1);
++
++ return 0;
++}
++
++int chunk_encode_end(chunkqueue *cq) {
++ chunk_encode_append_len(cq, 0);
++ chunkqueue_append_mem(cq, "\r\n", 2 + 1);
++ return 0;
++}
++
+diff -Naur lighttpd-1.4.10.orig/src/chunk_encode.h lighttpd-1.4.10/src/chunk_encode.h
+--- lighttpd-1.4.10.orig/src/chunk_encode.h 1969-12-31 16:00:00.000000000 -0800
++++ lighttpd-1.4.10/src/chunk_encode.h 2006-02-16 22:25:16.506346704 -0800
+@@ -0,0 +1,13 @@
++#ifndef _CHUNK_ENCODE_H_
++#define _CHUNK_ENCODE_H_
++
++#include "server.h"
++#include <sys/types.h>
++
++int chunk_encode_append_mem(chunkqueue *cq, const char * mem, size_t len);
++int chunk_encode_append_buffer(chunkqueue *cq, buffer *mem);
++int chunk_encode_append_file(chunkqueue *cq, buffer *fn, off_t offset, off_t len);
++int chunk_encode_append_queue(chunkqueue *cq, chunkqueue *src);
++int chunk_encode_end(chunkqueue *cq);
++
++#endif
+diff -Naur lighttpd-1.4.10.orig/src/connections.c lighttpd-1.4.10/src/connections.c
+--- lighttpd-1.4.10.orig/src/connections.c 2006-02-08 04:27:20.000000000 -0800
++++ lighttpd-1.4.10/src/connections.c 2006-02-16 22:25:16.507346536 -0800
+@@ -18,6 +18,7 @@
+ #include "response.h"
+ #include "network.h"
+ #include "http_chunk.h"
++#include "chunk_encode.h"
+ #include "stat_cache.h"
+ #include "joblist.h"
+
+@@ -146,6 +147,12 @@
+ return 0;
+ }
+
++int connection_queue_is_empty(connection *con) {
++ if(!chunkqueue_is_empty(con->write_queue)) return 0;
++ if(!chunkqueue_is_empty(con->output_queue)) return 0;
++ return 1;
++}
++
+ #if 0
+ static void dump_packet(const unsigned char *data, size_t len) {
+ size_t i, j;
+@@ -365,6 +372,7 @@
+ con->file_finished = 1;
+
+ chunkqueue_reset(con->write_queue);
++ chunkqueue_reset(con->output_queue);
+ }
+ break;
+ default:
+@@ -472,12 +480,27 @@
+ /* disable chunked encoding again as we have no body */
+ con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED;
+ chunkqueue_reset(con->write_queue);
++ chunkqueue_reset(con->output_queue);
+
+ con->file_finished = 1;
+ break;
+ }
+
+
++ /* Allow filter plugins to change response headers before they are written. */
++ switch(plugins_call_handle_response_start(srv, con)) {
++ case HANDLER_GO_ON:
++ case HANDLER_FINISHED:
++ /* response start is finished */
++ break;
++ default:
++ /* something strange happend */
++ log_error_write(srv, __FILE__, __LINE__, "s", "Filter plugin failed.");
++ connection_set_state(srv, con, CON_STATE_ERROR);
++ joblist_append(srv, con);
++ break;
++ }
++
+ if (con->file_finished) {
+ /* we have all the content and chunked encoding is not used, set a content-length */
+
+@@ -517,6 +540,7 @@
+
+ if (con->request.http_method == HTTP_METHOD_HEAD) {
+ chunkqueue_reset(con->write_queue);
++ chunkqueue_reset(con->output_queue);
+ }
+
+ http_response_write_header(srv, con);
+@@ -525,11 +549,57 @@
+ }
+
+ static int connection_handle_write(server *srv, connection *con) {
+- switch(network_write_chunkqueue(srv, con, con->write_queue)) {
++ int finished = 0;
++ int len;
++
++ /* Allow filter plugins to modify response conent */
++ switch(plugins_call_handle_response_filter(srv, con)) {
++ case HANDLER_GO_ON:
++ finished = con->file_finished;
++ /* response content not changed */
++ break;
++ case HANDLER_COMEBACK:
++ /* response filter has more work */
++ finished = 0;
++ break;
++ case HANDLER_FINISHED:
++ /* response filter is finished */
++ finished = 1;
++ break;
++ default:
++ /* something strange happend */
++ log_error_write(srv, __FILE__, __LINE__, "s", "Filter plugin failed.");
++ connection_set_state(srv, con, CON_STATE_ERROR);
++ joblist_append(srv, con);
++ finished = 1;
++ break;
++ }
++
++ /* move chunks from write_queue to output_queue. */
++ if (con->request.http_method == HTTP_METHOD_HEAD) {
++ chunkqueue_reset(con->write_queue);
++ } else {
++ len = chunkqueue_length(con->write_queue);
++ if(con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) {
++ chunk_encode_append_queue(con->output_queue, con->write_queue);
++ if(finished && !con->end_chunk) {
++ con->end_chunk = 1;
++ chunk_encode_end(con->output_queue);
++ }
++ } else {
++ chunkqueue_append_chunkqueue(con->output_queue, con->write_queue);
++ }
++ con->write_queue->bytes_out += len;
++ }
++ /* write chunks from output_queue to network */
++ switch(network_write_chunkqueue(srv, con, con->output_queue)) {
+ case 0:
+- if (con->file_finished) {
++ if (finished) {
+ connection_set_state(srv, con, CON_STATE_RESPONSE_END);
+ joblist_append(srv, con);
++ } else {
++ /* not finished yet -> WRITE */
++ con->is_writable = 1;
+ }
+ break;
+ case -1: /* error on our side */
+@@ -599,6 +669,7 @@
+
+ #undef CLEAN
+ con->write_queue = chunkqueue_init();
++ con->output_queue = chunkqueue_init();
+ con->read_queue = chunkqueue_init();
+ con->request_content_queue = chunkqueue_init();
+ chunkqueue_set_tempdirs(con->request_content_queue, srv->srvconf.upload_tempdirs);
+@@ -627,6 +698,7 @@
+ connection_reset(srv, con);
+
+ chunkqueue_free(con->write_queue);
++ chunkqueue_free(con->output_queue);
+ chunkqueue_free(con->read_queue);
+ chunkqueue_free(con->request_content_queue);
+ array_free(con->request.headers);
+@@ -681,6 +753,7 @@
+ con->http_status = 0;
+ con->file_finished = 0;
+ con->file_started = 0;
++ con->end_chunk = 0;
+ con->got_response = 0;
+
+ con->parsed_response = 0;
+@@ -751,6 +824,7 @@
+ array_reset(con->environment);
+
+ chunkqueue_reset(con->write_queue);
++ chunkqueue_reset(con->output_queue);
+ chunkqueue_reset(con->request_content_queue);
+
+ /* the plugins should cleanup themself */
+@@ -1178,7 +1252,6 @@
+ }
+
+ if (con->state == CON_STATE_WRITE &&
+- !chunkqueue_is_empty(con->write_queue) &&
+ con->is_writable) {
+
+ if (-1 == connection_handle_write(srv, con)) {
+@@ -1573,15 +1646,15 @@
+ }
+
+ /* only try to write if we have something in the queue */
+- if (!chunkqueue_is_empty(con->write_queue)) {
+ #if 0
++ if (!connection_queue_is_empty(con)) {
+ log_error_write(srv, __FILE__, __LINE__, "dsd",
+ con->fd,
+ "packets to write:",
+- con->write_queue->used);
+-#endif
++ con->output_queue->used);
+ }
+- if (!chunkqueue_is_empty(con->write_queue) && con->is_writable) {
++#endif
++ if (con->is_writable) {
+ if (-1 == connection_handle_write(srv, con)) {
+ log_error_write(srv, __FILE__, __LINE__, "ds",
+ con->fd,
+@@ -1691,9 +1764,9 @@
+ * - if we have data to write
+ * - if the socket is not writable yet
+ */
+- if (!chunkqueue_is_empty(con->write_queue) &&
+- (con->is_writable == 0) &&
+- (con->traffic_limit_reached == 0)) {
++ if ((con->is_writable == 0) &&
++ (con->traffic_limit_reached == 0) &&
++ !connection_queue_is_empty(con)) {
+ fdevent_event_add(srv->ev, &(con->fde_ndx), con->fd, FDEVENT_OUT);
+ } else {
+ fdevent_event_del(srv->ev, &(con->fde_ndx), con->fd);
+diff -Naur lighttpd-1.4.10.orig/src/http_chunk.c lighttpd-1.4.10/src/http_chunk.c
+--- lighttpd-1.4.10.orig/src/http_chunk.c 2005-08-10 15:26:50.000000000 -0700
++++ lighttpd-1.4.10/src/http_chunk.c 2006-02-16 22:25:16.508346367 -0800
+@@ -58,16 +58,9 @@
+
+ cq = con->write_queue;
+
+- if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) {
+- http_chunk_append_len(srv, con, len);
+- }
+-
++
+ chunkqueue_append_file(cq, fn, offset, len);
+
+- if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED && len > 0) {
+- chunkqueue_append_mem(cq, "\r\n", 2 + 1);
+- }
+-
+ return 0;
+ }
+
+@@ -78,16 +71,9 @@
+
+ cq = con->write_queue;
+
+- if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) {
+- http_chunk_append_len(srv, con, mem->used - 1);
+- }
+-
++
+ chunkqueue_append_buffer(cq, mem);
+
+- if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED && mem->used > 0) {
+- chunkqueue_append_mem(cq, "\r\n", 2 + 1);
+- }
+-
+ return 0;
+ }
+
+@@ -99,25 +85,11 @@
+ cq = con->write_queue;
+
+ if (len == 0) {
+- if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) {
+- http_chunk_append_len(srv, con, 0);
+- chunkqueue_append_mem(cq, "\r\n", 2 + 1);
+- } else {
+- chunkqueue_append_mem(cq, "", 1);
+- }
+ return 0;
+ }
+
+- if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) {
+- http_chunk_append_len(srv, con, len - 1);
+- }
+-
+ chunkqueue_append_mem(cq, mem, len);
+
+- if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) {
+- chunkqueue_append_mem(cq, "\r\n", 2 + 1);
+- }
+-
+ return 0;
+ }
+
+diff -Naur lighttpd-1.4.10.orig/src/joblist.c lighttpd-1.4.10/src/joblist.c
+--- lighttpd-1.4.10.orig/src/joblist.c 2005-08-10 15:26:41.000000000 -0700
++++ lighttpd-1.4.10/src/joblist.c 2006-02-16 22:25:16.508346367 -0800
+@@ -7,6 +7,7 @@
+
+ int joblist_append(server *srv, connection *con) {
+ if (con->in_joblist) return 0;
++ con->in_joblist = 1;
+
+ if (srv->joblist->size == 0) {
+ srv->joblist->size = 16;
+diff -Naur lighttpd-1.4.10.orig/src/mod_deflate.c lighttpd-1.4.10/src/mod_deflate.c
+--- lighttpd-1.4.10.orig/src/mod_deflate.c 1969-12-31 16:00:00.000000000 -0800
++++ lighttpd-1.4.10/src/mod_deflate.c 2006-02-17 23:26:45.885437687 -0800
+@@ -0,0 +1,1291 @@
++#include <sys/types.h>
++#include <sys/stat.h>
++
++#include <fcntl.h>
++#include <unistd.h>
++#include <ctype.h>
++#include <stdlib.h>
++#include <string.h>
++#include <errno.h>
++#include <time.h>
++#include <assert.h>
++
++#include "base.h"
++#include "log.h"
++#include "buffer.h"
++#include "response.h"
++#include "joblist.h"
++#include "stat_cache.h"
++
++#include "plugin.h"
++
++#include "crc32.h"
++#include "etag.h"
++
++#if defined HAVE_ZLIB_H && defined HAVE_LIBZ
++# define USE_ZLIB
++# include <zlib.h>
++#else
++# define Z_DEFAULT_COMPRESSION 1
++#endif
++
++#if defined HAVE_BZLIB_H && defined HAVE_LIBBZ2
++# define USE_BZ2LIB
++/* we don't need stdio interface */
++# define BZ_NO_STDIO
++# include <bzlib.h>
++#endif
++
++#include "sys-mmap.h"
++
++/* request: accept-encoding */
++#define HTTP_ACCEPT_ENCODING_IDENTITY BV(0)
++#define HTTP_ACCEPT_ENCODING_GZIP BV(1)
++#define HTTP_ACCEPT_ENCODING_DEFLATE BV(2)
++#define HTTP_ACCEPT_ENCODING_COMPRESS BV(3)
++#define HTTP_ACCEPT_ENCODING_BZIP2 BV(4)
++
++#define KByte * 1024
++#define MByte * 1024 KByte
++#define GByte * 1024 MByte
++
++typedef struct {
++ unsigned short debug;
++ unsigned short enabled;
++ unsigned short bzip2;
++ unsigned short sync_flush;
++ unsigned short output_buffer_size;
++ unsigned short min_compress_size;
++ unsigned short work_block_size;
++ short mem_level;
++ short compression_level;
++ short window_size;
++ array *mimetypes;
++} plugin_config;
++
++typedef struct {
++ PLUGIN_DATA;
++ buffer *tmp_buf;
++
++ plugin_config **config_storage;
++ plugin_config conf;
++} plugin_data;
++
++typedef struct {
++ int bytes_in;
++ int bytes_out;
++ chunkqueue *in_queue;
++ buffer *output;
++ /* compression type & state */
++ int compression_type;
++ int stream_open;
++#ifdef USE_ZLIB
++ unsigned long crc;
++ z_stream z;
++ unsigned short gzip_header;
++#endif
++#ifdef USE_BZ2LIB
++ bz_stream bz;
++#endif
++ plugin_data *plugin_data;
<<Diff was trimmed, longer than 597 lines>>
More information about the pld-cvs-commit
mailing list