History

fix for audio-mixer shutdown hang, removing spaces

Stephen Birarda committed 11 years ago

Commit ca87d641 parent 12a8f146 files · +229 −224Browse files

Showing the changes to libraries/networking/src/ThreadedAssignment.cpp (1 of 6 files). Show all

Unified · Split

libraries/networking/src/ThreadedAssignment.cpp+16−15
@@ -23,7 +23,7 @@ ThreadedAssignment::ThreadedAssignment(const QByteArray& packet) : · 22 unmodified lines
23 _isFinished(false),23 _isFinished(false),
24 _datagramProcessingThread(NULL)24 _datagramProcessingThread(NULL)
25{25{
26 26
27}27}
28 28
29void ThreadedAssignment::setFinished(bool isFinished) {29void ThreadedAssignment::setFinished(bool isFinished) {
@@ -41,7 +41,7 @@ void ThreadedAssignment::setFinished(bool isFinished) { · 11 unmodified lines
41 if (_statsTimer) {41 if (_statsTimer) {
42 _statsTimer->stop();42 _statsTimer->stop();
43 }43 }
44 44
45 // stop processing datagrams from the node socket45 // stop processing datagrams from the node socket
46 // this ensures we won't process a domain list while we are going down46 // this ensures we won't process a domain list while we are going down
47 auto nodeList = DependencyManager::get<NodeList>();47 auto nodeList = DependencyManager::get<NodeList>();
@@ -52,20 +52,21 @@ void ThreadedAssignment::setFinished(bool isFinished) { · 4 unmodified lines
52 52
53 // if we have a datagram processing thread, quit it and wait on it to make sure that53 // if we have a datagram processing thread, quit it and wait on it to make sure that
54 // the node socket is back on the same thread as the NodeList54 // the node socket is back on the same thread as the NodeList
55 55
56
56 if (_datagramProcessingThread) {57 if (_datagramProcessingThread) {
57 // tell the datagram processing thread to quit and wait until it is done, 58 // tell the datagram processing thread to quit and wait until it is done,
58 // then return the node socket to the NodeList59 // then return the node socket to the NodeList
59 _datagramProcessingThread->quit();60 _datagramProcessingThread->quit();
60 _datagramProcessingThread->wait();61 _datagramProcessingThread->wait();
61 62
62 // set node socket parent back to NodeList63 // set node socket parent back to NodeList
63 nodeList->getNodeSocket().setParent(nodeList.data());64 nodeList->getNodeSocket().setParent(nodeList.data());
64 }65 }
65 66
66 // move the NodeList back to the QCoreApplication instance's thread67 // move the NodeList back to the QCoreApplication instance's thread
67 nodeList->moveToThread(QCoreApplication::instance()->thread());68 nodeList->moveToThread(QCoreApplication::instance()->thread());
68 69
69 emit finished();70 emit finished();
70 }71 }
71 }72 }
@@ -74,17 +75,17 @@ void ThreadedAssignment::setFinished(bool isFinished) { · 2 unmodified lines
74void ThreadedAssignment::commonInit(const QString& targetName, NodeType_t nodeType, bool shouldSendStats) {75void ThreadedAssignment::commonInit(const QString& targetName, NodeType_t nodeType, bool shouldSendStats) {
75 // change the logging target name while the assignment is running76 // change the logging target name while the assignment is running
76 LogHandler::getInstance().setTargetName(targetName);77 LogHandler::getInstance().setTargetName(targetName);
77 78
78 auto nodeList = DependencyManager::get<NodeList>();79 auto nodeList = DependencyManager::get<NodeList>();
79 nodeList->setOwnerType(nodeType);80 nodeList->setOwnerType(nodeType);
80 81
81 // this is a temp fix for Qt 5.3 - rebinding the node socket gives us readyRead for the socket on this thread82 // this is a temp fix for Qt 5.3 - rebinding the node socket gives us readyRead for the socket on this thread
82 nodeList->rebindNodeSocket();83 nodeList->rebindNodeSocket();
83 84
84 _domainServerTimer = new QTimer();85 _domainServerTimer = new QTimer();
85 connect(_domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));86 connect(_domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));
86 _domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);87 _domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
87 88
88 if (shouldSendStats) {89 if (shouldSendStats) {
89 // send a stats packet every 1 second90 // send a stats packet every 1 second
90 _statsTimer = new QTimer();91 _statsTimer = new QTimer();
@@ -95,15 +96,15 @@ void ThreadedAssignment::commonInit(const QString& targetName, NodeType_t nodeTy · 4 unmodified lines
95 96
96void ThreadedAssignment::addPacketStatsAndSendStatsPacket(QJsonObject &statsObject) {97void ThreadedAssignment::addPacketStatsAndSendStatsPacket(QJsonObject &statsObject) {
97 auto nodeList = DependencyManager::get<NodeList>();98 auto nodeList = DependencyManager::get<NodeList>();
98 99
99 float packetsPerSecond, bytesPerSecond;100 float packetsPerSecond, bytesPerSecond;
100 // XXX can BandwidthRecorder be used for this?101 // XXX can BandwidthRecorder be used for this?
101 nodeList->getPacketStats(packetsPerSecond, bytesPerSecond);102 nodeList->getPacketStats(packetsPerSecond, bytesPerSecond);
102 nodeList->resetPacketStats();103 nodeList->resetPacketStats();
103 104
104 statsObject["packets_per_second"] = packetsPerSecond;105 statsObject["packets_per_second"] = packetsPerSecond;
105 statsObject["bytes_per_second"] = bytesPerSecond;106 statsObject["bytes_per_second"] = bytesPerSecond;
106 107
107 nodeList->sendStatsToDomainServer(statsObject);108 nodeList->sendStatsToDomainServer(statsObject);
108}109}
109 110
@@ -122,7 +123,7 @@ void ThreadedAssignment::checkInWithDomainServerOrExit() { · 12 unmodified lines
122 123
123bool ThreadedAssignment::readAvailableDatagram(QByteArray& destinationByteArray, HifiSockAddr& senderSockAddr) {124bool ThreadedAssignment::readAvailableDatagram(QByteArray& destinationByteArray, HifiSockAddr& senderSockAddr) {
124 auto nodeList = DependencyManager::get<NodeList>();125 auto nodeList = DependencyManager::get<NodeList>();
125 126
126 if (nodeList->getNodeSocket().hasPendingDatagrams()) {127 if (nodeList->getNodeSocket().hasPendingDatagrams()) {
127 destinationByteArray.resize(nodeList->getNodeSocket().pendingDatagramSize());128 destinationByteArray.resize(nodeList->getNodeSocket().pendingDatagramSize());
128 nodeList->getNodeSocket().readDatagram(destinationByteArray.data(), destinationByteArray.size(),129 nodeList->getNodeSocket().readDatagram(destinationByteArray.data(), destinationByteArray.size(),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t