mirror of
https://github.com/nginx/nginx.git
synced 2024-11-21 16:28:40 +00:00
nginx-0.0.2-2004-02-10-19:23:38 import
This commit is contained in:
parent
e9b2cb1b9d
commit
c7a2f68606
2
auto/configure
vendored
2
auto/configure
vendored
@ -3,7 +3,7 @@
|
|||||||
. auto/init
|
. auto/init
|
||||||
. auto/sources
|
. auto/sources
|
||||||
|
|
||||||
test -d $OBJ || mkdir $OBJ
|
test -d $OBJS || mkdir $OBJS
|
||||||
echo > $NGX_AUTO_CONFIG_H
|
echo > $NGX_AUTO_CONFIG_H
|
||||||
|
|
||||||
if [ "$PLATFORM" != win32 ]; then
|
if [ "$PLATFORM" != win32 ]; then
|
||||||
|
@ -98,6 +98,12 @@ ngx_func_test="char buf[20]; int n; n = strerror_r(1, buf, 20)"
|
|||||||
. auto/func
|
. auto/func
|
||||||
|
|
||||||
|
|
||||||
|
ngx_func="gnu_strerror_r()"
|
||||||
|
ngx_func_inc="#include <string.h>"
|
||||||
|
ngx_func_test="char buf[20], *str; str = strerror_r(1, buf, 20)"
|
||||||
|
. auto/func
|
||||||
|
|
||||||
|
|
||||||
ngx_func="localtime_r()"
|
ngx_func="localtime_r()"
|
||||||
ngx_func_inc="#include <time.h>"
|
ngx_func_inc="#include <time.h>"
|
||||||
ngx_func_test="struct tm t; time_t c=0; localtime_r(&c, &t)"
|
ngx_func_test="struct tm t; time_t c=0; localtime_r(&c, &t)"
|
||||||
|
@ -203,6 +203,15 @@ int main(int argc, char *const *argv, char **envp)
|
|||||||
ccf->pid.data = NGINX_PID;
|
ccf->pid.data = NGINX_PID;
|
||||||
ccf->newpid.len = sizeof(NGINX_NEW_PID) - 1;
|
ccf->newpid.len = sizeof(NGINX_NEW_PID) - 1;
|
||||||
ccf->newpid.data = NGINX_NEW_PID;
|
ccf->newpid.data = NGINX_NEW_PID;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ccf->newpid.len = ccf->pid.len + sizeof(NGINX_NEW_PID_EXT);
|
||||||
|
if (!(ccf->newpid.data = ngx_alloc(ccf->newpid.len, cycle->log))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_memcpy(ngx_cpymem(ccf->newpid.data, ccf->pid.data, ccf->pid.len),
|
||||||
|
NGINX_NEW_PID_EXT, sizeof(NGINX_NEW_PID_EXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
len = ngx_snprintf(pid, /* STUB */ 10, PID_T_FMT, ngx_getpid());
|
len = ngx_snprintf(pid, /* STUB */ 10, PID_T_FMT, ngx_getpid());
|
||||||
@ -785,7 +794,7 @@ static ngx_int_t ngx_getopt(ngx_master_ctx_t *ctx, ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cycle->conf_file.len == NULL) {
|
if (cycle->conf_file.data == NULL) {
|
||||||
cycle->conf_file.len = sizeof(NGINX_CONF) - 1;
|
cycle->conf_file.len = sizeof(NGINX_CONF) - 1;
|
||||||
cycle->conf_file.data = NGINX_CONF;
|
cycle->conf_file.data = NGINX_CONF;
|
||||||
}
|
}
|
||||||
@ -814,6 +823,7 @@ static ngx_int_t ngx_core_module_init(ngx_cycle_t *cycle)
|
|||||||
/* set by pcalloc()
|
/* set by pcalloc()
|
||||||
*
|
*
|
||||||
* ccf->pid = NULL;
|
* ccf->pid = NULL;
|
||||||
|
* ccf->newpid = NULL;
|
||||||
*/
|
*/
|
||||||
ccf->daemon = NGX_CONF_UNSET;
|
ccf->daemon = NGX_CONF_UNSET;
|
||||||
ccf->master = NGX_CONF_UNSET;
|
ccf->master = NGX_CONF_UNSET;
|
||||||
|
@ -2,19 +2,20 @@
|
|||||||
#define _NGINX_H_INCLUDED_
|
#define _NGINX_H_INCLUDED_
|
||||||
|
|
||||||
|
|
||||||
#define NGINX_VER "nginx/0.0.2"
|
#define NGINX_VER "nginx/0.0.2"
|
||||||
#define NGINX_CONF "nginx.conf"
|
#define NGINX_CONF "nginx.conf"
|
||||||
#define NGINX_PID "nginx.pid"
|
#define NGINX_PID "nginx.pid"
|
||||||
#define NGINX_NEW_PID NGINX_PID ".newbin"
|
#define NGINX_NEW_PID_EXT ".newbin"
|
||||||
|
#define NGINX_NEW_PID NGINX_PID NGINX_NEW_PID_EXT
|
||||||
|
|
||||||
#define NGINX_VAR "NGINX="
|
#define NGINX_VAR "NGINX="
|
||||||
#define NGINX_VAR_LEN (sizeof(NGINX_VAR) - 1)
|
#define NGINX_VAR_LEN (sizeof(NGINX_VAR) - 1)
|
||||||
|
|
||||||
extern ngx_module_t ngx_core_module;
|
extern ngx_module_t ngx_core_module;
|
||||||
|
|
||||||
extern ngx_uint_t ngx_connection_counter;
|
extern ngx_uint_t ngx_connection_counter;
|
||||||
|
|
||||||
extern ngx_int_t ngx_process;
|
extern ngx_int_t ngx_process;
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NGINX_H_INCLUDED_ */
|
#endif /* _NGINX_H_INCLUDED_ */
|
||||||
|
@ -243,14 +243,14 @@ ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text)
|
|||||||
ngx_int_t level;
|
ngx_int_t level;
|
||||||
|
|
||||||
if (err == NGX_ECONNRESET
|
if (err == NGX_ECONNRESET
|
||||||
&& c->read->log_error == NGX_ERROR_IGNORE_ECONNRESET)
|
&& c->log_error == NGX_ERROR_IGNORE_ECONNRESET)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err == NGX_ECONNRESET || err == NGX_EPIPE || err == NGX_ENOTCONN) {
|
if (err == NGX_ECONNRESET || err == NGX_EPIPE || err == NGX_ENOTCONN) {
|
||||||
|
|
||||||
switch (c->read->log_error) {
|
switch (c->log_error) {
|
||||||
|
|
||||||
case NGX_ERROR_INFO:
|
case NGX_ERROR_INFO:
|
||||||
level = NGX_LOG_INFO;
|
level = NGX_LOG_INFO;
|
||||||
|
@ -52,6 +52,14 @@ typedef struct {
|
|||||||
} ngx_listening_t;
|
} ngx_listening_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NGX_ERROR_CRIT = 0,
|
||||||
|
NGX_ERROR_ERR,
|
||||||
|
NGX_ERROR_INFO,
|
||||||
|
NGX_ERROR_IGNORE_ECONNRESET
|
||||||
|
} ngx_connection_log_error_e;
|
||||||
|
|
||||||
|
|
||||||
struct ngx_connection_s {
|
struct ngx_connection_s {
|
||||||
void *data;
|
void *data;
|
||||||
ngx_event_t *read;
|
ngx_event_t *read;
|
||||||
@ -84,6 +92,8 @@ struct ngx_connection_s {
|
|||||||
|
|
||||||
ngx_int_t number;
|
ngx_int_t number;
|
||||||
|
|
||||||
|
unsigned log_error:2; /* ngx_connection_log_error_e */
|
||||||
|
|
||||||
unsigned pipeline:1;
|
unsigned pipeline:1;
|
||||||
unsigned unexpected_eof:1;
|
unsigned unexpected_eof:1;
|
||||||
signed tcp_nopush:2;
|
signed tcp_nopush:2;
|
||||||
|
@ -132,12 +132,15 @@ ngx_module_t ngx_epoll_module = {
|
|||||||
static int ngx_epoll_init(ngx_cycle_t *cycle)
|
static int ngx_epoll_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
size_t n;
|
size_t n;
|
||||||
|
ngx_event_conf_t *ecf;
|
||||||
ngx_epoll_conf_t *epcf;
|
ngx_epoll_conf_t *epcf;
|
||||||
|
|
||||||
|
ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module);
|
||||||
|
|
||||||
epcf = ngx_event_get_conf(cycle->conf_ctx, ngx_epoll_module);
|
epcf = ngx_event_get_conf(cycle->conf_ctx, ngx_epoll_module);
|
||||||
|
|
||||||
if (ep == -1) {
|
if (ep == -1) {
|
||||||
ep = epoll_create(/* STUB: open_files / 2 */ 512);
|
ep = epoll_create(ecf->connections / 2);
|
||||||
|
|
||||||
if (ep == -1) {
|
if (ep == -1) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||||
|
@ -20,14 +20,6 @@ typedef struct {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
NGX_ERROR_CRIT = 0,
|
|
||||||
NGX_ERROR_ERR,
|
|
||||||
NGX_ERROR_INFO,
|
|
||||||
NGX_ERROR_IGNORE_ECONNRESET
|
|
||||||
} ngx_event_log_error_e;
|
|
||||||
|
|
||||||
|
|
||||||
struct ngx_event_s {
|
struct ngx_event_s {
|
||||||
void *data;
|
void *data;
|
||||||
/* TODO rename to handler */
|
/* TODO rename to handler */
|
||||||
@ -88,7 +80,6 @@ struct ngx_event_s {
|
|||||||
|
|
||||||
unsigned short read_discarded:1;
|
unsigned short read_discarded:1;
|
||||||
|
|
||||||
unsigned short log_error:2; /* ngx_event_log_error_e */
|
|
||||||
unsigned short unexpected_eof:1;
|
unsigned short unexpected_eof:1;
|
||||||
|
|
||||||
unsigned short deferred_accept:1;
|
unsigned short deferred_accept:1;
|
||||||
|
@ -79,10 +79,10 @@ void ngx_http_init_connection(ngx_connection_t *c)
|
|||||||
ctx->action = "reading client request line";
|
ctx->action = "reading client request line";
|
||||||
c->log->data = ctx;
|
c->log->data = ctx;
|
||||||
c->log->handler = ngx_http_log_error;
|
c->log->handler = ngx_http_log_error;
|
||||||
|
c->log_error = NGX_ERROR_INFO;
|
||||||
|
|
||||||
rev = c->read;
|
rev = c->read;
|
||||||
rev->event_handler = ngx_http_init_request;
|
rev->event_handler = ngx_http_init_request;
|
||||||
rev->log_error = NGX_ERROR_INFO;
|
|
||||||
|
|
||||||
/* STUB: epoll */ c->write->event_handler = ngx_http_empty_handler;
|
/* STUB: epoll */ c->write->event_handler = ngx_http_empty_handler;
|
||||||
|
|
||||||
@ -1272,10 +1272,10 @@ static void ngx_http_keepalive_handler(ngx_event_t *rev)
|
|||||||
* so we ignore ECONNRESET here.
|
* so we ignore ECONNRESET here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rev->log_error = NGX_ERROR_IGNORE_ECONNRESET;
|
c->log_error = NGX_ERROR_IGNORE_ECONNRESET;
|
||||||
ngx_set_socket_errno(0);
|
ngx_set_socket_errno(0);
|
||||||
n = ngx_recv(c, c->buffer->last, c->buffer->end - c->buffer->last);
|
n = ngx_recv(c, c->buffer->last, c->buffer->end - c->buffer->last);
|
||||||
rev->log_error = NGX_ERROR_INFO;
|
c->log_error = NGX_ERROR_INFO;
|
||||||
|
|
||||||
if (n == NGX_AGAIN) {
|
if (n == NGX_AGAIN) {
|
||||||
return;
|
return;
|
||||||
|
@ -25,4 +25,34 @@ ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif (HAVE_GNU_STRERROR_R)
|
||||||
|
|
||||||
|
/* Linux strerror_r() */
|
||||||
|
|
||||||
|
ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (size == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
errstr[0] = '\0';
|
||||||
|
|
||||||
|
str = strerror_r(err, errstr, size);
|
||||||
|
|
||||||
|
if (str != errstr) {
|
||||||
|
return ngx_cpystrn(errstr, str, size) - errstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (len = 0; len < size; len++) {
|
||||||
|
if (errstr[len] == '\0') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
#define _NGX_ERRNO_H_INCLUDED_
|
#define _NGX_ERRNO_H_INCLUDED_
|
||||||
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <ngx_config.h>
|
||||||
#include <string.h>
|
#include <ngx_core.h>
|
||||||
|
|
||||||
|
|
||||||
typedef int ngx_err_t;
|
typedef int ngx_err_t;
|
||||||
@ -34,7 +34,7 @@ typedef int ngx_err_t;
|
|||||||
#define ngx_set_socket_errno(err) errno = err
|
#define ngx_set_socket_errno(err) errno = err
|
||||||
|
|
||||||
|
|
||||||
#if (HAVE_STRERROR_R)
|
#if (HAVE_STRERROR_R || HAVE_GNU_STRERROR_R)
|
||||||
|
|
||||||
ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size);
|
ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size);
|
||||||
|
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
|
@ -32,7 +32,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, char *buf, size_t size)
|
|||||||
ngx_set_socket_errno(rev->kq_errno);
|
ngx_set_socket_errno(rev->kq_errno);
|
||||||
|
|
||||||
if (rev->kq_errno == NGX_ECONNRESET
|
if (rev->kq_errno == NGX_ECONNRESET
|
||||||
&& rev->log_error == NGX_ERROR_IGNORE_ECONNRESET)
|
&& c->log_error == NGX_ERROR_IGNORE_ECONNRESET)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <strings.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user