comparison src/event/ngx_event_connect.c @ 257:70e1c7d2b83d

nginx-0.0.2-2004-02-11-20:08:49 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 11 Feb 2004 17:08:49 +0000
parents 2357fa41738a
children f81d075ad172
comparison
equal deleted inserted replaced
256:8e39cab6abd5 257:70e1c7d2b83d
1 1
2 #include <ngx_config.h> 2 #include <ngx_config.h>
3 #include <ngx_core.h> 3 #include <ngx_core.h>
4 #include <ngx_event.h> 4 #include <ngx_event.h>
5 #include <ngx_event_connect.h> 5 #include <ngx_event_connect.h>
6 #include <nginx.h>
6 7
7 8
8 /* AF_INET only */ 9 /* AF_INET only */
9 10
10 int ngx_event_connect_peer(ngx_peer_connection_t *pc) 11 int ngx_event_connect_peer(ngx_peer_connection_t *pc)
178 179
179 c->fd = s; 180 c->fd = s;
180 181
181 pc->connection = c; 182 pc->connection = c;
182 183
184 /*
185 * TODO: MT: - atomic increment (x86: lock xadd)
186 * or protection by critical section or mutex
187 *
188 * TODO: MP: - allocated in a shared memory
189 * - atomic increment (x86: lock xadd)
190 * or protection by critical section or mutex
191 */
192
193 c->number = ngx_connection_counter++;
194
183 if (ngx_add_conn) { 195 if (ngx_add_conn) {
184 if (ngx_add_conn(c) == NGX_ERROR) { 196 if (ngx_add_conn(c) == NGX_ERROR) {
185 return NGX_ERROR; 197 return NGX_ERROR;
186 } 198 }
187 } 199 }
190 202
191 addr.sin_family = AF_INET; 203 addr.sin_family = AF_INET;
192 addr.sin_port = peer->port; 204 addr.sin_port = peer->port;
193 addr.sin_addr.s_addr = peer->addr; 205 addr.sin_addr.s_addr = peer->addr;
194 206
195 ngx_log_debug(pc->log, "CONNECT: %s" _ peer->addr_port_text.data); 207 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, 0,
208 "connect to %s", peer->addr_port_text.data);
196 209
197 rc = connect(s, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)); 210 rc = connect(s, (struct sockaddr *) &addr, sizeof(struct sockaddr_in));
198 211
199 if (rc == -1) { 212 if (rc == -1) {
200 err = ngx_socket_errno; 213 err = ngx_socket_errno;
267 } 280 }
268 281
269 return NGX_AGAIN; 282 return NGX_AGAIN;
270 } 283 }
271 284
272 ngx_log_debug(pc->log, "CONNECTED"); 285 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pc->log, 0, "connected");
273 286
274 wev->ready = 1; 287 wev->ready = 1;
275 288
276 return NGX_OK; 289 return NGX_OK;
277 } 290 }