Commit 14f45fc8 authored by Cunyin Chang's avatar Cunyin Chang Committed by Jim Harris
Browse files

env: close all files which still opened before shutdown.



For multiple db test, there will be some files not close at the end of test,
this patch make sure to close all the files before shutdown the app.

Change-Id: Ie87d9e44b55a9192a19c35c439fbf33268f8ca4c
Signed-off-by: default avatarCunyin Chang <cunyin.chang@intel.com>
Reviewed-on: https://review.gerrithub.io/375168


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 970891cc
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -609,6 +609,23 @@ SpdkEnv::SpdkEnv(Env *base_env, const std::string &dir, const std::string &conf,

SpdkEnv::~SpdkEnv()
{
	/* This is a workaround for rocksdb test, we close the files if the rocksdb not
	 * do the work before the test quit.
	 */
	if (g_fs != NULL) {
		spdk_fs_iter iter;
		struct spdk_file *file;

		if (!g_sync_args.channel)
			SpdkInitializeThread();
		iter = spdk_fs_iter_first(g_fs);
		while (iter != NULL) {
			file = spdk_fs_iter_get_file(iter);
			spdk_file_close(file, g_sync_args.channel);
			iter = spdk_fs_iter_next(iter);
		}
	}

	spdk_app_start_shutdown();
	pthread_join(mSpdkTid, NULL);
}