struct health_state health_thread_app_reg;
struct health_state health_thread_kernel;
+/*
+ * Socket timeout for receiving and sending in seconds.
+ */
+static int app_socket_timeout;
+
static
void setup_consumerd_path(void)
{
goto error;
}
+ /* Set socket timeout for both receiving and ending */
+ (void) lttcomm_setsockopt_rcv_timeout(ust_cmd.sock,
+ app_socket_timeout);
+ (void) lttcomm_setsockopt_snd_timeout(ust_cmd.sock,
+ app_socket_timeout);
+
DBG("Apps with sock %d added to poll set",
ust_cmd.sock);
}
{
int ret = 0;
void *status;
- const char *home_path;
+ const char *home_path, *env_app_timeout;
init_kernel_workarounds();
health_init(&ustconsumer64_data.health);
health_poll_update(&ustconsumer64_data.health);
+ /* Check for the application socket timeout env variable. */
+ env_app_timeout = getenv(DEFAULT_APP_SOCKET_TIMEOUT_ENV);
+ if (env_app_timeout) {
+ app_socket_timeout = atoi(env_app_timeout);
+ } else {
+ app_socket_timeout = DEFAULT_APP_SOCKET_RW_TIMEOUT;
+ }
+
/* Create thread to manage the client socket */
ret = pthread_create(&health_thread, NULL,
thread_manage_health, (void *) NULL);
*/
#define DEFAULT_DATA_AVAILABILITY_WAIT_TIME 200000 /* usec */
+/*
+ * Default receiving and sending timeout for an application socket.
+ */
+#define DEFAULT_APP_SOCKET_RW_TIMEOUT 5 /* sec */
+#define DEFAULT_APP_SOCKET_TIMEOUT_ENV "LTTNG_APP_SOCKET_TIMEOUT"
+
#endif /* _DEFAULTS_H */
#else
#error "Please implement credential support for your OS."
#endif /* __linux__ */
+
+/*
+ * Set socket reciving timeout.
+ */
+__attribute__((visibility("hidden")))
+int lttcomm_setsockopt_rcv_timeout(int sock, unsigned int sec)
+{
+ int ret;
+ struct timeval tv;
+
+ tv.tv_sec = sec;
+ tv.tv_usec = 0;
+
+ ret = setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ if (ret < 0) {
+ PERROR("setsockopt SO_RCVTIMEO");
+ ret = -errno;
+ }
+
+ return ret;
+}
+
+/*
+ * Set socket sending timeout.
+ */
+__attribute__((visibility("hidden")))
+int lttcomm_setsockopt_snd_timeout(int sock, unsigned int sec)
+{
+ int ret;
+ struct timeval tv;
+
+ tv.tv_sec = sec;
+ tv.tv_usec = 0;
+
+ ret = setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
+ if (ret < 0) {
+ PERROR("setsockopt SO_SNDTIMEO");
+ ret = -errno;
+ }
+
+ return ret;
+}
lttng_sock_cred *creds);
extern int lttcomm_setsockopt_creds_unix_sock(int sock);
+extern int lttcomm_setsockopt_rcv_timeout(int sock, unsigned int sec);
+extern int lttcomm_setsockopt_snd_timeout(int sock, unsigned int sec);
#endif /* _LTTCOMM_UNIX_H */