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);
con->rx_page = NULL;
}
- con->retries = 0;
- mutex_unlock(&con->sock_mutex);
+
+ /* If we are an 'othercon' then NULL the pointer to us
+ from the parent and tidy ourself up */
+ if (test_bit(CF_IS_OTHERCON, &con->flags)) {
+ struct connection *parent = __nodeid2con(con->nodeid, 0);
+ parent->othercon = NULL;
+ kmem_cache_free(con_cache, con);
+ }
+ else {
+ /* Parent connections get reused */
+ con->retries = 0;
+ mutex_unlock(&con->sock_mutex);
+ }
}
/* We only send shutdown messages to nodes that are not part of the cluster */
out_close:
mutex_unlock(&con->sock_mutex);
- if (ret != -EAGAIN && !test_bit(CF_IS_OTHERCON, &con->flags)) {
+ if (ret != -EAGAIN) {
close_connection(con, false);
/* Reconnect when there is something to send */
}
log_print("Using TCP for communications");
- set_bit(CF_IS_OTHERCON, &con->flags);
-
sock = tcp_create_listen_sock(con, dlm_local_addr[0]);
if (sock) {
add_sock(sock, con);
for (i = 0; i <= max_nodeid; i++) {
con = __nodeid2con(i, 0);
if (con) {
- con->flags |= 0xFF;
+ con->flags |= 0x0F;
if (con->sock)
con->sock->sk->sk_user_data = NULL;
}
con = __nodeid2con(i, 0);
if (con) {
close_connection(con, true);
- if (con->othercon)
- kmem_cache_free(con_cache, con->othercon);
kmem_cache_free(con_cache, con);
}
}