comparison src/event/ngx_event.c @ 36:c14d7232b11f

nginx-0.0.1-2002-12-23-09:29:22 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 23 Dec 2002 06:29:22 +0000
parents 95f1c2a938f3
children 9fe40e51d4a3
comparison
equal deleted inserted replaced
35:79c1fce18e71 36:c14d7232b11f
10 #include <ngx_connection.h> 10 #include <ngx_connection.h>
11 #include <ngx_event.h> 11 #include <ngx_event.h>
12 #include <ngx_event_accept.h> 12 #include <ngx_event_accept.h>
13 13
14 #include <ngx_select_module.h> 14 #include <ngx_select_module.h>
15 #if (HAVE_POLL)
16 #include <ngx_poll_module.h>
17 #endif
15 #if (HAVE_KQUEUE) 18 #if (HAVE_KQUEUE)
16 #include <ngx_kqueue_module.h> 19 #include <ngx_kqueue_module.h>
17 #endif 20 #endif
18 21
19 22
21 ngx_event_t *ngx_read_events, *ngx_write_events; 24 ngx_event_t *ngx_read_events, *ngx_write_events;
22 25
23 #if !(USE_KQUEUE) 26 #if !(USE_KQUEUE)
24 27
25 #if (HAVE_KQUEUE) 28 #if (HAVE_KQUEUE)
26 #if 1 29
30 #if 0
27 ngx_event_type_e ngx_event_type = NGX_SELECT_EVENT; 31 ngx_event_type_e ngx_event_type = NGX_SELECT_EVENT;
32 #elif 1
33 ngx_event_type_e ngx_event_type = NGX_POLL_EVENT;
28 #else 34 #else
29 ngx_event_type_e ngx_event_type = NGX_KQUEUE_EVENT; 35 ngx_event_type_e ngx_event_type = NGX_KQUEUE_EVENT;
30 #endif 36 #endif
37
31 #else 38 #else
32 ngx_event_type_e ngx_event_type = NGX_SELECT_EVENT; 39 ngx_event_type_e ngx_event_type = NGX_SELECT_EVENT;
33 #endif 40 #endif
34 41
35 ngx_event_actions_t ngx_event_actions; 42 ngx_event_actions_t ngx_event_actions;
49 56
50 57
51 void ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log) 58 void ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log)
52 { 59 {
53 int i, fd; 60 int i, fd;
54 ngx_listen_t *s; 61
62 ngx_listen_t *s;
63 ngx_event_t *ev;
64 ngx_connection_t *c;
55 65
56 /* STUB */ 66 /* STUB */
57 int max_connections = 512; 67 int max_connections = 512;
58 68
59 if (ngx_init_events(max_connections, log) == NGX_ERROR) 69 if (ngx_init_events(max_connections, log) == NGX_ERROR)
67 /* for each listening socket */ 77 /* for each listening socket */
68 s = (ngx_listen_t *) ls->elts; 78 s = (ngx_listen_t *) ls->elts;
69 for (i = 0; i < ls->nelts; i++) { 79 for (i = 0; i < ls->nelts; i++) {
70 80
71 fd = s[i].fd; 81 fd = s[i].fd;
82
83 c = &ngx_connections[fd];
84 ev = &ngx_read_events[fd];
72 85
73 ngx_memzero(&ngx_connections[fd], sizeof(ngx_connection_t)); 86 ngx_memzero(&ngx_connections[fd], sizeof(ngx_connection_t));
74 ngx_memzero(&ngx_read_events[fd], sizeof(ngx_event_t)); 87 ngx_memzero(&ngx_read_events[fd], sizeof(ngx_event_t));
75 88
76 ngx_connections[fd].fd = fd; 89 ngx_connections[fd].fd = fd;
87 100
88 ngx_test_null(ngx_read_events[fd].log, 101 ngx_test_null(ngx_read_events[fd].log,
89 ngx_palloc(pool, sizeof(ngx_log_t)), /* void */ ; ); 102 ngx_palloc(pool, sizeof(ngx_log_t)), /* void */ ; );
90 ngx_memcpy(ngx_read_events[fd].log, ngx_connections[fd].log, 103 ngx_memcpy(ngx_read_events[fd].log, ngx_connections[fd].log,
91 sizeof(ngx_log_t)); 104 sizeof(ngx_log_t));
105 c->read = ev;
92 ngx_read_events[fd].data = &ngx_connections[fd]; 106 ngx_read_events[fd].data = &ngx_connections[fd];
93 ngx_read_events[fd].event_handler = &ngx_event_accept; 107 ngx_read_events[fd].event_handler = &ngx_event_accept;
94 ngx_read_events[fd].listening = 1; 108 ngx_read_events[fd].listening = 1;
95 109
96 ngx_read_events[fd].available = 0; 110 ngx_read_events[fd].available = 0;