Skip to content

Commit

Permalink
Refs #6969. Applies the dbg patch from a couple days ago.
Browse files Browse the repository at this point in the history
This gets rid of the sock->UpRef()/DownRef() on broadcast, this is already done in PlaybackSock, and since we UpRef it a few lines earlier, the MythSocket can not be deleated while we're here. It can get disconnected so we add checks to see if it is still connected before doing a writeStringList.

svn commit -m Refs

git-svn-id: http://svn.mythtv.org/svn/trunk@21721 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
daniel-kristjansson committed Sep 7, 2009
1 parent e3a053c commit eddeeac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
38 changes: 17 additions & 21 deletions mythtv/programs/mythbackend/mainserver.cpp
Expand Up @@ -280,7 +280,6 @@ void MainServer::readyRead(MythSocket *sock)
}
}

QMutexLocker locker(&readReadyLock);
prt->setup(sock);
}

Expand Down Expand Up @@ -856,7 +855,16 @@ void MainServer::customEvent(QEvent *e)

if (!broadcast.empty())
{
QMutexLocker locker(&readReadyLock);
// Make a local copy of the list, upping the refcount as we go..
vector<PlaybackSock *> localPBSList;
sockListLock.lockForRead();
vector<PlaybackSock *>::iterator it = playbackList.begin();
for (; it != playbackList.end(); ++it)
{
(*it)->UpRef();
localPBSList.push_back(*it);
}
sockListLock.unlock();

bool sendGlobal = false;
if (ismaster && broadcast[1].left(7) == "GLOBAL_")
Expand All @@ -870,18 +878,7 @@ void MainServer::customEvent(QEvent *e)

vector<PlaybackSock*> sentSet;

// Make a local copy of the list, upping the refcount as we go..
vector<PlaybackSock *> localPBSList;
sockListLock.lockForRead();
vector<PlaybackSock *>::iterator iter = playbackList.begin();
for (; iter != playbackList.end(); iter++)
{
PlaybackSock *pbs = *iter;
pbs->UpRef();
localPBSList.push_back(pbs);
}
sockListLock.unlock();

vector<PlaybackSock*>::const_iterator iter;
for (iter = localPBSList.begin(); iter != localPBSList.end(); iter++)
{
PlaybackSock *pbs = *iter;
Expand Down Expand Up @@ -911,16 +908,15 @@ void MainServer::customEvent(QEvent *e)
reallysendit = true;
}

if (reallysendit)
MythSocket *sock = pbs->getSocket();
if (reallysendit && sock->socket() >= 0)
{
MythSocket *sock = pbs->getSocket();
sock->UpRef();

sock->Lock();
sock->writeStringList(broadcast);
sock->Unlock();

sock->DownRef();
if (sock->socket() >= 0)
sock->writeStringList(broadcast);

sock->Unlock();
}
}

Expand Down
2 changes: 0 additions & 2 deletions mythtv/programs/mythbackend/mainserver.h
Expand Up @@ -212,8 +212,6 @@ class MainServer : public QObject, public MythSocketCBs
Scheduler *m_sched;
AutoExpire *m_expirer;

QMutex readReadyLock;

struct DeferredDeleteStruct
{
PlaybackSock *sock;
Expand Down

0 comments on commit eddeeac

Please sign in to comment.