Commit 21c06bac authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7210


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 4ce63b98
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -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);
	}
	}
	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;