diff options
author | Denis Vlasenko | 2007-01-14 17:06:11 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-01-14 17:06:11 +0000 |
commit | b64eed6030d955ac6e4c3c653a923cf6535799c1 (patch) | |
tree | 92a7b88794f22cb10aed7d59e6598da7688ccabc | |
parent | d1a6e8d320633d5981a1dc7866d8e06aaad34dc1 (diff) | |
download | busybox-b64eed6030d955ac6e4c3c653a923cf6535799c1.zip busybox-b64eed6030d955ac6e4c3c653a923cf6535799c1.tar.gz |
httpd: use fd#1 in inetd mode
inetd: micro style fix
-rw-r--r-- | networking/httpd.c | 14 | ||||
-rw-r--r-- | networking/inetd.c | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index f877368..d14b113 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -846,7 +846,7 @@ static int sendHeaders(HttpResponseNum responseNum) const char *responseString = ""; const char *infoString = 0; const char *mime_type; - unsigned int i; + unsigned i; time_t timer = time(0); char timeStr[80]; int len; @@ -901,7 +901,9 @@ static int sendHeaders(HttpResponseNum responseNum) } if (DEBUG) fprintf(stderr, "headers: '%s'\n", buf); - return full_write(config->accepted_socket, buf, len); + i = config->accepted_socket; + if (i == 0) i++; /* write to fd# 1 in inetd mode */ + return full_write(i, buf, len); } /**************************************************************************** @@ -1302,7 +1304,9 @@ static int sendFile(const char *url) sendHeaders(HTTP_OK); /* TODO: sendfile() */ while ((count = full_read(f, buf, MAX_MEMORY_BUFF)) > 0) { - if (full_write(config->accepted_socket, buf, count) != count) + int fd = config->accepted_socket; + if (fd == 0) fd++; /* write to fd# 1 in inetd mode */ + if (full_write(fd, buf, count) != count) break; } close(f); @@ -1321,8 +1325,10 @@ static int checkPermIP(void) /* This could stand some work */ for (cur = config->ip_a_d; cur; cur = cur->next) { -#if DEBUG +#if ENABLE_FEATURE_HTTPD_CGI && DEBUG fprintf(stderr, "checkPermIP: '%s' ? ", config->rmt_ip_str); +#endif +#if DEBUG fprintf(stderr, "'%u.%u.%u.%u/%u.%u.%u.%u'\n", (unsigned char)(cur->ip >> 24), (unsigned char)(cur->ip >> 16), diff --git a/networking/inetd.c b/networking/inetd.c index 3cf7b2d..370dcbb 100644 --- a/networking/inetd.c +++ b/networking/inetd.c @@ -1470,7 +1470,7 @@ inetd_main(int argc, char *argv[]) (*sep->se_bi->bi_fn)(ctrl, sep); } else #endif - { + { pwd = getpwnam(sep->se_user); if (pwd == NULL) { bb_error_msg("getpwnam: %s: no such user", sep->se_user); |