本文整理汇总了C++中SocketHandler::UpRef方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketHandler::UpRef方法的具体用法?C++ SocketHandler::UpRef怎么用?C++ SocketHandler::UpRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketHandler
的用法示例。
在下文中一共展示了SocketHandler::UpRef方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleFileQuery
bool FileServerHandler::HandleFileQuery(SocketHandler *socket,
QStringList &slist)
{
QStringList res;
if (slist.size() != 4)
{
LOG(VB_GENERAL, LOG_ERR, QString("Invalid Request. %1")
.arg(slist.join("[]:[]")));
res << "EMPTY LIST";
socket->SendStringList(res);
return true;
}
QString wantHost = slist[1];
QString groupname = slist[2];
QString filename = slist[3];
LOG(VB_FILE, LOG_DEBUG, QString("HandleSGFileQuery: myth://%[email protected]%2/%3")
.arg(groupname).arg(wantHost).arg(filename));
if ((wantHost.toLower() == gCoreContext->GetHostName().toLower()) ||
(wantHost == gCoreContext->GetSetting("BackendServerIP")))
{
// handle request locally
LOG(VB_FILE, LOG_DEBUG, QString("Getting local info"));
StorageGroup sg(groupname, gCoreContext->GetHostName());
res = sg.GetFileInfo(filename);
if (res.count() == 0)
res << "EMPTY LIST";
}
else
{
// handle request on remote server
SocketHandler *remsock = NULL;
{
QReadLocker rlock(&m_fsLock);
if (m_fsMap.contains(wantHost))
{
remsock = m_fsMap[wantHost];
remsock->UpRef();
}
}
if (remsock)
{
res << "QUERY_SG_FILEQUERY" << wantHost << groupname << filename;
remsock->SendReceiveStringList(res);
remsock->DownRef();
}
else
{
res << "SLAVE UNREACHABLE: " << wantHost;
}
}
socket->SendStringList(res);
return true;
}
示例2: rlock
SocketHandler *MythSocketManager::GetConnectionBySocket(MythSocket *sock)
{
QReadLocker rlock(&m_socketLock);
if (!m_socketMap.contains(sock))
return NULL;
SocketHandler *handler = m_socketMap[sock];
handler->UpRef();
return handler;
}
示例3: HandleGetFileList
bool FileServerHandler::HandleGetFileList(SocketHandler *socket,
QStringList &slist)
{
QStringList res;
bool fileNamesOnly = false;
if (slist.size() == 5)
fileNamesOnly = slist[4].toInt();
else if (slist.size() != 4)
{
LOG(VB_GENERAL, LOG_ERR, QString("Invalid Request. %1")
.arg(slist.join("[]:[]")));
res << "EMPTY LIST";
socket->SendStringList(res);
return true;
}
QString host = gCoreContext->GetHostName();
QString wantHost = slist[1];
QString groupname = slist[2];
QString path = slist[3];
LOG(VB_FILE, LOG_INFO,
QString("HandleSGGetFileList: group = %1 host = %2 "
"path = %3 wanthost = %4")
.arg(groupname).arg(host).arg(path).arg(wantHost));
if ((host.toLower() == wantHost.toLower()) ||
(gCoreContext->GetSetting("BackendServerIP") == wantHost))
{
StorageGroup sg(groupname, host);
LOG(VB_FILE, LOG_INFO, "Getting local info");
if (fileNamesOnly)
res = sg.GetFileList(path);
else
res = sg.GetFileInfoList(path);
if (res.count() == 0)
res << "EMPTY LIST";
}
else
{
// handle request on remote server
SocketHandler *remsock = NULL;
{
QReadLocker rlock(&m_fsLock);
if (m_fsMap.contains(wantHost))
{
remsock = m_fsMap[wantHost];
remsock->UpRef();
}
}
if (remsock)
{
LOG(VB_FILE, LOG_INFO, "Getting remote info");
res << "QUERY_SG_GETFILELIST" << wantHost << groupname << path
<< QString::number(fileNamesOnly);
remsock->SendReceiveStringList(res);
remsock->DownRef();
}
else
{
LOG(VB_FILE, LOG_ERR, QString("Failed to grab slave socket : %1 :")
.arg(wantHost));
res << "SLAVE UNREACHABLE: " << wantHost;
}
}
socket->SendStringList(res);
return true;
}