make forking while tracing work correctly
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Fri, 11 Sep 2009 19:35:21 +0000 (15:35 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Fri, 11 Sep 2009 19:35:21 +0000 (15:35 -0400)
libinterfork/interfork.c
libust/tracectl.c
libust/tracer.c
libustcomm/ustcomm.c
libustcomm/ustcomm.h

index e57b7e593c06664a5cf73313185ef6cea3462935..a8db252fe0154fdf3567a5b9db0061e48ade850c 100644 (file)
@@ -34,7 +34,6 @@ pid_t fork(void)
                }
        }
 
-       printf("IN FORK!\n");
        retval = plibc_func();
 
        if(retval == 0)
index 412cca2b1cfdb1b4969cbaeb030f170ae871b988..a52b208f34b369a6887a59f5ce95da94d48a85d4 100644 (file)
@@ -1109,14 +1109,35 @@ static void __attribute__((destructor)) keepalive()
 
 void ust_fork(void)
 {
+       struct blocked_consumer *bc;
+       struct blocked_consumer *deletable_bc = NULL;
+       int result;
+
        DBG("ust: forking");
        ltt_trace_stop("auto");
        ltt_trace_destroy("auto");
-       ltt_trace_alloc("auto");
-       ltt_trace_start("auto");
-       init_socket();
+       /* Delete all active connections */
+       ustcomm_close_all_connections(&ustcomm_app.server);
+
+       /* Delete all blocked consumers */
+       list_for_each_entry(bc, &blocked_consumers, list) {
+               free(deletable_bc);
+               deletable_bc = bc;
+               list_del(&bc->list);
+       }
+
        have_listener = 0;
        create_listener();
+       init_socket();
+       ltt_trace_setup("auto");
+       result = ltt_trace_set_type("auto", "ustrelay");
+       if(result < 0) {
+               ERR("ltt_trace_set_type failed");
+               return (void *)1;
+       }
+
+       ltt_trace_alloc("auto");
+       ltt_trace_start("auto");
        inform_consumer_daemon("auto");
 }
 
index cc1dbfddfd2ffd36fa664cb91c5a35f0ec338e16..6f192130df269e7820df085bed8cc464684c56d9 100644 (file)
@@ -807,7 +807,7 @@ traces_error:
 //ust// }
 
 /* Must be called while sure that trace is in the list. */
-static int _ltt_trace_destroy(struct ltt_trace_struct  *trace)
+static int _ltt_trace_destroy(struct ltt_trace_struct *trace)
 {
        int err = -EPERM;
 
index 1f4bce95cbc4a7f726c1d612ca28e5cb130d42d2..e773f7189fe313f78f0704f1ad907730a715aa38 100644 (file)
@@ -191,6 +191,23 @@ int ustcomm_send_reply(struct ustcomm_server *server, char *msg, struct ustcomm_
        return 0;
 } 
 
+/* Called after a fork. */
+
+int ustcomm_close_all_connections(struct ustcomm_server *server)
+{
+       struct ustcomm_connection *conn;
+       struct ustcomm_connection *deletable_conn = NULL;
+
+       list_for_each_entry(conn, &server->connections, list) {
+               free(deletable_conn);
+               deletable_conn = conn;
+               close(conn->fd);
+               list_del(&conn->list);
+       }
+
+       return 0;
+}
+
 /* @timeout: max blocking time in milliseconds, -1 means infinity
  *
  * returns 1 to indicate a message was received
index 76209406baecc7abbb6c253aca7f875a58ca679e..b7d8839928dd75f6f345f150e3182a15c8758075 100644 (file)
@@ -71,6 +71,7 @@ extern int ustcomm_connect_path(const char *path, struct ustcomm_connection *con
 extern int ustcomm_send_request(struct ustcomm_connection *conn, const char *req, char **reply);
 extern int ustcomm_send_reply(struct ustcomm_server *server, char *msg, struct ustcomm_source *src);
 extern int ustcomm_disconnect(struct ustcomm_connection *conn);
+extern int ustcomm_close_all_connections(struct ustcomm_server *server);
 
 extern int nth_token_is(char *str, char *token, int tok_no);
 
This page took 0.030837 seconds and 4 git commands to generate.