summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2018-11-13 19:04:48 +0300
committerIgor Sysoev <igor@sysoev.ru>2018-11-13 19:04:48 +0300
commit92ddc15a84d50306b3d1e22387dd0373994968af (patch)
tree020433b939b7d451d6338cb7d11799295df5e5fc /src
parentcf1f84b67c50156dc371e834bbdfd49c105abb25 (diff)
downloadunit-92ddc15a84d50306b3d1e22387dd0373994968af.tar.gz
unit-92ddc15a84d50306b3d1e22387dd0373994968af.tar.bz2
Checking error states in I/O handlers.
Diffstat (limited to '')
-rw-r--r--src/nxt_conn_read.c4
-rw-r--r--src/nxt_openssl.c38
2 files changed, 36 insertions, 6 deletions
diff --git a/src/nxt_conn_read.c b/src/nxt_conn_read.c
index e458bf81..8228326b 100644
--- a/src/nxt_conn_read.c
+++ b/src/nxt_conn_read.c
@@ -48,6 +48,10 @@ nxt_conn_io_read(nxt_task_t *task, void *obj, void *data)
nxt_debug(task, "conn read fd:%d rdy:%d cl:%d",
c->socket.fd, c->socket.read_ready, c->socket.closed);
+ if (c->socket.error != 0) {
+ return;
+ }
+
engine = task->thread->engine;
/*
diff --git a/src/nxt_openssl.c b/src/nxt_openssl.c
index 401de2de..99dd2077 100644
--- a/src/nxt_openssl.c
+++ b/src/nxt_openssl.c
@@ -503,13 +503,19 @@ fail:
nxt_inline void
-nxt_openssl_conn_free(nxt_task_t *task, nxt_openssl_conn_t *tls)
+nxt_openssl_conn_free(nxt_task_t *task, nxt_conn_t *c)
{
+ nxt_openssl_conn_t *tls;
+
nxt_debug(task, "openssl conn free");
- nxt_free(tls->buffer.start);
+ tls = c->u.tls;
- SSL_free(tls->session);
+ if (tls != NULL) {
+ c->u.tls = NULL;
+ nxt_free(tls->buffer.start);
+ SSL_free(tls->session);
+ }
}
@@ -526,9 +532,20 @@ nxt_openssl_conn_handshake(nxt_task_t *task, void *obj, void *data)
const nxt_conn_state_t *state;
c = obj;
+
+ nxt_debug(task, "openssl conn handshake fd:%d", c->socket.fd);
+
+ if (c->socket.error != 0) {
+ return;
+ }
+
tls = c->u.tls;
- nxt_debug(task, "openssl conn handshake: %d", tls->times);
+ if (tls == NULL) {
+ return;
+ }
+
+ nxt_debug(task, "openssl conn handshake: %d times", tls->times);
/* "tls->times == 1" is suitable to run SSL_do_handshake() in job. */
@@ -715,10 +732,19 @@ nxt_openssl_conn_io_shutdown(nxt_task_t *task, void *obj, void *data)
c = obj;
- nxt_debug(task, "openssl conn shutdown");
+ nxt_debug(task, "openssl conn shutdown fd:%d", c->socket.fd);
+
+ if (c->socket.error != 0) {
+ return;
+ }
c->read_state = NULL;
tls = c->u.tls;
+
+ if (tls == NULL) {
+ return;
+ }
+
s = tls->session;
if (s == NULL || !tls->handshake) {
@@ -807,7 +833,7 @@ nxt_openssl_conn_io_shutdown(nxt_task_t *task, void *obj, void *data)
done:
- nxt_openssl_conn_free(task, tls);
+ nxt_openssl_conn_free(task, c);
nxt_work_queue_add(c->write_work_queue, handler, task, c, data);
}