mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 21:03:09 +02:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
851b833d35
4 changed files with 29 additions and 22 deletions
|
@ -19,8 +19,6 @@
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Agent::Agent() {}
|
|
||||||
|
|
||||||
Agent::Agent(sockaddr *agentPublicSocket, sockaddr *agentLocalSocket, char agentType, uint16_t thisAgentId) {
|
Agent::Agent(sockaddr *agentPublicSocket, sockaddr *agentLocalSocket, char agentType, uint16_t thisAgentId) {
|
||||||
publicSocket = new sockaddr;
|
publicSocket = new sockaddr;
|
||||||
memcpy(publicSocket, agentPublicSocket, sizeof(sockaddr));
|
memcpy(publicSocket, agentPublicSocket, sizeof(sockaddr));
|
||||||
|
@ -37,7 +35,8 @@ Agent::Agent(sockaddr *agentPublicSocket, sockaddr *agentLocalSocket, char agent
|
||||||
activeSocket = NULL;
|
activeSocket = NULL;
|
||||||
linkedData = NULL;
|
linkedData = NULL;
|
||||||
|
|
||||||
pthread_mutex_init(&deleteMutex, NULL);
|
deleteMutex = new pthread_mutex_t;
|
||||||
|
pthread_mutex_init(deleteMutex, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Agent::Agent(const Agent &otherAgent) {
|
Agent::Agent(const Agent &otherAgent) {
|
||||||
|
@ -67,25 +66,34 @@ Agent::Agent(const Agent &otherAgent) {
|
||||||
linkedData = NULL;
|
linkedData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_init(&deleteMutex, NULL);
|
deleteMutex = new pthread_mutex_t;
|
||||||
|
pthread_mutex_init(deleteMutex, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Agent& Agent::operator=(Agent otherAgent) {
|
Agent& Agent::operator=(Agent otherAgent) {
|
||||||
|
std::cout << "Agent swap constructor called on resize?\n";
|
||||||
swap(*this, otherAgent);
|
swap(*this, otherAgent);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Agent::swap(Agent &first, Agent &second) {
|
void Agent::swap(Agent &first, Agent &second) {
|
||||||
using std::swap;
|
using std::swap;
|
||||||
|
|
||||||
swap(first.publicSocket, second.publicSocket);
|
swap(first.publicSocket, second.publicSocket);
|
||||||
swap(first.localSocket, second.localSocket);
|
swap(first.localSocket, second.localSocket);
|
||||||
swap(first.activeSocket, second.activeSocket);
|
swap(first.activeSocket, second.activeSocket);
|
||||||
swap(first.type, second.type);
|
swap(first.type, second.type);
|
||||||
swap(first.linkedData, second.linkedData);
|
swap(first.linkedData, second.linkedData);
|
||||||
swap(first.agentId, second.agentId);
|
swap(first.agentId, second.agentId);
|
||||||
|
swap(first.firstRecvTimeUsecs, second.firstRecvTimeUsecs);
|
||||||
|
swap(first.lastRecvTimeUsecs, second.lastRecvTimeUsecs);
|
||||||
|
swap(first.deleteMutex, second.deleteMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Agent::~Agent() {
|
Agent::~Agent() {
|
||||||
|
// the deleteMutex isn't destroyed here
|
||||||
|
// that's handled by the agent list silent agent removal thread
|
||||||
|
|
||||||
delete publicSocket;
|
delete publicSocket;
|
||||||
delete localSocket;
|
delete localSocket;
|
||||||
delete linkedData;
|
delete linkedData;
|
||||||
|
|
|
@ -19,17 +19,8 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class Agent {
|
class Agent {
|
||||||
void swap(Agent &first, Agent &second);
|
public:
|
||||||
sockaddr *publicSocket, *localSocket, *activeSocket;
|
|
||||||
char type;
|
|
||||||
uint16_t agentId;
|
|
||||||
double firstRecvTimeUsecs;
|
|
||||||
double lastRecvTimeUsecs;
|
|
||||||
AgentData *linkedData;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Agent();
|
|
||||||
Agent(sockaddr *agentPublicSocket, sockaddr *agentLocalSocket, char agentType, uint16_t thisAgentId);
|
Agent(sockaddr *agentPublicSocket, sockaddr *agentLocalSocket, char agentType, uint16_t thisAgentId);
|
||||||
Agent(const Agent &otherAgent);
|
Agent(const Agent &otherAgent);
|
||||||
~Agent();
|
~Agent();
|
||||||
|
@ -38,7 +29,7 @@ public:
|
||||||
|
|
||||||
bool matches(sockaddr *otherPublicSocket, sockaddr *otherLocalSocket, char otherAgentType);
|
bool matches(sockaddr *otherPublicSocket, sockaddr *otherLocalSocket, char otherAgentType);
|
||||||
|
|
||||||
pthread_mutex_t deleteMutex;
|
pthread_mutex_t *deleteMutex;
|
||||||
|
|
||||||
char getType() const;
|
char getType() const;
|
||||||
const char* getTypeName() const;
|
const char* getTypeName() const;
|
||||||
|
@ -59,7 +50,15 @@ public:
|
||||||
AgentData* getLinkedData();
|
AgentData* getLinkedData();
|
||||||
void setLinkedData(AgentData *newData);
|
void setLinkedData(AgentData *newData);
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& os, const Agent* agent);
|
friend std::ostream& operator<<(std::ostream& os, const Agent* agent);
|
||||||
|
private:
|
||||||
|
void swap(Agent &first, Agent &second);
|
||||||
|
sockaddr *publicSocket, *localSocket, *activeSocket;
|
||||||
|
char type;
|
||||||
|
uint16_t agentId;
|
||||||
|
double firstRecvTimeUsecs;
|
||||||
|
double lastRecvTimeUsecs;
|
||||||
|
AgentData *linkedData;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const Agent* agent);
|
std::ostream& operator<<(std::ostream& os, const Agent* agent);
|
||||||
|
|
|
@ -331,7 +331,7 @@ void *removeSilentAgents(void *args) {
|
||||||
|
|
||||||
for(std::vector<Agent>::iterator agent = agents->begin(); agent != agents->end();) {
|
for(std::vector<Agent>::iterator agent = agents->begin(); agent != agents->end();) {
|
||||||
|
|
||||||
pthread_mutex_t * agentDeleteMutex = &agent->deleteMutex;
|
pthread_mutex_t* agentDeleteMutex = agent->deleteMutex;
|
||||||
|
|
||||||
if ((checkTimeUSecs - agent->getLastRecvTimeUsecs()) > AGENT_SILENCE_THRESHOLD_USECS
|
if ((checkTimeUSecs - agent->getLastRecvTimeUsecs()) > AGENT_SILENCE_THRESHOLD_USECS
|
||||||
&& agent->getType() != AGENT_TYPE_VOXEL
|
&& agent->getType() != AGENT_TYPE_VOXEL
|
||||||
|
|
|
@ -129,7 +129,7 @@ void eraseVoxelTreeAndCleanupAgentVisitData() {
|
||||||
|
|
||||||
// lock this agent's delete mutex so that the delete thread doesn't
|
// lock this agent's delete mutex so that the delete thread doesn't
|
||||||
// kill the agent while we are working with it
|
// 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
|
// clean up the agent visit data
|
||||||
delete agentData->rootMarkerNode;
|
delete agentData->rootMarkerNode;
|
||||||
|
@ -137,7 +137,7 @@ void eraseVoxelTreeAndCleanupAgentVisitData() {
|
||||||
|
|
||||||
// unlock the delete mutex so the other thread can
|
// unlock the delete mutex so the other thread can
|
||||||
// kill the agent if it has dissapeared
|
// kill the agent if it has dissapeared
|
||||||
pthread_mutex_unlock(&thisAgent->deleteMutex);
|
pthread_mutex_unlock(thisAgent->deleteMutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ void *distributeVoxelsToListeners(void *args) {
|
||||||
|
|
||||||
// lock this agent's delete mutex so that the delete thread doesn't
|
// lock this agent's delete mutex so that the delete thread doesn't
|
||||||
// kill the agent while we are working with it
|
// kill the agent while we are working with it
|
||||||
pthread_mutex_lock(&thisAgent->deleteMutex);
|
pthread_mutex_lock(thisAgent->deleteMutex);
|
||||||
|
|
||||||
stopOctal = NULL;
|
stopOctal = NULL;
|
||||||
packetCount = 0;
|
packetCount = 0;
|
||||||
|
@ -207,7 +207,7 @@ void *distributeVoxelsToListeners(void *args) {
|
||||||
|
|
||||||
// unlock the delete mutex so the other thread can
|
// unlock the delete mutex so the other thread can
|
||||||
// kill the agent if it has dissapeared
|
// 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
|
// dynamically sleep until we need to fire off the next set of voxels
|
||||||
|
|
Loading…
Reference in a new issue