summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/nxt_application.c26
-rw-r--r--src/nxt_controller.c59
-rw-r--r--src/nxt_event_conn.h13
-rw-r--r--src/nxt_event_conn_connect.c2
-rw-r--r--src/nxt_event_conn_job_sendfile.c4
-rw-r--r--src/nxt_event_conn_proxy.c129
-rw-r--r--src/nxt_event_conn_read.c2
-rw-r--r--src/nxt_event_conn_write.c2
-rw-r--r--src/nxt_kqueue_engine.c2
9 files changed, 81 insertions, 158 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c
index eedfd0c9..293807b0 100644
--- a/src/nxt_application.c
+++ b/src/nxt_application.c
@@ -827,16 +827,13 @@ nxt_app_delivery_handler(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_app_delivery_write_state
nxt_aligned(64) =
{
- NXT_EVENT_NO_BUF_PROCESS,
- NXT_EVENT_TIMER_AUTORESET,
+ .ready_handler = nxt_app_delivery_ready,
+ .error_handler = nxt_app_delivery_error,
- nxt_app_delivery_ready,
- NULL,
- nxt_app_delivery_error,
-
- nxt_app_delivery_timeout,
- nxt_app_delivery_timer_value,
- 0,
+ .timer_handler = nxt_app_delivery_timeout,
+ .timer_value = nxt_app_delivery_timer_value,
+ .timer_data = 0,
+ .timer_autoreset = 1,
};
@@ -871,16 +868,7 @@ nxt_app_delivery_ready(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_app_delivery_close_state
nxt_aligned(64) =
{
- NXT_EVENT_NO_BUF_PROCESS,
- NXT_EVENT_TIMER_NO_AUTORESET,
-
- nxt_app_close_request,
- NULL,
- NULL,
-
- NULL,
- NULL,
- 0,
+ .ready_handler = nxt_app_close_request,
};
diff --git a/src/nxt_controller.c b/src/nxt_controller.c
index 93d0c2c5..c8522573 100644
--- a/src/nxt_controller.c
+++ b/src/nxt_controller.c
@@ -240,16 +240,13 @@ nxt_controller_conn_init(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_controller_conn_read_state
nxt_aligned(64) =
{
- NXT_EVENT_NO_BUF_PROCESS,
- NXT_EVENT_TIMER_NO_AUTORESET,
+ .ready_handler = nxt_controller_conn_read,
+ .close_handler = nxt_controller_conn_close,
+ .error_handler = nxt_controller_conn_read_error,
- nxt_controller_conn_read,
- nxt_controller_conn_close,
- nxt_controller_conn_read_error,
-
- nxt_controller_conn_read_timeout,
- nxt_controller_conn_timeout_value,
- 60 * 1000,
+ .timer_handler = nxt_controller_conn_read_timeout,
+ .timer_value = nxt_controller_conn_timeout_value,
+ .timer_data = 60 * 1000,
};
@@ -365,16 +362,14 @@ nxt_controller_conn_read_timeout(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_controller_conn_body_read_state
nxt_aligned(64) =
{
- NXT_EVENT_NO_BUF_PROCESS,
- NXT_EVENT_TIMER_AUTORESET,
-
- nxt_controller_conn_body_read,
- nxt_controller_conn_close,
- nxt_controller_conn_read_error,
-
- nxt_controller_conn_read_timeout,
- nxt_controller_conn_timeout_value,
- 60 * 1000,
+ .ready_handler = nxt_controller_conn_body_read,
+ .close_handler = nxt_controller_conn_close,
+ .error_handler = nxt_controller_conn_read_error,
+
+ .timer_handler = nxt_controller_conn_read_timeout,
+ .timer_value = nxt_controller_conn_timeout_value,
+ .timer_data = 60 * 1000,
+ .timer_autoreset = 1,
};
@@ -409,16 +404,13 @@ nxt_controller_conn_body_read(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_controller_conn_write_state
nxt_aligned(64) =
{
- NXT_EVENT_NO_BUF_PROCESS,
- NXT_EVENT_TIMER_AUTORESET,
+ .ready_handler = nxt_controller_conn_write,
+ .error_handler = nxt_controller_conn_write_error,
- nxt_controller_conn_write,
- NULL,
- nxt_controller_conn_write_error,
-
- nxt_controller_conn_write_timeout,
- nxt_controller_conn_timeout_value,
- 60 * 1000,
+ .timer_handler = nxt_controller_conn_write_timeout,
+ .timer_value = nxt_controller_conn_timeout_value,
+ .timer_data = 60 * 1000,
+ .timer_autoreset = 1,
};
@@ -479,16 +471,7 @@ nxt_controller_conn_write_timeout(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_controller_conn_close_state
nxt_aligned(64) =
{
- NXT_EVENT_NO_BUF_PROCESS,
- NXT_EVENT_TIMER_NO_AUTORESET,
-
- nxt_controller_conn_free,
- NULL,
- NULL,
-
- NULL,
- NULL,
- 0,
+ .ready_handler = nxt_controller_conn_free,
};
diff --git a/src/nxt_event_conn.h b/src/nxt_event_conn.h
index 902dff9f..02c088b8 100644
--- a/src/nxt_event_conn.h
+++ b/src/nxt_event_conn.h
@@ -12,18 +12,7 @@ typedef nxt_msec_t (*nxt_event_conn_timer_val_t)(nxt_event_conn_t *c,
uintptr_t data);
-#define NXT_EVENT_NO_BUF_PROCESS 0
-#define NXT_EVENT_BUF_PROCESS 1
-#define NXT_EVENT_BUF_COMPLETION 1
-
-#define NXT_EVENT_TIMER_AUTORESET 1
-#define NXT_EVENT_TIMER_NO_AUTORESET 0
-
-
typedef struct {
- uint8_t process_buffers;
- uint8_t autoreset_timer;
-
nxt_work_handler_t ready_handler;
nxt_work_handler_t close_handler;
nxt_work_handler_t error_handler;
@@ -31,6 +20,8 @@ typedef struct {
nxt_work_handler_t timer_handler;
nxt_event_conn_timer_val_t timer_value;
uintptr_t timer_data;
+
+ uint8_t timer_autoreset;
} nxt_event_conn_state_t;
diff --git a/src/nxt_event_conn_connect.c b/src/nxt_event_conn_connect.c
index 7db8f704..55aa33f9 100644
--- a/src/nxt_event_conn_connect.c
+++ b/src/nxt_event_conn_connect.c
@@ -128,7 +128,7 @@ nxt_event_conn_connect_test(nxt_task_t *task, void *obj, void *data)
nxt_fd_event_block_write(task->thread->engine, &c->socket);
- if (c->write_state->autoreset_timer) {
+ if (c->write_state->timer_autoreset) {
nxt_timer_disable(task->thread->engine, &c->write_timer);
}
diff --git a/src/nxt_event_conn_job_sendfile.c b/src/nxt_event_conn_job_sendfile.c
index a283de86..dae5079c 100644
--- a/src/nxt_event_conn_job_sendfile.c
+++ b/src/nxt_event_conn_job_sendfile.c
@@ -184,7 +184,7 @@ nxt_event_conn_job_sendfile_return(nxt_task_t *task, void *obj, void *data)
/* The job must be destroyed before connection error handler. */
nxt_job_destroy(task, jbs);
- if (c->write_state->process_buffers) {
+ if (0 /* STUB: c->write_state->process_buffers */) {
b = nxt_event_conn_job_sendfile_completion(task, c, b);
done = (b == NULL);
@@ -205,7 +205,7 @@ nxt_event_conn_job_sendfile_return(nxt_task_t *task, void *obj, void *data)
}
}
- if (sent != 0 && c->write_state->autoreset_timer) {
+ if (sent != 0 && c->write_state->timer_autoreset) {
nxt_timer_disable(task->thread->engine, &c->write_timer);
}
diff --git a/src/nxt_event_conn_proxy.c b/src/nxt_event_conn_proxy.c
index 20c96370..45a6b257 100644
--- a/src/nxt_event_conn_proxy.c
+++ b/src/nxt_event_conn_proxy.c
@@ -142,16 +142,13 @@ nxt_event_conn_proxy(nxt_task_t *task, nxt_event_conn_proxy_t *p)
static const nxt_event_conn_state_t nxt_event_conn_proxy_client_wait_state
nxt_aligned(64) =
{
- NXT_EVENT_NO_BUF_PROCESS,
- NXT_EVENT_TIMER_NO_AUTORESET,
+ .ready_handler = nxt_event_conn_proxy_client_buffer_alloc,
+ .close_handler = nxt_event_conn_proxy_close,
+ .error_handler = nxt_event_conn_proxy_error,
- nxt_event_conn_proxy_client_buffer_alloc,
- nxt_event_conn_proxy_close,
- nxt_event_conn_proxy_error,
-
- nxt_event_conn_proxy_read_timeout,
- nxt_event_conn_proxy_timeout_value,
- offsetof(nxt_event_conn_proxy_t, client_wait_timeout),
+ .timer_handler = nxt_event_conn_proxy_read_timeout,
+ .timer_value = nxt_event_conn_proxy_timeout_value,
+ .timer_data = offsetof(nxt_event_conn_proxy_t, client_wait_timeout),
};
@@ -210,16 +207,14 @@ static const nxt_event_conn_state_t
nxt_event_conn_proxy_client_first_read_state
nxt_aligned(64) =
{
- NXT_EVENT_BUF_PROCESS,
- NXT_EVENT_TIMER_AUTORESET,
-
- nxt_event_conn_proxy_peer_connect,
- nxt_event_conn_proxy_close,
- nxt_event_conn_proxy_error,
+ .ready_handler = nxt_event_conn_proxy_peer_connect,
+ .close_handler = nxt_event_conn_proxy_close,
+ .error_handler = nxt_event_conn_proxy_error,
- nxt_event_conn_proxy_read_timeout,
- nxt_event_conn_proxy_timeout_value,
- offsetof(nxt_event_conn_proxy_t, client_wait_timeout),
+ .timer_handler = nxt_event_conn_proxy_read_timeout,
+ .timer_value = nxt_event_conn_proxy_timeout_value,
+ .timer_data = offsetof(nxt_event_conn_proxy_t, client_wait_timeout),
+ .timer_autoreset = 1,
};
@@ -250,16 +245,14 @@ nxt_event_conn_proxy_peer_connect(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_event_conn_proxy_peer_connect_state
nxt_aligned(64) =
{
- NXT_EVENT_NO_BUF_PROCESS,
- NXT_EVENT_TIMER_AUTORESET,
-
- nxt_event_conn_proxy_connected,
- nxt_event_conn_proxy_refused,
- nxt_event_conn_proxy_error,
+ .ready_handler = nxt_event_conn_proxy_connected,
+ .close_handler = nxt_event_conn_proxy_refused,
+ .error_handler = nxt_event_conn_proxy_error,
- nxt_event_conn_proxy_write_timeout,
- nxt_event_conn_proxy_timeout_value,
- offsetof(nxt_event_conn_proxy_t, connect_timeout),
+ .timer_handler = nxt_event_conn_proxy_write_timeout,
+ .timer_value = nxt_event_conn_proxy_timeout_value,
+ .timer_data = offsetof(nxt_event_conn_proxy_t, connect_timeout),
+ .timer_autoreset = 1,
};
@@ -303,16 +296,13 @@ nxt_event_conn_proxy_connected(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_event_conn_proxy_peer_wait_state
nxt_aligned(64) =
{
- NXT_EVENT_NO_BUF_PROCESS,
- NXT_EVENT_TIMER_NO_AUTORESET,
+ .ready_handler = nxt_event_conn_proxy_peer_read,
+ .close_handler = nxt_event_conn_proxy_close,
+ .error_handler = nxt_event_conn_proxy_error,
- nxt_event_conn_proxy_peer_read,
- nxt_event_conn_proxy_close,
- nxt_event_conn_proxy_error,
-
- nxt_event_conn_proxy_read_timeout,
- nxt_event_conn_proxy_timeout_value,
- offsetof(nxt_event_conn_proxy_t, peer_wait_timeout),
+ .timer_handler = nxt_event_conn_proxy_read_timeout,
+ .timer_value = nxt_event_conn_proxy_timeout_value,
+ .timer_data = offsetof(nxt_event_conn_proxy_t, peer_wait_timeout),
};
@@ -357,16 +347,9 @@ nxt_event_conn_proxy_peer_read(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_event_conn_proxy_client_read_state
nxt_aligned(64) =
{
- NXT_EVENT_BUF_PROCESS,
- NXT_EVENT_TIMER_NO_AUTORESET,
-
- nxt_event_conn_proxy_client_read_ready,
- nxt_event_conn_proxy_close,
- nxt_event_conn_proxy_read_error,
-
- NULL,
- NULL,
- 0,
+ .ready_handler = nxt_event_conn_proxy_client_read_ready,
+ .close_handler = nxt_event_conn_proxy_close,
+ .error_handler = nxt_event_conn_proxy_read_error,
};
@@ -389,16 +372,9 @@ nxt_event_conn_proxy_client_read_ready(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_event_conn_proxy_peer_read_state
nxt_aligned(64) =
{
- NXT_EVENT_BUF_PROCESS,
- NXT_EVENT_TIMER_NO_AUTORESET,
-
- nxt_event_conn_proxy_peer_read_ready,
- nxt_event_conn_proxy_close,
- nxt_event_conn_proxy_read_error,
-
- NULL,
- NULL,
- 0,
+ .ready_handler = nxt_event_conn_proxy_peer_read_ready,
+ .close_handler = nxt_event_conn_proxy_close,
+ .error_handler = nxt_event_conn_proxy_read_error,
};
@@ -556,16 +532,13 @@ nxt_event_conn_proxy_read(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_event_conn_proxy_client_write_state
nxt_aligned(64) =
{
- NXT_EVENT_NO_BUF_PROCESS,
- NXT_EVENT_TIMER_AUTORESET,
-
- nxt_event_conn_proxy_client_write_ready,
- NULL,
- nxt_event_conn_proxy_write_error,
+ .ready_handler = nxt_event_conn_proxy_client_write_ready,
+ .error_handler = nxt_event_conn_proxy_write_error,
- nxt_event_conn_proxy_write_timeout,
- nxt_event_conn_proxy_timeout_value,
- offsetof(nxt_event_conn_proxy_t, client_write_timeout),
+ .timer_handler = nxt_event_conn_proxy_write_timeout,
+ .timer_value = nxt_event_conn_proxy_timeout_value,
+ .timer_data = offsetof(nxt_event_conn_proxy_t, client_write_timeout),
+ .timer_autoreset = 1,
};
@@ -588,16 +561,13 @@ nxt_event_conn_proxy_client_write_ready(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_event_conn_proxy_peer_write_state
nxt_aligned(64) =
{
- NXT_EVENT_NO_BUF_PROCESS,
- NXT_EVENT_TIMER_AUTORESET,
+ .ready_handler = nxt_event_conn_proxy_peer_write_ready,
+ .error_handler = nxt_event_conn_proxy_write_error,
- nxt_event_conn_proxy_peer_write_ready,
- NULL,
- nxt_event_conn_proxy_write_error,
-
- nxt_event_conn_proxy_write_timeout,
- nxt_event_conn_proxy_timeout_value,
- offsetof(nxt_event_conn_proxy_t, peer_write_timeout),
+ .timer_handler = nxt_event_conn_proxy_write_timeout,
+ .timer_value = nxt_event_conn_proxy_timeout_value,
+ .timer_data = offsetof(nxt_event_conn_proxy_t, peer_write_timeout),
+ .timer_autoreset = 1,
};
@@ -993,16 +963,7 @@ nxt_event_conn_proxy_write_error(nxt_task_t *task, void *obj, void *data)
static const nxt_event_conn_state_t nxt_event_conn_proxy_close_state
nxt_aligned(64) =
{
- NXT_EVENT_NO_BUF_PROCESS,
- NXT_EVENT_TIMER_NO_AUTORESET,
-
- nxt_event_conn_proxy_completion,
- NULL,
- NULL,
-
- NULL,
- NULL,
- 0,
+ .ready_handler = nxt_event_conn_proxy_completion,
};
diff --git a/src/nxt_event_conn_read.c b/src/nxt_event_conn_read.c
index d898c694..be2dfdb2 100644
--- a/src/nxt_event_conn_read.c
+++ b/src/nxt_event_conn_read.c
@@ -72,7 +72,7 @@ nxt_event_conn_io_read(nxt_task_t *task, void *obj, void *data)
nxt_fd_event_block_read(engine, &c->socket);
- if (state->autoreset_timer) {
+ if (state->timer_autoreset) {
nxt_timer_disable(engine, &c->read_timer);
}
diff --git a/src/nxt_event_conn_write.c b/src/nxt_event_conn_write.c
index 4ac6e2d8..fa5b9241 100644
--- a/src/nxt_event_conn_write.c
+++ b/src/nxt_event_conn_write.c
@@ -77,7 +77,7 @@ nxt_conn_io_write(nxt_task_t *task, void *obj, void *data)
nxt_debug(task, "event conn: %i sent:%z", ret, sb.sent);
if (sb.sent != 0) {
- if (c->write_state->autoreset_timer) {
+ if (c->write_state->timer_autoreset) {
nxt_timer_disable(engine, &c->write_timer);
}
}
diff --git a/src/nxt_kqueue_engine.c b/src/nxt_kqueue_engine.c
index d15ce15a..c5e40eeb 100644
--- a/src/nxt_kqueue_engine.c
+++ b/src/nxt_kqueue_engine.c
@@ -902,7 +902,7 @@ nxt_kqueue_event_conn_connected(nxt_task_t *task, void *obj, void *data)
c->socket.write = NXT_EVENT_BLOCKED;
- if (c->write_state->autoreset_timer) {
+ if (c->write_state->timer_autoreset) {
nxt_timer_disable(task->thread->engine, &c->write_timer);
}