Permalink
Browse files

add README and rename to mod_fastcgi_handler

  • Loading branch information...
hollow committed Jun 17, 2010
1 parent a8fb09c commit 457084ec5e979ca22bd8b32b9d3795b67ff7ba4d
Showing with 83 additions and 48 deletions.
  1. +25 −0 LICENSE
  2. +33 −0 README.rst
  3. +3 −3 fcgi_request.c
  4. +2 −25 fcgi_request.h
  5. +18 −18 mod_fastcgi_pass.c → mod_fastcgi_handler.c
  6. +2 −2 mod_fastcgi_pass.h → mod_fastcgi_handler.h
View
25 LICENSE
@@ -0,0 +1,25 @@
+Copyright (c) 2010 Benedikt Böhm <bb@xnull.de>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
@@ -0,0 +1,33 @@
+===================
+mod_fastcgi_handler
+===================
+
+:Author: `Benedikt Böhm <bb@xnull.de>`_
+:Version: 0.1
+:Web: http://bb.xnull.de/projects/mod_fastcgi_handler/
+:Source: http://git.xnull.de/cgit/mod_fastcgi_handler/ (also on `github <http://github.com/hollow/mod_fastcgi_handler>`_)
+:Download: http://bb.xnull.de/projects/mod_fastcgi_handler/dist/
+
+mod_fastcgi_handler is a very simple FastCGI implementation derived from
+mod_fastcgi and mod_proxy_fcgi. mod_fastcgi_handler does not implement a
+process manager, nor does it support Authenticator and Authorizer roles.
+mod_fastcgi_handler is a module for rapidly deploying FastCGI applications with
+Apache.
+
+Rationale
+=========
+
+mod_fastcgi and mod_fcgid both include a huge process manager code, which is
+not needed with a typical FastCGI application. Such applications, including
+Django and PHP-FPM, ship their own process manager and provide a socket to
+communication with the web server. Thus a simple mechanism for talking to this
+socket is required. While mod_fastcgi and mod_proxy_fcgi both provide such a
+feature, the former has a quite complex configuration syntax while the latter
+does not support unix domain sockets.
+
+The solution is to provide simple handler for external FastCGI applications.
+
+Installation
+============
+
+TBD
View
@@ -11,7 +11,7 @@
#include "fcgi_header.h"
#include "fcgi_request.h"
-#include "mod_fastcgi_pass.h"
+#include "mod_fastcgi_handler.h"
#ifndef SUN_LEN
#define SUN_LEN(sock) \
@@ -129,13 +129,13 @@ int fcgi_request_create(request_rec *r, fcgi_request_t **frP)
if (err) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
- "fastcgi_pass: invalid server address: '%s': %s",
+ "FastCGI: invalid server address: '%s': %s",
fr->server, err);
return HTTP_INTERNAL_SERVER_ERROR;
}
/* keep a pointer to cfg and r for convenience */
- fr->cfg = ap_get_module_config(r->per_dir_config, &fastcgi_pass_module);
+ fr->cfg = ap_get_module_config(r->per_dir_config, &fastcgi_handler_module);
fr->r = r;
*frP = fr;
View
@@ -5,39 +5,16 @@
#include <httpd.h>
-#include "mod_fastcgi_pass.h"
+#include "mod_fastcgi_handler.h"
typedef struct {
const char *server; /* server name as given in httpd.conf */
- fastcgi_pass_cfg *cfg; /* pointer to per-dir config for convenience */
+ fastcgi_handler_cfg *cfg; /* pointer to per-dir config for convenience */
request_rec *r;
struct sockaddr *socket_addr; /* socket address of the FastCGI application */
int socket_addr_len; /* length of socket struct */
int socket_fd; /* socket descriptor to FastCGI server */
-
- //int gotHeader; /* TRUE if reading content bytes */
- //unsigned char packetType; /* type of packet */
- //int dataLen; /* length of data bytes */
- //int paddingLen; /* record padding after content */
-
- //fcgi_buf_t *server_input_buffer; /* input buffer from FastCgi server */
- //fcgi_buf_t *server_output_buffer; /* output buffer to FastCgi server */
- //fcgi_buf_t *client_input_buffer; /* client input buffer */
- //fcgi_buf_t *client_output_buffer; /* client output buffer */
-
- //int should_client_block; /* >0 => more content, <=0 => no more */
- //apr_array_header_t *header;
- //char *stderr;
- //int stderr_len;
- //int parseHeader; /* TRUE iff parsing response headers */
- //int readingEndRequestBody;
- //FCGI_EndRequestBody endRequestBody;
- //fcgi_buf_t *erBufPtr;
- //int exitStatus;
- //int exitStatusSet;
- //unsigned int requestId;
- //int eofSent;
} fcgi_request_t;
int fcgi_request_create(request_rec *r, fcgi_request_t **frP);
@@ -4,7 +4,7 @@
#include "fcgi_server.h"
static
-int fastcgi_pass_handler(request_rec *r)
+int fastcgi_handler_handler(request_rec *r)
{
if (strncmp(r->handler, "fcgi:", 5))
return DECLINED;
@@ -27,9 +27,9 @@ int fastcgi_pass_handler(request_rec *r)
}
static
-void *fastcgi_pass_create_dir_config(apr_pool_t *p, char *dir)
+void *fastcgi_handler_create_dir_config(apr_pool_t *p, char *dir)
{
- fastcgi_pass_cfg *cfg = apr_pcalloc(p, sizeof(fastcgi_pass_cfg));
+ fastcgi_handler_cfg *cfg = apr_pcalloc(p, sizeof(fastcgi_handler_cfg));
cfg->idle_timeout = -1;
cfg->headers = apr_array_make(p, 1, sizeof(char *));
@@ -38,11 +38,11 @@ void *fastcgi_pass_create_dir_config(apr_pool_t *p, char *dir)
}
static
-void *fastcgi_pass_merge_dir_config(apr_pool_t *p, void *parent, void *current)
+void *fastcgi_handler_merge_dir_config(apr_pool_t *p, void *parent, void *current)
{
- fastcgi_pass_cfg *parent_cfg = (fastcgi_pass_cfg *) parent;
- fastcgi_pass_cfg *current_cfg = (fastcgi_pass_cfg *) current;
- fastcgi_pass_cfg *cfg = apr_pcalloc(p, sizeof(fastcgi_pass_cfg));
+ fastcgi_handler_cfg *parent_cfg = (fastcgi_handler_cfg *) parent;
+ fastcgi_handler_cfg *current_cfg = (fastcgi_handler_cfg *) current;
+ fastcgi_handler_cfg *cfg = apr_pcalloc(p, sizeof(fastcgi_handler_cfg));
cfg->idle_timeout = current_cfg->idle_timeout == -1 ?
parent_cfg->idle_timeout : current_cfg->idle_timeout;
@@ -53,36 +53,36 @@ void *fastcgi_pass_merge_dir_config(apr_pool_t *p, void *parent, void *current)
}
static
-const char *fastcgi_pass_cmd_pass_header(cmd_parms *cmd, void *mconf,
+const char *fastcgi_handler_cmd_pass_header(cmd_parms *cmd, void *mconf,
const char *arg)
{
- fastcgi_pass_cfg *cfg = (fastcgi_pass_cfg *) mconf;
+ fastcgi_handler_cfg *cfg = (fastcgi_handler_cfg *) mconf;
*(const char **)apr_array_push(cfg->headers) = arg;
return NULL;
}
static
-const command_rec fastcgi_pass_cmds[] =
+const command_rec fastcgi_handler_cmds[] =
{
- AP_INIT_ITERATE("FastCgiPassHeader", fastcgi_pass_cmd_pass_header, NULL,
+ AP_INIT_ITERATE("FastCgiPassHeader", fastcgi_handler_cmd_pass_header, NULL,
OR_FILEINFO, "a list of headers to pass to the FastCGI application."),
{ NULL }
};
static
-void fastcgi_pass_register_hooks(apr_pool_t * p)
+void fastcgi_handler_register_hooks(apr_pool_t * p)
{
- ap_hook_handler(fastcgi_pass_handler, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_handler(fastcgi_handler_handler, NULL, NULL, APR_HOOK_MIDDLE);
}
-module AP_MODULE_DECLARE_DATA fastcgi_pass_module =
+module AP_MODULE_DECLARE_DATA fastcgi_handler_module =
{
STANDARD20_MODULE_STUFF,
- fastcgi_pass_create_dir_config,
- fastcgi_pass_merge_dir_config,
+ fastcgi_handler_create_dir_config,
+ fastcgi_handler_merge_dir_config,
NULL,
NULL,
- fastcgi_pass_cmds,
- fastcgi_pass_register_hooks,
+ fastcgi_handler_cmds,
+ fastcgi_handler_register_hooks,
};
@@ -11,8 +11,8 @@
typedef struct {
int idle_timeout;
apr_array_header_t *headers;
-} fastcgi_pass_cfg;
+} fastcgi_handler_cfg;
-extern module MODULE_VAR_EXPORT fastcgi_pass_module;
+extern module MODULE_VAR_EXPORT fastcgi_handler_module;
#endif

0 comments on commit 457084e

Please sign in to comment.