[ LTTNG_UST_FILTER ] = "Create Filter",
};
+static const char *str_timeout;
+static int got_timeout_env;
+
extern void lttng_ring_buffer_client_overwrite_init(void);
extern void lttng_ring_buffer_client_discard_init(void);
extern void lttng_ring_buffer_metadata_client_init(void);
return 0;
}
+/*
+ * Get notify_sock timeout, in ms.
+ * -1: don't wait. 0: wait forever. >0: timeout, in ms.
+ */
+static
+long get_timeout(void)
+{
+ 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)
{
if (lum->handle == LTTNG_UST_ROOT_HANDLE)
ret = -EPERM;
else
- ret = lttng_ust_objd_unref(lum->handle);
+ ret = lttng_ust_objd_unref(lum->handle, 1);
break;
case LTTNG_UST_FILTER:
{
case LTTNG_UST_CHANNEL:
{
void *chan_data;
+ int wakeup_fd;
len = ustcomm_recv_channel_from_sessiond(sock,
- &chan_data, lum->u.channel.len);
+ &chan_data, lum->u.channel.len,
+ &wakeup_fd);
switch (len) {
case 0: /* orderly shutdown */
ret = 0;
}
}
args.channel.chan_data = chan_data;
+ args.channel.wakeup_fd = wakeup_fd;
if (ops->cmd)
ret = ops->cmd(lum->handle, lum->cmd,
(unsigned long) &lum->u,
sock_info->notify_socket = -1;
}
if (sock_info->root_handle != -1) {
- ret = lttng_ust_objd_unref(sock_info->root_handle);
+ ret = lttng_ust_objd_unref(sock_info->root_handle, 1);
if (ret) {
ERR("Error unref root handle");
}
int sock, ret, prev_connect_failed = 0, has_waited = 0;
int open_sock[2];
int i;
+ long timeout;
/* Restart trying to connect to the session daemon */
restart:
sock_info->socket = open_sock[0];
sock_info->notify_socket = open_sock[1];
+ timeout = get_notify_sock_timeout();
+ if (timeout >= 0) {
+ /*
+ * Give at least 10ms to sessiond to reply to
+ * notifications.
+ */
+ if (timeout < 10)
+ timeout = 10;
+ ret = ustcomm_setsockopt_rcv_timeout(sock_info->notify_socket,
+ timeout);
+ if (ret < 0) {
+ WARN("Error setting socket receive timeout");
+ }
+ ret = ustcomm_setsockopt_snd_timeout(sock_info->notify_socket,
+ timeout);
+ if (ret < 0) {
+ WARN("Error setting socket send timeout");
+ }
+ } else if (timeout < -1) {
+ WARN("Unsuppoorted timeout value %ld", timeout);
+ }
+
/*
* Create only one root handle per listener thread for the whole
* process lifetime, so we ensure we get ID which is statically
return NULL;
}
-/*
- * Return values: -1: don't wait. 0: wait forever. 1: timeout wait.
- */
-static
-int get_timeout(struct timespec *constructor_timeout)
-{
- long constructor_delay_ms = LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS;
- char *str_delay;
- int ret;
-
- str_delay = getenv("LTTNG_UST_REGISTER_TIMEOUT");
- if (str_delay) {
- constructor_delay_ms = strtol(str_delay, NULL, 10);
- }
-
- 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;
-}
-
/*
* sessiond monitoring thread: monitor presence of global and per-user
* sessiond by polling the application common named pipe.
lttng_ring_buffer_client_overwrite_init();
lttng_ring_buffer_client_discard_init();
- timeout_mode = get_timeout(&constructor_timeout);
+ timeout_mode = get_constructor_timeout(&constructor_timeout);
ret = sem_init(&constructor_wait, 0, 0);
assert(!ret);