X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=libust%2Ftracectl.c;h=97ab2eb1fb768433c4561733dcfded9b25cee235;hb=4d65ee62f53c9e3b7c7b56d2067ab347f3ce90aa;hp=277dbcd75d773f31f9c19f1056d49715d7dfabde;hpb=acbf228bbea7ed81ed3bfcb0158fc9d0547fe71d;p=lttng-ust.git diff --git a/libust/tracectl.c b/libust/tracectl.c index 277dbcd7..97ab2eb1 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -1,3 +1,20 @@ +/* Copyright (C) 2009 Pierre-Marc Fournier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + #define _GNU_SOURCE #include #include @@ -9,6 +26,8 @@ #include #include +#include + #include "marker.h" #include "tracer.h" #include "localerr.h" @@ -89,8 +108,13 @@ void do_command(struct tracecmd *cmd) { } -void receive_commands() +/* This needs to be called whenever a new thread is created. It notifies + * liburcu of the new thread. + */ + +void ust_register_thread(void) { + rcu_register_thread(); } int fd_notif = -1; @@ -147,7 +171,8 @@ void process_blocked_consumers(void) idx++; } - result = poll(fds, n_fds, 0); + while((result = poll(fds, n_fds, 0)) == -1 && errno == EINTR) + /* nothing */; if(result == -1) { PERROR("poll"); return; @@ -206,6 +231,8 @@ void *listener_main(void *p) { int result; + ust_register_thread(); + DBG("LISTENER"); for(;;) { @@ -785,6 +812,12 @@ static void auto_probe_connect(struct marker *m) static void __attribute__((constructor(101))) init0() { + /* Initialize RCU in case the constructor order is not good. */ + urcu_init(); + + /* It is important to do this before events start to be generated. */ + ust_register_thread(); + DBG("UST_AUTOPROBE constructor"); if(getenv("UST_AUTOPROBE")) { marker_set_new_marker_cb(auto_probe_connect);