]> Pileus Git - ~andy/linux/blobdiff - fs/dlm/lowcomms.c
[DLM] Clear othercon pointers when a connection is closed
[~andy/linux] / fs / dlm / lowcomms.c
index fc0bff74c61eddfdbc7022f636ddbd7ba711a6aa..d15fd5f9f5c562f17f9a275a2c7646c948d72a83 100644 (file)
@@ -327,6 +327,8 @@ static void close_connection(struct connection *con, bool and_other)
        if (con->othercon && and_other) {
                /* Will only re-enter once. */
                close_connection(con->othercon, false);
+               kmem_cache_free(con_cache, con->othercon);
+               con->othercon = NULL;
        }
        if (con->rx_page) {
                __free_page(con->rx_page);
@@ -720,11 +722,17 @@ static int tcp_accept_from_sock(struct connection *con)
                        INIT_WORK(&othercon->rwork, process_recv_sockets);
                        set_bit(CF_IS_OTHERCON, &othercon->flags);
                        newcon->othercon = othercon;
+                       othercon->sock = newsock;
+                       newsock->sk->sk_user_data = othercon;
+                       add_sock(newsock, othercon);
+                       addcon = othercon;
+               }
+               else {
+                       printk("Extra connection from node %d attempted\n", nodeid);
+                       result = -EAGAIN;
+                       mutex_unlock(&newcon->sock_mutex);
+                       goto accept_err;
                }
-               othercon->sock = newsock;
-               newsock->sk->sk_user_data = othercon;
-               add_sock(newsock, othercon);
-               addcon = othercon;
        }
        else {
                newsock->sk->sk_user_data = newcon;
@@ -1443,7 +1451,7 @@ int dlm_lowcomms_start(void)
        error = -ENOMEM;
        con_cache = kmem_cache_create("dlm_conn", sizeof(struct connection),
                                      __alignof__(struct connection), 0,
-                                     NULL, NULL);
+                                     NULL);
        if (!con_cache)
                goto out;