diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-02-04 23:43:44 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-02-04 23:43:44 +0000 |
commit | 1cbfd98ded582f7d73662d8316120e137f94fe25 (patch) | |
tree | 0c31ee4dbbbe6311938efb9797178eaef5e2fc0d | |
parent | 6d5590f9d023a27a42106274ee119b6ed16e15f2 (diff) | |
download | busybox-w32-1cbfd98ded582f7d73662d8316120e137f94fe25.tar.gz busybox-w32-1cbfd98ded582f7d73662d8316120e137f94fe25.tar.bz2 busybox-w32-1cbfd98ded582f7d73662d8316120e137f94fe25.zip |
httpd:
Kill config options by making them always on:
FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES
This makes httpd.c remotely readable - it had ~125 #ifdefs, now it has ~100.
The growth on a .config with all FEATURE_HTTPDs off is:
function old new delta
send_file_and_exit - 269 +269
parse_conf 683 763 +80
free_llist - 32 +32
httpd_main 427 454 +27
sighup_handler - 15 +15
handle_incoming_and_exit 1110 905 -205
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 2/1 up/down: 423/-205) Total: 218 bytes
-rw-r--r-- | TODO_config_nommu | 2 | ||||
-rw-r--r-- | networking/Config.in | 16 | ||||
-rw-r--r-- | networking/httpd.c | 157 | ||||
-rw-r--r-- | scripts/defconfig | 2 |
4 files changed, 56 insertions, 121 deletions
diff --git a/TODO_config_nommu b/TODO_config_nommu index b2496cf3c..428d9b300 100644 --- a/TODO_config_nommu +++ b/TODO_config_nommu | |||
@@ -630,11 +630,9 @@ CONFIG_HOSTNAME=y | |||
630 | CONFIG_HTTPD=y | 630 | CONFIG_HTTPD=y |
631 | CONFIG_FEATURE_HTTPD_RANGES=y | 631 | CONFIG_FEATURE_HTTPD_RANGES=y |
632 | CONFIG_FEATURE_HTTPD_USE_SENDFILE=y | 632 | CONFIG_FEATURE_HTTPD_USE_SENDFILE=y |
633 | CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP=y | ||
634 | CONFIG_FEATURE_HTTPD_SETUID=y | 633 | CONFIG_FEATURE_HTTPD_SETUID=y |
635 | CONFIG_FEATURE_HTTPD_BASIC_AUTH=y | 634 | CONFIG_FEATURE_HTTPD_BASIC_AUTH=y |
636 | CONFIG_FEATURE_HTTPD_AUTH_MD5=y | 635 | CONFIG_FEATURE_HTTPD_AUTH_MD5=y |
637 | CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES=y | ||
638 | CONFIG_FEATURE_HTTPD_CGI=y | 636 | CONFIG_FEATURE_HTTPD_CGI=y |
639 | CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y | 637 | CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y |
640 | CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y | 638 | CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y |
diff --git a/networking/Config.in b/networking/Config.in index b3d07e63c..af160e7a1 100644 --- a/networking/Config.in +++ b/networking/Config.in | |||
@@ -141,14 +141,6 @@ config FEATURE_HTTPD_USE_SENDFILE | |||
141 | When enabled, httpd will use the kernel sendfile() function | 141 | When enabled, httpd will use the kernel sendfile() function |
142 | instead of read/write loop. | 142 | instead of read/write loop. |
143 | 143 | ||
144 | config FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP | ||
145 | bool "Support reloading of global config file on HUP signal" | ||
146 | default n | ||
147 | depends on HTTPD | ||
148 | help | ||
149 | This option enables processing of SIGHUP to reload cached | ||
150 | configuration settings. | ||
151 | |||
152 | config FEATURE_HTTPD_SETUID | 144 | config FEATURE_HTTPD_SETUID |
153 | bool "Enable -u <user> option" | 145 | bool "Enable -u <user> option" |
154 | default n | 146 | default n |
@@ -175,14 +167,6 @@ config FEATURE_HTTPD_AUTH_MD5 | |||
175 | Enables basic per URL authentication from /etc/httpd.conf | 167 | Enables basic per URL authentication from /etc/httpd.conf |
176 | using md5 passwords. | 168 | using md5 passwords. |
177 | 169 | ||
178 | config FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES | ||
179 | bool "Support loading additional MIME types at run-time" | ||
180 | default n | ||
181 | depends on HTTPD | ||
182 | help | ||
183 | This option enables support for additional MIME types at | ||
184 | run-time to be specified in the configuration file. | ||
185 | |||
186 | config FEATURE_HTTPD_CGI | 170 | config FEATURE_HTTPD_CGI |
187 | bool "Support Common Gateway Interface (CGI)" | 171 | bool "Support Common Gateway Interface (CGI)" |
188 | default y | 172 | default y |
diff --git a/networking/httpd.c b/networking/httpd.c index fc8b51240..66ce1e1f7 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -97,7 +97,7 @@ | |||
97 | 97 | ||
98 | #include "libbb.h" | 98 | #include "libbb.h" |
99 | #if ENABLE_FEATURE_HTTPD_USE_SENDFILE | 99 | #if ENABLE_FEATURE_HTTPD_USE_SENDFILE |
100 | #include <sys/sendfile.h> | 100 | # include <sys/sendfile.h> |
101 | #endif | 101 | #endif |
102 | 102 | ||
103 | //#define DEBUG 1 | 103 | //#define DEBUG 1 |
@@ -268,9 +268,7 @@ struct globals { | |||
268 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH | 268 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
269 | Htaccess *g_auth; /* config user:password lines */ | 269 | Htaccess *g_auth; /* config user:password lines */ |
270 | #endif | 270 | #endif |
271 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES | ||
272 | Htaccess *mime_a; /* config mime types */ | 271 | Htaccess *mime_a; /* config mime types */ |
273 | #endif | ||
274 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | 272 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
275 | Htaccess *script_i; /* config script interpreters */ | 273 | Htaccess *script_i; /* config script interpreters */ |
276 | #endif | 274 | #endif |
@@ -310,6 +308,12 @@ struct globals { | |||
310 | #define range_start (G.range_start ) | 308 | #define range_start (G.range_start ) |
311 | #define range_end (G.range_end ) | 309 | #define range_end (G.range_end ) |
312 | #define range_len (G.range_len ) | 310 | #define range_len (G.range_len ) |
311 | #else | ||
312 | enum { | ||
313 | range_start = 0, | ||
314 | range_end = MAXINT(off_t) - 1, | ||
315 | range_len = MAXINT(off_t), | ||
316 | }; | ||
313 | #endif | 317 | #endif |
314 | #define rmt_ip_str (G.rmt_ip_str ) | 318 | #define rmt_ip_str (G.rmt_ip_str ) |
315 | #define g_auth (G.g_auth ) | 319 | #define g_auth (G.g_auth ) |
@@ -328,14 +332,6 @@ struct globals { | |||
328 | file_size = -1; \ | 332 | file_size = -1; \ |
329 | } while (0) | 333 | } while (0) |
330 | 334 | ||
331 | #if !ENABLE_FEATURE_HTTPD_RANGES | ||
332 | enum { | ||
333 | range_start = 0, | ||
334 | range_end = MAXINT(off_t) - 1, | ||
335 | range_len = MAXINT(off_t), | ||
336 | }; | ||
337 | #endif | ||
338 | |||
339 | 335 | ||
340 | #define STRNCASECMP(a, str) strncasecmp((a), (str), sizeof(str)-1) | 336 | #define STRNCASECMP(a, str) strncasecmp((a), (str), sizeof(str)-1) |
341 | 337 | ||
@@ -358,14 +354,10 @@ static void free_llist(has_next_ptr **pptr) | |||
358 | *pptr = NULL; | 354 | *pptr = NULL; |
359 | } | 355 | } |
360 | 356 | ||
361 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH \ | ||
362 | || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \ | ||
363 | || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | ||
364 | static ALWAYS_INLINE void free_Htaccess_list(Htaccess **pptr) | 357 | static ALWAYS_INLINE void free_Htaccess_list(Htaccess **pptr) |
365 | { | 358 | { |
366 | free_llist((has_next_ptr**)pptr); | 359 | free_llist((has_next_ptr**)pptr); |
367 | } | 360 | } |
368 | #endif | ||
369 | 361 | ||
370 | static ALWAYS_INLINE void free_Htaccess_IP_list(Htaccess_IP **pptr) | 362 | static ALWAYS_INLINE void free_Htaccess_IP_list(Htaccess_IP **pptr) |
371 | { | 363 | { |
@@ -488,11 +480,7 @@ static void parse_conf(const char *path, int flag) | |||
488 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH | 480 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
489 | Htaccess *prev; | 481 | Htaccess *prev; |
490 | #endif | 482 | #endif |
491 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH \ | ||
492 | || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \ | ||
493 | || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | ||
494 | Htaccess *cur; | 483 | Htaccess *cur; |
495 | #endif | ||
496 | const char *filename = configFile; | 484 | const char *filename = configFile; |
497 | char buf[160]; | 485 | char buf[160]; |
498 | char *p, *p0; | 486 | char *p, *p0; |
@@ -502,22 +490,16 @@ static void parse_conf(const char *path, int flag) | |||
502 | /* discard old rules */ | 490 | /* discard old rules */ |
503 | free_Htaccess_IP_list(&ip_a_d); | 491 | free_Htaccess_IP_list(&ip_a_d); |
504 | flg_deny_all = 0; | 492 | flg_deny_all = 0; |
505 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH \ | ||
506 | || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \ | ||
507 | || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | ||
508 | /* retain previous auth and mime config only for subdir parse */ | 493 | /* retain previous auth and mime config only for subdir parse */ |
509 | if (flag != SUBDIR_PARSE) { | 494 | if (flag != SUBDIR_PARSE) { |
510 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH | 495 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH |
511 | free_Htaccess_list(&g_auth); | 496 | free_Htaccess_list(&g_auth); |
512 | #endif | 497 | #endif |
513 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES | ||
514 | free_Htaccess_list(&mime_a); | 498 | free_Htaccess_list(&mime_a); |
515 | #endif | ||
516 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | 499 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
517 | free_Htaccess_list(&script_i); | 500 | free_Htaccess_list(&script_i); |
518 | #endif | 501 | #endif |
519 | } | 502 | } |
520 | #endif | ||
521 | 503 | ||
522 | if (flag == SUBDIR_PARSE || filename == NULL) { | 504 | if (flag == SUBDIR_PARSE || filename == NULL) { |
523 | filename = alloca(strlen(path) + sizeof(httpd_conf) + 2); | 505 | filename = alloca(strlen(path) + sizeof(httpd_conf) + 2); |
@@ -701,9 +683,6 @@ static void parse_conf(const char *path, int flag) | |||
701 | continue; | 683 | continue; |
702 | } | 684 | } |
703 | 685 | ||
704 | #if ENABLE_FEATURE_HTTPD_BASIC_AUTH \ | ||
705 | || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \ | ||
706 | || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | ||
707 | /* storing current config line */ | 686 | /* storing current config line */ |
708 | cur = xzalloc(sizeof(Htaccess) + strlen(p0)); | 687 | cur = xzalloc(sizeof(Htaccess) + strlen(p0)); |
709 | strcpy(cur->before_colon, p0); | 688 | strcpy(cur->before_colon, p0); |
@@ -713,14 +692,12 @@ static void parse_conf(const char *path, int flag) | |||
713 | #endif | 692 | #endif |
714 | cur->after_colon = strchr(cur->before_colon, ':'); | 693 | cur->after_colon = strchr(cur->before_colon, ':'); |
715 | *cur->after_colon++ = '\0'; | 694 | *cur->after_colon++ = '\0'; |
716 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES | ||
717 | if (cur->before_colon[0] == '.') { | 695 | if (cur->before_colon[0] == '.') { |
718 | /* .mime line: prepend to mime_a list */ | 696 | /* .mime line: prepend to mime_a list */ |
719 | cur->next = mime_a; | 697 | cur->next = mime_a; |
720 | mime_a = cur; | 698 | mime_a = cur; |
721 | continue; | 699 | continue; |
722 | } | 700 | } |
723 | #endif | ||
724 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | 701 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
725 | if (cur->before_colon[0] == '*' && cur->before_colon[1] == '.') { | 702 | if (cur->before_colon[0] == '*' && cur->before_colon[1] == '.') { |
726 | /* script interpreter line: prepend to script_i list */ | 703 | /* script interpreter line: prepend to script_i list */ |
@@ -762,7 +739,6 @@ static void parse_conf(const char *path, int flag) | |||
762 | } | 739 | } |
763 | } | 740 | } |
764 | #endif /* BASIC_AUTH */ | 741 | #endif /* BASIC_AUTH */ |
765 | #endif /* BASIC_AUTH || MIME_TYPES || SCRIPT_INTERPR */ | ||
766 | } /* while (fgets) */ | 742 | } /* while (fgets) */ |
767 | fclose(f); | 743 | fclose(f); |
768 | } | 744 | } |
@@ -1507,7 +1483,7 @@ static void send_cgi_and_exit( | |||
1507 | * const char *url The requested URL (with leading /). | 1483 | * const char *url The requested URL (with leading /). |
1508 | * what What to send (headers/body/both). | 1484 | * what What to send (headers/body/both). |
1509 | */ | 1485 | */ |
1510 | static void send_file_and_exit(const char *url, int what) | 1486 | static NOINLINE void send_file_and_exit(const char *url, int what) |
1511 | { | 1487 | { |
1512 | static const char *const suffixTable[] = { | 1488 | static const char *const suffixTable[] = { |
1513 | /* Warning: shorter equivalent suffix in one line must be first */ | 1489 | /* Warning: shorter equivalent suffix in one line must be first */ |
@@ -1532,13 +1508,26 @@ static void send_file_and_exit(const char *url, int what) | |||
1532 | }; | 1508 | }; |
1533 | 1509 | ||
1534 | char *suffix; | 1510 | char *suffix; |
1535 | int f; | 1511 | int fd; |
1536 | const char *const *table; | 1512 | const char *const *table; |
1537 | const char *try_suffix; | 1513 | const char *try_suffix; |
1538 | ssize_t count; | 1514 | ssize_t count; |
1539 | #if ENABLE_FEATURE_HTTPD_USE_SENDFILE | 1515 | |
1540 | off_t offset; | 1516 | fd = open(url, O_RDONLY); |
1541 | #endif | 1517 | if (fd < 0) { |
1518 | if (DEBUG) | ||
1519 | bb_perror_msg("can't open '%s'", url); | ||
1520 | /* Error pages are sent by using send_file_and_exit(SEND_BODY). | ||
1521 | * IOW: it is unsafe to call send_headers_and_exit | ||
1522 | * if what is SEND_BODY! Can recurse! */ | ||
1523 | if (what != SEND_BODY) | ||
1524 | send_headers_and_exit(HTTP_NOT_FOUND); | ||
1525 | log_and_exit(); | ||
1526 | } | ||
1527 | |||
1528 | if (DEBUG) | ||
1529 | bb_error_msg("sending file '%s' content-type: %s", | ||
1530 | url, found_mime_type); | ||
1542 | 1531 | ||
1543 | /* If you want to know about EPIPE below | 1532 | /* If you want to know about EPIPE below |
1544 | * (happens if you abort downloads from local httpd): */ | 1533 | * (happens if you abort downloads from local httpd): */ |
@@ -1549,9 +1538,7 @@ static void send_file_and_exit(const char *url, int what) | |||
1549 | /* If not found, set default as "application/octet-stream"; */ | 1538 | /* If not found, set default as "application/octet-stream"; */ |
1550 | found_mime_type = "application/octet-stream"; | 1539 | found_mime_type = "application/octet-stream"; |
1551 | if (suffix) { | 1540 | if (suffix) { |
1552 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES | ||
1553 | Htaccess *cur; | 1541 | Htaccess *cur; |
1554 | #endif | ||
1555 | for (table = suffixTable; *table; table += 2) { | 1542 | for (table = suffixTable; *table; table += 2) { |
1556 | try_suffix = strstr(table[0], suffix); | 1543 | try_suffix = strstr(table[0], suffix); |
1557 | if (try_suffix) { | 1544 | if (try_suffix) { |
@@ -1562,30 +1549,12 @@ static void send_file_and_exit(const char *url, int what) | |||
1562 | } | 1549 | } |
1563 | } | 1550 | } |
1564 | } | 1551 | } |
1565 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES | ||
1566 | for (cur = mime_a; cur; cur = cur->next) { | 1552 | for (cur = mime_a; cur; cur = cur->next) { |
1567 | if (strcmp(cur->before_colon, suffix) == 0) { | 1553 | if (strcmp(cur->before_colon, suffix) == 0) { |
1568 | found_mime_type = cur->after_colon; | 1554 | found_mime_type = cur->after_colon; |
1569 | break; | 1555 | break; |
1570 | } | 1556 | } |
1571 | } | 1557 | } |
1572 | #endif | ||
1573 | } | ||
1574 | |||
1575 | if (DEBUG) | ||
1576 | bb_error_msg("sending file '%s' content-type: %s", | ||
1577 | url, found_mime_type); | ||
1578 | |||
1579 | f = open(url, O_RDONLY); | ||
1580 | if (f < 0) { | ||
1581 | if (DEBUG) | ||
1582 | bb_perror_msg("can't open '%s'", url); | ||
1583 | /* Error pages are sent by using send_file_and_exit(SEND_BODY). | ||
1584 | * IOW: it is unsafe to call send_headers_and_exit | ||
1585 | * if what is SEND_BODY! Can recurse! */ | ||
1586 | if (what != SEND_BODY) | ||
1587 | send_headers_and_exit(HTTP_NOT_FOUND); | ||
1588 | log_and_exit(); | ||
1589 | } | 1558 | } |
1590 | #if ENABLE_FEATURE_HTTPD_RANGES | 1559 | #if ENABLE_FEATURE_HTTPD_RANGES |
1591 | if (what == SEND_BODY) | 1560 | if (what == SEND_BODY) |
@@ -1596,9 +1565,9 @@ static void send_file_and_exit(const char *url, int what) | |||
1596 | range_end = file_size - 1; | 1565 | range_end = file_size - 1; |
1597 | } | 1566 | } |
1598 | if (range_end < range_start | 1567 | if (range_end < range_start |
1599 | || lseek(f, range_start, SEEK_SET) != range_start | 1568 | || lseek(fd, range_start, SEEK_SET) != range_start |
1600 | ) { | 1569 | ) { |
1601 | lseek(f, 0, SEEK_SET); | 1570 | lseek(fd, 0, SEEK_SET); |
1602 | range_start = 0; | 1571 | range_start = 0; |
1603 | } else { | 1572 | } else { |
1604 | range_len = range_end - range_start + 1; | 1573 | range_len = range_end - range_start + 1; |
@@ -1607,43 +1576,42 @@ static void send_file_and_exit(const char *url, int what) | |||
1607 | } | 1576 | } |
1608 | } | 1577 | } |
1609 | #endif | 1578 | #endif |
1610 | |||
1611 | if (what & SEND_HEADERS) | 1579 | if (what & SEND_HEADERS) |
1612 | send_headers(HTTP_OK); | 1580 | send_headers(HTTP_OK); |
1613 | |||
1614 | #if ENABLE_FEATURE_HTTPD_USE_SENDFILE | 1581 | #if ENABLE_FEATURE_HTTPD_USE_SENDFILE |
1615 | offset = range_start; | 1582 | { |
1616 | do { | 1583 | off_t offset = range_start; |
1617 | /* sz is rounded down to 64k */ | 1584 | while (1) { |
1618 | ssize_t sz = MAXINT(ssize_t) - 0xffff; | 1585 | /* sz is rounded down to 64k */ |
1619 | USE_FEATURE_HTTPD_RANGES(if (sz > range_len) sz = range_len;) | 1586 | ssize_t sz = MAXINT(ssize_t) - 0xffff; |
1620 | count = sendfile(1, f, &offset, sz); | 1587 | USE_FEATURE_HTTPD_RANGES(if (sz > range_len) sz = range_len;) |
1621 | if (count < 0) { | 1588 | count = sendfile(STDOUT_FILENO, fd, &offset, sz); |
1622 | if (offset == range_start) | 1589 | if (count < 0) { |
1623 | goto fallback; | 1590 | if (offset == range_start) |
1624 | goto fin; | 1591 | break; /* fall back to read/write loop */ |
1592 | goto fin; | ||
1593 | } | ||
1594 | USE_FEATURE_HTTPD_RANGES(range_len -= sz;) | ||
1595 | if (count == 0 || range_len == 0) | ||
1596 | log_and_exit(); | ||
1625 | } | 1597 | } |
1626 | USE_FEATURE_HTTPD_RANGES(range_len -= sz;) | 1598 | } |
1627 | } while (count > 0 && range_len); | ||
1628 | log_and_exit(); | ||
1629 | |||
1630 | fallback: | ||
1631 | #endif | 1599 | #endif |
1632 | while ((count = safe_read(f, iobuf, IOBUF_SIZE)) > 0) { | 1600 | while ((count = safe_read(fd, iobuf, IOBUF_SIZE)) > 0) { |
1633 | ssize_t n; | 1601 | ssize_t n; |
1634 | USE_FEATURE_HTTPD_RANGES(if (count > range_len) count = range_len;) | 1602 | USE_FEATURE_HTTPD_RANGES(if (count > range_len) count = range_len;) |
1635 | n = full_write(STDOUT_FILENO, iobuf, count); | 1603 | n = full_write(STDOUT_FILENO, iobuf, count); |
1636 | if (count != n) | 1604 | if (count != n) |
1637 | break; | 1605 | break; |
1638 | USE_FEATURE_HTTPD_RANGES(range_len -= count;) | 1606 | USE_FEATURE_HTTPD_RANGES(range_len -= count;) |
1639 | if (!range_len) | 1607 | if (range_len == 0) |
1640 | break; | 1608 | break; |
1641 | } | 1609 | } |
1642 | #if ENABLE_FEATURE_HTTPD_USE_SENDFILE | 1610 | if (count < 0) { |
1643 | fin: | 1611 | USE_FEATURE_HTTPD_USE_SENDFILE(fin:) |
1644 | #endif | 1612 | if (verbose > 1) |
1645 | if (count < 0 && verbose > 1) | 1613 | bb_perror_msg("error"); |
1646 | bb_perror_msg("error"); | 1614 | } |
1647 | log_and_exit(); | 1615 | log_and_exit(); |
1648 | } | 1616 | } |
1649 | 1617 | ||
@@ -2199,10 +2167,8 @@ static void mini_httpd(int server_socket) | |||
2199 | 2167 | ||
2200 | if (fork() == 0) { | 2168 | if (fork() == 0) { |
2201 | /* child */ | 2169 | /* child */ |
2202 | #if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP | ||
2203 | /* Do not reload config on HUP */ | 2170 | /* Do not reload config on HUP */ |
2204 | signal(SIGHUP, SIG_IGN); | 2171 | signal(SIGHUP, SIG_IGN); |
2205 | #endif | ||
2206 | close(server_socket); | 2172 | close(server_socket); |
2207 | xmove_fd(n, 0); | 2173 | xmove_fd(n, 0); |
2208 | xdup2(0, 1); | 2174 | xdup2(0, 1); |
@@ -2244,10 +2210,8 @@ static void mini_httpd_nommu(int server_socket, int argc, char **argv) | |||
2244 | 2210 | ||
2245 | if (vfork() == 0) { | 2211 | if (vfork() == 0) { |
2246 | /* child */ | 2212 | /* child */ |
2247 | #if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP | ||
2248 | /* Do not reload config on HUP */ | 2213 | /* Do not reload config on HUP */ |
2249 | signal(SIGHUP, SIG_IGN); | 2214 | signal(SIGHUP, SIG_IGN); |
2250 | #endif | ||
2251 | close(server_socket); | 2215 | close(server_socket); |
2252 | xmove_fd(n, 0); | 2216 | xmove_fd(n, 0); |
2253 | xdup2(0, 1); | 2217 | xdup2(0, 1); |
@@ -2278,13 +2242,10 @@ static void mini_httpd_inetd(void) | |||
2278 | handle_incoming_and_exit(&fromAddr); | 2242 | handle_incoming_and_exit(&fromAddr); |
2279 | } | 2243 | } |
2280 | 2244 | ||
2281 | #if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP | 2245 | static void sighup_handler(int sig UNUSED_PARAM) |
2282 | static void sighup_handler(int sig) | ||
2283 | { | 2246 | { |
2284 | parse_conf(default_path_httpd_conf, sig ? SIGNALED_PARSE : FIRST_PARSE); | 2247 | parse_conf(default_path_httpd_conf, SIGNALED_PARSE); |
2285 | signal_SA_RESTART_empty_mask(SIGHUP, sighup_handler); | ||
2286 | } | 2248 | } |
2287 | #endif | ||
2288 | 2249 | ||
2289 | enum { | 2250 | enum { |
2290 | c_opt_config_file = 0, | 2251 | c_opt_config_file = 0, |
@@ -2395,7 +2356,7 @@ int httpd_main(int argc UNUSED_PARAM, char **argv) | |||
2395 | #endif | 2356 | #endif |
2396 | } | 2357 | } |
2397 | 2358 | ||
2398 | #if 0 /*was #if ENABLE_FEATURE_HTTPD_CGI*/ | 2359 | #if 0 |
2399 | /* User can do it himself: 'env - PATH="$PATH" httpd' | 2360 | /* User can do it himself: 'env - PATH="$PATH" httpd' |
2400 | * We don't do it because we don't want to screw users | 2361 | * We don't do it because we don't want to screw users |
2401 | * which want to do | 2362 | * which want to do |
@@ -2413,15 +2374,9 @@ int httpd_main(int argc UNUSED_PARAM, char **argv) | |||
2413 | } | 2374 | } |
2414 | #endif | 2375 | #endif |
2415 | 2376 | ||
2416 | #if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP | 2377 | parse_conf(default_path_httpd_conf, FIRST_PARSE); |
2417 | if (!(opt & OPT_INETD)) { | 2378 | if (!(opt & OPT_INETD)) |
2418 | /* runs parse_conf() inside */ | 2379 | signal(SIGHUP, sighup_handler); |
2419 | sighup_handler(0); | ||
2420 | } else | ||
2421 | #endif | ||
2422 | { | ||
2423 | parse_conf(default_path_httpd_conf, FIRST_PARSE); | ||
2424 | } | ||
2425 | 2380 | ||
2426 | xfunc_error_retval = 0; | 2381 | xfunc_error_retval = 0; |
2427 | if (opt & OPT_INETD) | 2382 | if (opt & OPT_INETD) |
diff --git a/scripts/defconfig b/scripts/defconfig index b8b8c575e..6bf1a4a28 100644 --- a/scripts/defconfig +++ b/scripts/defconfig | |||
@@ -632,11 +632,9 @@ CONFIG_HOSTNAME=y | |||
632 | CONFIG_HTTPD=y | 632 | CONFIG_HTTPD=y |
633 | CONFIG_FEATURE_HTTPD_RANGES=y | 633 | CONFIG_FEATURE_HTTPD_RANGES=y |
634 | CONFIG_FEATURE_HTTPD_USE_SENDFILE=y | 634 | CONFIG_FEATURE_HTTPD_USE_SENDFILE=y |
635 | CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP=y | ||
636 | CONFIG_FEATURE_HTTPD_SETUID=y | 635 | CONFIG_FEATURE_HTTPD_SETUID=y |
637 | CONFIG_FEATURE_HTTPD_BASIC_AUTH=y | 636 | CONFIG_FEATURE_HTTPD_BASIC_AUTH=y |
638 | CONFIG_FEATURE_HTTPD_AUTH_MD5=y | 637 | CONFIG_FEATURE_HTTPD_AUTH_MD5=y |
639 | CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES=y | ||
640 | CONFIG_FEATURE_HTTPD_CGI=y | 638 | CONFIG_FEATURE_HTTPD_CGI=y |
641 | CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y | 639 | CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y |
642 | CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y | 640 | CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y |