Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-09-13 20:18:09 +0400
committerIgor Sysoev <igor@sysoev.ru>2004-09-13 20:18:09 +0400
commit0292cbbe35cc6296a3128315a9a982fa2aa6832b (patch)
tree595e5e0ad5b6d904d327f550398b31c34a932cad /src
parent32e5771747809a31ed245a3299fefe19ace03ce6 (diff)
nginx-0.0.10-2004-09-13-20:18:09 import
Diffstat (limited to 'src')
-rw-r--r--src/core/ngx_conf_file.h16
-rw-r--r--src/event/ngx_event.h2
-rw-r--r--src/http/ngx_http.c8
-rw-r--r--src/http/ngx_http_core_module.h2
-rw-r--r--src/http/ngx_http_header_filter.c6
-rw-r--r--src/http/ngx_http_request.c2
-rw-r--r--src/http/ngx_http_request.h2
-rw-r--r--src/imap/ngx_imap.h5
-rw-r--r--src/imap/ngx_imap_handler.c12
-rw-r--r--src/imap/ngx_imap_proxy.c66
10 files changed, 87 insertions, 34 deletions
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 7286dbf41..1bd135473 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -91,15 +91,15 @@ struct ngx_open_file_s {
struct ngx_module_s {
- ngx_uint_t ctx_index;
- ngx_uint_t index;
- void *ctx;
- ngx_command_t *commands;
- ngx_uint_t type;
- ngx_int_t (*init_module)(ngx_cycle_t *cycle);
- ngx_int_t (*init_process)(ngx_cycle_t *cycle);
+ ngx_uint_t ctx_index;
+ ngx_uint_t index;
+ void *ctx;
+ ngx_command_t *commands;
+ ngx_uint_t type;
+ ngx_int_t (*init_module)(ngx_cycle_t *cycle);
+ ngx_int_t (*init_process)(ngx_cycle_t *cycle);
#if 0
- ngx_int_t (*init_thread)(ngx_cycle_t *cycle);
+ ngx_int_t (*init_thread)(ngx_cycle_t *cycle);
#endif
};
diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h
index 0f7e9bcd3..2b3fa4f6e 100644
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -394,7 +394,7 @@ extern ngx_event_actions_t ngx_event_actions;
#define NGX_EVENT_MODULE 0x544E5645 /* "EVNT" */
-#define NGX_EVENT_CONF 0x00200000
+#define NGX_EVENT_CONF 0x02000000
typedef struct {
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index 391bd1bf8..9eb023809 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -418,10 +418,10 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
in_port->port = lscf[l].port;
- ngx_test_null(in_port->port_name.data, ngx_palloc(cf->pool, 7),
+ ngx_test_null(in_port->port_text.data, ngx_palloc(cf->pool, 7),
NGX_CONF_ERROR);
- in_port->port_name.len = ngx_snprintf((char *)
- in_port->port_name.data,
+ in_port->port_text.len = ngx_snprintf((char *)
+ in_port->port_text.data,
7, ":%d",
in_port->port);
@@ -549,7 +549,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
NGX_CONF_ERROR);
inport->port = in_port[p].port;
- inport->port_name = in_port[p].port_name;
+ inport->port_text = in_port[p].port_text;
/* init list of the addresses ... */
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 25101aa7c..3a70f29d9 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -79,7 +79,7 @@ typedef struct {
typedef struct {
in_port_t port;
- ngx_str_t port_name;
+ ngx_str_t port_text;
ngx_array_t addrs; /* array of ngx_http_in_addr_t */
} ngx_http_in_port_t;
diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c
index a08c73e15..5e9a11578 100644
--- a/src/http/ngx_http_header_filter.c
+++ b/src/http/ngx_http_header_filter.c
@@ -206,7 +206,7 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
+ r->server_name->len + r->headers_out.location->value.len + 2;
if (r->port != 80) {
- len += r->port_name->len;
+ len += r->port_text->len;
}
}
@@ -325,8 +325,8 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
b->last = ngx_cpymem(b->last, r->server_name->data,
r->server_name->len);
if (r->port != 80) {
- b->last = ngx_cpymem(b->last, r->port_name->data,
- r->port_name->len);
+ b->last = ngx_cpymem(b->last, r->port_text->data,
+ r->port_text->len);
}
b->last = ngx_cpymem(b->last, r->headers_out.location->value.data,
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index a1081af12..734576783 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -202,7 +202,7 @@ static void ngx_http_init_request(ngx_event_t *rev)
in_addr = in_port->addrs.elts;
r->port = in_port->port;
- r->port_name = &in_port->port_name;
+ r->port_text = &in_port->port_text;
i = 0;
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index cc0cbbf5e..8055b5f1f 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -257,7 +257,7 @@ struct ngx_http_request_s {
uint32_t in_addr;
ngx_uint_t port;
- ngx_str_t *port_name; /* ":80" */
+ ngx_str_t *port_text; /* ":80" */
ngx_str_t *server_name;
ngx_array_t *virtual_names;
diff --git a/src/imap/ngx_imap.h b/src/imap/ngx_imap.h
index 25f08d031..81f490be1 100644
--- a/src/imap/ngx_imap.h
+++ b/src/imap/ngx_imap.h
@@ -66,6 +66,11 @@ typedef struct {
#define NGX_IMAP_PROXY_ERROR 11
+#define NGX_IMAP_MODULE 0x50414D49 /* "IMAP" */
+
+#define NGX_IMAP_CONF 0x02000000
+
+
void ngx_imap_init_connection(ngx_connection_t *c);
void ngx_imap_close_connection(ngx_connection_t *c);
diff --git a/src/imap/ngx_imap_handler.c b/src/imap/ngx_imap_handler.c
index f9e3983a2..6c97416d0 100644
--- a/src/imap/ngx_imap_handler.c
+++ b/src/imap/ngx_imap_handler.c
@@ -58,7 +58,11 @@ static void ngx_imap_init_session(ngx_event_t *rev)
c = rev->data;
- /* TODO: timeout */
+ if (rev->timedout) {
+ ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
+ ngx_imap_close_connection(c);
+ return;
+ }
if (!(s = ngx_pcalloc(c->pool, sizeof(ngx_imap_session_t)))) {
ngx_imap_close_connection(c);
@@ -102,7 +106,11 @@ static void ngx_pop3_auth_state(ngx_event_t *rev)
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, c->log, 0, "pop3 auth state");
- /* TODO: timeout */
+ if (rev->timedout) {
+ ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
+ ngx_imap_close_connection(c);
+ return;
+ }
rc = ngx_pop3_read_command(s);
diff --git a/src/imap/ngx_imap_proxy.c b/src/imap/ngx_imap_proxy.c
index ba6b36cbd..ba6f51703 100644
--- a/src/imap/ngx_imap_proxy.c
+++ b/src/imap/ngx_imap_proxy.c
@@ -41,10 +41,17 @@ void ngx_imap_proxy_init(ngx_imap_session_t *s)
peers->number = 1;
peers->max_fails = 1;
+#if 0
peers->peers[0].addr = inet_addr("81.19.69.70");
peers->peers[0].addr_port_text.len = sizeof("81.19.69.70:110") - 1;
peers->peers[0].addr_port_text.data = "81.19.69.70:110";
peers->peers[0].port = htons(110);
+#else
+ peers->peers[0].addr = inet_addr("81.19.64.101");
+ peers->peers[0].addr_port_text.len = sizeof("81.19.64.101:110") - 1;
+ peers->peers[0].addr_port_text.data = "81.19.64.101:110";
+ peers->peers[0].port = htons(110);
+#endif
rc = ngx_event_connect_peer(&p->upstream);
@@ -91,6 +98,12 @@ static void ngx_imap_proxy_auth_handler(ngx_event_t *rev)
c = rev->data;
s = c->data;
+ if (rev->timedout) {
+ ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
+ ngx_imap_proxy_close_session(s);
+ return;
+ }
+
if (s->proxy->buffer == NULL) {
s->proxy->buffer = ngx_create_temp_buf(c->pool, /* STUB */ 4096);
if (s->proxy->buffer == NULL) {
@@ -238,22 +251,49 @@ static void ngx_imap_proxy_handler(ngx_event_t *ev)
size_t size;
ssize_t n;
ngx_buf_t *b;
- ngx_uint_t data, do_write;
+ ngx_uint_t again, do_write;
ngx_connection_t *c, *src, *dst;
ngx_imap_session_t *s;
c = ev->data;
s = c->data;
+ if (ev->timedout) {
+ if (c == s->connection) {
+ ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT,
+ "client timed out");
+ } else {
+ ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT,
+ "upstream timed out");
+ }
+
+ ngx_imap_proxy_close_session(s);
+ return;
+ }
+
if (c == s->connection) {
- src = c;
- dst = s->proxy->upstream.connection;
- b = s->buffer;
+ if (ev->write) {
+ src = s->proxy->upstream.connection;
+ dst = c;
+ b = s->proxy->buffer;
+
+ } else {
+ src = c;
+ dst = s->proxy->upstream.connection;
+ b = s->buffer;
+ }
} else {
- src = c;
- dst = s->connection;
- b = s->proxy->buffer;
+ if (ev->write) {
+ src = s->connection;
+ dst = c;
+ b = s->buffer;
+
+ } else {
+ src = c;
+ dst = s->connection;
+ b = s->proxy->buffer;
+ }
}
do_write = ev->write ? 1 : 0;
@@ -263,13 +303,13 @@ static void ngx_imap_proxy_handler(ngx_event_t *ev)
do_write, src->fd, dst->fd);
do {
- data = 0;
+ again = 0;
if (do_write == 1) {
size = b->last - b->pos;
- if (dst->write->ready && size) {
+ if (size && dst->write->ready) {
n = ngx_send(dst, b->pos, size);
if (n == NGX_ERROR) {
@@ -278,7 +318,7 @@ static void ngx_imap_proxy_handler(ngx_event_t *ev)
}
if (n > 0) {
- data = 1;
+ again = 1;
b->pos += n;
if (b->pos == b->last) {
@@ -301,7 +341,7 @@ static void ngx_imap_proxy_handler(ngx_event_t *ev)
size = b->end - b->last;
- if (src->read->ready && size) {
+ if (size && src->read->ready) {
n = ngx_recv(src, b->last, size);
if (n == NGX_ERROR || n == 0) {
@@ -310,7 +350,7 @@ static void ngx_imap_proxy_handler(ngx_event_t *ev)
}
if (n > 0) {
- data = 1;
+ again = 1;
do_write = 1;
b->last += n;
}
@@ -323,7 +363,7 @@ static void ngx_imap_proxy_handler(ngx_event_t *ev)
}
}
- } while (data);
+ } while (again);
}