mirror of
https://github.com/lxsang/antd-cgi-plugin
synced 2024-12-26 18:08:21 +01:00
fix env vars missing
This commit is contained in:
parent
6ed698d1f8
commit
e37706d008
35
cgi.c
35
cgi.c
@ -106,6 +106,7 @@ static list_t get_env_vars(antd_request_t *rq)
|
|||||||
add_vars(&env_vars, "QUERY_STRING", "");
|
add_vars(&env_vars, "QUERY_STRING", "");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
add_vars(&env_vars, "REQUEST_URI", tmp);
|
||||||
sub = strchr(tmp, '?');
|
sub = strchr(tmp, '?');
|
||||||
if (sub)
|
if (sub)
|
||||||
{
|
{
|
||||||
@ -131,7 +132,18 @@ static list_t get_env_vars(antd_request_t *rq)
|
|||||||
add_vars(&env_vars, "DOCUMENT_ROOT", rq->client->port_config->htdocs);
|
add_vars(&env_vars, "DOCUMENT_ROOT", rq->client->port_config->htdocs);
|
||||||
tmp = (char *)dvalue(request, "REQUEST_PATH");
|
tmp = (char *)dvalue(request, "REQUEST_PATH");
|
||||||
if (tmp)
|
if (tmp)
|
||||||
add_vars(&env_vars, "PATH_INFO", tmp);
|
{
|
||||||
|
sub = tmp;
|
||||||
|
while(*sub == '/') sub++;
|
||||||
|
if(sub)
|
||||||
|
{
|
||||||
|
add_vars(&env_vars, "PATH_INFO", sub);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
add_vars(&env_vars, "PATH_INFO", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
add_vars(&env_vars, "PATH_INFO", "");
|
add_vars(&env_vars, "PATH_INFO", "");
|
||||||
tmp = (char *)dvalue(header, "REMOTE_ADDR");
|
tmp = (char *)dvalue(header, "REMOTE_ADDR");
|
||||||
@ -245,7 +257,7 @@ void *handle(void *data)
|
|||||||
//wpid = 0;
|
//wpid = 0;
|
||||||
//waitpid(pid, &status, 0); // wait for the child finish
|
//waitpid(pid, &status, 0); // wait for the child finish
|
||||||
// WNOHANG
|
// WNOHANG
|
||||||
while (1)
|
while ( waitpid(pid, &status, WNOHANG) == 0)
|
||||||
{
|
{
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
ssize_t count = read(inpipefd[0], buf, BUFFLEN);
|
ssize_t count = read(inpipefd[0], buf, BUFFLEN);
|
||||||
@ -257,30 +269,23 @@ void *handle(void *data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//perror("read");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (count == 0)
|
else if (count == 0)
|
||||||
{
|
{
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
antd_send(cl, buf, count);
|
antd_send(cl, buf, count);
|
||||||
|
//printf("sent: %d with count: %d\n", sent, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
//kill(pid, SIGKILL);
|
||||||
do {
|
//waitpid(pid, &status, 0);
|
||||||
memset(buf, 0, sizeof(buf));
|
//printf("End cgi\n");
|
||||||
int r = read(inpipefd[0], buf, BUFFLEN-1);
|
|
||||||
if(r > 0)
|
|
||||||
{
|
|
||||||
__t(cl, buf);
|
|
||||||
}
|
|
||||||
} while(wpid == 0);
|
|
||||||
*/
|
|
||||||
kill(pid, SIGKILL);
|
|
||||||
waitpid(pid, &status, 0);
|
|
||||||
free(envs);
|
free(envs);
|
||||||
list_free(&env_vars);
|
list_free(&env_vars);
|
||||||
task = antd_create_task(NULL, data, NULL,rq->client->last_io);
|
task = antd_create_task(NULL, data, NULL,rq->client->last_io);
|
||||||
|
BIN
dist/cgi-1.0.0b.tar.gz
vendored
BIN
dist/cgi-1.0.0b.tar.gz
vendored
Binary file not shown.
Loading…
Reference in New Issue
Block a user