Commit bd44e2b0 authored by Patrick Caulfield's avatar Patrick Caulfield Committed by Steven Whitehouse

[DLM] fix lowcomms receiving

This patch fixes a bug whereby data on a newly accepted connection would be
ignored if it arrived soon after the accept.
Signed-Off-By: default avatarPatrick Caulfield <pcaulfie@redhat.com>
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent b5d32bea
...@@ -327,6 +327,9 @@ static int receive_from_sock(struct connection *con) ...@@ -327,6 +327,9 @@ static int receive_from_sock(struct connection *con)
if (ret <= 0) if (ret <= 0)
goto out_close; goto out_close;
if (ret == -EAGAIN)
goto out_resched;
if (ret == len) if (ret == len)
call_again_soon = 1; call_again_soon = 1;
cbuf_add(&con->cb, ret); cbuf_add(&con->cb, ret);
...@@ -359,8 +362,7 @@ static int receive_from_sock(struct connection *con) ...@@ -359,8 +362,7 @@ static int receive_from_sock(struct connection *con)
if (!test_and_set_bit(CF_READ_PENDING, &con->flags)) if (!test_and_set_bit(CF_READ_PENDING, &con->flags))
queue_work(recv_workqueue, &con->rwork); queue_work(recv_workqueue, &con->rwork);
up_read(&con->sock_sem); up_read(&con->sock_sem);
cond_resched(); return -EAGAIN;
return 0;
out_close: out_close:
up_read(&con->sock_sem); up_read(&con->sock_sem);
...@@ -381,6 +383,7 @@ static int accept_from_sock(struct connection *con) ...@@ -381,6 +383,7 @@ static int accept_from_sock(struct connection *con)
int len; int len;
int nodeid; int nodeid;
struct connection *newcon; struct connection *newcon;
struct connection *addcon;
memset(&peeraddr, 0, sizeof(peeraddr)); memset(&peeraddr, 0, sizeof(peeraddr));
result = sock_create_kern(dlm_local_addr.ss_family, SOCK_STREAM, result = sock_create_kern(dlm_local_addr.ss_family, SOCK_STREAM,
...@@ -454,12 +457,13 @@ static int accept_from_sock(struct connection *con) ...@@ -454,12 +457,13 @@ static int accept_from_sock(struct connection *con)
othercon->sock = newsock; othercon->sock = newsock;
newsock->sk->sk_user_data = othercon; newsock->sk->sk_user_data = othercon;
add_sock(newsock, othercon); add_sock(newsock, othercon);
addcon = othercon;
} }
else { else {
newsock->sk->sk_user_data = newcon; newsock->sk->sk_user_data = newcon;
newcon->rx_action = receive_from_sock; newcon->rx_action = receive_from_sock;
add_sock(newsock, newcon); add_sock(newsock, newcon);
addcon = newcon;
} }
up_write(&newcon->sock_sem); up_write(&newcon->sock_sem);
...@@ -469,8 +473,8 @@ static int accept_from_sock(struct connection *con) ...@@ -469,8 +473,8 @@ static int accept_from_sock(struct connection *con)
* beween processing the accept adding the socket * beween processing the accept adding the socket
* to the read_sockets list * to the read_sockets list
*/ */
if (!test_and_set_bit(CF_READ_PENDING, &newcon->flags)) if (!test_and_set_bit(CF_READ_PENDING, &addcon->flags))
queue_work(recv_workqueue, &newcon->rwork); queue_work(recv_workqueue, &addcon->rwork);
up_read(&con->sock_sem); up_read(&con->sock_sem);
return 0; return 0;
...@@ -610,8 +614,7 @@ static struct socket *create_listen_sock(struct connection *con, ...@@ -610,8 +614,7 @@ static struct socket *create_listen_sock(struct connection *con,
result = sock->ops->listen(sock, 5); result = sock->ops->listen(sock, 5);
if (result < 0) { if (result < 0) {
printk("dlm: Can't listen on port %d\n", printk("dlm: Can't listen on port %d\n", dlm_config.ci_tcp_port);
dlm_config.ci_tcp_port);
sock_release(sock); sock_release(sock);
sock = NULL; sock = NULL;
goto create_out; goto create_out;
...@@ -811,7 +814,7 @@ static void send_to_sock(struct connection *con) ...@@ -811,7 +814,7 @@ static void send_to_sock(struct connection *con)
out_connect: out_connect:
up_read(&con->sock_sem); up_read(&con->sock_sem);
lowcomms_connect_sock(con); connect_to_sock(con);
return; return;
} }
...@@ -873,9 +876,8 @@ static void process_send_sockets(struct work_struct *work) ...@@ -873,9 +876,8 @@ static void process_send_sockets(struct work_struct *work)
connect_to_sock(con); connect_to_sock(con);
} }
if (test_and_clear_bit(CF_WRITE_PENDING, &con->flags)) { clear_bit(CF_WRITE_PENDING, &con->flags);
send_to_sock(con); send_to_sock(con);
}
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment