[mythtv] [BUG?] Endless waiting for thread...
Kevin Kuphal
kuphal at dls.net
Wed Mar 9 16:14:05 UTC 2005
Kevin Kuphal wrote:
> void MainServer::readSocket(void)
> {
> RefSocket *socket = (RefSocket *)sender();
>
> PlaybackSock *testsock = getPlaybackBySock(socket);
> if (testsock && testsock->isExpectingReply())
> return;
>
> readReadyLock.lock();
>
> ProcessRequestThread *prt = NULL;
> while (!prt)
> {
> threadPoolLock.lock();
> if (!threadPool.empty())
> {
> prt = threadPool.back();
> threadPool.pop_back();
> }
> threadPoolLock.unlock();
>
> if (!prt)
> {
> VERBOSE(VB_ALL, "waiting for a thread..");
> usleep(50);
> }
> }
>
> prt->setup(socket);
>
> readReadyLock.unlock();
> }
>
In looking at this code further, if the threadPool is empty when
entering this function, won't it endlessly loop because prt is never set
to anything other than null?
Shouldn't there be an else condition on the empty check to break out of
the loop if the threadPool is empty and return some kind of error?
Kevin
More information about the mythtv-dev
mailing list