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

Function show_progress

progress.c:182–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182void show_progress(OFF_T ofs, OFF_T size)
183{
184 struct timeval now;
185#if defined HAVE_GETPGRP && defined HAVE_TCGETPGRP
186 static pid_t pgrp = -1;
187 pid_t tc_pgrp;
188#endif
189
190 if (am_server)
191 return;
192
193#if defined HAVE_GETPGRP && defined HAVE_TCGETPGRP
194 if (pgrp == -1)
195 pgrp = getpgrp(GETPGRP_ARG);
196#endif
197
198 gettimeofday(&now, NULL);
199
200 if (INFO_GTE(PROGRESS, 2)) {
201 ofs = stats.total_transferred_size - size + ofs;
202 size = stats.total_size;
203 }
204
205 if (!ph_start.time.tv_sec) {
206 int i;
207
208 /* Try to guess the real starting time when the sender started
209 * to send us data by using the time we last received some data
210 * in the last file (if it was recent enough). */
211 if (msdiff(&ph_list[newest_hpos].time, &now) <= 1500) {
212 ph_start.time = ph_list[newest_hpos].time;
213 ph_start.ofs = 0;
214 } else {
215 ph_start.time.tv_sec = now.tv_sec;
216 ph_start.time.tv_usec = now.tv_usec;
217 ph_start.ofs = ofs;
218 }
219
220 for (i = 0; i < PROGRESS_HISTORY_SECS; i++)
221 ph_list[i] = ph_start;
222 }
223 else {
224 if (msdiff(&ph_list[newest_hpos].time, &now) < 1000)
225 return;
226
227 newest_hpos = oldest_hpos;
228 oldest_hpos = (oldest_hpos + 1) % PROGRESS_HISTORY_SECS;
229 ph_list[newest_hpos].time.tv_sec = now.tv_sec;
230 ph_list[newest_hpos].time.tv_usec = now.tv_usec;
231 ph_list[newest_hpos].ofs = ofs;
232 }
233
234#if defined HAVE_GETPGRP && defined HAVE_TCGETPGRP
235 tc_pgrp = tcgetpgrp(STDOUT_FILENO);
236 if (tc_pgrp != pgrp && tc_pgrp != -1)
237 return;
238#endif
239

Callers 3

matchedFunction · 0.85
match_sumsFunction · 0.85
receive_dataFunction · 0.85

Calls 2

msdiffFunction · 0.85
rprint_progressFunction · 0.85

Tested by

no test coverage detected