Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[PATCH] Temporary fix to get lttng-agent to compile w/ ust.

* Fix to get flush thread to compile
* Started work to get write network to work.

Signed-off-by: Matthew Khouzam <matthew.khouzam@xxxxxxxxxxxx>
---
 agent/lttctlprovider.c     |    3 ++-
 agent/lttctlustinterface.c |   14 +++++++-------
 agent/lttctlusttransfer.c  |   25 ++++++++++++++++---------
 agent/lttctlusttransfer.h  |    2 +-
 4 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/agent/lttctlprovider.c b/agent/lttctlprovider.c
index 377d5f4..e756107 100644
--- a/agent/lttctlprovider.c
+++ b/agent/lttctlprovider.c
@@ -152,10 +152,11 @@ LTTCTLInterface* ltt_provider_iterator_prev(LTTCTLProviderIterator* it){
 LTTCTLInterface* ltt_get_provider(const char * providerName){
     LTTCTLProviderIterator it = ltt_get_provider_iterator();
     while(ltt_provider_iterator_next(&it))
+    {
         if(strcmp(providerName, ltt_provider_iterator_get_current(&it)->name)
                 == 0)
             return ltt_provider_iterator_get_current(&it);
-
+	}
     return NULL;
 }
 
diff --git a/agent/lttctlustinterface.c b/agent/lttctlustinterface.c
index aaf57b2..d341015 100644
--- a/agent/lttctlustinterface.c
+++ b/agent/lttctlustinterface.c
@@ -118,6 +118,7 @@ int ltt_ust_destroy(void) {
  * @return		0 if successful, else _UST_ERR_GEN
  */
 int ltt_ust_setup_trace(int sock, const char* name) {
+	printf( "setup trace ( %u, %s)\n" , sock, name ) ;
 	if (ustctl_setup_and_start(sock, name)) {
 		_u_setle("Could not setup & start trace");
 
@@ -516,7 +517,7 @@ int ltt_ust_get_targets(LTTCTLStringArray* array) {
  *
  * @param target	Targeted PID
  * @param name		Trace name
- * @param dest		Destination path - not used yet
+ * @param dest		Destination path - experimentally used
  * @param threads	Number of threads - not used yet
  * @param append	Append to existing trace - not used yet
  * @param fr_only	1 to only write flight recorder channel, or 0 - unused
@@ -531,9 +532,10 @@ int fr_only, int n_only) {
 
 		return _UST_ERR_GEN;
 	}
-	char* ustd_argv [] = {NULL};
+	char* ustd_argv [2] = {NULL,NULL};
 	char* ustd_envp [] = {NULL};
-
+	ustd_argv[0] = (char*)malloc( strlen(dest) + 4 ) ;
+	sprintf( ustd_argv[0], "-o %s" , dest) ;
 	pid_t pid = fork();
 	if (pid < 0) {
 		_u_setle("Error while forking for ustd daemon");
@@ -566,7 +568,6 @@ static void *ltt_ust_write_thread(void *arg)
 
 	ustctl_get_sock_path(args->sock, &sock_path);
 	ustctl_set_sock_path(args->sock, args->instance->sock_path);
-
 	ustconsumer_init_instance(args->instance);
 	ustconsumer_start_instance(args->instance);
 
@@ -603,7 +604,7 @@ int ltt_ust_write_network(const char *target, const char* b, unsigned long c,
 	args->pid = ltt_pid_from_str(target);
 	/* Connect to application using the pid */
 	args->sock = ustctl_connect_pid(args->pid);
-	if (args->sock) {
+	if ((args->sock==-1) || (args->sock == 0)) {
 		ret = -1;
 		goto error;
 	}
@@ -616,8 +617,7 @@ int ltt_ust_write_network(const char *target, const char* b, unsigned long c,
 		goto free_callbacks;
 	}
 	pthread_detach(tid);
-
-	ltt_start_flush_thread(args->sock);
+	ltt_start_flush_thread(args);
 
 	return 0;
 
diff --git a/agent/lttctlusttransfer.c b/agent/lttctlusttransfer.c
index 838b3cb..642c16f 100644
--- a/agent/lttctlusttransfer.c
+++ b/agent/lttctlusttransfer.c
@@ -44,6 +44,14 @@
 
 #define SOCK_DIR "/tmp/ust-app-socks"
 
+
+
+struct write_thread_args {
+	struct ustconsumer_instance *instance;
+	pid_t pid;
+	int sock;
+};
+
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static struct LTTCTLInstanceArray instance_array = {
@@ -58,12 +66,12 @@ static int flush_thread_started = 0;
 static pthread_mutex_t flush_thread_mutex;
 static unsigned long flush_period = 5000;
 
-static void *flush_thread(void *arg)
+static void *flush_thread(void* args)
 {
 	struct ltt_list_node * node;
-	pid_t pid;
-
+	int sock =((struct write_thread_args *) args)->sock;
 	for(;;) {
+		int nodeNum = 0; 
 		useconds_t usec_period = (useconds_t)flush_period * 1000;
 		usleep(usec_period);
 		pthread_mutex_lock(&ust_pid_list_mutex);
@@ -77,9 +85,7 @@ static void *flush_thread(void *arg)
 		}
 		node = ust_pid_list;
 		while(node) {
-			int sock = *((int*)arg);
-			pid = ltt_pid_from_str(node->data);
-			ustctl_force_switch(sock, pid);
+			ustctl_force_switch(sock, node->data);
 			node = node->next;
 		}
 		pthread_mutex_unlock(&ust_pid_list_mutex);
@@ -88,14 +94,15 @@ static void *flush_thread(void *arg)
 	return 0;
 }
 
-void ltt_start_flush_thread(int sock)
+void ltt_start_flush_thread(void* args)
 {
 	int ret;
 	pthread_t tid;
-
+	struct write_thread_args * arg = args; 
+	printf( "Socket data %u\n" , arg->sock); 
 	pthread_mutex_lock(&flush_thread_mutex);
 	if(!flush_thread_started) {
-		ret = pthread_create(&tid, NULL, flush_thread, (void*)(&sock));
+		ret = pthread_create(&tid, NULL, flush_thread, args);
 		if(ret) {
 			fprintf(stderr, "error creating flush thread\n");
 			pthread_mutex_unlock(&flush_thread_mutex);
diff --git a/agent/lttctlusttransfer.h b/agent/lttctlusttransfer.h
index e901ae1..6117c58 100644
--- a/agent/lttctlusttransfer.h
+++ b/agent/lttctlusttransfer.h
@@ -56,7 +56,7 @@ int ltt_ust_stop_ustconsumer_instance(const char* target);
 /**
  * @brief Function to start the periodical flush thread if necessary
  */
-void ltt_start_flush_thread(int sock);
+void ltt_start_flush_thread(void* args);
 
 /**
  * @brief Function to set the flush period
-- 
1.7.0.4


--------------000109040107060607000004--


Back to the top