Ticket #5319: mythtv-5319-require_same_time_zone_settings_on_sbe_and_frontends.patch
File mythtv-5319-require_same_time_zone_settings_on_sbe_and_frontends.patch, 9.7 KB (added by , 16 years ago) |
---|
-
libs/libmythdb/exitcodes.h
old new 10 10 #define GENERIC_EXIT_DB_ERROR 250 11 11 #define GENERIC_EXIT_SOCKET_ERROR 249 12 12 #define GENERIC_EXIT_OPENING_LOGFILE_ERROR 248 13 #define GENERIC_EXIT_UNKNOWN_ERROR 247 14 #define GENERIC_EXIT_EXECL_ERROR 246 15 #define FIXME_BUG__LIBRARY_EXIT_NO_THEME 245 16 #define FIXME_BUG__LIBRARY_EXIT_TFW_FAILED_OPEN 244 17 #define GENERIC_EXIT_START 244 13 #define GENERIC_EXIT_INVALID_TIMEZONE 247 14 #define GENERIC_EXIT_UNKNOWN_ERROR 246 15 #define GENERIC_EXIT_EXECL_ERROR 245 16 #define FIXME_BUG__LIBRARY_EXIT_NO_THEME 244 17 #define FIXME_BUG__LIBRARY_EXIT_TFW_FAILED_OPEN 243 18 #define GENERIC_EXIT_START 243 18 19 #define GENERIC_EXIT_CMD_NOT_FOUND 127 19 20 20 21 // libmyth … … 33 34 #define FRONTEND_EXIT_DB_OUTOFDATE GENERIC_EXIT_DB_OUTOFDATE 34 35 #define FRONTEND_EXIT_DB_ERROR GENERIC_EXIT_DB_ERROR 35 36 37 #define FRONTEND_EXIT_INVALID_TIMEZONE GENERIC_EXIT_INVALID_TIMEZONE 36 38 #define FRONTEND_BUGGY_EXIT_NO_THEME GENERIC_EXIT_NO_THEME 37 39 #define FRONTEND_BUGGY_EXIT_NO_SELECTOR GENERIC_EXIT_START-1 38 40 #define FRONTEND_EXIT_START GENERIC_EXIT_START-1 … … 42 44 #define BACKEND_EXIT_NO_MYTHCONTEXT GENERIC_EXIT_NO_MYTHCONTEXT 43 45 #define BACKEND_EXIT_INVALID_CMDLINE GENERIC_EXIT_INVALID_CMDLINE 44 46 #define BACKEND_EXIT_DB_OUTOFDATE GENERIC_EXIT_DB_OUTOFDATE 47 #define BACKEND_EXIT_INVALID_TIMEZONE GENERIC_EXIT_INVALID_TIMEZONE 45 48 #define BACKEND_EXIT_OPENING_LOGFILE_ERROR GENERIC_EXIT_OPENING_LOGFILE_ERROR 46 49 #define BACKEND_EXIT_NO_CONNECT GENERIC_EXIT_START-1 47 50 #define BACKEND_EXIT_NO_IP_ADDRESS GENERIC_EXIT_START-2 -
programs/mythbackend/main.cpp
old new 782 782 } 783 783 } 784 784 785 if (!checkTimeZone()) 786 { 787 // Check for different time zones, different offsets, different times 788 VERBOSE(VB_IMPORTANT, "The time and/or time zone settings on this " 789 "system do not match those in use on the master backend. " 790 "Please ensure all frontend and backend systems are " 791 "configured to use the same time zone and have the current " 792 "time properly set."); 793 VERBOSE(VB_IMPORTANT, "Unable to run with invalid time settings. " 794 "Exiting."); 795 return BACKEND_EXIT_INVALID_TIMEZONE; 796 } 785 797 if (!UpgradeTVDatabaseSchema(true, true)) 786 798 { 787 799 VERBOSE(VB_IMPORTANT, "Couldn't upgrade database to new schema"); -
programs/mythfrontend/main.cpp
old new 1301 1301 } 1302 1302 setuid(getuid()); 1303 1303 1304 if (!checkTimeZone()) 1305 { 1306 // Check for different time zones, different offsets, different times 1307 VERBOSE(VB_IMPORTANT, "The time and/or time zone settings on this " 1308 "system do not match those in use on the master backend. " 1309 "Please ensure all frontend and backend systems are " 1310 "configured to use the same time zone and have the current " 1311 "time properly set."); 1312 VERBOSE(VB_IMPORTANT, "Unable to run with invalid time settings. " 1313 "Exiting."); 1314 return FRONTEND_EXIT_INVALID_TIMEZONE; 1315 } 1304 1316 if (!UpgradeTVDatabaseSchema(upgradeAllowed)) 1305 1317 { 1306 1318 VERBOSE(VB_IMPORTANT, -
libs/libmyth/util.cpp
old new 349 349 return zone_id; 350 350 } 351 351 352 /** \fn checkTimeZone() 353 * \brief Verifies the time zone settings on this system agree with those 354 * on the master backend 355 */ 356 bool checkTimeZone(void) 357 { 358 if (gContext->IsMasterBackend()) 359 return true; 360 361 QStringList master_settings(QString("QUERY_TIME_ZONE")); 362 if (!gContext->SendReceiveStringList(master_settings)) 363 { 364 VERBOSE(VB_IMPORTANT, "Unable to determine master backend time zone " 365 "settings. If those settings differ from local " 366 "settings, some functionality will fail."); 367 return true; 368 } 369 370 bool have_zone_IDs = true; 371 QString master_time_zone_ID = master_settings[0]; 372 QString master_utc_offset = master_settings[1]; 373 QString master_time_string = master_settings[2]; 374 QString local_time_zone_ID = getTimeZoneID(); 375 QString local_utc_offset = format_utc_offset(); 376 QDateTime local_time = mythCurrentDateTime(); 377 378 if (master_time_zone_ID == "UNDEF") 379 { 380 VERBOSE(VB_IMPORTANT, "Unable to determine master backend time zone " 381 "settings. If local time zone settings differ " 382 "from master backend settings, some " 383 "functionality will fail."); 384 have_zone_IDs = false; 385 } 386 if (local_time_zone_ID == "UNDEF") 387 { 388 VERBOSE(VB_IMPORTANT, "Unable to determine local time zone settings. " 389 "If local time zone settings differ from " 390 "master backend settings, some functionality " 391 "will fail."); 392 have_zone_IDs = false; 393 } 394 395 if (have_zone_IDs && (master_time_zone_ID != local_time_zone_ID)) 396 { 397 VERBOSE(VB_IMPORTANT, "Time zone settings on the master backend " 398 "differ from those on this system."); 399 VERBOSE(VB_IMPORTANT, QString("Detected time zone settings:\n" 400 "Zone ID: Master: '%1'. Local: '%2'.\n" 401 "UTC Offset: Master: '%3'. Local: '%4'.\n" 402 "Current Time: Master: '%5'. Local: '%6'") 403 .arg(master_time_zone_ID).arg(local_time_zone_ID) 404 .arg(master_utc_offset).arg(local_utc_offset) 405 .arg(master_time_string).arg(local_time.toString(Qt::ISODate))); 406 return false; 407 } 408 409 // Verify offset 410 if (master_utc_offset == "UNDEF") 411 { 412 VERBOSE(VB_IMPORTANT, "Unable to determine master backend UTC " 413 "offset. If local time zone settings differ " 414 "from master backend settings, some " 415 "functionality will fail."); 416 } 417 else if (master_utc_offset != local_utc_offset) 418 { 419 VERBOSE(VB_IMPORTANT, "UTC offset on the master backend differs " 420 "from offset on this system."); 421 VERBOSE(VB_IMPORTANT, QString("Detected time zone settings:\n" 422 "Zone ID: Master: '%1'. Local: '%2'.\n" 423 "UTC Offset: Master: '%3'. Local: '%4'.\n" 424 "Current Time: Master: '%5'. Local: '%6'") 425 .arg(master_time_zone_ID).arg(local_time_zone_ID) 426 .arg(master_utc_offset).arg(local_utc_offset) 427 .arg(master_time_string).arg(local_time.toString(Qt::ISODate))); 428 return false; 429 } 430 431 // Verify current time 432 if (master_time_string == "UNDEF") 433 { 434 VERBOSE(VB_IMPORTANT, "Unable to determine current time on the master " 435 "backend . If local time or time zone settings " 436 "differ from those on the master backend, some " 437 "functionality will fail."); 438 } 439 else 440 { 441 QDateTime master_time = QDateTime::fromString(master_time_string, 442 Qt::ISODate); 443 if (abs(master_time.secsTo(local_time)) > 300) 444 { 445 VERBOSE(VB_IMPORTANT, "Current time on the master backend " 446 "differs from time on this system."); 447 VERBOSE(VB_IMPORTANT, QString("Detected time zone settings:\n" 448 "Zone ID: Master: '%1'. Local: '%2'.\n" 449 "UTC Offset: Master: '%3'. Local: '%4'.\n" 450 "Current Time: Master: '%5'. Local: '%6'") 451 .arg(master_time_zone_ID).arg(local_time_zone_ID) 452 .arg(master_utc_offset).arg(local_utc_offset) 453 .arg(master_time_string) 454 .arg(local_time.toString(Qt::ISODate))); 455 return false; 456 } 457 } 458 459 return true; 460 } 461 352 462 /** \fn encodeLongLong(QStringList&,long long) 353 463 * \brief Encodes a long for streaming in the MythTV protocol. 354 464 * -
libs/libmyth/util.h
old new 26 26 MPUBLIC int calc_utc_offset(void); 27 27 MPUBLIC QString format_utc_offset(void); 28 28 MPUBLIC QString getTimeZoneID(void); 29 MPUBLIC bool checkTimeZone(void); 29 30 30 31 // This is necessary for GCC 3.3, which has llabs(long long) 31 32 // but not abs(long long) or std::llabs(long long)