don't copy agent delete mutex

This commit is contained in:
Stephen Birarda 2013-04-10 13:39:31 -07:00
parent fcee05e9f0
commit d56952cdc7
3 changed files with 13 additions and 15 deletions

View file

@ -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() {

View file

@ -285,13 +285,11 @@ void *pingUnknownAgents(void *args) {
for(std::vector<Agent>::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<int>(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);

View file

@ -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