MCPcopy Index your code
hub / github.com/RsyncProject/rsync / receive_sums

Function receive_sums

sender.c:73–129  ·  view source on GitHub ↗

* Receive the checksums for a buffer **/

Source from the content-addressed store, hash-verified

71 * Receive the checksums for a buffer
72 **/
73static struct sum_struct *receive_sums(int f)
74{
75 struct sum_struct *s = new(struct sum_struct);
76 int lull_mod = protocol_version >= 31 ? 0 : allowed_lull * 5;
77 OFF_T offset = 0;
78 int32 i;
79
80 read_sum_head(f, s);
81
82 s->sums = NULL;
83
84 if (DEBUG_GTE(DELTASUM, 3)) {
85 rprintf(FINFO, "count=%s n=%ld rem=%ld\n",
86 big_num(s->count), (long)s->blength, (long)s->remainder);
87 }
88
89 if (append_mode > 0) {
90 s->flength = (OFF_T)s->count * s->blength;
91 if (s->remainder)
92 s->flength -= s->blength - s->remainder;
93 return s;
94 }
95
96 if (s->count == 0)
97 return(s);
98
99 s->sums = new_array(struct sum_buf, s->count);
100 s->sum2_array = new_array(char, (size_t)s->count * xfer_sum_len);
101
102 for (i = 0; i < s->count; i++) {
103 s->sums[i].sum1 = read_int(f);
104 read_buf(f, sum2_at(s, i), s->s2length);
105
106 s->sums[i].offset = offset;
107 s->sums[i].flags = 0;
108
109 if (i == s->count-1 && s->remainder != 0)
110 s->sums[i].len = s->remainder;
111 else
112 s->sums[i].len = s->blength;
113 offset += s->sums[i].len;
114
115 if (lull_mod && !(i % lull_mod))
116 maybe_send_keepalive(time(NULL), True);
117
118 if (DEBUG_GTE(DELTASUM, 3)) {
119 rprintf(FINFO,
120 "chunk[%d] len=%d offset=%s sum1=%08x\n",
121 i, s->sums[i].len, big_num(s->sums[i].offset),
122 s->sums[i].sum1);
123 }
124 }
125
126 s->flength = offset;
127
128 return s;
129}
130

Callers 1

send_filesFunction · 0.85

Calls 6

read_sum_headFunction · 0.85
big_numFunction · 0.85
read_intFunction · 0.85
maybe_send_keepaliveFunction · 0.85
rprintfFunction · 0.70
read_bufFunction · 0.70

Tested by

no test coverage detected