Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions berthad-vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ static void conn_put_free(BProgram* prog, GList* lhconn)
BConnPut* data = conn->state_data;
if (data->checksum)
g_checksum_free(data->checksum);
if (data->fd)
if (data->fd != -1)
close (data->fd);
if (data->tmp_fn) {
unlink(data->tmp_fn->str);
Expand All @@ -589,7 +589,7 @@ static void conn_get_free(BProgram* prog, GList* lhconn)
{
BConn* conn = lhconn->data;
BConnGet* data = conn->state_data;
if (data->fd)
if (data->fd != -1)
close(data->fd);
#ifdef USE_SPLICE
if (data->pipe[0])
Expand Down Expand Up @@ -1019,8 +1019,11 @@ static inline void conn_get_handle__sendfile(BProgram* prog, GList* lhconn)
/* Socket buffers are full */
data->socket_ready = FALSE;
} else if(errno == EBUSY) {
char cbuf;
/* File buffers are depleted */
data->file_ready = FALSE;
/* Trigger the kernel to read from the disk */
res = read(data->fd, &cbuf, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is blocking, right? Would a async read do it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 740 marks the file as non-blocking.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A, right :).

} else {
perror("sendfile");
g_error("Sendfile failed?!\n");
Expand All @@ -1035,7 +1038,9 @@ static inline void conn_get_handle__sendfile(BProgram* prog, GList* lhconn)
/* We're done! */
shutdown(conn->sock, SHUT_RDWR);
conn_close(prog, lhconn);
return;
}
lseek(data->fd, data->n_sent, SEEK_SET);
}
#endif /* USE_SENDFILE */

Expand Down Expand Up @@ -1296,7 +1301,7 @@ static void conn_put_handle(BProgram* prog, GList* lhconn)

/* Close the file descriptor */
close(data->fd);
data->fd = 0;
data->fd = -1;

/* Get the final key */
g_checksum_get_digest(data->checksum, key, &len);
Expand Down