本文整理汇总了C++中SocketHandler::DecrRef方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketHandler::DecrRef方法的具体用法?C++ SocketHandler::DecrRef怎么用?C++ SocketHandler::DecrRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketHandler
的用法示例。
在下文中一共展示了SocketHandler::DecrRef方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()) ||
gCoreContext->IsThisHost(wantHost))
{
// 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->IncrRef();
}
}
if (remsock)
{
res << "QUERY_SG_FILEQUERY" << wantHost << groupname << filename;
remsock->SendReceiveStringList(res);
remsock->DecrRef();
}
else
{
res << "SLAVE UNREACHABLE: " << wantHost;
}
}
socket->SendStringList(res);
return true;
}
示例2: DoConnectToMaster
bool OutboundRequestHandler::DoConnectToMaster(void)
{
if (m_socket)
m_socket->DecrRef();
m_socket = new MythSocket(-1, m_parent);
QString server = gCoreContext->GetMasterServerIP();
QString hostname = gCoreContext->GetMasterHostName();
int port = gCoreContext->GetMasterServerPort();
if (!m_socket->ConnectToHost(server, port))
{
LOG(VB_GENERAL, LOG_ERR, "Failed to connect to master backend.");
m_socket->DecrRef();
m_socket = NULL;
return false;
}
#ifndef IGNORE_PROTO_VER_MISMATCH
if (!m_socket->Validate())
{
LOG(VB_GENERAL, LOG_NOTICE, "Unable to confirm protocol version with backend.");
m_socket->DecrRef();
m_socket = NULL;
return false;
}
#endif
if (!AnnounceSocket())
{
LOG(VB_GENERAL, LOG_NOTICE, "Announcement to upstream master backend failed.");
m_socket->DecrRef();
m_socket = NULL;
return false;
}
SocketHandler *handler = new SocketHandler(m_socket, m_parent, hostname);
handler->BlockShutdown(true);
handler->AllowStandardEvents(true);
handler->AllowSystemEvents(true);
m_parent->AddSocketHandler(handler); // register socket for reception of events
handler->DecrRef(); // drop local instance in counter
handler = NULL;
LOG(VB_GENERAL, LOG_NOTICE, "Connected to master backend.");
return true;
}
示例3: connectionClosed
void MythSocketManager::connectionClosed(MythSocket *sock)
{
{
QReadLocker rlock(&m_handlerLock);
QMap<QString, SocketRequestHandler*>::const_iterator i;
for (i = m_handlerMap.constBegin(); i != m_handlerMap.constEnd(); ++i)
(*i)->connectionClosed(sock);
}
{
QWriteLocker wlock(&m_socketLock);
if (m_socketMap.contains(sock))
{
SocketHandler *handler = m_socketMap.take(sock);
handler->DecrRef();
}
}
}
示例4: HandleAnnounce
bool BaseRequestHandler::HandleAnnounce(MythSocket *socket,
QStringList &commands, QStringList &slist)
{
if (commands.size() != 4)
return false;
bool blockShutdown;
if (commands[1] == "Playback")
blockShutdown = true;
else if (commands[1] == "Monitor")
blockShutdown = false;
else
return false;
QString hostname = commands[2];
int eventlevel = commands[3].toInt();
bool systemevents = ( (eventlevel == 1) || (eventlevel == 3));
bool normalevents = ( (eventlevel == 1) || (eventlevel == 2));
SocketHandler *handler = new SocketHandler(socket, m_parent, hostname);
socket->SetAnnounce(slist);
handler->BlockShutdown(blockShutdown);
handler->AllowStandardEvents(normalevents);
handler->AllowSystemEvents(systemevents);
m_parent->AddSocketHandler(handler);
handler->WriteStringList(QStringList("OK"));
handler->DecrRef();
handler = NULL;
LOG(VB_GENERAL, LOG_DEBUG, QString("MainServer::ANN %1")
.arg(commands[1]));
LOG(VB_GENERAL, LOG_NOTICE, QString("adding: %1 as a client (events: %2)")
.arg(commands[2]).arg(eventlevel));
gCoreContext->SendSystemEvent(QString("CLIENT_CONNECTED HOSTNAME %1")
.arg(commands[2]));
return true;
}
示例5: 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->IsThisHost(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->IncrRef();
}
}
if (remsock)
{
LOG(VB_FILE, LOG_INFO, "Getting remote info");
res << "QUERY_SG_GETFILELIST" << wantHost << groupname << path
<< QString::number(fileNamesOnly);
remsock->SendReceiveStringList(res);
remsock->DecrRef();
}
else
{
LOG(VB_FILE, LOG_ERR, QString("Failed to grab slave socket : %1 :")
.arg(wantHost));
res << "SLAVE UNREACHABLE: " << wantHost;
}
}
socket->SendStringList(res);
return true;
}