Skip to content

Commit

Permalink
DW-1398 move putting lister to conn_disconnect()
Browse files Browse the repository at this point in the history
closing listening socket busts accepted socket, put those sockets when disconnecting instead.
  • Loading branch information
HyunjunLee committed Feb 14, 2017
1 parent e42a80d commit 75ec335
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions drbd-headers/drbd_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ struct drbd_transport {

#ifdef _WIN32
atomic_t listening;
// DW-1398: accepted all peers and listening socket is no longer available.
atomic_t listening_done;
#endif
};

Expand Down
5 changes: 5 additions & 0 deletions drbd/drbd_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -2309,6 +2309,11 @@ extern struct drbd_resource *drbd_find_resource(const char *name);
extern void drbd_destroy_resource(struct kref *kref);
extern void conn_free_crypto(struct drbd_connection *connection);

#ifdef _WIN32
// DW-1398
extern void dtt_put_listeners(struct drbd_transport *);
#endif

/* drbd_req */
extern void do_submit(struct work_struct *ws);
#ifdef _WIN32
Expand Down
5 changes: 5 additions & 0 deletions drbd/drbd_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -8062,6 +8062,11 @@ void conn_disconnect(struct drbd_connection *connection)

change_cstate(connection, C_NETWORK_FAILURE, CS_HARD);

#ifdef _WIN32
// DW-1398: closing listening socket busts accepted socket, put those sockets here instead.
dtt_put_listeners(&connection->transport);
#endif

del_connect_timer(connection);

/* ack_receiver does not clean up anything. it must not interfere, either */
Expand Down
23 changes: 22 additions & 1 deletion drbd/drbd_transport_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,19 @@ static void dtt_incoming_connection(struct sock *sock)
spin_unlock(&listener->listener.waiters_lock);
return STATUS_REQUEST_NOT_ACCEPTED;
}

#ifdef _WIN32
// DW-1398: do not accept if already connected.
if (atomic_read(&waiter->transport->listening_done))
{
WDRBD_WARN("listening is done for this transport, request won't be accepted\n");
kfree(s_estab->sk_linux_attr);
kfree(s_estab);
spin_unlock(&listener->listener.waiters_lock);
return STATUS_REQUEST_NOT_ACCEPTED;
}
#endif

struct dtt_path * path = container_of(waiter, struct dtt_path, waiter);

if (path)
Expand Down Expand Up @@ -1517,6 +1530,8 @@ static int dtt_create_listener(struct drbd_transport *transport,
err = -1;
goto out;
}
// DW-1398: initialize.
atomic_set(&transport->listening_done, false);
#endif
return 0;
out:
Expand Down Expand Up @@ -1547,7 +1562,12 @@ static void dtt_cleanup_accepted_sockets(struct dtt_path *path)
}
#endif

#ifdef _WIN32
// DW-1398
void dtt_put_listeners(struct drbd_transport *transport)
#else
static void dtt_put_listeners(struct drbd_transport *transport)
#endif
{
struct drbd_tcp_transport *tcp_transport =
container_of(transport, struct drbd_tcp_transport, transport);
Expand Down Expand Up @@ -1852,7 +1872,8 @@ static int dtt_connect(struct drbd_transport *transport)
connect_to_path->path.established = true;
drbd_path_event(transport, &connect_to_path->path);
#ifdef _WIN32
dtt_put_listeners(transport);
// DW-1398: closing listening socket here makes accepted socket be unavailable, putting listeners is moved to conn_disconnect()
atomic_set(&transport->listening_done, true);
#else
dtt_put_listeners(transport);
#endif
Expand Down

0 comments on commit 75ec335

Please sign in to comment.