- patch from Denis Vlasenko to add bb_xbind() and bb_xlisten()
This commit is contained in:
@@ -216,9 +216,8 @@ listen_socket(char *iface_addr, int listen_port)
|
||||
a.sin_family = AF_INET;
|
||||
if (!inet_aton(iface_addr, &a.sin_addr))
|
||||
bb_perror_msg_and_die("bad iface address");
|
||||
if (bind(s, (struct sockaddr *)&a, sizeof(a)) < 0)
|
||||
bb_perror_msg_and_die("bind() failed");
|
||||
listen(s, 50);
|
||||
bb_xbind(s, (struct sockaddr *)&a, sizeof(a));
|
||||
listen(s, 50); /* bb_xlisten? */
|
||||
sprintf(msg, "accepting UDP packets on addr:port %s:%d\n",
|
||||
iface_addr, (int)listen_port);
|
||||
log_message(LOG_FILE, msg);
|
||||
|
||||
@@ -113,10 +113,10 @@ static void inetbind(void)
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(port);
|
||||
|
||||
if (bind(s, (struct sockaddr *)&addr, len) < 0)
|
||||
if (bind(s, (struct sockaddr *)&addr, len) < 0) /* bb_xbind? */
|
||||
bb_perror_msg_and_die("Cannot bind() port %i", IDENT_PORT);
|
||||
|
||||
if (listen(s, 5) < 0)
|
||||
if (listen(s, 5) < 0) /* bb_xlisten? */
|
||||
bb_perror_msg_and_die("Cannot listen() on port %i", IDENT_PORT);
|
||||
|
||||
movefd(s, 0);
|
||||
|
||||
@@ -958,12 +958,9 @@ static int openServer(void)
|
||||
#else
|
||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) ;
|
||||
#endif
|
||||
if (bind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket)) == 0) {
|
||||
listen(fd, 9);
|
||||
signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */
|
||||
} else {
|
||||
bb_perror_msg_and_die("bind");
|
||||
}
|
||||
bb_xbind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket));
|
||||
listen(fd, 9); /* bb_xlisten? */
|
||||
signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */
|
||||
return fd;
|
||||
}
|
||||
#endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */
|
||||
|
||||
@@ -90,16 +90,13 @@ int nc_main(int argc, char **argv)
|
||||
memset(&address.sin_addr, 0, sizeof(address.sin_addr));
|
||||
address.sin_port = lport;
|
||||
|
||||
if (bind(sfd, (struct sockaddr *) &address, sizeof(address)) < 0)
|
||||
bb_perror_msg_and_die("bind");
|
||||
bb_xbind(sfd, (struct sockaddr *) &address, sizeof(address));
|
||||
}
|
||||
|
||||
if (do_listen) {
|
||||
socklen_t addrlen = sizeof(address);
|
||||
|
||||
if (listen(sfd, 1) < 0)
|
||||
bb_perror_msg_and_die("listen");
|
||||
|
||||
bb_xlisten(sfd, 1);
|
||||
if ((tmpfd = accept(sfd, (struct sockaddr *) &address, &addrlen)) < 0)
|
||||
bb_perror_msg_and_die("accept");
|
||||
|
||||
|
||||
@@ -461,14 +461,8 @@ telnetd_main(int argc, char **argv)
|
||||
sa.sin_addr = bind_addr;
|
||||
#endif
|
||||
|
||||
if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
|
||||
bb_perror_msg_and_die("bind");
|
||||
}
|
||||
|
||||
if (listen(master_fd, 1) < 0) {
|
||||
bb_perror_msg_and_die("listen");
|
||||
}
|
||||
|
||||
bb_xbind(master_fd, (struct sockaddr *) &sa, sizeof(sa));
|
||||
bb_xlisten(master_fd, 1);
|
||||
bb_xdaemon(0, 0);
|
||||
|
||||
maxfd = master_fd;
|
||||
|
||||
@@ -1253,9 +1253,7 @@ traceroute_main(int argc, char *argv[])
|
||||
|
||||
outip->ip_src = from->sin_addr;
|
||||
#ifndef IP_HDRINCL
|
||||
if (bind(sndsock, (struct sockaddr *)from, sizeof(*from)) < 0) {
|
||||
bb_perror_msg_and_die("bind");
|
||||
}
|
||||
bb_xbind(sndsock, (struct sockaddr *)from, sizeof(*from));
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "traceroute to %s (%s)", hostname, inet_ntoa(to->sin_addr));
|
||||
|
||||
Reference in New Issue
Block a user