2

I am developing a program by read data from disk and sent to network socket.

I use memfd_create() to create a memory file as buffer and get the mem_fd, use ftruncate() to set the file size, and mmap() to map the buffer address buf.

The program repeatedly read data into buf, and sent mem_fd using sendfile(). When sendfile() call returns, the return value is checked (it says all data has been sent), then new data starts overwrite into buf.

But I found the data may be wrong sometimes, it looks like sendfile() sending the overwritten data rather than the old data.

ivan_wl
  • 51
  • 5
  • I found this article https://systemsnotes.wordpress.com/2013/03/24/sendfile-on-memory-mapped-files/ – ivan_wl Feb 11 '22 at 10:03

0 Answers0