Commit e0d4b063 authored by Andrey Filippov's avatar Andrey Filippov

Added sendvile64() limit of 620756992 (0x25000000) bytes failed and did not continus if more)

parent 6190b834
......@@ -39,6 +39,8 @@
#include <sys/reboot.h>
// sendfile64 failed at this size: //620756992='0x25000000'
#define MAX_SENDFILE_SIZE 620756992
// change to 0 when done
#define ELPHEL_DEBUG 0
......@@ -2152,7 +2154,7 @@ void listener_loop(struct file_set *fset)
int tiff_bin_shift = 3; // histogram bin size is 1<<3 == 8
int tiff_bin = 1;
int tiff_auto = -1;
long long ssd_offs_byte, ssd_count_bytes, ssd_sent_bytes; //, ssd_set_byte;
long long ssd_offs_byte, ssd_count_bytes, ssd_sent_bytes, ssd_limited_count; //, ssd_set_byte;
// imgsrv -p 2323 -s /dev/sda2
// int bin_shift, // binsize = 1 << bin_shift
......@@ -2244,7 +2246,9 @@ void listener_loop(struct file_set *fset)
//STDOUT_FILENO
//ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
fprintf(stderr, "Sending %lld bytes, offs=%lld\n", ssd_count_bytes, ssd_offs_byte);
#if 0
// not updated with MAX_SENDFILE_SIZE
ssd_offs_byte=lseek64(fset->ssd_fd, ssd_offs_byte, SEEK_SET);
fprintf(stderr, "lseek64()-> %lld, STDOUT_FILENO=%d, errno=%d\n", ssd_offs_byte, STDOUT_FILENO, errno);
while (ssd_count_bytes > 0) {
......@@ -2260,8 +2264,13 @@ void listener_loop(struct file_set *fset)
ssd_count_bytes -= ssd_sent_bytes;
}
#else
//MAX_SENDFILE_SIZE
while (ssd_count_bytes > 0) {
ssd_sent_bytes = sendfile64(STDOUT_FILENO, fset->ssd_fd, &ssd_offs_byte, ssd_count_bytes);
ssd_limited_count = ssd_count_bytes;
if (ssd_limited_count > MAX_SENDFILE_SIZE) {
ssd_limited_count = MAX_SENDFILE_SIZE;
}
ssd_sent_bytes = sendfile64(STDOUT_FILENO, fset->ssd_fd, &ssd_offs_byte, ssd_limited_count);
if (ssd_sent_bytes <= 0){
fprintf(stderr, "sendfile64() failed: sent %lld bytes (wanted %lld), offs=%lld, errno=%d\n", \
ssd_sent_bytes, ssd_count_bytes, ssd_offs_byte, errno);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment