- if (!start_time.tv_sec) {
- gettimeofday(&now, NULL);
- start_time.tv_sec = now.tv_sec;
- start_time.tv_usec = now.tv_usec;
- start_ofs = ofs;
- if (am_server)
- return;
+ if (am_server)
+ return;
+
+#if HAVE_GETPGRP && HAVE_TCGETPGRP
+ if (pgrp == -1) {
+# if GETPGRP_VOID
+ pgrp = getpgrp();
+# else
+ pgrp = getpgrp(0);
+# endif
+ }
+#endif
+
+ gettimeofday(&now, NULL);
+
+ if (!ph_start.time.tv_sec) {
+ int i;
+
+ /* Try to guess the real starting time when the sender started
+ * to send us data by using the time we last received some data
+ * in the last file (if it was recent enough). */
+ if (msdiff(&ph_list[newest_hpos].time, &now) <= 1500) {
+ ph_start.time = ph_list[newest_hpos].time;
+ ph_start.ofs = 0;
+ } else {
+ ph_start.time.tv_sec = now.tv_sec;
+ ph_start.time.tv_usec = now.tv_usec;
+ ph_start.ofs = ofs;
+ }
+
+ for (i = 0; i < PROGRESS_HISTORY_SECS; i++)
+ ph_list[i] = ph_start;