comparison src/mail/ngx_mail.c @ 2799:8b54548fef6e

delete ngx_listening_inet_stream_socket()
author Igor Sysoev <igor@sysoev.ru>
date Mon, 04 May 2009 19:51:09 +0000
parents 268d8d3faa34
children a445bd4eb571
comparison
equal deleted inserted replaced
2798:268d8d3faa34 2799:8b54548fef6e
70 ngx_conf_t pcf; 70 ngx_conf_t pcf;
71 ngx_array_t in_ports; 71 ngx_array_t in_ports;
72 ngx_listening_t *ls; 72 ngx_listening_t *ls;
73 ngx_mail_listen_t *mls; 73 ngx_mail_listen_t *mls;
74 ngx_mail_module_t *module; 74 ngx_mail_module_t *module;
75 struct sockaddr *sa;
76 struct sockaddr_in *sin;
75 ngx_mail_in_port_t *mip; 77 ngx_mail_in_port_t *mip;
76 ngx_mail_conf_ctx_t *ctx; 78 ngx_mail_conf_ctx_t *ctx;
77 ngx_mail_conf_in_port_t *in_port; 79 ngx_mail_conf_in_port_t *in_port;
78 ngx_mail_conf_in_addr_t *in_addr; 80 ngx_mail_conf_in_addr_t *in_addr;
79 ngx_mail_core_srv_conf_t **cscfp; 81 ngx_mail_core_srv_conf_t **cscfp;
80 ngx_mail_core_main_conf_t *cmcf; 82 ngx_mail_core_main_conf_t *cmcf;
83 u_char buf[NGX_SOCKADDR_STRLEN];
81 84
82 if (cmd->name.data[0] == 'i') { 85 if (cmd->name.data[0] == 'i') {
83 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, 86 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
84 "the \"imap\" directive is deprecated, " 87 "the \"imap\" directive is deprecated, "
85 "use the \"mail\" directive instead"); 88 "use the \"mail\" directive instead");
297 if (!bind_all && !in_addr[a].bind) { 300 if (!bind_all && !in_addr[a].bind) {
298 a++; 301 a++;
299 continue; 302 continue;
300 } 303 }
301 304
302 ls = ngx_listening_inet_stream_socket(cf, in_addr[a].addr, 305 ls = ngx_array_push(&cf->cycle->listening);
303 in_port[p].port);
304 if (ls == NULL) { 306 if (ls == NULL) {
305 return NGX_CONF_ERROR; 307 return NULL;
308 }
309
310 ngx_memzero(ls, sizeof(ngx_listening_t));
311
312 sin = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_in));
313 if (sin == NULL) {
314 return NULL;
315 }
316
317 sin->sin_family = AF_INET;
318 sin->sin_addr.s_addr = in_addr[a].addr;
319 sin->sin_port = htons(in_port[p].port);
320
321 sa = (struct sockaddr *) sin;
322
323 ls->sockaddr = sa;
324 ls->socklen = sizeof(struct sockaddr_in);
325
326 ls->addr_text.len = ngx_sock_ntop(sa, buf, NGX_SOCKADDR_STRLEN, 1);
327
328 ls->addr_text.data = ngx_pnalloc(cf->pool, ls->addr_text.len);
329 if (ls->addr_text.data == NULL) {
330 return NULL;
331 }
332
333 ngx_memcpy(ls->addr_text.data, buf, ls->addr_text.len);
334
335 ls->fd = (ngx_socket_t) -1;
336 ls->type = SOCK_STREAM;
337
338 switch (ls->sockaddr->sa_family) {
339 #if (NGX_HAVE_INET6)
340 case AF_INET6:
341 ls->addr_text_max_len = NGX_INET6_ADDRSTRLEN;
342 break;
343 #endif
344 case AF_INET:
345 ls->addr_text_max_len = NGX_INET_ADDRSTRLEN;
346 break;
347 default:
348 ls->addr_text_max_len = NGX_SOCKADDR_STRLEN;
349 break;
306 } 350 }
307 351
308 ls->backlog = NGX_LISTEN_BACKLOG; 352 ls->backlog = NGX_LISTEN_BACKLOG;
309 ls->rcvbuf = -1; 353 ls->rcvbuf = -1;
310 ls->sndbuf = -1; 354 ls->sndbuf = -1;