sock: Release sock_map entries before shutdown

There are a small, bounded set of placement_ids that the socket layer
will ever encounter, and they remain valid for the lifetime of the
program. The association between a poll group and a placement_id is now
correctly broken when the reference count drops to 0 (in response to
sock_map_release calls), so do not free the entry when the poll group is
destroyed so that it may be reused again.

Change-Id: Iad90e2da7d0860fa8c5cff24f9699bef30cd7bc2
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7210
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Ben Walker 2021-03-30 11:20:16 -07:00 committed by Jim Harris
parent 4ce63b9877
commit 21c06bac09

View File

@ -149,21 +149,17 @@ sock_map_lookup(int placement_id, struct spdk_sock_group **group)
return rc;
}
/* Remove the socket group from the map table */
static void
sock_remove_sock_group_from_map_table(struct spdk_sock_group *group)
__attribute((destructor)) static void
sock_map_cleanup(void)
{
struct spdk_sock_placement_id_entry *entry, *tmp;
pthread_mutex_lock(&g_map_table_mutex);
STAILQ_FOREACH_SAFE(entry, &g_placement_id_map, link, tmp) {
if (entry->group == group) {
STAILQ_REMOVE(&g_placement_id_map, entry, spdk_sock_placement_id_entry, link);
free(entry);
}
STAILQ_REMOVE(&g_placement_id_map, entry, spdk_sock_placement_id_entry, link);
free(entry);
}
pthread_mutex_unlock(&g_map_table_mutex);
}
static int
@ -741,7 +737,6 @@ spdk_sock_group_close(struct spdk_sock_group **group)
}
}
sock_remove_sock_group_from_map_table(*group);
free(*group);
*group = NULL;