version 1.1.1.1, 2013/10/14 10:32:47
|
version 1.1.1.2, 2014/06/15 20:20:06
|
Line 351 static handler_ctx * handler_ctx_init(void) {
|
Line 351 static handler_ctx * handler_ctx_init(void) {
|
handler_ctx * hctx; |
handler_ctx * hctx; |
|
|
hctx = calloc(1, sizeof(*hctx)); |
hctx = calloc(1, sizeof(*hctx)); |
assert(hctx); | force_assert(hctx); |
|
|
hctx->fde_ndx = -1; |
hctx->fde_ndx = -1; |
|
|
Line 495 static int scgi_extension_insert(scgi_exts *ext, buffe
|
Line 495 static int scgi_extension_insert(scgi_exts *ext, buffe
|
if (i == ext->used) { |
if (i == ext->used) { |
/* filextension is new */ |
/* filextension is new */ |
fe = calloc(1, sizeof(*fe)); |
fe = calloc(1, sizeof(*fe)); |
assert(fe); | force_assert(fe); |
fe->key = buffer_init(); |
fe->key = buffer_init(); |
buffer_copy_string_buffer(fe->key, key); |
buffer_copy_string_buffer(fe->key, key); |
|
|
Line 504 static int scgi_extension_insert(scgi_exts *ext, buffe
|
Line 504 static int scgi_extension_insert(scgi_exts *ext, buffe
|
if (ext->size == 0) { |
if (ext->size == 0) { |
ext->size = 8; |
ext->size = 8; |
ext->exts = malloc(ext->size * sizeof(*(ext->exts))); |
ext->exts = malloc(ext->size * sizeof(*(ext->exts))); |
assert(ext->exts); | force_assert(ext->exts); |
} else if (ext->used == ext->size) { |
} else if (ext->used == ext->size) { |
ext->size += 8; |
ext->size += 8; |
ext->exts = realloc(ext->exts, ext->size * sizeof(*(ext->exts))); |
ext->exts = realloc(ext->exts, ext->size * sizeof(*(ext->exts))); |
assert(ext->exts); | force_assert(ext->exts); |
} |
} |
ext->exts[ext->used++] = fe; |
ext->exts[ext->used++] = fe; |
} else { |
} else { |
Line 518 static int scgi_extension_insert(scgi_exts *ext, buffe
|
Line 518 static int scgi_extension_insert(scgi_exts *ext, buffe
|
if (fe->size == 0) { |
if (fe->size == 0) { |
fe->size = 4; |
fe->size = 4; |
fe->hosts = malloc(fe->size * sizeof(*(fe->hosts))); |
fe->hosts = malloc(fe->size * sizeof(*(fe->hosts))); |
assert(fe->hosts); | force_assert(fe->hosts); |
} else if (fe->size == fe->used) { |
} else if (fe->size == fe->used) { |
fe->size += 4; |
fe->size += 4; |
fe->hosts = realloc(fe->hosts, fe->size * sizeof(*(fe->hosts))); |
fe->hosts = realloc(fe->hosts, fe->size * sizeof(*(fe->hosts))); |
assert(fe->hosts); | force_assert(fe->hosts); |
} |
} |
|
|
fe->hosts[fe->used++] = fh; |
fe->hosts[fe->used++] = fh; |
Line 670 static int scgi_spawn_connection(server *srv,
|
Line 670 static int scgi_spawn_connection(server *srv,
|
|
|
#ifdef HAVE_SYS_UN_H |
#ifdef HAVE_SYS_UN_H |
scgi_addr_un.sun_family = AF_UNIX; |
scgi_addr_un.sun_family = AF_UNIX; |
strcpy(scgi_addr_un.sun_path, proc->socket->ptr); | if (proc->socket->used > sizeof(scgi_addr_un.sun_path)) { |
| log_error_write(srv, __FILE__, __LINE__, "sB", |
| "ERROR: Unix Domain socket filename too long:", |
| proc->socket); |
| return -1; |
| } |
| memcpy(scgi_addr_un.sun_path, proc->socket->ptr, proc->socket->used); |
|
|
#ifdef SUN_LEN |
#ifdef SUN_LEN |
servlen = SUN_LEN(&scgi_addr_un); |
servlen = SUN_LEN(&scgi_addr_un); |
Line 752 static int scgi_spawn_connection(server *srv,
|
Line 758 static int scgi_spawn_connection(server *srv,
|
if (setsockopt(scgi_fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) { |
if (setsockopt(scgi_fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) { |
log_error_write(srv, __FILE__, __LINE__, "ss", |
log_error_write(srv, __FILE__, __LINE__, "ss", |
"socketsockopt failed:", strerror(errno)); |
"socketsockopt failed:", strerror(errno)); |
|
close(scgi_fd); |
return -1; |
return -1; |
} |
} |
|
|
Line 762 static int scgi_spawn_connection(server *srv,
|
Line 769 static int scgi_spawn_connection(server *srv,
|
proc->socket, |
proc->socket, |
proc->port, |
proc->port, |
strerror(errno)); |
strerror(errno)); |
|
close(scgi_fd); |
return -1; |
return -1; |
} |
} |
|
|
if (-1 == listen(scgi_fd, 1024)) { |
if (-1 == listen(scgi_fd, 1024)) { |
log_error_write(srv, __FILE__, __LINE__, "ss", |
log_error_write(srv, __FILE__, __LINE__, "ss", |
"listen failed:", strerror(errno)); |
"listen failed:", strerror(errno)); |
|
close(scgi_fd); |
return -1; |
return -1; |
} |
} |
|
|
Line 918 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 927 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
plugin_data *p = p_d; |
plugin_data *p = p_d; |
data_unset *du; |
data_unset *du; |
size_t i = 0; |
size_t i = 0; |
|
scgi_extension_host *df = NULL; |
|
|
config_values_t cv[] = { |
config_values_t cv[] = { |
{ "scgi.server", NULL, T_CONFIG_LOCAL, T_CONFIG_SCOPE_CONNECTION }, /* 0 */ |
{ "scgi.server", NULL, T_CONFIG_LOCAL, T_CONFIG_SCOPE_CONNECTION }, /* 0 */ |
Line 925 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 935 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET } |
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET } |
}; |
}; |
|
|
p->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *)); | p->config_storage = calloc(1, srv->config_context->used * sizeof(plugin_config *)); |
|
|
for (i = 0; i < srv->config_context->used; i++) { |
for (i = 0; i < srv->config_context->used; i++) { |
plugin_config *s; |
plugin_config *s; |
Line 942 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 952 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
ca = ((data_config *)srv->config_context->data[i])->value; |
ca = ((data_config *)srv->config_context->data[i])->value; |
|
|
if (0 != config_insert_values_global(srv, ca, cv)) { |
if (0 != config_insert_values_global(srv, ca, cv)) { |
return HANDLER_ERROR; | goto error; |
} |
} |
|
|
/* |
/* |
Line 957 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 967 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
log_error_write(srv, __FILE__, __LINE__, "sss", |
log_error_write(srv, __FILE__, __LINE__, "sss", |
"unexpected type for key: ", "scgi.server", "array of strings"); |
"unexpected type for key: ", "scgi.server", "array of strings"); |
|
|
return HANDLER_ERROR; | goto error; |
} |
} |
|
|
|
|
Line 975 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 985 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
"unexpected type for key: ", "scgi.server", |
"unexpected type for key: ", "scgi.server", |
"[", da->value->data[j]->key, "](string)"); |
"[", da->value->data[j]->key, "](string)"); |
|
|
return HANDLER_ERROR; | goto error; |
} |
} |
|
|
/* |
/* |
Line 993 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 1003 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
for (n = 0; n < da_ext->value->used; n++) { |
for (n = 0; n < da_ext->value->used; n++) { |
data_array *da_host = (data_array *)da_ext->value->data[n]; |
data_array *da_host = (data_array *)da_ext->value->data[n]; |
|
|
scgi_extension_host *df; |
|
|
|
config_values_t fcv[] = { |
config_values_t fcv[] = { |
{ "host", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 0 */ |
{ "host", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 0 */ |
{ "docroot", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 1 */ |
{ "docroot", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 1 */ |
Line 1023 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 1031 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
"scgi.server", |
"scgi.server", |
"[", da_host->key, "](string)"); |
"[", da_host->key, "](string)"); |
|
|
return HANDLER_ERROR; | goto error; |
} |
} |
|
|
df = scgi_host_init(); |
df = scgi_host_init(); |
Line 1055 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 1063 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
|
|
|
|
if (0 != config_insert_values_internal(srv, da_host->value, fcv)) { |
if (0 != config_insert_values_internal(srv, da_host->value, fcv)) { |
return HANDLER_ERROR; | goto error; |
} |
} |
|
|
if ((!buffer_is_empty(df->host) || df->port) && |
if ((!buffer_is_empty(df->host) || df->port) && |
Line 1063 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 1071 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
log_error_write(srv, __FILE__, __LINE__, "s", |
log_error_write(srv, __FILE__, __LINE__, "s", |
"either host+port or socket"); |
"either host+port or socket"); |
|
|
return HANDLER_ERROR; | goto error; |
} |
} |
|
|
if (!buffer_is_empty(df->unixsocket)) { |
if (!buffer_is_empty(df->unixsocket)) { |
Line 1073 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 1081 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
if (df->unixsocket->used > sizeof(un.sun_path) - 2) { |
if (df->unixsocket->used > sizeof(un.sun_path) - 2) { |
log_error_write(srv, __FILE__, __LINE__, "s", |
log_error_write(srv, __FILE__, __LINE__, "s", |
"path of the unixdomain socket is too large"); |
"path of the unixdomain socket is too large"); |
return HANDLER_ERROR; | goto error; |
} |
} |
} else { |
} else { |
/* tcp/ip */ |
/* tcp/ip */ |
Line 1087 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 1095 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
da_host->key, |
da_host->key, |
"host"); |
"host"); |
|
|
return HANDLER_ERROR; | goto error; |
} else if (df->port == 0) { |
} else if (df->port == 0) { |
log_error_write(srv, __FILE__, __LINE__, "sbbbs", |
log_error_write(srv, __FILE__, __LINE__, "sbbbs", |
"missing key (short):", |
"missing key (short):", |
Line 1095 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 1103 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
da_ext->key, |
da_ext->key, |
da_host->key, |
da_host->key, |
"port"); |
"port"); |
return HANDLER_ERROR; | goto error; |
} |
} |
} |
} |
|
|
Line 1145 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 1153 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
if (scgi_spawn_connection(srv, p, df, proc)) { |
if (scgi_spawn_connection(srv, p, df, proc)) { |
log_error_write(srv, __FILE__, __LINE__, "s", |
log_error_write(srv, __FILE__, __LINE__, "s", |
"[ERROR]: spawning fcgi failed."); |
"[ERROR]: spawning fcgi failed."); |
return HANDLER_ERROR; | scgi_process_free(proc); |
| goto error; |
} |
} |
|
|
proc->next = df->first; |
proc->next = df->first; |
Line 1176 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
Line 1185 SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
|
|
|
/* if extension already exists, take it */ |
/* if extension already exists, take it */ |
scgi_extension_insert(s->exts, da_ext->key, df); |
scgi_extension_insert(s->exts, da_ext->key, df); |
|
df = NULL; |
} |
} |
} |
} |
} |
} |
} |
} |
|
|
return HANDLER_GO_ON; |
return HANDLER_GO_ON; |
|
|
|
error: |
|
if (NULL != df) scgi_host_free(df); |
|
return HANDLER_ERROR; |
} |
} |
|
|
static int scgi_set_state(server *srv, handler_ctx *hctx, scgi_connection_state_t state) { |
static int scgi_set_state(server *srv, handler_ctx *hctx, scgi_connection_state_t state) { |
Line 1332 static int scgi_establish_connection(server *srv, hand
|
Line 1346 static int scgi_establish_connection(server *srv, hand
|
#ifdef HAVE_SYS_UN_H |
#ifdef HAVE_SYS_UN_H |
/* use the unix domain socket */ |
/* use the unix domain socket */ |
scgi_addr_un.sun_family = AF_UNIX; |
scgi_addr_un.sun_family = AF_UNIX; |
strcpy(scgi_addr_un.sun_path, proc->socket->ptr); | if (proc->socket->used > sizeof(scgi_addr_un.sun_path)) { |
| log_error_write(srv, __FILE__, __LINE__, "sB", |
| "ERROR: Unix Domain socket filename too long:", |
| proc->socket); |
| return -1; |
| } |
| memcpy(scgi_addr_un.sun_path, proc->socket->ptr, proc->socket->used); |
| |
#ifdef SUN_LEN |
#ifdef SUN_LEN |
servlen = SUN_LEN(&scgi_addr_un); |
servlen = SUN_LEN(&scgi_addr_un); |
#else |
#else |
Line 2997 TRIGGER_FUNC(mod_scgi_handle_trigger) {
|
Line 3018 TRIGGER_FUNC(mod_scgi_handle_trigger) {
|
if (scgi_spawn_connection(srv, p, host, fp)) { |
if (scgi_spawn_connection(srv, p, host, fp)) { |
log_error_write(srv, __FILE__, __LINE__, "s", |
log_error_write(srv, __FILE__, __LINE__, "s", |
"ERROR: spawning fcgi failed."); |
"ERROR: spawning fcgi failed."); |
|
scgi_process_free(fp); |
return HANDLER_ERROR; |
return HANDLER_ERROR; |
} |
} |
|
|