aboutsummaryrefslogtreecommitdiff
path: root/networking/httpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/httpd.c')
-rw-r--r--networking/httpd.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index c89073a2a..fde8ae4bd 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -6,19 +6,7 @@
6 * 6 *
7 * simplify patch stolen from libbb without using strdup 7 * simplify patch stolen from libbb without using strdup
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * 10 *
23 ***************************************************************************** 11 *****************************************************************************
24 * 12 *
@@ -959,25 +947,21 @@ static int openServer(void)
959 memset(&lsocket, 0, sizeof(lsocket)); 947 memset(&lsocket, 0, sizeof(lsocket));
960 lsocket.sin_family = AF_INET; 948 lsocket.sin_family = AF_INET;
961 lsocket.sin_addr.s_addr = INADDR_ANY; 949 lsocket.sin_addr.s_addr = INADDR_ANY;
962 lsocket.sin_port = htons(config->port) ; 950 lsocket.sin_port = htons(config->port);
963 fd = socket(AF_INET, SOCK_STREAM, 0); 951 fd = bb_xsocket(AF_INET, SOCK_STREAM, 0);
964 if (fd >= 0) { 952 /* tell the OS it's OK to reuse a previous address even though */
965 /* tell the OS it's OK to reuse a previous address even though */ 953 /* it may still be in a close down state. Allows bind to succeed. */
966 /* it may still be in a close down state. Allows bind to succeed. */ 954 int on = 1;
967 int on = 1;
968#ifdef SO_REUSEPORT 955#ifdef SO_REUSEPORT
969 setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *)&on, sizeof(on)) ; 956 setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *)&on, sizeof(on)) ;
970#else 957#else
971 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) ; 958 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) ;
972#endif 959#endif
973 if (bind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket)) == 0) { 960 if (bind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket)) == 0) {
974 listen(fd, 9); 961 listen(fd, 9);
975 signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */ 962 signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */
976 } else {
977 bb_perror_msg_and_die("bind");
978 }
979 } else { 963 } else {
980 bb_perror_msg_and_die("create socket"); 964 bb_perror_msg_and_die("bind");
981 } 965 }
982 return fd; 966 return fd;
983} 967}