filter: add seqnum field to filter command
[lttng-ust.git] / liblttng-ust / lttng-ust-comm.c
index 78201835719d36d82d2bc20fc9d0a07bf7f3957b..58461462698b3758b48100558f811b28cd4a1787 100644 (file)
@@ -288,7 +288,7 @@ int handle_message(struct sock_info *sock_info,
        case LTTNG_UST_FILTER:
        {
                /* Receive filter data */
-               struct lttng_ust_filter_bytecode *bytecode;
+               struct lttng_ust_filter_bytecode_node *bytecode;
 
                if (lum->u.filter.data_size > FILTER_BYTECODE_MAX_LEN) {
                        ERR("Filter data size is too large: %u bytes",
@@ -309,7 +309,7 @@ int handle_message(struct sock_info *sock_info,
                        ret = -ENOMEM;
                        goto error;
                }
-               len = ustcomm_recv_unix_sock(sock, bytecode->data,
+               len = ustcomm_recv_unix_sock(sock, bytecode->bc.data,
                                lum->u.filter.data_size);
                switch (len) {
                case 0: /* orderly shutdown */
@@ -337,12 +337,13 @@ int handle_message(struct sock_info *sock_info,
                                goto end;
                        }
                }
-               bytecode->len = lum->u.filter.data_size;
-               bytecode->reloc_offset = lum->u.filter.reloc_offset;
+               bytecode->bc.len = lum->u.filter.data_size;
+               bytecode->bc.reloc_offset = lum->u.filter.reloc_offset;
+               bytecode->bc.seqnum = lum->u.filter.seqnum;
                if (ops->cmd) {
                        ret = ops->cmd(lum->handle, lum->cmd,
                                        (unsigned long) bytecode,
-                                       &args);
+                                       &args, sock_info);
                        if (ret) {
                                free(bytecode);
                        }
@@ -357,7 +358,7 @@ int handle_message(struct sock_info *sock_info,
                if (ops->cmd)
                        ret = ops->cmd(lum->handle, lum->cmd,
                                        (unsigned long) &lum->u,
-                                       &args);
+                                       &args, sock_info);
                else
                        ret = -ENOSYS;
                break;
@@ -376,10 +377,31 @@ end:
                 * we already have a more precise error message to
                 * report.
                 */
-               if (ret > -LTTNG_UST_ERR)
-                       lur.ret_code = -LTTNG_UST_ERR;
-               else
+               if (ret > -LTTNG_UST_ERR) {
+                       /* Translate code to UST error. */
+                       switch (ret) {
+                       case -EEXIST:
+                               lur.ret_code = -LTTNG_UST_ERR_EXIST;
+                               break;
+                       case -EINVAL:
+                               lur.ret_code = -LTTNG_UST_ERR_INVAL;
+                               break;
+                       case -ENOENT:
+                               lur.ret_code = -LTTNG_UST_ERR_NOENT;
+                               break;
+                       case -EPERM:
+                               lur.ret_code = -LTTNG_UST_ERR_PERM;
+                               break;
+                       case -ENOSYS:
+                               lur.ret_code = -LTTNG_UST_ERR_NOSYS;
+                               break;
+                       default:
+                               lur.ret_code = -LTTNG_UST_ERR;
+                               break;
+                       }
+               } else {
                        lur.ret_code = ret;
+               }
        }
        if (ret >= 0) {
                switch (lum->cmd) {
@@ -825,7 +847,8 @@ restart:
 
        /*
         * Create only one root handle per listener thread for the whole
-        * process lifetime.
+        * process lifetime, so we ensure we get ID which is statically
+        * assigned to the root handle.
         */
        if (sock_info->root_handle == -1) {
                ret = lttng_abi_create_root_handle();
@@ -897,6 +920,10 @@ restart:
 
        }
 end:
+       ust_lock();
+       /* Cleanup socket handles before trying to reconnect */
+       lttng_ust_objd_table_owner_cleanup(sock_info);
+       ust_unlock();
        goto restart;   /* try to reconnect */
 quit:
        return NULL;
This page took 0.027486 seconds and 4 git commands to generate.