*/
extern int ustcomm_create_unix_sock(const char *pathname);
-extern int ustcomm_connect_unix_sock(const char *pathname);
+extern int ustcomm_connect_unix_sock(const char *pathname,
+ long timeout);
extern int ustcomm_accept_unix_sock(int sock);
extern int ustcomm_listen_unix_sock(int sock);
extern int ustcomm_close_unix_sock(int sock);
*
* Connect to unix socket using the path name.
*/
-int ustcomm_connect_unix_sock(const char *pathname)
+int ustcomm_connect_unix_sock(const char *pathname, long timeout)
{
struct sockaddr_un sun;
int fd, ret;
ret = -errno;
goto error;
}
+ if (timeout >= 0) {
+ /* Give at least 10ms. */
+ if (timeout < 10)
+ timeout = 10;
+ ret = ustcomm_setsockopt_snd_timeout(fd, timeout);
+ if (ret < 0) {
+ WARN("Error setting connect socket send timeout");
+ }
+ }
ret = fcntl(fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
PERROR("fcntl");
}
/*
- * Get notify_sock timeout, in ms.
+ * Get socket timeout, in ms.
* -1: wait forever. 0: don't wait. >0: timeout, in ms.
*/
static
return constructor_delay_ms;
}
+/* Timeout for notify socket send and recv. */
static
long get_notify_sock_timeout(void)
{
return get_timeout();
}
+/* Timeout for connecting to cmd and notify sockets. */
+static
+long get_connect_sock_timeout(void)
+{
+ return get_timeout();
+}
+
/*
* Return values: -1: wait forever. 0: don't wait. 1: timeout wait.
*/
* first connect registration message.
*/
/* Connect cmd socket */
- ret = ustcomm_connect_unix_sock(sock_info->sock_path);
+ ret = ustcomm_connect_unix_sock(sock_info->sock_path,
+ get_connect_sock_timeout());
if (ret < 0) {
DBG("Info: sessiond not accepting connections to %s apps socket", sock_info->name);
prev_connect_failed = 1;
ust_unlock();
/* Connect notify socket */
- ret = ustcomm_connect_unix_sock(sock_info->sock_path);
+ ret = ustcomm_connect_unix_sock(sock_info->sock_path,
+ get_connect_sock_timeout());
if (ret < 0) {
DBG("Info: sessiond not accepting connections to %s apps socket", sock_info->name);
prev_connect_failed = 1;