- ssize_t ret;
- struct {
- uint32_t major;
- uint32_t minor;
- pid_t pid;
- pid_t ppid;
- uid_t uid;
- gid_t gid;
- uint32_t bits_per_long;
- char name[16]; /* process name */
- } reg_msg;
-
- reg_msg.major = LTTNG_UST_COMM_VERSION_MAJOR;
- reg_msg.minor = LTTNG_UST_COMM_VERSION_MINOR;
- reg_msg.pid = getpid();
- reg_msg.ppid = getppid();
- reg_msg.uid = getuid();
- reg_msg.gid = getgid();
- reg_msg.bits_per_long = CAA_BITS_PER_LONG;
- lttng_ust_getprocname(reg_msg.name);
-
- ret = ustcomm_send_unix_sock(socket, ®_msg, sizeof(reg_msg));
- if (ret >= 0 && ret != sizeof(reg_msg))
- return -EIO;
- return ret;
+ long constructor_delay_ms = LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS;
+
+ if (!got_timeout_env) {
+ str_timeout = getenv("LTTNG_UST_REGISTER_TIMEOUT");
+ got_timeout_env = 1;
+ }
+ if (str_timeout)
+ constructor_delay_ms = strtol(str_timeout, NULL, 10);
+ return constructor_delay_ms;
+}
+
+static
+long get_notify_sock_timeout(void)
+{
+ return get_timeout();
+}
+
+/*
+ * Return values: -1: don't wait. 0: wait forever. 1: timeout wait.
+ */
+static
+int get_constructor_timeout(struct timespec *constructor_timeout)
+{
+ long constructor_delay_ms;
+ int ret;
+
+ constructor_delay_ms = get_timeout();
+
+ switch (constructor_delay_ms) {
+ case -1:/* fall-through */
+ case 0:
+ return constructor_delay_ms;
+ default:
+ break;
+ }
+
+ /*
+ * If we are unable to find the current time, don't wait.
+ */
+ ret = clock_gettime(CLOCK_REALTIME, constructor_timeout);
+ if (ret) {
+ return -1;
+ }
+ constructor_timeout->tv_sec += constructor_delay_ms / 1000UL;
+ constructor_timeout->tv_nsec +=
+ (constructor_delay_ms % 1000UL) * 1000000UL;
+ if (constructor_timeout->tv_nsec >= 1000000000UL) {
+ constructor_timeout->tv_sec++;
+ constructor_timeout->tv_nsec -= 1000000000UL;
+ }
+ return 1;
+}
+
+static
+int register_to_sessiond(int socket, enum ustctl_socket_type type)
+{
+ return ustcomm_send_reg_msg(socket,
+ type,
+ CAA_BITS_PER_LONG,
+ lttng_alignof(uint8_t) * CHAR_BIT,
+ lttng_alignof(uint16_t) * CHAR_BIT,
+ lttng_alignof(uint32_t) * CHAR_BIT,
+ lttng_alignof(uint64_t) * CHAR_BIT,
+ lttng_alignof(unsigned long) * CHAR_BIT);