sock/posix: Store pointer to group in sock
It was previously impossible to get back to the group from the socket. This will be needed later. Change-Id: I7b72c1b3bb9f5f4fda7e94475636e103df409316 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470522 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
a0889ece60
commit
7756ba14e4
@ -49,10 +49,11 @@ extern "C" {
|
||||
#define MAX_EVENTS_PER_POLL 32
|
||||
|
||||
struct spdk_sock {
|
||||
struct spdk_net_impl *net_impl;
|
||||
spdk_sock_cb cb_fn;
|
||||
void *cb_arg;
|
||||
TAILQ_ENTRY(spdk_sock) link;
|
||||
struct spdk_net_impl *net_impl;
|
||||
spdk_sock_cb cb_fn;
|
||||
void *cb_arg;
|
||||
struct spdk_sock_group_impl *group_impl;
|
||||
TAILQ_ENTRY(spdk_sock) link;
|
||||
};
|
||||
|
||||
struct spdk_sock_group {
|
||||
|
@ -363,7 +363,7 @@ spdk_sock_group_add_sock(struct spdk_sock_group *group, struct spdk_sock *sock,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sock->cb_fn != NULL) {
|
||||
if (sock->group_impl != NULL) {
|
||||
/*
|
||||
* This sock is already part of a sock_group. Currently we don't
|
||||
* support this.
|
||||
@ -394,6 +394,7 @@ spdk_sock_group_add_sock(struct spdk_sock_group *group, struct spdk_sock *sock,
|
||||
rc = group_impl->net_impl->group_impl_add_sock(group_impl, sock);
|
||||
if (rc == 0) {
|
||||
TAILQ_INSERT_TAIL(&group_impl->socks, sock, link);
|
||||
sock->group_impl = group_impl;
|
||||
sock->cb_fn = cb_fn;
|
||||
sock->cb_arg = cb_arg;
|
||||
}
|
||||
@ -418,6 +419,8 @@ spdk_sock_group_remove_sock(struct spdk_sock_group *group, struct spdk_sock *soc
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(group_impl == sock->group_impl);
|
||||
|
||||
rc = sock->net_impl->get_placement_id(sock, &placement_id);
|
||||
if (!rc && (placement_id != 0)) {
|
||||
spdk_sock_map_release(placement_id);
|
||||
@ -426,6 +429,7 @@ spdk_sock_group_remove_sock(struct spdk_sock_group *group, struct spdk_sock *soc
|
||||
rc = group_impl->net_impl->group_impl_remove_sock(group_impl, sock);
|
||||
if (rc == 0) {
|
||||
TAILQ_REMOVE(&group_impl->socks, sock, link);
|
||||
sock->group_impl = NULL;
|
||||
sock->cb_fn = NULL;
|
||||
sock->cb_arg = NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user