This repository was archived by the owner on Mar 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmod_fastcgi_handler.c
More file actions
73 lines (58 loc) · 1.52 KB
/
mod_fastcgi_handler.c
File metadata and controls
73 lines (58 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <unistd.h>
#include "fcgi_request.h"
#include "fcgi_server.h"
static
int fastcgi_handler(request_rec *r)
{
if (strncmp(r->handler, "fcgi:", 5))
return DECLINED;
fcgi_request_t *fr = NULL;
int ret;
/* Step 1: create a new FastCGI request object */
if ((ret = fcgi_request_create(r, &fr)) != OK) {
return ret;
}
/* Step 2: connect to the FastCGI server */
if ((ret = fcgi_server_connect(fr)) != OK) {
return ret;
}
/* Step 3: process the request */
return fcgi_request_process(fr);
}
static
void *fastcgi_handler_create_dir_config(apr_pool_t *p, char *dir)
{
fastcgi_handler_cfg *cfg = apr_pcalloc(p, sizeof(fastcgi_handler_cfg));
cfg->idle_timeout = -1;
return cfg;
}
static
void *fastcgi_handler_merge_dir_config(apr_pool_t *p, void *parent, void *current)
{
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;
return cfg;
}
static
const command_rec fastcgi_handler_cmds[] =
{
{ NULL }
};
static
void fastcgi_handler_register_hooks(apr_pool_t * p)
{
ap_hook_handler(fastcgi_handler, NULL, NULL, APR_HOOK_MIDDLE);
}
module AP_MODULE_DECLARE_DATA fastcgi_handler_module =
{
STANDARD20_MODULE_STUFF,
fastcgi_handler_create_dir_config,
fastcgi_handler_merge_dir_config,
NULL,
NULL,
fastcgi_handler_cmds,
fastcgi_handler_register_hooks,
};