comparison src/event/ngx_event.c @ 44:0e81ac0bb3e2

nginx-0.0.1-2003-01-09-08:36:00 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 09 Jan 2003 05:36:00 +0000
parents 83fa61cd3d2f
children d1e42f1b8fd4
comparison
equal deleted inserted replaced
43:53cd05892261 44:0e81ac0bb3e2
82 ngx_connection_t *c; 82 ngx_connection_t *c;
83 83
84 /* STUB */ 84 /* STUB */
85 int max_connections = 512; 85 int max_connections = 512;
86 86
87 if (ngx_init_events(max_connections, log) == NGX_ERROR) 87 if (ngx_init_events(max_connections, log) == NGX_ERROR) {
88 exit(1); 88 exit(1);
89 }
89 90
90 ngx_connections = ngx_alloc(sizeof(ngx_connection_t) 91 ngx_connections = ngx_alloc(sizeof(ngx_connection_t)
91 * max_connections, log); 92 * max_connections, log);
92 ngx_read_events = ngx_alloc(sizeof(ngx_event_t) * max_connections, log); 93 ngx_read_events = ngx_alloc(sizeof(ngx_event_t) * max_connections, log);
93 ngx_write_events = ngx_alloc(sizeof(ngx_event_t) * max_connections, log); 94 ngx_write_events = ngx_alloc(sizeof(ngx_event_t) * max_connections, log);
99 fd = s[i].fd; 100 fd = s[i].fd;
100 101
101 c = &ngx_connections[fd]; 102 c = &ngx_connections[fd];
102 ev = &ngx_read_events[fd]; 103 ev = &ngx_read_events[fd];
103 104
104 ngx_memzero(&ngx_connections[fd], sizeof(ngx_connection_t)); 105 ngx_memzero(c, sizeof(ngx_connection_t));
105 ngx_memzero(&ngx_read_events[fd], sizeof(ngx_event_t)); 106 ngx_memzero(ev, sizeof(ngx_event_t));
106 107
107 ngx_connections[fd].fd = fd; 108 c->fd = fd;
108 ngx_connections[fd].family = s[i].family; 109 c->family = s[i].family;
109 ngx_connections[fd].socklen = s[i].socklen; 110 c->socklen = s[i].socklen;
110 ngx_connections[fd].sockaddr = ngx_palloc(pool, s[i].socklen); 111 c->sockaddr = ngx_palloc(pool, s[i].socklen);
111 ngx_connections[fd].addr = s[i].addr; 112 c->addr = s[i].addr;
112 ngx_connections[fd].addr_text = s[i].addr_text; 113 c->addr_text = s[i].addr_text;
113 ngx_connections[fd].post_accept_timeout = s[i].post_accept_timeout; 114 c->addr_text_max_len = s[i].addr_text_max_len;
115 c->post_accept_timeout = s[i].post_accept_timeout;
114 116
115 ngx_connections[fd].server = s[i].server; 117 c->handler = s[i].handler;
116 ngx_connections[fd].handler = s[i].handler; 118 c->ctx = s[i].ctx;
117 ngx_connections[fd].log = s[i].log; 119 c->servers = s[i].servers;
120 c->log = s[i].log;
118 121
119 ngx_test_null(ngx_read_events[fd].log, 122 ngx_test_null(ev->log,
120 ngx_palloc(pool, sizeof(ngx_log_t)), /* void */ ; ); 123 ngx_palloc(pool, sizeof(ngx_log_t)), /* void */ ; );
121 ngx_memcpy(ngx_read_events[fd].log, ngx_connections[fd].log, 124 ngx_memcpy(ev->log, c->log, sizeof(ngx_log_t));
122 sizeof(ngx_log_t));
123 c->read = ev; 125 c->read = ev;
124 ngx_read_events[fd].data = &ngx_connections[fd]; 126 ev->data = c;
125 ngx_read_events[fd].event_handler = &ngx_event_accept; 127 ev->event_handler = &ngx_event_accept;
126 ngx_read_events[fd].listening = 1; 128 ev->listening = 1;
127 ev->index = NGX_INVALID_INDEX; 129 ev->index = NGX_INVALID_INDEX;
128 130
129 ngx_read_events[fd].available = 0; 131 ev->available = 0;
130 132
131 #if (HAVE_DEFERRED_ACCEPT) 133 #if (HAVE_DEFERRED_ACCEPT)
132 ngx_read_events[fd].deferred_accept = s[i].deferred_accept; 134 ev->deferred_accept = s[i].deferred_accept;
133 #endif 135 #endif
134 ngx_add_event(&ngx_read_events[fd], NGX_READ_EVENT, 0); 136 ngx_add_event(ev, NGX_READ_EVENT, 0);
135 } 137 }
136 } 138 }
137 139
138 void ngx_worker(ngx_log_t *log) 140 void ngx_worker(ngx_log_t *log)
139 { 141 {
140 while (1) { 142 for ( ;; ) {
141 ngx_log_debug(log, "ngx_worker cycle"); 143 ngx_log_debug(log, "ngx_worker cycle");
142 144
143 ngx_process_events(log); 145 ngx_process_events(log);
144 } 146 }
145 } 147 }