Professional Documents
Culture Documents
20 源码分析
7 Chunk.c 源码分析
7.1 chunk 数据结构体定义
chunk 结构体内指定了两种块类型,一种是 MEM_CHUNK,一种是 FILE_CHUNK,对
于各自块类型给出了相应的数据保存结构字段。另外有个 next 字段可以将各个 chunk 结构
体连接起来组成链表。
buffer *mem; /* either the storage of the mem-chunk or the read-ahead buffer */
struct {
/* filechunk */
buffer *name; /* name of the file */
off_t start; /* starting offset in the file */
/*从 start 开始需要发送的字节数目*/
off_t length; /* octets to send from the starting offset *//*octet 就是 byte*/
int fd;
struct {
char *start; /* the start pointer of the mmap'ed area */
size_t length; /* size of the mmap'ed area */
off_t offset; /* start is <n> octet away from the start of the file */
} mmap;
typedef struct {
chunk *first;
chunk *last;
chunk *unused;
size_t unused_chunks;
array *tempdirs;