Filter: double comparator produces s64
[lttng-ust.git] / liblttng-ust / lttng-ust-comm.c
index 7a9097014d26e4d483f4d4a9f7d98cbd581807d9..cca5dcf83716d9ce0e854305185689290b3e72aa 100644 (file)
@@ -43,6 +43,7 @@
 #include <lttng/ust.h>
 #include <ust-comm.h>
 #include <usterr-signal-safe.h>
+#include <helper.h>
 #include "tracepoint-internal.h"
 #include "ltt-tracer-core.h"
 #include "compat.h"
@@ -136,6 +137,15 @@ extern void ltt_ring_buffer_client_overwrite_exit(void);
 extern void ltt_ring_buffer_client_discard_exit(void);
 extern void ltt_ring_buffer_metadata_client_exit(void);
 
+/*
+ * Force a read (imply TLS fixup for dlopen) of TLS variables.
+ */
+static
+void lttng_fixup_nest_count_tls(void)
+{
+       asm volatile ("" : : "m" (lttng_ust_nest_count));
+}
+
 static
 int setup_local_apps(void)
 {
@@ -272,6 +282,66 @@ int handle_message(struct sock_info *sock_info,
                else
                        ret = lttng_ust_objd_unref(lum->handle);
                break;
+       case LTTNG_UST_FILTER:
+       {
+               /* Receive filter data */
+               struct lttng_ust_filter_bytecode *bytecode;
+
+               if (lum->u.filter.data_size > FILTER_BYTECODE_MAX_LEN) {
+                       ERR("Filter data size is too large: %u bytes\n",
+                               lum->u.filter.data_size);
+                       ret = -EINVAL;
+                       goto error;
+               }
+               bytecode = zmalloc(sizeof(*bytecode) + lum->u.filter.data_size);
+               if (!bytecode) {
+                       ret = -ENOMEM;
+                       goto error;
+               }
+               len = ustcomm_recv_unix_sock(sock, bytecode->data,
+                               lum->u.filter.data_size);
+               switch (len) {
+               case 0: /* orderly shutdown */
+                       ret = 0;
+                       free(bytecode);
+                       goto error;
+               case -1:
+                       DBG("Receive failed from lttng-sessiond with errno %d", errno);
+                       if (errno == ECONNRESET) {
+                               ERR("%s remote end closed connection\n", sock_info->name);
+                               ret = -EINVAL;
+                               free(bytecode);
+                               goto error;
+                       }
+                       ret = -EINVAL;
+                       goto end;
+               default:
+                       if (len == lum->u.filter.data_size) {
+                               DBG("filter data received\n");
+                               break;
+                       } else {
+                               ERR("incorrect filter data message size: %zd\n", len);
+                               ret = -EINVAL;
+                               free(bytecode);
+                               goto end;
+                       }
+               }
+               bytecode->len = lum->u.filter.data_size;
+               bytecode->reloc_offset = lum->u.filter.reloc_offset;
+               if (ops->cmd) {
+                       ret = ops->cmd(lum->handle, lum->cmd,
+                                       (unsigned long) bytecode,
+                                       &args);
+                       if (ret) {
+                               free(bytecode);
+                       }
+                       /* don't free bytecode if everything went fine. */
+               } else {
+                       ret = -ENOSYS;
+                       free(bytecode);
+               }
+               break;
+       }
        default:
                if (ops->cmd)
                        ret = ops->cmd(lum->handle, lum->cmd,
@@ -672,7 +742,7 @@ error:
  * This thread does not allocate any resource, except within
  * handle_message, within mutex protection. This mutex protects against
  * fork and exit.
- * The other moment it allocates resources is at socket connexion, which
+ * The other moment it allocates resources is at socket connection, which
  * is also protected by the mutex.
  */
 static
@@ -872,6 +942,7 @@ void __attribute__((constructor)) lttng_ust_init(void)
        lttng_fixup_event_tls();
        lttng_fixup_ringbuffer_tls();
        lttng_fixup_vtid_tls();
+       lttng_fixup_nest_count_tls();
 
        /*
         * We want precise control over the order in which we construct
This page took 0.025808 seconds and 4 git commands to generate.