mirror of
https://github.com/nginx/nginx.git
synced 2024-11-26 19:00:16 -06:00
nginx-0.0.1-2003-11-17-19:15:03 import
This commit is contained in:
parent
f2e676aa15
commit
d7fdb3535b
@ -14,8 +14,8 @@ static ngx_connection_t pending_connects[NGX_MAX_PENDING_CONN];
|
||||
static HANDLE pending_connect_event;
|
||||
|
||||
__declspec(thread) int nevents = 0;
|
||||
__declspec(thread) WSAEVENT events[WSA_MAXIMUM_WAIT_EVENTS];
|
||||
__declspec(thread) ngx_connection_t *conn[WSA_MAXIMUM_WAIT_EVENTS];
|
||||
__declspec(thread) WSAEVENT events[WSA_MAXIMUM_WAIT_EVENTS + 1];
|
||||
__declspec(thread) ngx_connection_t *conn[WSA_MAXIMUM_WAIT_EVENTS + 1];
|
||||
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@ void ngx_iocp_wait_events(int main)
|
||||
conn[0] = NULL;
|
||||
|
||||
for ( ;; ) {
|
||||
offset = (nevents == WSA_MAXIMUM_WAIT_EVENTS) ? 1: 0;
|
||||
offset = (nevents == WSA_MAXIMUM_WAIT_EVENTS + 1) ? 1: 0;
|
||||
timeout = (nevents == 1 && !first) ? 60000: INFINITE;
|
||||
|
||||
n = WSAWaitForMultipleEvents(nevents - offset, events[offset],
|
||||
@ -133,7 +133,7 @@ void ngx_iocp_wait_events(int main)
|
||||
}
|
||||
|
||||
if (n == WAIT_TIMEOUT) {
|
||||
if (nevents == 1 && !main) {
|
||||
if (nevents == 2 && !main) {
|
||||
ExitThread(0);
|
||||
}
|
||||
|
||||
@ -145,9 +145,9 @@ void ngx_iocp_wait_events(int main)
|
||||
|
||||
n -= WSA_WAIT_EVENT_0;
|
||||
|
||||
if (n == 0) {
|
||||
if (events[n] == NULL) {
|
||||
|
||||
/* the first event is pending_connect_event */
|
||||
/* the pending_connect_event */
|
||||
|
||||
if (nevents == WSA_MAXIMUM_WAIT_EVENTS) {
|
||||
ngx_iocp_new_thread(0);
|
||||
|
@ -451,26 +451,22 @@ int ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
||||
static int ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p)
|
||||
{
|
||||
int size, hsize;
|
||||
char *save_pos;
|
||||
ngx_hunk_t *h;
|
||||
ngx_chain_t *cl, *tl, *next, *out, **ll, **last_free;
|
||||
ngx_chain_t *cl, *tl, *next, *out, **ll, **last_free, fl;
|
||||
|
||||
ngx_log_debug(p->log, "write to file");
|
||||
|
||||
out = p->in;
|
||||
|
||||
if (out->hunk->type & NGX_HUNK_PREREAD) {
|
||||
save_pos = out->hunk->pos;
|
||||
out->hunk->pos = out->hunk->start;
|
||||
if (p->hunk_to_file) {
|
||||
fl.hunk = p->hunk_to_file;
|
||||
fl.next = p->in;
|
||||
out = &fl;
|
||||
|
||||
} else {
|
||||
save_pos = NULL;
|
||||
out = p->in;
|
||||
}
|
||||
|
||||
if (!p->cachable) {
|
||||
|
||||
size = 0;
|
||||
cl = p->in;
|
||||
cl = out;
|
||||
ll = NULL;
|
||||
|
||||
ngx_log_debug(p->log, "offset: %d" _ p->temp_file->offset);
|
||||
@ -519,10 +515,10 @@ ngx_log_debug(p->log, "size: %d" _ size);
|
||||
/* void */
|
||||
}
|
||||
|
||||
if (out->hunk->type & NGX_HUNK_PREREAD) {
|
||||
p->temp_file->offset += save_pos - out->hunk->pos;
|
||||
out->hunk->pos = save_pos;
|
||||
out->hunk->type &= ~NGX_HUNK_PREREAD;
|
||||
if (p->hunk_to_file) {
|
||||
p->temp_file->offset = p->hunk_to_file->last - p->hunk_to_file->pos;
|
||||
p->hunk_to_file = NULL;
|
||||
out = out->next;
|
||||
}
|
||||
|
||||
for (cl = out; cl; cl = next) {
|
||||
@ -566,8 +562,6 @@ int ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_hunk_t *hunk)
|
||||
ngx_hunk_t *h;
|
||||
ngx_chain_t *cl;
|
||||
|
||||
ngx_log_debug(p->log, "COPY");
|
||||
|
||||
if (hunk->pos == hunk->last) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ typedef int (*ngx_event_pipe_output_filter_pt)(void *data, ngx_chain_t *chain);
|
||||
|
||||
|
||||
struct ngx_event_pipe_s {
|
||||
ngx_connection_t *upstream;
|
||||
ngx_connection_t *downstream;
|
||||
|
||||
ngx_chain_t *free_raw_hunks;
|
||||
ngx_chain_t *in;
|
||||
ngx_chain_t **last_in;
|
||||
@ -59,9 +62,6 @@ struct ngx_event_pipe_s {
|
||||
off_t max_temp_file_size;
|
||||
int temp_file_write_size;
|
||||
|
||||
ngx_connection_t *upstream;
|
||||
ngx_connection_t *downstream;
|
||||
|
||||
ngx_msec_t read_timeout;
|
||||
ngx_msec_t send_timeout;
|
||||
ssize_t send_lowat;
|
||||
@ -71,6 +71,7 @@ struct ngx_event_pipe_s {
|
||||
|
||||
ngx_chain_t *preread_hunks;
|
||||
int preread_size;
|
||||
ngx_hunk_t *hunk_to_file;
|
||||
|
||||
ngx_temp_file_t *temp_file;
|
||||
|
||||
|
@ -956,10 +956,18 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p)
|
||||
}
|
||||
ep->preread_hunks->hunk = p->header_in;
|
||||
ep->preread_hunks->next = NULL;
|
||||
p->header_in->type |= NGX_HUNK_PREREAD;
|
||||
|
||||
ep->preread_size = p->header_in->last - p->header_in->pos;
|
||||
|
||||
ep->hunk_to_file = ngx_calloc_hunk(r->pool);
|
||||
if (ep->preread_hunks == NULL) {
|
||||
ngx_http_proxy_finalize_request(p, 0);
|
||||
return;
|
||||
}
|
||||
ep->hunk_to_file->pos = p->header_in->start;
|
||||
ep->hunk_to_file->last = p->header_in->pos;
|
||||
ep->hunk_to_file->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
|
||||
|
||||
if (ngx_event_flags & NGX_USE_AIO_EVENT) {
|
||||
|
||||
/* the posted aio operation can currupt shadow buf */
|
||||
|
Loading…
Reference in New Issue
Block a user