Skip to content

Commit

Permalink
Wow, dumb bug. Been there for a long time!
Browse files Browse the repository at this point in the history
Only added for Linux in this commit because the changes for Akaros are
more substantial (I didn't even have the loop in there!).
  • Loading branch information
klueska committed Mar 27, 2015
1 parent 9d9d633 commit 5d4b8da
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion kweb.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void http_server(struct kqueue *q, struct kitem *__c);
void init_connection(struct http_connection *c);
void destroy_connection(struct http_connection *c);
ssize_t timed_read(struct http_connection *c, void *buf, size_t count);
ssize_t timed_write(struct http_connection *c, const void *buf, size_t count);
ssize_t timed_write(struct http_connection *c, const char *buf, size_t count);
void dispatch_call(int call_fd, void *client_addr);

#ifndef DEBUG
Expand Down
4 changes: 2 additions & 2 deletions linux-custom-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ ssize_t timed_read(struct http_connection *c, void *buf, size_t count)
return ret;
}

ssize_t timed_write(struct http_connection *c, const void *buf, size_t count)
ssize_t timed_write(struct http_connection *c, const char *buf, size_t count)
{
int ret = 0;
int remaining = count;
while(remaining > 0) {
set_syscall_timeout(KWEB_SREAD_TIMEOUT * 1000);
ret = write(c->socketfd, buf, remaining);
ret = write(c->socketfd, &buf[count-remaining], remaining);
if(ret < 0)
return ret;
remaining -= ret;
Expand Down
5 changes: 3 additions & 2 deletions linux-upthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ ssize_t timed_read(struct http_connection *c, void *buf, size_t count)
return ret;
}

ssize_t timed_write(struct http_connection *c, const void *buf, size_t count)
ssize_t timed_write(struct http_connection *c, const char *buf, size_t count)
{
int ret = 0;
int remaining = count;
while(remaining > 0) {
tpool_inform_blocking(&tpool);
ret = write(c->socketfd, buf, remaining);
set_syscall_timeout(KWEB_SREAD_TIMEOUT * 1000);
ret = write(c->socketfd, &buf[count-remaining], remaining);
tpool_inform_unblocked(&tpool);
if(ret < 0)
return ret;
Expand Down
4 changes: 2 additions & 2 deletions linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ ssize_t timed_read(struct http_connection *c, void *buf, size_t count)
return read(c->socketfd, buf, count);
}

ssize_t timed_write(struct http_connection *c, const void *buf, size_t count)
ssize_t timed_write(struct http_connection *c, const char *buf, size_t count)
{
int ret = 0;
int remaining = count;
Expand All @@ -94,7 +94,7 @@ ssize_t timed_write(struct http_connection *c, const void *buf, size_t count)
tpool_inform_blocking(&tpool);
epoll_wait(c->epollwfd, &event, 1, KWEB_SWRITE_TIMEOUT);
tpool_inform_unblocked(&tpool);
ret = write(c->socketfd, buf, remaining);
ret = write(c->socketfd, &buf[count-remaining], remaining);
if(ret < 0)
return ret;
remaining -= ret;
Expand Down

0 comments on commit 5d4b8da

Please sign in to comment.