Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refs #10948. Fully randomize EIT crawl start time.

The deadlocks we've been seeing here should be fixed now, but they
should have been rare to begin with due to randomization of the
EIT Scanning start time. But they were occurring at fairly high
frequency. It turns out we were not applying enough randomness when
there were multiple cards and we were also losing randomness after
the first recording on a tuner finished and we reset the clock.
(cherry picked from commit 0e5d159)
  • Loading branch information...
commit 957c7e20c8b9e2f2bb50a5fc826810c39689db4b 1 parent eb52783
daniel-kristjansson daniel-kristjansson authored stuartm committed

Showing 1 changed file with 22 additions and 14 deletions. Show diff stats Hide diff stats

  1. +22 14 mythtv/libs/libmythtv/tv_rec.cpp
36 mythtv/libs/libmythtv/tv_rec.cpp
@@ -52,7 +52,7 @@ static QString load_profile(QString,void*,RecordingInfo*,RecordingProfile&);
52 52 static int init_jobs(const RecordingInfo *rec, RecordingProfile &profile,
53 53 bool on_host, bool transcode_bfr_comm, bool on_line_comm);
54 54 static void apply_broken_dvb_driver_crc_hack(ChannelBase*, MPEGStreamData*);
55   -
  55 +static int eit_start_rand(uint cardid, int eitTransportTimeout);
56 56
57 57 /** \class TVRec
58 58 * \brief This is the coordinating class of the \ref recorder_subsystem.
@@ -161,7 +161,8 @@ bool TVRec::Init(void)
161 161 gCoreContext->GetNumSetting("AutoTranscodeBeforeAutoCommflag", 0);
162 162 earlyCommFlag = gCoreContext->GetNumSetting("AutoCommflagWhileRecording", 0);
163 163 runJobOnHostOnly = gCoreContext->GetNumSetting("JobsRunOnRecordHost", 0);
164   - eitTransportTimeout=gCoreContext->GetNumSetting("EITTransportTimeout", 5) * 60;
  164 + eitTransportTimeout =
  165 + max(gCoreContext->GetNumSetting("EITTransportTimeout", 5) * 60, 6);
165 166 eitCrawlIdleStart = gCoreContext->GetNumSetting("EITCrawIdleStart", 60);
166 167 audioSampleRateDB = gCoreContext->GetNumSetting("AudioSampleRate");
167 168 overRecordSecNrml = gCoreContext->GetNumSetting("RecordOverTime");
@@ -1034,7 +1035,10 @@ void TVRec::HandleStateChange(void)
1034 1035
1035 1036 eitScanStartTime = QDateTime::currentDateTime();
1036 1037 if (scanner && (internalState == kState_None))
1037   - eitScanStartTime = eitScanStartTime.addSecs(eitCrawlIdleStart);
  1038 + {
  1039 + eitScanStartTime = eitScanStartTime.addSecs(
  1040 + eitCrawlIdleStart + eit_start_rand(cardid, eitTransportTimeout));
  1041 + }
1038 1042 else
1039 1043 eitScanStartTime = eitScanStartTime.addYears(1);
1040 1044 }
@@ -1213,6 +1217,19 @@ static int no_capturecards(uint cardid)
1213 1217 return -1;
1214 1218 }
1215 1219
  1220 +static int eit_start_rand(uint cardid, int eitTransportTimeout)
  1221 +{
  1222 + // randomize start time a bit
  1223 + int timeout = random() % (eitTransportTimeout / 3);
  1224 + // get the number of capture cards and the position of the current card
  1225 + // to distribute the the scan start evenly over eitTransportTimeout
  1226 + int card_pos = no_capturecards(cardid);
  1227 + int no_cards = no_capturecards(0);
  1228 + if (no_cards > 0 && card_pos >= 0)
  1229 + timeout += eitTransportTimeout * card_pos / no_cards;
  1230 + return timeout;
  1231 +}
  1232 +
1216 1233 /// \brief Event handling method, contains event loop.
1217 1234 void TVRec::run(void)
1218 1235 {
@@ -1227,17 +1244,8 @@ void TVRec::run(void)
1227 1244 (dvbOpt.dvb_eitscan || get_use_eit(cardid)))
1228 1245 {
1229 1246 scanner = new EITScanner(cardid);
1230   - uint timeout = eitCrawlIdleStart;
1231   - // get the number of capture cards and the position of the current card
1232   - // to distribute the the scan start evenly over eitTransportTimeout
1233   - int card_pos = no_capturecards(cardid);
1234   - int no_cards = no_capturecards(0);
1235   - if (no_cards > 0 && card_pos >= 0)
1236   - timeout += eitTransportTimeout * card_pos / no_cards;
1237   - else
1238   - timeout += random() % eitTransportTimeout;
1239   -
1240   - eitScanStartTime = eitScanStartTime.addSecs(timeout);
  1247 + eitScanStartTime = eitScanStartTime.addSecs(
  1248 + eitCrawlIdleStart + eit_start_rand(cardid, eitTransportTimeout));
1241 1249 }
1242 1250 else
1243 1251 eitScanStartTime = eitScanStartTime.addYears(1);

0 comments on commit 957c7e2

Please sign in to comment.
Something went wrong with that request. Please try again.