Refactor loop inside writedata()
Use for for this stuff.
This commit is contained in:
parent
76834092d7
commit
92b8bc27da
1 changed files with 2 additions and 3 deletions
5
quark.c
5
quark.c
|
@ -95,14 +95,13 @@ static Request req;
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
writedata(const char *buf, size_t buf_len) {
|
writedata(const char *buf, size_t buf_len) {
|
||||||
ssize_t r, offset = 0;
|
ssize_t r, offset;
|
||||||
|
|
||||||
while(offset < buf_len) {
|
for(offset = 0; offset < buf_len; offset += r) {
|
||||||
if((r = write(req.fd, buf + offset, buf_len - offset)) == -1) {
|
if((r = write(req.fd, buf + offset, buf_len - offset)) == -1) {
|
||||||
logerrmsg("client %s closed connection\n", host);
|
logerrmsg("client %s closed connection\n", host);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
offset += r;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue