aboutsummaryrefslogtreecommitdiff
path: root/daemon/Child.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/Child.cpp')
-rw-r--r--daemon/Child.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/daemon/Child.cpp b/daemon/Child.cpp
index ca33561..1901ecc 100644
--- a/daemon/Child.cpp
+++ b/daemon/Child.cpp
@@ -26,13 +26,13 @@
#include "Driver.h"
#include "PerfSource.h"
#include "DriverSource.h"
-#include "UserSpaceSource.h"
#include "ExternalSource.h"
+#include "UserSpaceSource.h"
static sem_t haltPipeline, senderThreadStarted, startProfile, senderSem; // Shared by Child and spawned threads
static Source *primarySource = NULL;
-static Source *userSpaceSource = NULL;
static Source *externalSource = NULL;
+static Source *userSpaceSource = NULL;
static Sender* sender = NULL; // Shared by Child.cpp and spawned threads
Child* child = NULL; // shared by Child.cpp and main.cpp
@@ -147,16 +147,16 @@ static void *senderThread(void *) {
prctl(PR_SET_NAME, (unsigned long)&"gatord-sender", 0, 0, 0);
sem_wait(&haltPipeline);
- while (!primarySource->isDone() || (userSpaceSource != NULL && !userSpaceSource->isDone()) || (externalSource != NULL && !externalSource->isDone())) {
+ while (!primarySource->isDone() ||
+ !externalSource->isDone() ||
+ (userSpaceSource != NULL && !userSpaceSource->isDone())) {
sem_wait(&senderSem);
primarySource->write(sender);
+ externalSource->write(sender);
if (userSpaceSource != NULL) {
userSpaceSource->write(sender);
}
- if (externalSource != NULL) {
- externalSource->write(sender);
- }
}
// write end-of-capture sequence
@@ -202,6 +202,10 @@ void Child::initialization() {
void Child::endSession() {
gSessionData->mSessionIsActive = false;
primarySource->interrupt();
+ externalSource->interrupt();
+ if (userSpaceSource != NULL) {
+ userSpaceSource->interrupt();
+ }
sem_post(&haltPipeline);
}
@@ -227,9 +231,9 @@ void Child::run() {
// Set up the driver; must be done after gSessionData->mPerfCounterType[] is populated
if (!gSessionData->perf.isSetup()) {
- primarySource = new DriverSource(&senderSem, &startProfile);
+ primarySource = new DriverSource(&senderSem, &startProfile);
} else {
- primarySource = new PerfSource(&senderSem, &startProfile);
+ primarySource = new PerfSource(&senderSem, &startProfile);
}
// Initialize all drivers
@@ -280,11 +284,18 @@ void Child::run() {
thread_creation_success = false;
} else if (socket && pthread_create(&stopThreadID, NULL, stopThread, NULL)) {
thread_creation_success = false;
- } else if (pthread_create(&senderThreadID, NULL, senderThread, NULL)){
+ } else if (pthread_create(&senderThreadID, NULL, senderThread, NULL)) {
thread_creation_success = false;
}
- if (gSessionData->hwmon.countersEnabled()) {
+ externalSource = new ExternalSource(&senderSem);
+ if (!externalSource->prepare()) {
+ logg->logError(__FILE__, __LINE__, "Unable to prepare for capture");
+ handleException();
+ }
+ externalSource->start();
+
+ if (gSessionData->hwmon.countersEnabled() || gSessionData->fsDriver.countersEnabled()) {
userSpaceSource = new UserSpaceSource(&senderSem);
if (!userSpaceSource->prepare()) {
logg->logError(__FILE__, __LINE__, "Unable to prepare for capture");
@@ -292,14 +303,6 @@ void Child::run() {
}
userSpaceSource->start();
}
- if (access("/tmp/gator", F_OK) == 0) {
- externalSource = new ExternalSource(&senderSem);
- if (!externalSource->prepare()) {
- logg->logError(__FILE__, __LINE__, "Unable to prepare for capture");
- handleException();
- }
- externalSource->start();
- }
if (!thread_creation_success) {
logg->logError(__FILE__, __LINE__, "Failed to create gator threads");
@@ -312,12 +315,10 @@ void Child::run() {
// Start profiling
primarySource->run();
- if (externalSource != NULL) {
- externalSource->join();
- }
if (userSpaceSource != NULL) {
userSpaceSource->join();
}
+ externalSource->join();
// Wait for the other threads to exit
pthread_join(senderThreadID, NULL);
@@ -337,8 +338,8 @@ void Child::run() {
logg->logMessage("Profiling ended.");
- delete externalSource;
delete userSpaceSource;
+ delete externalSource;
delete primarySource;
delete sender;
delete localCapture;