summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buffer_handler.c4
-rw-r--r--src/file_service.c10
2 files changed, 9 insertions, 5 deletions
diff --git a/src/buffer_handler.c b/src/buffer_handler.c
index ea35e84..2c5493c 100644
--- a/src/buffer_handler.c
+++ b/src/buffer_handler.c
@@ -1332,6 +1332,7 @@ static inline struct buffer *raw_open_file(const char *filename)
struct buffer *buffer;
int fd;
off_t off;
+ int ret;
fd = open(filename, O_RDONLY);
if (fd < 0) {
@@ -1373,7 +1374,8 @@ static inline struct buffer *raw_open_file(const char *filename)
buffer->refcnt = 0;
buffer->info = (void *)off;
- if (read(fd, buffer->data, off) < 0) {
+ ret = read(fd, buffer->data, off);
+ if (ret < 0) {
ErrPrint("read: %s\n", strerror(errno));
free(buffer);
diff --git a/src/file_service.c b/src/file_service.c
index 15c2304..eabf755 100644
--- a/src/file_service.c
+++ b/src/file_service.c
@@ -120,6 +120,8 @@ static inline struct request_item *create_request_item(struct tcb *tcb, int type
item->data.shm = (int)data;
break;
default:
+ ErrPrint("Invalid type of request\n");
+ free(item);
return NULL;
}
@@ -398,14 +400,10 @@ static int send_file(int handle, const struct request_item *item)
while (fsize > 0) {
if (fsize > PKT_CHUNKSZ) {
body->size = PKT_CHUNKSZ;
- fsize -= PKT_CHUNKSZ;
} else {
body->size = fsize;
- fsize = 0;
}
- pktsz = sizeof(*body) + body->size;
-
ret = read(fd, body->data, body->size);
if (ret < 0) {
ErrPrint("read: %s\n", strerror(errno));
@@ -413,6 +411,10 @@ static int send_file(int handle, const struct request_item *item)
break;
}
+ body->size = ret;
+ fsize -= ret;
+ pktsz = sizeof(*body) + body->size;
+
/* Send BODY */
ret = com_core_send(handle, (void *)body, pktsz, 2.0f);
if (ret != pktsz) {