Skip to content

Commit

Permalink
fix a write NULL event bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoweibin committed Mar 11, 2010
1 parent f24177f commit 80c5e45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions modules/ngx_tcp_proxy_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ ngx_tcp_upstream_proxy_generic_handler(ngx_tcp_session_t *s, ngx_tcp_upstream_t

ngx_tcp_proxy_conf_t *pcf;
ngx_tcp_proxy_ctx_t *pctx;
ngx_connection_t *c;
ngx_connection_t *c;


c = s->connection;
c->log->action = "ngx_tcp_proxy_handler";
Expand Down Expand Up @@ -184,7 +185,7 @@ ngx_tcp_proxy_init_session(ngx_connection_t *c, ngx_tcp_session_t *s) {
return;
}

c->read->handler = ngx_tcp_proxy_dummy_write_handler;
c->write->handler = ngx_tcp_proxy_dummy_write_handler;
c->read->handler = ngx_tcp_proxy_dummy_read_handler;

if (ngx_tcp_upstream_create(s) != NGX_OK) {
Expand Down Expand Up @@ -242,7 +243,7 @@ ngx_tcp_proxy_init(ngx_connection_t *c, ngx_tcp_session_t *s) {
return;
}

static ngx_int_t
ngx_int_t
ngx_tcp_proxy_test_connect(ngx_connection_t *c) {

int err;
Expand Down Expand Up @@ -296,8 +297,7 @@ ngx_tcp_proxy_dummy_write_handler(ngx_event_t *wev) {

ngx_log_debug1(NGX_LOG_DEBUG_TCP, wev->log, 0, "tcp proxy dummy write handler: %d", c->fd);

if (ngx_tcp_proxy_test_connect(c) != NGX_OK
|| ngx_handle_write_event(wev, 0) != NGX_OK) {
if (ngx_handle_write_event(wev, 0) != NGX_OK) {
ngx_tcp_finalize_session(s);
}
}
Expand Down
4 changes: 3 additions & 1 deletion ngx_tcp_upstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,10 @@ ngx_tcp_upstream_connect(ngx_tcp_session_t *s, ngx_tcp_upstream_t *u) {
ngx_log_debug1(NGX_LOG_DEBUG_TCP, s->connection->log, 0, "tcp upstream connect: %d", rc);

if (rc != NGX_OK && rc != NGX_AGAIN) {

ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
"upstream servers error or busy!", rc);
"upstream servers error or busy!");

ngx_tcp_upstream_finalize_session(s, u, 0);
return;
}
Expand Down

0 comments on commit 80c5e45

Please sign in to comment.