Skip to content

Commit c37d3b0

Browse files
committed
Add empty function for recvfile and fix sendfile
1 parent 2bacb0c commit c37d3b0

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/recv_buffer.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ int recv_buffer_read(char *data, int len)
1717
{
1818
return buffer_read(&buffer, data, len);
1919
}
20+
21+
int64_t recv_file_buffer_read(int fd, int64_t *offset, int64_t size, int64_t blocksize)
22+
{
23+
/* TODO: implement this */
24+
return 0;
25+
}

src/send_buffer.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ int64_t send_file_buffer_write(int fd, int64_t offset, int64_t size, int64_t blo
7676

7777
packet_t packet;
7878

79-
off_t pos;
8079
int retval;
8180
int seqnum;
8281
char buffer[PACKET_DATA_SIZE];
8382
int boundary;
8483
int len;
8584

86-
pos = offset;
87-
retval = size;
85+
retval = 0;
8886
seqnum = 2142894844; /* TODO: generate random number */
8987
boundary = PACKET_BOUNDARY_START;
9088

@@ -93,6 +91,8 @@ int64_t send_file_buffer_write(int fd, int64_t offset, int64_t size, int64_t blo
9391
while (size > 0)
9492
{
9593
len = pread(fd, buffer, PACKET_DATA_SIZE, offset);
94+
if (len < 0) break;
95+
retval += len;
9696
size -= len;
9797

9898
boundary |= (size > 0) ? PACKET_BOUNDARY_NONE : PACKET_BOUNDARY_END;
@@ -111,7 +111,7 @@ int64_t send_file_buffer_write(int fd, int64_t offset, int64_t size, int64_t blo
111111

112112
boundary = PACKET_BOUNDARY_NONE;
113113

114-
pos += blocksize;
114+
offset += len;
115115
}
116116

117117
packet_clear_header (packet);
@@ -123,5 +123,5 @@ int64_t send_file_buffer_write(int fd, int64_t offset, int64_t size, int64_t blo
123123
packet_new(&packet, NULL, 0);
124124
send_packet_buffer_write(&packet);
125125

126-
return retval; /* return total bytes sent */
126+
return retval;
127127
}

0 commit comments

Comments
 (0)