From d56952cdc7f18e09421f7a3a5d943600d81d8118 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 10 Apr 2013 13:39:31 -0700 Subject: [PATCH] don't copy agent delete mutex --- shared/src/Agent.cpp | 3 +-- shared/src/AgentList.cpp | 17 ++++++++--------- voxel/src/main.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/shared/src/Agent.cpp b/shared/src/Agent.cpp index db3f7f4726..8c14d9a617 100644 --- a/shared/src/Agent.cpp +++ b/shared/src/Agent.cpp @@ -67,7 +67,7 @@ Agent::Agent(const Agent &otherAgent) { linkedData = NULL; } - deleteMutex = otherAgent.deleteMutex; + pthread_mutex_init(&deleteMutex, NULL); } Agent& Agent::operator=(Agent otherAgent) { @@ -83,7 +83,6 @@ void Agent::swap(Agent &first, Agent &second) { swap(first.type, second.type); swap(first.linkedData, second.linkedData); swap(first.agentId, second.agentId); - swap(first.deleteMutex, second.deleteMutex); } Agent::~Agent() { diff --git a/shared/src/AgentList.cpp b/shared/src/AgentList.cpp index 8826477ea3..0cfac49429 100644 --- a/shared/src/AgentList.cpp +++ b/shared/src/AgentList.cpp @@ -285,13 +285,11 @@ void *pingUnknownAgents(void *args) { for(std::vector::iterator agent = agentList->getAgents().begin(); agent != agentList->getAgents().end(); agent++) { - if (agent->getType() == AGENT_TYPE_INTERFACE) { - if (agent->getActiveSocket() == NULL) { - // ping both of the sockets for the agent so we can figure out - // which socket we can use - agentList->getAgentSocket().send(agent->getPublicSocket(), &PACKET_HEADER_PING, 1); - agentList->getAgentSocket().send(agent->getLocalSocket(), &PACKET_HEADER_PING, 1); - } + if (agent->getActiveSocket() == NULL) { + // ping both of the sockets for the agent so we can figure out + // which socket we can use + agentList->getAgentSocket().send(agent->getPublicSocket(), &PACKET_HEADER_PING, 1); + agentList->getAgentSocket().send(agent->getLocalSocket(), &PACKET_HEADER_PING, 1); } } @@ -344,7 +342,6 @@ void *removeSilentAgents(void *args) { } } - sleepTime = AGENT_SILENCE_THRESHOLD_USECS - (usecTimestampNow() - checkTimeUSecs); #ifdef _WIN32 Sleep( static_cast(1000.0f*sleepTime) ); @@ -380,6 +377,8 @@ void AgentList::stopSilentAgentRemovalThread() { void *checkInWithDomainServer(void *args) { + const int DOMAIN_SERVER_CHECK_IN_USECS = 1 * 1000000; + AgentList *parentAgentList = (AgentList *)args; timeval lastSend; @@ -410,7 +409,7 @@ void *checkInWithDomainServer(void *args) { parentAgentList->getAgentSocket().send(DOMAIN_IP, DOMAINSERVER_PORT, output, 7); - double usecToSleep = 1000000 - (usecTimestampNow() - usecTimestamp(&lastSend)); + double usecToSleep = DOMAIN_SERVER_CHECK_IN_USECS - (usecTimestampNow() - usecTimestamp(&lastSend)); if (usecToSleep > 0) { usleep(usecToSleep); diff --git a/voxel/src/main.cpp b/voxel/src/main.cpp index bbc5a92452..e88777913f 100644 --- a/voxel/src/main.cpp +++ b/voxel/src/main.cpp @@ -131,7 +131,7 @@ void eraseVoxelTreeAndCleanupAgentVisitData() { // lock this agent's delete mutex so that the delete thread doesn't // kill the agent while we are working with it - pthread_mutex_lock(&thisAgent->deleteMutex); + pthread_mutex_lock(thisAgent->deleteMutex); // clean up the agent visit data delete agentData->rootMarkerNode; @@ -139,7 +139,7 @@ void eraseVoxelTreeAndCleanupAgentVisitData() { // unlock the delete mutex so the other thread can // kill the agent if it has dissapeared - pthread_mutex_unlock(&thisAgent->deleteMutex); + pthread_mutex_unlock(thisAgent->deleteMutex); } } @@ -168,7 +168,7 @@ void *distributeVoxelsToListeners(void *args) { // lock this agent's delete mutex so that the delete thread doesn't // kill the agent while we are working with it - pthread_mutex_lock(&thisAgent->deleteMutex); + pthread_mutex_lock(thisAgent->deleteMutex); stopOctal = NULL; packetCount = 0; @@ -208,7 +208,7 @@ void *distributeVoxelsToListeners(void *args) { // unlock the delete mutex so the other thread can // kill the agent if it has dissapeared - pthread_mutex_unlock(&thisAgent->deleteMutex); + pthread_mutex_unlock(thisAgent->deleteMutex); } // dynamically sleep until we need to fire off the next set of voxels