aboutsummaryrefslogtreecommitdiff
path: root/networking/httpd_ratelimit_cgi.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2026-01-26 07:15:54 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2026-01-26 07:21:11 +0100
commit28e4d2b854d7072c510f416acd2eea5dcdbc346a (patch)
treeefc0725d3d5b4b0a2808ecdb69ad358195acf34f /networking/httpd_ratelimit_cgi.c
parent4e82d99460d36ab09b651eb90c77e7cd13fb368a (diff)
downloadbusybox-w32-busybox.tar.gz
busybox-w32-busybox.tar.bz2
busybox-w32-busybox.zip
httpd: optimize example CGIsbusybox
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/httpd_ratelimit_cgi.c')
-rw-r--r--networking/httpd_ratelimit_cgi.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/networking/httpd_ratelimit_cgi.c b/networking/httpd_ratelimit_cgi.c
index 96702131e..cadaf5a07 100644
--- a/networking/httpd_ratelimit_cgi.c
+++ b/networking/httpd_ratelimit_cgi.c
@@ -39,31 +39,18 @@ httpd_ratelimit_cgi.c -o httpd_ratelimit_cgi
39#include <sys/stat.h> /* mkdir */ 39#include <sys/stat.h> /* mkdir */
40#include <limits.h> 40#include <limits.h>
41 41
42static ssize_t full_write(int fd, const void *buf, size_t len) 42static void full_write(int fd, const void *buf, size_t len)
43{ 43{
44 ssize_t cc; 44 ssize_t cc;
45 ssize_t total;
46
47 total = 0;
48 45
49 while (len) { 46 while (len) {
50 cc = write(fd, buf, len); 47 cc = write(fd, buf, len);
51 48
52 if (cc < 0) { 49 if (cc < 0)
53 if (total) { 50 return;
54 /* we already wrote some! */
55 /* user can do another write to know the error code */
56 return total;
57 }
58 return cc; /* write() returns -1 on failure. */
59 }
60
61 total += cc;
62 buf = ((const char *)buf) + cc; 51 buf = ((const char *)buf) + cc;
63 len -= cc; 52 len -= cc;
64 } 53 }
65
66 return total;
67} 54}
68 55
69static void full_write2(int fd, const char *msg, const char *msg2) 56static void full_write2(int fd, const char *msg, const char *msg2)