|
@@ -1037,6 +1037,7 @@ static void sctp_connect_to_sock(struct connection *con)
|
|
|
int result;
|
|
|
int addr_len;
|
|
|
struct socket *sock;
|
|
|
+ struct timeval tv = { .tv_sec = 5, .tv_usec = 0 };
|
|
|
|
|
|
if (con->nodeid == 0) {
|
|
|
log_print("attempt to connect sock 0 foiled");
|
|
@@ -1083,8 +1084,19 @@ static void sctp_connect_to_sock(struct connection *con)
|
|
|
kernel_setsockopt(sock, SOL_SCTP, SCTP_NODELAY, (char *)&one,
|
|
|
sizeof(one));
|
|
|
|
|
|
+ /*
|
|
|
+ * Make sock->ops->connect() function return in specified time,
|
|
|
+ * since O_NONBLOCK argument in connect() function does not work here,
|
|
|
+ * then, we should restore the default value of this attribute.
|
|
|
+ */
|
|
|
+ kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,
|
|
|
+ sizeof(tv));
|
|
|
result = sock->ops->connect(sock, (struct sockaddr *)&daddr, addr_len,
|
|
|
O_NONBLOCK);
|
|
|
+ memset(&tv, 0, sizeof(tv));
|
|
|
+ kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,
|
|
|
+ sizeof(tv));
|
|
|
+
|
|
|
if (result == -EINPROGRESS)
|
|
|
result = 0;
|
|
|
if (result == 0)
|