Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cause backend to terminate if requested IP address is unavailable.
This performs a check within mainserver to ensure the the selected IP
addresses that the backend should be available on are detected on the
system, and will otherwise immediately terminate rather than continue to
operate in a potentially inaccessible fashion.
  • Loading branch information
wagnerrp committed Oct 2, 2012
1 parent 1a66ff9 commit cb1e284
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions mythtv/programs/mythbackend/mainserver.cpp
Expand Up @@ -246,6 +246,27 @@ MainServer::MainServer(bool master, int port,

mythserver = new MythServer();
mythserver->setProxy(QNetworkProxy::NoProxy);

// test to make sure listen addresses are available
// no reason to run the backend if the mainserver is not active
QHostAddress config_v4(gCoreContext->GetSetting("BackendServerIP"));
bool v4IsSet = config_v4.isNull() ? false : true;
#if !defined(QT_NO_IPV6)
QHostAddress config_v6(gCoreContext->GetSetting("BackendServerIP6"));
bool v6IsSet = config_v6.isNull() ? false : true;
#endif
QList<QHostAddress> listenAddrs = mythserver->DefaultListen();

if ((v4IsSet && !listenAddrs.contains(config_v4))
#if !defined(QT_NO_IPV6)
|| (v6IsSet && !listenAddrs.contains(config_v6))
#endif
)
{
SetExitCode(GENERIC_EXIT_SOCKET_ERROR, false);
return;
}

if (!mythserver->listen(port))
{
SetExitCode(GENERIC_EXIT_SOCKET_ERROR, false);
Expand Down

0 comments on commit cb1e284

Please sign in to comment.