connect: don't report EACCES
[lttng-ust.git] / liblttng-ust-comm / lttng-ust-comm.c
index a666ab274b5f3a25af9f77f5cea779938d2da986..087424fe66626a6dd393315ccb3fa896c54322ff 100644 (file)
@@ -123,7 +123,7 @@ int ustcomm_connect_unix_sock(const char *pathname)
                 * file exists but no sessiond is listening.
                 */
                if (errno != ECONNREFUSED && errno != ECONNRESET
-                               && errno != ENOENT)
+                               && errno != ENOENT && errno != EACCES)
                        PERROR("connect");
                ret = -errno;
                if (ret == -ECONNREFUSED || ret == -ECONNRESET)
@@ -546,10 +546,12 @@ int ustcomm_send_app_cmd(int sock,
  * expected var_len.
  */
 ssize_t ustcomm_recv_channel_from_sessiond(int sock,
-               void **_chan_data, uint64_t var_len)
+               void **_chan_data, uint64_t var_len,
+               int *_wakeup_fd)
 {
        void *chan_data;
-       ssize_t len;
+       ssize_t len, nr_fd;
+       int wakeup_fd;
 
        if (var_len > LTTNG_UST_CHANNEL_DATA_MAX_LEN) {
                len = -EINVAL;
@@ -565,6 +567,18 @@ ssize_t ustcomm_recv_channel_from_sessiond(int sock,
        if (len != var_len) {
                goto error_recv;
        }
+       /* recv wakeup fd */
+       nr_fd = ustcomm_recv_fds_unix_sock(sock, &wakeup_fd, 1);
+       if (nr_fd <= 0) {
+               if (nr_fd < 0) {
+                       len = nr_fd;
+                       goto error_recv;
+               } else {
+                       len = -EIO;
+                       goto error_recv;
+               }
+       }
+       *_wakeup_fd = wakeup_fd;
        *_chan_data = chan_data;
        return len;
 
@@ -642,6 +656,26 @@ int ustcomm_send_reg_msg(int sock,
        return 0;
 }
 
+static
+int serialize_string_encoding(enum ustctl_string_encodings *ue,
+               enum lttng_string_encodings le)
+{
+       switch (le) {
+       case lttng_encode_none:
+               *ue = ustctl_encode_none;
+               break;
+       case lttng_encode_UTF8:
+               *ue = ustctl_encode_UTF8;
+               break;
+       case lttng_encode_ASCII:
+               *ue = ustctl_encode_ASCII;
+               break;
+       default:
+               return -EINVAL;
+       }
+       return 0;
+}
+
 static
 int serialize_basic_type(enum ustctl_abstract_types *uatype,
                enum lttng_abstract_types atype,
@@ -660,14 +694,17 @@ int serialize_basic_type(enum ustctl_abstract_types *uatype,
                uit->signedness = lit->signedness;
                uit->reverse_byte_order = lit->reverse_byte_order;
                uit->base = lit->base;
-               uit->encoding = lit->encoding;
+               if (serialize_string_encoding(&uit->encoding, lit->encoding))
+                       return -EINVAL;
                uit->alignment = lit->alignment;
                *uatype = ustctl_atype_integer;
                break;
        }
        case atype_string:
        {
-               ubt->string.encoding = lbt->string.encoding;
+               if (serialize_string_encoding(&ubt->string.encoding,
+                               lbt->string.encoding))
+                       return -EINVAL;
                *uatype = ustctl_atype_string;
                break;
        }
@@ -817,7 +854,7 @@ int ustcomm_register_event(int sock,
                struct ustcomm_notify_event_reply r;
        } reply;
        size_t signature_len, fields_len, model_emf_uri_len;
-       struct ustctl_field *fields;
+       struct ustctl_field *fields = NULL;
        size_t nr_write_fields = 0;
        int ret;
 
This page took 0.024088 seconds and 4 git commands to generate.