comparison src/listen.c @ 204:5745edd5b769

removed the --disable-smtp-server configure option masqmail will now always have the possibility to listen on a port compiled in if you don't want it to listen on a port add this to your masqmail.conf: listen_addresses = "" also, if you don't start it as daemon it will not listen neither
author meillo@marmaro.de
date Fri, 16 Jul 2010 15:38:53 +0200
parents f671821d8222
children dcb315792513
comparison
equal deleted inserted replaced
203:45acc5727493 204:5745edd5b769
44 logwrite(LOG_WARNING, "process with pid %d got signal: %d\n", pid, WTERMSIG(status)); 44 logwrite(LOG_WARNING, "process with pid %d got signal: %d\n", pid, WTERMSIG(status));
45 } 45 }
46 signal(SIGCHLD, sigchld_handler); 46 signal(SIGCHLD, sigchld_handler);
47 } 47 }
48 48
49 #ifdef ENABLE_SMTP_SERVER
50 void 49 void
51 accept_connect(int listen_sock, int sock, struct sockaddr_in *sock_addr) 50 accept_connect(int listen_sock, int sock, struct sockaddr_in *sock_addr)
52 { 51 {
53 pid_t pid; 52 pid_t pid;
54 int dup_sock = dup(sock); 53 int dup_sock = dup(sock);
90 #endif 89 #endif
91 90
92 close(sock); 91 close(sock);
93 close(dup_sock); 92 close(dup_sock);
94 } 93 }
95 #endif /*ifdef ENABLE_SMTP_SERVER */
96 94
97 void 95 void
98 listen_port(GList * iface_list, gint qival, char *argv[]) 96 listen_port(GList * iface_list, gint qival, char *argv[])
99 { 97 {
100 int i; 98 int i;
106 GList *node, *node_next; 104 GList *node, *node_next;
107 int sel_ret; 105 int sel_ret;
108 106
109 /* Create the sockets and set them up to accept connections. */ 107 /* Create the sockets and set them up to accept connections. */
110 FD_ZERO(&active_fd_set); 108 FD_ZERO(&active_fd_set);
111 #ifdef ENABLE_SMTP_SERVER
112 for (node = g_list_first(iface_list); node; node = node_next) { 109 for (node = g_list_first(iface_list); node; node = node_next) {
113 interface *iface = (interface *) (node->data); 110 interface *iface = (interface *) (node->data);
114 int sock; 111 int sock;
115 112
116 node_next = g_list_next(node); 113 node_next = g_list_next(node);
125 } 122 }
126 logwrite(LOG_NOTICE, "listening on interface %s:%d\n", iface->address, iface->port); 123 logwrite(LOG_NOTICE, "listening on interface %s:%d\n", iface->address, iface->port);
127 DEBUG(5) debugf("sock = %d\n", sock); 124 DEBUG(5) debugf("sock = %d\n", sock);
128 FD_SET(sock, &active_fd_set); 125 FD_SET(sock, &active_fd_set);
129 } 126 }
130 #endif
131 127
132 /* setup handler for HUP signal: */ 128 /* setup handler for HUP signal: */
133 signal(SIGHUP, sighup_handler); 129 signal(SIGHUP, sighup_handler);
134 signal(SIGCHLD, sigchld_handler); 130 signal(SIGCHLD, sigchld_handler);
135 131
190 logwrite(LOG_ALERT, "restarting failed: %s\n", strerror(errno)); 186 logwrite(LOG_ALERT, "restarting failed: %s\n", strerror(errno));
191 exit(EXIT_FAILURE); 187 exit(EXIT_FAILURE);
192 } 188 }
193 } 189 }
194 } else if (sel_ret > 0) { 190 } else if (sel_ret > 0) {
195 #ifdef ENABLE_SMTP_SERVER
196 for (i = 0; i < FD_SETSIZE; i++) { 191 for (i = 0; i < FD_SETSIZE; i++) {
197 if (FD_ISSET(i, &read_fd_set)) { 192 if (FD_ISSET(i, &read_fd_set)) {
198 int sock = i; 193 int sock = i;
199 int new; 194 int new;
200 size = sizeof(clientname); 195 size = sizeof(clientname);
203 logwrite(LOG_ALERT, "accept: (ignoring): %s\n", strerror(errno)); 198 logwrite(LOG_ALERT, "accept: (ignoring): %s\n", strerror(errno));
204 } else 199 } else
205 accept_connect(sock, new, &clientname); 200 accept_connect(sock, new, &clientname);
206 } 201 }
207 } 202 }
208 #else
209 ;
210 #endif
211 } else { 203 } else {
212 /* If select returns 0, the interval time has elapsed. 204 /* If select returns 0, the interval time has elapsed.
213 We start a new queue runner process */ 205 We start a new queue runner process */
214 int pid; 206 int pid;
215 signal(SIGCHLD, sigchld_handler); 207 signal(SIGCHLD, sigchld_handler);