Dolda2000 GitWeb
/
ashd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
accesslog: Use bufio for filtering instead of stdio.
[ashd.git]
/
src
/
accesslog.c
diff --git
a/src/accesslog.c
b/src/accesslog.c
index
a3894bf
..
7328c4d
100644
(file)
--- a/
src/accesslog.c
+++ b/
src/accesslog.c
@@
-39,6
+39,7
@@
#include <proc.h>
#include <mt.h>
#include <mtio.h>
#include <proc.h>
#include <mt.h>
#include <mtio.h>
+#include <bufio.h>
#define DEFFORMAT "%{%Y-%m-%d %H:%M:%S}t %m %u %A \"%G\""
#define DEFFORMAT "%{%Y-%m-%d %H:%M:%S}t %m %u %A \"%G\""
@@
-215,20
+216,18
@@
static void serve(struct hthead *req, int fd)
logreq(&data);
}
logreq(&data);
}
-static int passdata(
FILE *in, FILE
*out, off_t *passed)
+static int passdata(
struct bufio *in, struct bufio
*out, off_t *passed)
{
{
- size_t read;
+ s
s
ize_t read;
off_t total;
off_t total;
- char buf[8192];
total = 0;
total = 0;
- while(!feof(in)) {
- read = fread(buf, 1, sizeof(buf), in);
- if(ferror(in))
- return(-1);
- if(fwrite(buf, 1, read, out) != read)
+ while(!bioeof(in)) {
+ if((read = biocopysome(out, in)) < 0)
return(-1);
total += read;
return(-1);
total += read;
+ if(biorspace(in) && (biofillsome(in) < 0))
+ return(-1);
}
if(passed)
*passed = total;
}
if(passed)
*passed = total;
@@
-241,7
+240,7
@@
static void filterreq(struct muth *mt, va_list args)
vavar(int, fd);
int pfds[2];
struct hthead *resp;
vavar(int, fd);
int pfds[2];
struct hthead *resp;
-
FILE
*cl, *hd;
+
struct bufio
*cl, *hd;
struct logdata data;
hd = NULL;
struct logdata data;
hd = NULL;
@@
-249,10
+248,10
@@
static void filterreq(struct muth *mt, va_list args)
data = defdata;
data.req = req;
gettimeofday(&data.start, NULL);
data = defdata;
data.req = req;
gettimeofday(&data.start, NULL);
- cl = mt
std
open(fd, 1, 600, "r+", NULL);
+ cl = mt
bio
open(fd, 1, 600, "r+", NULL);
if(socketpair(PF_UNIX, SOCK_STREAM, 0, pfds))
goto out;
if(socketpair(PF_UNIX, SOCK_STREAM, 0, pfds))
goto out;
- hd = mt
std
open(pfds[1], 1, 600, "r+", NULL);
+ hd = mt
bio
open(pfds[1], 1, 600, "r+", NULL);
if(sendreq(ch, req, pfds[0])) {
close(pfds[0]);
goto out;
if(sendreq(ch, req, pfds[0])) {
close(pfds[0]);
goto out;
@@
-261,14
+260,14
@@
static void filterreq(struct muth *mt, va_list args)
if(passdata(cl, hd, &data.bytesin))
goto out;
if(passdata(cl, hd, &data.bytesin))
goto out;
- if(
f
flush(hd))
+ if(
bio
flush(hd))
goto out;
shutdown(pfds[1], SHUT_WR);
goto out;
shutdown(pfds[1], SHUT_WR);
- if((resp = parseresponse(hd)) == NULL)
+ if((resp = parseresponse
b
(hd)) == NULL)
goto out;
data.resp = resp;
goto out;
data.resp = resp;
- writeresp(cl, resp);
-
f
printf(cl, "\r\n");
+ writeresp
b
(cl, resp);
+
bio
printf(cl, "\r\n");
if(passdata(hd, cl, &data.bytesout))
goto out;
gettimeofday(&data.end, NULL);
if(passdata(hd, cl, &data.bytesout))
goto out;
gettimeofday(&data.end, NULL);
@@
-279,9
+278,9
@@
out:
freehthead(req);
if(resp != NULL)
freehthead(resp);
freehthead(req);
if(resp != NULL)
freehthead(resp);
-
f
close(cl);
+
bio
close(cl);
if(hd != NULL)
if(hd != NULL)
-
f
close(hd);
+
bio
close(hd);
}
static void sighandler(int sig)
}
static void sighandler(int sig)