mirror of
https://github.com/nginx/nginx.git
synced 2025-06-08 02:02:38 +08:00
nginx-0.0.1-2003-05-30-18:27:59 import
This commit is contained in:
parent
1393325df8
commit
aa3436c04c
@ -1,31 +1,17 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include <ngx_config.h>
|
||||||
|
#include <ngx_core.h>
|
||||||
|
|
||||||
|
#include <ngx_listen.h>
|
||||||
|
|
||||||
#include <nginx.h>
|
#include <nginx.h>
|
||||||
|
|
||||||
#include <ngx_config.h>
|
|
||||||
|
|
||||||
#include <ngx_core.h>
|
|
||||||
#include <ngx_connection.h>
|
|
||||||
#include <ngx_os_init.h>
|
|
||||||
#include <ngx_server.h>
|
|
||||||
#include <ngx_listen.h>
|
|
||||||
#include <ngx_conf_file.h>
|
|
||||||
|
|
||||||
/* STUB */
|
|
||||||
#include <ngx_http.h>
|
|
||||||
/* */
|
|
||||||
|
|
||||||
|
|
||||||
static void ngx_set_signals(ngx_log_t *log);
|
static int ngx_open_listening_sockets(ngx_log_t *log);
|
||||||
static void ngx_open_listening_sockets(ngx_log_t *log);
|
|
||||||
|
|
||||||
|
|
||||||
/* STUB */
|
|
||||||
int ngx_max_conn = 512;
|
|
||||||
u_int ngx_sendfile_flags;
|
|
||||||
|
|
||||||
ngx_server_t ngx_server;
|
|
||||||
/* */
|
|
||||||
|
|
||||||
ngx_log_t ngx_log;
|
ngx_log_t ngx_log;
|
||||||
ngx_pool_t *ngx_pool;
|
ngx_pool_t *ngx_pool;
|
||||||
void ****ngx_conf_ctx;
|
void ****ngx_conf_ctx;
|
||||||
@ -34,8 +20,8 @@ void ****ngx_conf_ctx;
|
|||||||
ngx_os_io_t ngx_io;
|
ngx_os_io_t ngx_io;
|
||||||
|
|
||||||
|
|
||||||
int ngx_max_module;
|
int ngx_max_module;
|
||||||
void *ctx_conf;
|
void *ctx_conf;
|
||||||
|
|
||||||
int ngx_connection_counter;
|
int ngx_connection_counter;
|
||||||
|
|
||||||
@ -109,7 +95,9 @@ int main(int argc, char *const *argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_open_listening_sockets(&ngx_log);
|
if (ngx_open_listening_sockets(&ngx_log) == NGX_ERROR) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: daemon, once only */
|
/* TODO: daemon, once only */
|
||||||
|
|
||||||
@ -127,7 +115,7 @@ int main(int argc, char *const *argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_open_listening_sockets(ngx_log_t *log)
|
static int ngx_open_listening_sockets(ngx_log_t *log)
|
||||||
{
|
{
|
||||||
int times, failed, reuseaddr, i;
|
int times, failed, reuseaddr, i;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
@ -161,7 +149,7 @@ static void ngx_open_listening_sockets(ngx_log_t *log)
|
|||||||
if (s == -1) {
|
if (s == -1) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
||||||
ngx_socket_n " %s falied", ls[i].addr_text.data);
|
ngx_socket_n " %s falied", ls[i].addr_text.data);
|
||||||
exit(1);
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
|
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
|
||||||
@ -169,7 +157,7 @@ static void ngx_open_listening_sockets(ngx_log_t *log)
|
|||||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
||||||
"setsockopt(SO_REUSEADDR) %s failed",
|
"setsockopt(SO_REUSEADDR) %s failed",
|
||||||
ls[i].addr_text.data);
|
ls[i].addr_text.data);
|
||||||
exit(1);
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: close on exit */
|
/* TODO: close on exit */
|
||||||
@ -179,7 +167,7 @@ static void ngx_open_listening_sockets(ngx_log_t *log)
|
|||||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
||||||
ngx_nonblocking_n " %s failed",
|
ngx_nonblocking_n " %s failed",
|
||||||
ls[i].addr_text.data);
|
ls[i].addr_text.data);
|
||||||
exit(1);
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +177,7 @@ static void ngx_open_listening_sockets(ngx_log_t *log)
|
|||||||
"bind() to %s failed", ls[i].addr_text.data);
|
"bind() to %s failed", ls[i].addr_text.data);
|
||||||
|
|
||||||
if (err != NGX_EADDRINUSE)
|
if (err != NGX_EADDRINUSE)
|
||||||
exit(1);
|
return NGX_ERROR;
|
||||||
|
|
||||||
if (ngx_close_socket(s) == -1)
|
if (ngx_close_socket(s) == -1)
|
||||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
||||||
@ -203,7 +191,7 @@ static void ngx_open_listening_sockets(ngx_log_t *log)
|
|||||||
if (listen(s, ls[i].backlog) == -1) {
|
if (listen(s, ls[i].backlog) == -1) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
||||||
"listen() to %s failed", ls[i].addr_text.data);
|
"listen() to %s failed", ls[i].addr_text.data);
|
||||||
exit(1);
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: deferred accept */
|
/* TODO: deferred accept */
|
||||||
@ -222,6 +210,8 @@ static void ngx_open_listening_sockets(ngx_log_t *log)
|
|||||||
|
|
||||||
if (failed) {
|
if (failed) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, log, 0, "can not bind(), exiting");
|
ngx_log_error(NGX_LOG_EMERG, log, 0, "can not bind(), exiting");
|
||||||
exit(1);
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ static int ngx_conf_read_token(ngx_conf_t *cf);
|
|||||||
|
|
||||||
char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
|
char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
|
||||||
{
|
{
|
||||||
int m, rc, found;
|
int m, rc, found, valid;
|
||||||
char *rv;
|
char *rv;
|
||||||
void *conf, **confp;
|
void *conf, **confp;
|
||||||
ngx_str_t *name;
|
ngx_str_t *name;
|
||||||
@ -139,15 +139,33 @@ ngx_log_debug(cf->log, "command '%s'" _ cmd->name.data);
|
|||||||
|
|
||||||
/* is the directive's argument count right ? */
|
/* is the directive's argument count right ? */
|
||||||
|
|
||||||
if (!(cmd->type & NGX_CONF_ANY)
|
if (cmd->type & argument_number[cf->args->nelts - 1]) {
|
||||||
&& ((cmd->type & NGX_CONF_FLAG && cf->args->nelts != 2)
|
valid = 1;
|
||||||
|| (!(cmd->type & NGX_CONF_FLAG)
|
|
||||||
&& !(cmd->type
|
} else if (cmd->type & NGX_CONF_ANY1) {
|
||||||
& argument_number[cf->args->nelts - 1])
|
|
||||||
)
|
if (cf->args->nelts != 1) {
|
||||||
)
|
valid = 1;
|
||||||
)
|
} else {
|
||||||
{
|
valid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (cmd->type & NGX_CONF_FLAG) {
|
||||||
|
|
||||||
|
if (cf->args->nelts == 2) {
|
||||||
|
valid = 1;
|
||||||
|
} else {
|
||||||
|
valid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (cmd->type & NGX_CONF_ANY) {
|
||||||
|
valid = 1;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
valid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!valid) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||||
"invalid number arguments in "
|
"invalid number arguments in "
|
||||||
"directive \"%s\" in %s:%d",
|
"directive \"%s\" in %s:%d",
|
||||||
@ -441,10 +459,12 @@ ngx_log_debug(cf->log, "FOUND %d:'%s'" _ word->len _ word->data);
|
|||||||
|
|
||||||
char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
|
char *p = conf;
|
||||||
|
|
||||||
int flag;
|
int flag;
|
||||||
ngx_str_t *value;
|
ngx_str_t *value;
|
||||||
|
|
||||||
if (*(int *) (conf + cmd->offset) != NGX_CONF_UNSET) {
|
if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) {
|
||||||
return "is duplicate";
|
return "is duplicate";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,10 +477,13 @@ char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
flag = 0;
|
flag = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return "must be \"on\" or \"off\"";
|
ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
|
||||||
|
"invalid value \"%s\", it must be \"on\" or \"off\"",
|
||||||
|
value[1].data);
|
||||||
|
return ngx_conf_errstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(int *) (conf + cmd->offset) = flag;
|
*(int *) (p + cmd->offset) = flag;
|
||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
@ -468,9 +491,11 @@ char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
|
char *p = conf;
|
||||||
|
|
||||||
ngx_str_t *field, *value;
|
ngx_str_t *field, *value;
|
||||||
|
|
||||||
field = (ngx_str_t *) (conf + cmd->offset);
|
field = (ngx_str_t *) (p + cmd->offset);
|
||||||
|
|
||||||
if (field->data) {
|
if (field->data) {
|
||||||
return "is duplicate";
|
return "is duplicate";
|
||||||
@ -487,10 +512,12 @@ char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
|
char *p = conf;
|
||||||
|
|
||||||
int num, len;
|
int num, len;
|
||||||
ngx_str_t *value;
|
ngx_str_t *value;
|
||||||
|
|
||||||
if (*(int *) (conf + cmd->offset) != NGX_CONF_UNSET) {
|
if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) {
|
||||||
return "is duplicate";
|
return "is duplicate";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,10 +527,10 @@ char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
num = ngx_atoi(value[1].data, len);
|
num = ngx_atoi(value[1].data, len);
|
||||||
if (num == NGX_ERROR) {
|
if (num == NGX_ERROR) {
|
||||||
return "invalid value";
|
return "invalid number";
|
||||||
}
|
}
|
||||||
|
|
||||||
*(int *) (conf + cmd->offset) = num;
|
*(int *) (p + cmd->offset) = num;
|
||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
@ -511,11 +538,13 @@ char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
|
char *p = conf;
|
||||||
|
|
||||||
int size, len, scale;
|
int size, len, scale;
|
||||||
char last;
|
char last;
|
||||||
ngx_str_t *value;
|
ngx_str_t *value;
|
||||||
|
|
||||||
if (*(int *) (conf + cmd->offset) != NGX_CONF_UNSET) {
|
if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) {
|
||||||
return "is duplicate";
|
return "is duplicate";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,7 +577,7 @@ char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
size *= scale;
|
size *= scale;
|
||||||
|
|
||||||
*(int *) (conf + cmd->offset) = size;
|
*(int *) (p + cmd->offset) = size;
|
||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
@ -556,12 +585,14 @@ char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
|
char *p = conf;
|
||||||
|
|
||||||
int size, total, len, scale;
|
int size, total, len, scale;
|
||||||
u_int max, i;
|
u_int max, i;
|
||||||
char last, *start;
|
char last, *start;
|
||||||
ngx_str_t *value;
|
ngx_str_t *value;
|
||||||
|
|
||||||
if (*(int *) (conf + cmd->offset) != NGX_CONF_UNSET) {
|
if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) {
|
||||||
return "is duplicate";
|
return "is duplicate";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,7 +674,7 @@ char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
start = &value[1].data[i + 1];
|
start = &value[1].data[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
*(int *) (conf + cmd->offset) = total;
|
*(int *) (p + cmd->offset) = total;
|
||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
@ -651,12 +682,14 @@ char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
|
char *p = conf;
|
||||||
|
|
||||||
int size, total, len, scale;
|
int size, total, len, scale;
|
||||||
u_int max, i;
|
u_int max, i;
|
||||||
char last, *start;
|
char last, *start;
|
||||||
ngx_str_t *value;
|
ngx_str_t *value;
|
||||||
|
|
||||||
if (*(int *) (conf + cmd->offset) != NGX_CONF_UNSET) {
|
if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) {
|
||||||
return "is duplicate";
|
return "is duplicate";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,7 +783,7 @@ char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
start = &value[1].data[i + 1];
|
start = &value[1].data[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
*(int *) (conf + cmd->offset) = total;
|
*(int *) (p + cmd->offset) = total;
|
||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,9 @@
|
|||||||
#define NGX_CONF_TAKE2 0x00000004
|
#define NGX_CONF_TAKE2 0x00000004
|
||||||
#define NGX_CONF_ARGS_NUMBER 0x0000ffff
|
#define NGX_CONF_ARGS_NUMBER 0x0000ffff
|
||||||
#define NGX_CONF_ANY 0x00010000
|
#define NGX_CONF_ANY 0x00010000
|
||||||
#define NGX_CONF_BLOCK 0x00020000
|
#define NGX_CONF_ANY1 0x00020000
|
||||||
#define NGX_CONF_FLAG 0x00040000
|
#define NGX_CONF_BLOCK 0x00040000
|
||||||
|
#define NGX_CONF_FLAG 0x00080000
|
||||||
|
|
||||||
#define NGX_MAIN_CONF 0x01000000
|
#define NGX_MAIN_CONF 0x01000000
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
typedef char *(*ngx_conf_handler_pt)(ngx_conf_t *cf,
|
typedef char *(*ngx_conf_handler_pt)(ngx_conf_t *cf,
|
||||||
ngx_command_t *dummy, char *conf);
|
ngx_command_t *dummy, void *conf);
|
||||||
|
|
||||||
|
|
||||||
struct ngx_conf_s {
|
struct ngx_conf_s {
|
||||||
|
@ -43,7 +43,7 @@ typedef struct ngx_event_s ngx_event_t;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define NGX_MAXHOSTNAMELEN 32
|
#define NGX_MAXHOSTNAMELEN 64
|
||||||
/*
|
/*
|
||||||
#define NGX_MAXHOSTNAMELEN MAXHOSTNAMELEN
|
#define NGX_MAXHOSTNAMELEN MAXHOSTNAMELEN
|
||||||
*/
|
*/
|
||||||
|
@ -46,7 +46,7 @@ typedef struct {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ngx_memcpy(dst, src, n) memcpy(dst, src, n)
|
#define ngx_memcpy(dst, src, n) memcpy(dst, src, n)
|
||||||
#define ngx_cpymem(dst, src, n) memcpy(dst, src, n) + n
|
#define ngx_cpymem(dst, src, n) ((char *) memcpy(dst, src, n)) + n
|
||||||
|
|
||||||
char *ngx_cpystrn(char *dst, char *src, size_t n);
|
char *ngx_cpystrn(char *dst, char *src, size_t n);
|
||||||
int ngx_rstrncmp(char *s1, char *s2, size_t n);
|
int ngx_rstrncmp(char *s1, char *s2, size_t n);
|
||||||
|
@ -63,7 +63,8 @@ void ngx_event_accept(ngx_event_t *ev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s >= ecf->connections) {
|
/* disable warnings: Win32 SOCKET is u_int while UNIX socket is int */
|
||||||
|
if ((unsigned) s >= (unsigned) ecf->connections) {
|
||||||
|
|
||||||
ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
|
ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
|
||||||
"accept() %s returned socket #%d while "
|
"accept() %s returned socket #%d while "
|
||||||
|
@ -14,7 +14,7 @@ static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
static ngx_command_t ngx_http_index_commands[] = {
|
static ngx_command_t ngx_http_index_commands[] = {
|
||||||
|
|
||||||
{ngx_string("index"),
|
{ngx_string("index"),
|
||||||
NGX_HTTP_LOC_CONF|NGX_CONF_ANY,
|
NGX_HTTP_LOC_CONF|NGX_CONF_ANY1,
|
||||||
ngx_http_index_set_index,
|
ngx_http_index_set_index,
|
||||||
NGX_HTTP_LOC_CONF_OFFSET,
|
NGX_HTTP_LOC_CONF_OFFSET,
|
||||||
0,
|
0,
|
||||||
@ -280,7 +280,7 @@ static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
for (i = 1; i < cf->args->nelts; i++) {
|
for (i = 1; i < cf->args->nelts; i++) {
|
||||||
if (value[i].len == 0) {
|
if (value[i].len == 0) {
|
||||||
ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
|
ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
|
||||||
"index \"%s\" is invalid", value[1].data);
|
"index \"%s\" is invalid", value[i].data);
|
||||||
return ngx_conf_errstr;
|
return ngx_conf_errstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,14 +151,14 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
and its location{}s' loc_conf's */
|
and its location{}s' loc_conf's */
|
||||||
|
|
||||||
cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
|
cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
|
||||||
cscfp = (ngx_http_core_srv_conf_t **)cmcf->servers.elts;
|
cscfp = cmcf->servers.elts;
|
||||||
|
|
||||||
for (m = 0; ngx_modules[m]; m++) {
|
for (m = 0; ngx_modules[m]; m++) {
|
||||||
if (ngx_modules[m]->type != NGX_HTTP_MODULE) {
|
if (ngx_modules[m]->type != NGX_HTTP_MODULE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
module = (ngx_http_module_t *) ngx_modules[m]->ctx;
|
module = ngx_modules[m]->ctx;
|
||||||
mi = ngx_modules[m]->ctx_index;
|
mi = ngx_modules[m]->ctx_index;
|
||||||
|
|
||||||
/* init http{} main_conf's */
|
/* init http{} main_conf's */
|
||||||
@ -227,18 +227,18 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
NGX_CONF_ERROR);
|
NGX_CONF_ERROR);
|
||||||
|
|
||||||
/* "server" directives */
|
/* "server" directives */
|
||||||
cscfp = (ngx_http_core_srv_conf_t **) cmcf->servers.elts;
|
cscfp = cmcf->servers.elts;
|
||||||
for (s = 0; s < cmcf->servers.nelts; s++) {
|
for (s = 0; s < cmcf->servers.nelts; s++) {
|
||||||
|
|
||||||
/* "listen" directives */
|
/* "listen" directives */
|
||||||
lscf = (ngx_http_listen_t *) cscfp[s]->listen.elts;
|
lscf = cscfp[s]->listen.elts;
|
||||||
for (l = 0; l < cscfp[s]->listen.nelts; l++) {
|
for (l = 0; l < cscfp[s]->listen.nelts; l++) {
|
||||||
|
|
||||||
port_found = 0;
|
port_found = 0;
|
||||||
|
|
||||||
/* AF_INET only */
|
/* AF_INET only */
|
||||||
|
|
||||||
in_port = (ngx_http_in_port_t *) in_ports.elts;
|
in_port = in_ports.elts;
|
||||||
for (p = 0; p < in_ports.nelts; p++) {
|
for (p = 0; p < in_ports.nelts; p++) {
|
||||||
|
|
||||||
if (lscf[l].port == in_port[p].port) {
|
if (lscf[l].port == in_port[p].port) {
|
||||||
@ -248,7 +248,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
port_found = 1;
|
port_found = 1;
|
||||||
addr_found = 0;
|
addr_found = 0;
|
||||||
|
|
||||||
in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts;
|
in_addr = in_port[p].addrs.elts;
|
||||||
for (a = 0; a < in_port[p].addrs.nelts; a++) {
|
for (a = 0; a < in_port[p].addrs.nelts; a++) {
|
||||||
|
|
||||||
if (lscf[l].addr == in_addr[a].addr) {
|
if (lscf[l].addr == in_addr[a].addr) {
|
||||||
@ -256,8 +256,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
/* the address is already bound to this port */
|
/* the address is already bound to this port */
|
||||||
|
|
||||||
/* "server_name" directives */
|
/* "server_name" directives */
|
||||||
s_name = (ngx_http_server_name_t *)
|
s_name = cscfp[s]->server_names.elts;
|
||||||
cscfp[s]->server_names.elts;
|
|
||||||
for (n = 0; n < cscfp[s]->server_names.nelts; n++) {
|
for (n = 0; n < cscfp[s]->server_names.nelts; n++) {
|
||||||
|
|
||||||
/* add the server name and server core module
|
/* add the server name and server core module
|
||||||
@ -394,17 +393,17 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
/* AF_INET only */
|
/* AF_INET only */
|
||||||
|
|
||||||
in_port = (ngx_http_in_port_t *) in_ports.elts;
|
in_port = in_ports.elts;
|
||||||
for (p = 0; p < in_ports.nelts; p++) {
|
for (p = 0; p < in_ports.nelts; p++) {
|
||||||
|
|
||||||
/* check whether the all server names point to the same server */
|
/* check whether the all server names point to the same server */
|
||||||
|
|
||||||
in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts;
|
in_addr = in_port[p].addrs.elts;
|
||||||
for (a = 0; a < in_port[p].addrs.nelts; a++) {
|
for (a = 0; a < in_port[p].addrs.nelts; a++) {
|
||||||
|
|
||||||
virtual_names = 0;
|
virtual_names = 0;
|
||||||
|
|
||||||
name = (ngx_http_server_name_t *) in_addr[a].names.elts;
|
name = in_addr[a].names.elts;
|
||||||
for (n = 0; n < in_addr[a].names.nelts; n++) {
|
for (n = 0; n < in_addr[a].names.nelts; n++) {
|
||||||
if (in_addr[a].core_srv_conf != name[n].core_srv_conf) {
|
if (in_addr[a].core_srv_conf != name[n].core_srv_conf) {
|
||||||
virtual_names = 1;
|
virtual_names = 1;
|
||||||
@ -430,7 +429,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
a = 0;
|
a = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts;
|
in_addr = in_port[p].addrs.elts;
|
||||||
while (a < in_port[p].addrs.nelts) {
|
while (a < in_port[p].addrs.nelts) {
|
||||||
|
|
||||||
ngx_test_null(ls, ngx_push_array(&ngx_listening_sockets),
|
ngx_test_null(ls, ngx_push_array(&ngx_listening_sockets),
|
||||||
@ -443,7 +442,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
addr_in->sin_family = AF_INET;
|
addr_in->sin_family = AF_INET;
|
||||||
addr_in->sin_addr.s_addr = in_addr[a].addr;
|
addr_in->sin_addr.s_addr = in_addr[a].addr;
|
||||||
addr_in->sin_port = htons(in_port[p].port);
|
addr_in->sin_port = htons((u_short) in_port[p].port);
|
||||||
|
|
||||||
ngx_test_null(ls->addr_text.data,
|
ngx_test_null(ls->addr_text.data,
|
||||||
ngx_palloc(cf->pool, INET_ADDRSTRLEN + 6),
|
ngx_palloc(cf->pool, INET_ADDRSTRLEN + 6),
|
||||||
@ -478,7 +477,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
if (in_port[p].addrs.nelts > 1) {
|
if (in_port[p].addrs.nelts > 1) {
|
||||||
|
|
||||||
in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts;
|
in_addr = in_port[p].addrs.elts;
|
||||||
if (in_addr[in_port[p].addrs.nelts - 1].addr != INADDR_ANY) {
|
if (in_addr[in_port[p].addrs.nelts - 1].addr != INADDR_ANY) {
|
||||||
|
|
||||||
/* if this port has not the "*:port" binding then create
|
/* if this port has not the "*:port" binding then create
|
||||||
@ -523,14 +522,19 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* DEBUG STUFF */
|
/* DEBUG STUFF */
|
||||||
in_port = (ngx_http_in_port_t *) in_ports.elts;
|
in_port = in_ports.elts;
|
||||||
for (p = 0; p < in_ports.nelts; p++) {
|
for (p = 0; p < in_ports.nelts; p++) {
|
||||||
ngx_log_debug(cf->log, "port: %d" _ in_port[p].port);
|
ngx_log_debug(cf->log, "port: %d" _ in_port[p].port);
|
||||||
in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts;
|
in_addr = in_port[p].addrs.elts;
|
||||||
for (a = 0; a < in_port[p].addrs.nelts; a++) {
|
for (a = 0; a < in_port[p].addrs.nelts; a++) {
|
||||||
char ip[20];
|
char ip[20];
|
||||||
ngx_inet_ntop(AF_INET, (char *) &in_addr[a].addr, ip, 20);
|
ngx_inet_ntop(AF_INET, (char *) &in_addr[a].addr, ip, 20);
|
||||||
ngx_log_debug(cf->log, "%s %08x" _ ip _ in_addr[a].core_srv_conf);
|
ngx_log_debug(cf->log, "%s %08x" _ ip _ in_addr[a].core_srv_conf);
|
||||||
|
s_name = in_addr[a].names.elts;
|
||||||
|
for (n = 0; n < in_addr[a].names.nelts; n++) {
|
||||||
|
ngx_log_debug(cf->log, "%s %08x" _ s_name[n].name.data _
|
||||||
|
s_name[n].core_srv_conf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**/
|
/**/
|
||||||
|
@ -32,6 +32,7 @@ static int ngx_cmp_locations(const void *first, const void *second);
|
|||||||
static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd,
|
static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||||
void *dummy);
|
void *dummy);
|
||||||
static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
||||||
|
static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf);
|
||||||
static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
||||||
static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd,
|
static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||||
void *conf);
|
void *conf);
|
||||||
@ -103,7 +104,7 @@ static ngx_command_t ngx_http_core_commands[] = {
|
|||||||
NULL},
|
NULL},
|
||||||
|
|
||||||
{ngx_string("server_name"),
|
{ngx_string("server_name"),
|
||||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_ANY,
|
NGX_HTTP_SRV_CONF|NGX_CONF_ANY1,
|
||||||
ngx_set_server_name,
|
ngx_set_server_name,
|
||||||
NGX_HTTP_SRV_CONF_OFFSET,
|
NGX_HTTP_SRV_CONF_OFFSET,
|
||||||
0,
|
0,
|
||||||
@ -281,8 +282,6 @@ int ngx_http_core_translate_handler(ngx_http_request_t *r)
|
|||||||
char *location, *last;
|
char *location, *last;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
ngx_table_elt_t *h;
|
ngx_table_elt_t *h;
|
||||||
ngx_http_in_port_t *in_port;
|
|
||||||
ngx_http_server_name_t *s_name;
|
|
||||||
ngx_http_core_srv_conf_t *cscf;
|
ngx_http_core_srv_conf_t *cscf;
|
||||||
ngx_http_core_loc_conf_t *clcf;
|
ngx_http_core_loc_conf_t *clcf;
|
||||||
|
|
||||||
@ -669,9 +668,24 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, char *conf)
|
static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
ngx_http_core_loc_conf_t *lcf = (ngx_http_core_loc_conf_t *) conf;
|
char *rv;
|
||||||
|
ngx_conf_t pcf;
|
||||||
|
|
||||||
|
pcf = *cf;
|
||||||
|
cf->handler = ngx_set_type;
|
||||||
|
cf->handler_conf = conf;
|
||||||
|
rv = ngx_conf_parse(cf, NULL);
|
||||||
|
*cf = pcf;
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
|
||||||
|
{
|
||||||
|
ngx_http_core_loc_conf_t *lcf = conf;
|
||||||
|
|
||||||
int i, key;
|
int i, key;
|
||||||
ngx_str_t *args;
|
ngx_str_t *args;
|
||||||
@ -705,21 +719,6 @@ static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, char *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
||||||
{
|
|
||||||
char *rv;
|
|
||||||
ngx_conf_t pcf;
|
|
||||||
|
|
||||||
pcf = *cf;
|
|
||||||
cf->handler = ngx_set_type;
|
|
||||||
cf->handler_conf = conf;
|
|
||||||
rv = ngx_conf_parse(cf, NULL);
|
|
||||||
*cf = pcf;
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void *ngx_http_core_create_main_conf(ngx_pool_t *pool)
|
static void *ngx_http_core_create_main_conf(ngx_pool_t *pool)
|
||||||
{
|
{
|
||||||
ngx_http_core_main_conf_t *cmcf;
|
ngx_http_core_main_conf_t *cmcf;
|
||||||
@ -775,9 +774,10 @@ static void *ngx_http_core_create_srv_conf(ngx_pool_t *pool)
|
|||||||
static char *ngx_http_core_merge_srv_conf(ngx_pool_t *pool,
|
static char *ngx_http_core_merge_srv_conf(ngx_pool_t *pool,
|
||||||
void *parent, void *child)
|
void *parent, void *child)
|
||||||
{
|
{
|
||||||
ngx_http_core_srv_conf_t *prev = (ngx_http_core_srv_conf_t *) parent;
|
ngx_http_core_srv_conf_t *prev = parent;
|
||||||
ngx_http_core_srv_conf_t *conf = (ngx_http_core_srv_conf_t *) child;
|
ngx_http_core_srv_conf_t *conf = child;
|
||||||
|
|
||||||
|
int len;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
ngx_http_listen_t *l;
|
ngx_http_listen_t *l;
|
||||||
ngx_http_server_name_t *n;
|
ngx_http_server_name_t *n;
|
||||||
@ -798,9 +798,12 @@ static char *ngx_http_core_merge_srv_conf(ngx_pool_t *pool,
|
|||||||
|
|
||||||
if (gethostname(n->name.data, NGX_MAXHOSTNAMELEN) == -1) {
|
if (gethostname(n->name.data, NGX_MAXHOSTNAMELEN) == -1) {
|
||||||
err = ngx_errno;
|
err = ngx_errno;
|
||||||
ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
|
len = ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
|
||||||
"gethostname() failed (%d: %s)",
|
"gethostname() failed (%d: ", err);
|
||||||
err, ngx_strerror(err));
|
len += ngx_strerror_r(err, ngx_conf_errstr + len,
|
||||||
|
sizeof(ngx_conf_errstr) - len - 1);
|
||||||
|
ngx_conf_errstr[len++] = ')';
|
||||||
|
ngx_conf_errstr[len++] = '\0';
|
||||||
return ngx_conf_errstr;
|
return ngx_conf_errstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -862,8 +865,8 @@ static ngx_http_type_t default_types[] = {
|
|||||||
static char *ngx_http_core_merge_loc_conf(ngx_pool_t *pool,
|
static char *ngx_http_core_merge_loc_conf(ngx_pool_t *pool,
|
||||||
void *parent, void *child)
|
void *parent, void *child)
|
||||||
{
|
{
|
||||||
ngx_http_core_loc_conf_t *prev = (ngx_http_core_loc_conf_t *) parent;
|
ngx_http_core_loc_conf_t *prev = parent;
|
||||||
ngx_http_core_loc_conf_t *conf = (ngx_http_core_loc_conf_t *) child;
|
ngx_http_core_loc_conf_t *conf = child;
|
||||||
|
|
||||||
int i, key;
|
int i, key;
|
||||||
ngx_http_type_t *t;
|
ngx_http_type_t *t;
|
||||||
@ -919,7 +922,7 @@ static char *ngx_http_core_merge_loc_conf(ngx_pool_t *pool,
|
|||||||
|
|
||||||
static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
ngx_http_core_srv_conf_t *scf = (ngx_http_core_srv_conf_t *) conf;
|
ngx_http_core_srv_conf_t *scf = conf;
|
||||||
|
|
||||||
char *addr;
|
char *addr;
|
||||||
u_int p;
|
u_int p;
|
||||||
@ -963,11 +966,11 @@ static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
} else if ((ls->port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */
|
} else if ((ls->port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */
|
||||||
|| (ls->port < 1 || ls->port > 65536)) { /* "listen 99999" */
|
|| (ls->port < 1 || ls->port > 65536)) { /* "listen 99999" */
|
||||||
|
|
||||||
ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
|
ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
|
||||||
"invalid port \"%s\", "
|
"invalid port \"%s\", "
|
||||||
"it must be a number between 1 and 65535",
|
"it must be a number between 1 and 65535",
|
||||||
&addr[p]);
|
&addr[p]);
|
||||||
return ngx_conf_errstr;
|
return ngx_conf_errstr;
|
||||||
|
|
||||||
} else if (p == 0) {
|
} else if (p == 0) {
|
||||||
ls->addr = INADDR_ANY;
|
ls->addr = INADDR_ANY;
|
||||||
@ -993,21 +996,30 @@ static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
ngx_http_core_srv_conf_t *scf = (ngx_http_core_srv_conf_t *) conf;
|
ngx_http_core_srv_conf_t *scf = conf;
|
||||||
|
|
||||||
ngx_str_t *args;
|
int i;
|
||||||
|
ngx_str_t *value;
|
||||||
ngx_http_server_name_t *sn;
|
ngx_http_server_name_t *sn;
|
||||||
|
|
||||||
/* TODO: several names */
|
/* TODO: several names */
|
||||||
/* TODO: warn about duplicate 'server_name' directives */
|
/* TODO: warn about duplicate 'server_name' directives */
|
||||||
|
|
||||||
ngx_test_null(sn, ngx_push_array(&scf->server_names), NGX_CONF_ERROR);
|
value = cf->args->elts;
|
||||||
|
|
||||||
args = cf->args->elts;
|
for (i = 1; i < cf->args->nelts; i++) {
|
||||||
|
if (value[i].len == 0) {
|
||||||
|
ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
|
||||||
|
"server name \"%s\" is invalid", value[i].data);
|
||||||
|
return ngx_conf_errstr;
|
||||||
|
}
|
||||||
|
|
||||||
sn->name.len = args[1].len;
|
ngx_test_null(sn, ngx_push_array(&scf->server_names), NGX_CONF_ERROR);
|
||||||
sn->name.data = args[1].data;
|
|
||||||
sn->core_srv_conf = scf;
|
sn->name.len = value[i].len;
|
||||||
|
sn->name.data = value[i].data;
|
||||||
|
sn->core_srv_conf = scf;
|
||||||
|
}
|
||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
|
|
||||||
|
#include <ngx_config.h>
|
||||||
|
#include <ngx_core.h>
|
||||||
|
|
||||||
#include <nginx.h>
|
#include <nginx.h>
|
||||||
|
|
||||||
#include <ngx_config.h>
|
|
||||||
|
|
||||||
#include <ngx_core.h>
|
|
||||||
#include <ngx_string.h>
|
|
||||||
#include <ngx_table.h>
|
|
||||||
#include <ngx_hunk.h>
|
|
||||||
#include <ngx_conf_file.h>
|
|
||||||
|
|
||||||
#include <ngx_http.h>
|
#include <ngx_http.h>
|
||||||
#include <ngx_http_config.h>
|
|
||||||
#include <ngx_http_write_filter.h>
|
#include <ngx_http_write_filter.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk)
|
|||||||
if (hunk->type & NGX_HUNK_IN_MEMORY) {
|
if (hunk->type & NGX_HUNK_IN_MEMORY) {
|
||||||
size = hunk->last - hunk->pos;
|
size = hunk->last - hunk->pos;
|
||||||
} else {
|
} else {
|
||||||
size = hunk->file_last - hunk->file_pos;
|
size = (size_t) (hunk->file_last - hunk->file_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size > conf->hunk_size) {
|
if (size > conf->hunk_size) {
|
||||||
@ -201,8 +201,8 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk)
|
|||||||
size = ctx->incoming->hunk->last - ctx->incoming->hunk->pos;
|
size = ctx->incoming->hunk->last - ctx->incoming->hunk->pos;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
size = ctx->incoming->hunk->file_last
|
size = (size_t) (ctx->incoming->hunk->file_last
|
||||||
- ctx->incoming->hunk->file_pos;
|
- ctx->incoming->hunk->file_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* delete the completed hunk from the incoming chain */
|
/* delete the completed hunk from the incoming chain */
|
||||||
@ -241,7 +241,7 @@ static int ngx_http_output_filter_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src)
|
|||||||
if (src->type & NGX_HUNK_IN_MEMORY) {
|
if (src->type & NGX_HUNK_IN_MEMORY) {
|
||||||
size = src->last - src->pos;
|
size = src->last - src->pos;
|
||||||
} else {
|
} else {
|
||||||
size = src->file_last - src->file_pos;
|
size = (size_t) (src->file_last - src->file_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size > (dst->end - dst->pos)) {
|
if (size > (dst->end - dst->pos)) {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
#include <nginx.h>
|
|
||||||
|
|
||||||
#include <ngx_config.h>
|
#include <ngx_config.h>
|
||||||
#include <ngx_core.h>
|
#include <ngx_core.h>
|
||||||
#include <ngx_string.h>
|
|
||||||
|
#include <nginx.h>
|
||||||
|
|
||||||
#include <ngx_http.h>
|
#include <ngx_http.h>
|
||||||
#include <ngx_http_output_filter.h>
|
#include <ngx_http_output_filter.h>
|
||||||
|
|
||||||
|
@ -24,7 +24,9 @@ typedef int ngx_err_t;
|
|||||||
#define ngx_socket_errno errno
|
#define ngx_socket_errno errno
|
||||||
#define ngx_set_socket_errno(err) errno = err
|
#define ngx_set_socket_errno(err) errno = err
|
||||||
|
|
||||||
|
#if 0
|
||||||
#define ngx_strerror(err) strerror(err)
|
#define ngx_strerror(err) strerror(err)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ngx_strerror_r(err, errstr, size) \
|
#define ngx_strerror_r(err, errstr, size) \
|
||||||
ngx_cpystrn(errstr, strerror(err), size) - (errstr)
|
ngx_cpystrn(errstr, strerror(err), size) - (errstr)
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
TODO:
|
TODO:
|
||||||
add WSA error messages
|
add WSA error messages for NT and 98
|
||||||
test for English only messages
|
test for English only messages
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ngx_config.h>
|
#include <ngx_config.h>
|
||||||
#include <ngx_string.h>
|
#include <ngx_core.h>
|
||||||
#include <ngx_errno.h>
|
|
||||||
|
|
||||||
int ngx_strerror_r(ngx_err_t err, char *errstr, size_t size)
|
int ngx_strerror_r(ngx_err_t err, char *errstr, size_t size)
|
||||||
{
|
{
|
||||||
|
@ -53,8 +53,8 @@
|
|||||||
int ngx_file_type(char *filename, ngx_file_info_t *fi);
|
int ngx_file_type(char *filename, ngx_file_info_t *fi);
|
||||||
#define ngx_file_type_n "GetFileAttributes"
|
#define ngx_file_type_n "GetFileAttributes"
|
||||||
|
|
||||||
#define ngx_stat_fd(fd, fi) GetFileInformationByHandle(fd, fi)
|
#define ngx_stat_fd(fd, fi) GetFileInformationByHandle(fd, fi)
|
||||||
#define ngx_stat_fd_n "GetFileInformationByHandle"
|
#define ngx_stat_fd_n "GetFileInformationByHandle"
|
||||||
|
|
||||||
#define ngx_is_dir(fi) (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
#define ngx_is_dir(fi) (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
#define ngx_is_file(fi) !(fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
#define ngx_is_file(fi) !(fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
@ -73,7 +73,10 @@ int ngx_file_type(char *filename, ngx_file_info_t *fi);
|
|||||||
|
|
||||||
|
|
||||||
ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset);
|
ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset);
|
||||||
#define ngx_read_file_n "ReadFile()"
|
#define ngx_read_file_n "ReadFile()"
|
||||||
|
|
||||||
|
|
||||||
|
#define STDERR_FILENO (HANDLE) 2
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NGX_FILES_H_INCLUDED_ */
|
#endif /* _NGX_FILES_H_INCLUDED_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user