comparison src/event/ngx_event.c @ 6:669801705ab1

nginx-0.0.1-2002-08-26-19:18:19 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 26 Aug 2002 15:18:19 +0000
parents c5f071d376e5
children b5481d6fbbd4
comparison
equal deleted inserted replaced
5:62b1a364857c 6:669801705ab1
44 void ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log) 44 void ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log)
45 { 45 {
46 int i, fd; 46 int i, fd;
47 ngx_listen_t *s; 47 ngx_listen_t *s;
48 48
49 /* per group */ 49 /* STUB */
50 int max_connections = 512; 50 int max_connections = 512;
51 51
52 ngx_init_events(max_connections, log); 52 ngx_init_events(max_connections, log);
53 53
54 ngx_connections = ngx_alloc(sizeof(ngx_connection_t)
55 * max_connections, log);
54 ngx_read_events = ngx_alloc(sizeof(ngx_event_t) * max_connections, log); 56 ngx_read_events = ngx_alloc(sizeof(ngx_event_t) * max_connections, log);
55 ngx_write_events = ngx_alloc(sizeof(ngx_event_t) * max_connections, log); 57 ngx_write_events = ngx_alloc(sizeof(ngx_event_t) * max_connections, log);
56 ngx_connections = ngx_alloc(sizeof(ngx_connection_t)
57 * max_connections, log);
58 58
59 /* for each listening socket */ 59 /* for each listening socket */
60 s = (ngx_listen_t *) ls->elts; 60 s = (ngx_listen_t *) ls->elts;
61 for (i = 0; i < ls->nelts; i++) { 61 for (i = 0; i < ls->nelts; i++) {
62 62
63 fd = s[i].fd; 63 fd = s[i].fd;
64 64
65 ngx_memzero(&ngx_connections[fd], sizeof(ngx_connection_t));
65 ngx_memzero(&ngx_read_events[fd], sizeof(ngx_event_t)); 66 ngx_memzero(&ngx_read_events[fd], sizeof(ngx_event_t));
66 ngx_memzero(&ngx_write_events[fd], sizeof(ngx_event_t));
67 ngx_memzero(&ngx_connections[fd], sizeof(ngx_connection_t));
68 67
69 ngx_connections[fd].fd = fd; 68 ngx_connections[fd].fd = fd;
69 ngx_connections[fd].family = s[i].family;
70 ngx_connections[fd].socklen = s[i].socklen;
71 ngx_connections[fd].sockaddr = ngx_palloc(pool, s[i].socklen);
72 ngx_connections[fd].addr = s[i].addr;
73 ngx_connections[fd].addr_text = s[i].addr_text;
74 ngx_connections[fd].addr_textlen = s[i].addr_textlen;
75 ngx_connections[fd].post_accept_timeout = s[i].post_accept_timeout;
76
70 ngx_connections[fd].server = s[i].server; 77 ngx_connections[fd].server = s[i].server;
71 ngx_connections[fd].read = (void *) &ngx_read_events[fd].data;
72 ngx_connections[fd].handler = s[i].handler; 78 ngx_connections[fd].handler = s[i].handler;
73 ngx_read_events[fd].data = &ngx_connections[fd]; 79 ngx_connections[fd].log = s[i].log;
74 ngx_read_events[fd].log = ngx_connections[fd].log = s[i].log; 80
81 ngx_read_events[fd].log = ngx_connections[fd].log;
75 ngx_read_events[fd].data = &ngx_connections[fd]; 82 ngx_read_events[fd].data = &ngx_connections[fd];
76 ngx_read_events[fd].event_handler = &ngx_event_accept; 83 ngx_read_events[fd].event_handler = &ngx_event_accept;
77 ngx_read_events[fd].listening = 1; 84 ngx_read_events[fd].listening = 1;
78 85
79 ngx_read_events[fd].available = 0; 86 ngx_read_events[fd].available = 0;
80 87
81 #if (HAVE_DEFERRED_ACCEPT) 88 #if (HAVE_DEFERRED_ACCEPT)
82 ngx_read_events[fd].accept_filter = s[i].accept_filter; 89 ngx_read_events[fd].deferred_accept = s[i].deferred_accept;
83 #endif 90 #endif
84 ngx_add_event(&ngx_read_events[fd], NGX_READ_EVENT, 0); 91 ngx_add_event(&ngx_read_events[fd], NGX_READ_EVENT, 0);
85 } 92 }
86 } 93 }
87 94