summaryrefslogtreecommitdiffhomepage
path: root/src/event
diff options
context:
space:
mode:
Diffstat (limited to 'src/event')
-rw-r--r--src/event/modules/ngx_kqueue_module.c36
-rw-r--r--src/event/ngx_event.c106
-rw-r--r--src/event/ngx_event.h6
3 files changed, 148 insertions, 0 deletions
diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c
index 917fe2ccf..8cc7190a1 100644
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -10,6 +10,7 @@
#include <ngx_connection.h>
#include <ngx_event.h>
#include <ngx_event_timer.h>
+#include <ngx_conf_file.h>
#include <ngx_kqueue_module.h>
@@ -18,6 +19,10 @@
#define KQUEUE_NEVENTS 512
+static int ngx_kqueue_changes;
+static int ngx_kqueue_events;
+
+
/* should be per-thread if threads are used without thread pool */
#if 1
int kq;
@@ -32,6 +37,37 @@ static ngx_event_t *timer_queue;
/* */
+static ngx_str_t kqueue_name = ngx_string("kqueue");
+
+static ngx_command_t ngx_kqueue_commands[] = {
+
+ {ngx_string("kqueue_changes"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ addressof(ngx_kqueue_changes),
+ NULL},
+
+ {ngx_string("kqueue_events"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ addressof(ngx_kqueue_events),
+ NULL},
+
+ {ngx_string(""), 0, NULL, 0, 0, NULL}
+};
+
+ngx_module_t ngx_kqueue_module = {
+ &kqueue_name, /* module context */
+ 0, /* module index */
+ ngx_kqueue_commands, /* module directives */
+ NGX_EVENT_MODULE_TYPE, /* module type */
+ NULL /* init module */
+};
+
+
+
int ngx_kqueue_init(int max_connections, ngx_log_t *log)
{
int change_size, event_size;
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index d3acb4fe2..a3b12d0f6 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -9,6 +9,7 @@
#include <ngx_listen.h>
#include <ngx_connection.h>
#include <ngx_event.h>
+#include <ngx_conf_file.h>
#include <ngx_select_module.h>
@@ -34,6 +35,9 @@
#endif
+static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy);
+
+
ngx_connection_t *ngx_connections;
ngx_event_t *ngx_read_events, *ngx_write_events;
@@ -68,6 +72,66 @@ static int (*ngx_event_init[]) (int max_connections, ngx_log_t *log) = {
#endif /* USE_KQUEUE */
+static int ngx_event_connections;
+
+
+static ngx_str_t events_name = ngx_string("events");
+
+static ngx_command_t ngx_events_commands[] = {
+
+ {ngx_string("events"),
+ NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+ ngx_events_block,
+ 0,
+ 0,
+ NULL},
+
+ {ngx_string(""), 0, NULL, 0, 0, NULL}
+};
+
+
+ngx_module_t ngx_events_module = {
+ &events_name, /* module context */
+ 0, /* module index */
+ ngx_events_commands, /* module directives */
+ NGX_CORE_MODULE_TYPE, /* module type */
+ NULL /* init module */
+};
+
+
+
+static ngx_command_t ngx_event_commands[] = {
+
+ {ngx_string("connections"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ addressof(ngx_event_connections),
+ NULL},
+
+#if 0
+ {ngx_string("type"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_event_set_type,
+ 0,
+ 0,
+ NULL},
+#endif
+
+ {ngx_string(""), 0, NULL, 0, 0, NULL}
+};
+
+
+ngx_module_t ngx_event_module = {
+ NULL, /* module context */
+ 0, /* module index */
+ ngx_events_commands, /* module directives */
+ NGX_EVENT_MODULE_TYPE, /* module type */
+ NULL /* init module */
+};
+
+
+
void ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log)
{
int i, fd;
@@ -173,6 +237,7 @@ void ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log)
}
}
+
void ngx_worker(ngx_log_t *log)
{
for ( ;; ) {
@@ -181,3 +246,44 @@ void ngx_worker(ngx_log_t *log)
ngx_process_events(log);
}
}
+
+
+static char *ngx_events_init(ngx_pool_t *pool)
+{
+ ngx_event_connections = -1;
+ ngx_event_type = -1;
+
+ return NGX_CONF_OK;
+}
+
+
+static char *ngx_events_postconf(ngx_pool_t *pool)
+{
+ if (ngx_event_connections == -1) {
+ ngx_event_connections = 512;
+ }
+
+ return NGX_CONF_OK;
+}
+
+
+static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
+{
+ char *rv;
+ ngx_conf_t pcf;
+
+#if 0
+ *(ngx_events_conf_ctx_t **) conf = ctx;
+#endif
+
+ pcf = *cf;
+ cf->module_type = NGX_EVENT_MODULE_TYPE;
+ cf->cmd_type = NGX_EVENT_CONF;
+ rv = ngx_conf_parse(cf, NULL);
+ *cf = pcf;
+
+ if (rv != NGX_CONF_OK)
+ return rv;
+
+ return NGX_CONF_OK;
+}
diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h
index 72f4ba985..c976e17a5 100644
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -298,6 +298,12 @@ extern int ngx_event_flags;
#endif
+#define NGX_EVENT_MODULE_TYPE 0x544E5645 /* "EVNT" */
+
+#define NGX_EVENT_CONF 0x00200000
+
+
+
void ngx_event_accept(ngx_event_t *ev);