changed to call lt_dlinit() and lt_dlexit() as necessary when libltdl is enabled
This commit is contained in:
		| @ -1916,6 +1916,10 @@ hcl_server_t* hcl_server_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_server_p | |||||||
| 	vmprim.vm_gettime = vm_gettime; | 	vmprim.vm_gettime = vm_gettime; | ||||||
| 	vmprim.vm_sleep = vm_sleep; | 	vmprim.vm_sleep = vm_sleep; | ||||||
|  |  | ||||||
|  | #if defined(USE_LTDL) | ||||||
|  | 	lt_dlinit (); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	hcl = hcl_open(mmgr, HCL_SIZEOF(*xtn), 2048, &vmprim, errnum); | 	hcl = hcl_open(mmgr, HCL_SIZEOF(*xtn), 2048, &vmprim, errnum); | ||||||
| 	if (!hcl) goto oops; | 	if (!hcl) goto oops; | ||||||
|  |  | ||||||
| @ -1992,7 +1996,11 @@ oops: | |||||||
| 	/* NOTE: pipe should be closed if jump to here is made after pipe() above */ | 	/* NOTE: pipe should be closed if jump to here is made after pipe() above */ | ||||||
| 	if (tmr) hcl_tmr_close (tmr); | 	if (tmr) hcl_tmr_close (tmr); | ||||||
| 	if (hcl) hcl_close (hcl); | 	if (hcl) hcl_close (hcl); | ||||||
|  | #if defined(USE_LTDL) | ||||||
|  | 	lt_dlexit (); | ||||||
|  | #endif | ||||||
| 	if (server) HCL_MMGR_FREE (mmgr, server); | 	if (server) HCL_MMGR_FREE (mmgr, server); | ||||||
|  |  | ||||||
| 	return HCL_NULL; | 	return HCL_NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -2019,6 +2027,11 @@ void hcl_server_close (hcl_server_t* server) | |||||||
|  |  | ||||||
| 	hcl_tmr_close (server->tmr); | 	hcl_tmr_close (server->tmr); | ||||||
| 	hcl_close (server->dummy_hcl); | 	hcl_close (server->dummy_hcl); | ||||||
|  |  | ||||||
|  | #if defined(USE_LTDL) | ||||||
|  | 	lt_dlexit (); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	HCL_MMGR_FREE (server->mmgr, server); | 	HCL_MMGR_FREE (server->mmgr, server); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -320,7 +320,8 @@ int main (int argc, char* argv[]) | |||||||
| 	json_xtn = hcl_json_getxtn(json); | 	json_xtn = hcl_json_getxtn(json); | ||||||
| 	json_xtn->logmask = HCL_LOG_ALL_LEVELS | HCL_LOG_ALL_TYPES; | 	json_xtn->logmask = HCL_LOG_ALL_LEVELS | HCL_LOG_ALL_TYPES; | ||||||
|  |  | ||||||
| 	p = "[ \"ab\\xab\\uC88B\\uC544\\uC6A9c\", \"kaden\", \"iron\", true, { \"null\": \"a\\1bc\", \"123\": \"AA20AA\", \"10\": -0.123, \"way\": '\\uC88B' } ]"; | 	//p = "[ \"ab\\xab\\uC88B\\uC544\\uC6A9c\", \"kaden\", \"iron\", true, { \"null\": \"a\\1bc\", \"123\": \"AA20AA\", \"10\": -0.123, \"way\": '\\uC88B' } ]"; | ||||||
|  | 	p = "{ \"result\": \"SUCCESS\", \"message\": \"1 clients\", \"sessions\": [] }"; | ||||||
|  |  | ||||||
| 	if (hcl_json_feed(json, p, strlen(p), &xlen) <= -1) | 	if (hcl_json_feed(json, p, strlen(p), &xlen) <= -1) | ||||||
| 	{	 | 	{	 | ||||||
|  | |||||||
| @ -1663,7 +1663,7 @@ static void print_synerr (hcl_t* hcl) | |||||||
|   |   | ||||||
| int main (int argc, char* argv[]) | int main (int argc, char* argv[]) | ||||||
| { | { | ||||||
| 	hcl_t* hcl; | 	hcl_t* hcl = HCL_NULL; | ||||||
| 	xtn_t* xtn; | 	xtn_t* xtn; | ||||||
| 	hcl_vmprim_t vmprim; | 	hcl_vmprim_t vmprim; | ||||||
| 	hcl_cb_t hclcb; | 	hcl_cb_t hclcb; | ||||||
| @ -1762,11 +1762,15 @@ int main (int argc, char* argv[]) | |||||||
| 	vmprim.vm_gettime = vm_gettime; | 	vmprim.vm_gettime = vm_gettime; | ||||||
| 	vmprim.vm_sleep = vm_sleep; | 	vmprim.vm_sleep = vm_sleep; | ||||||
|  |  | ||||||
|  | #if defined(USE_LTDL) | ||||||
|  | 	lt_dlinit (); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	hcl = hcl_open (&sys_mmgr, HCL_SIZEOF(xtn_t), memsize, &vmprim, HCL_NULL); | 	hcl = hcl_open (&sys_mmgr, HCL_SIZEOF(xtn_t), memsize, &vmprim, HCL_NULL); | ||||||
| 	if (!hcl) | 	if (!hcl) | ||||||
| 	{ | 	{ | ||||||
| 		printf ("cannot open hcl\n"); | 		printf ("ERROR: cannot open hcl\n"); | ||||||
| 		return -1; | 		goto oops; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	{ | 	{ | ||||||
| @ -1805,11 +1809,7 @@ int main (int argc, char* argv[]) | |||||||
|  |  | ||||||
| 	if (logopt) | 	if (logopt) | ||||||
| 	{ | 	{ | ||||||
| 		if (handle_logopt (hcl, logopt) <= -1)  | 		if (handle_logopt (hcl, logopt) <= -1) goto oops; | ||||||
| 		{ |  | ||||||
| 			hcl_close (hcl); |  | ||||||
| 			return -1; |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| @ -1820,26 +1820,20 @@ int main (int argc, char* argv[]) | |||||||
| #if defined(HCL_BUILD_DEBUG) | #if defined(HCL_BUILD_DEBUG) | ||||||
| 	if (dbgopt) | 	if (dbgopt) | ||||||
| 	{ | 	{ | ||||||
| 		if (handle_dbgopt (hcl, dbgopt) <= -1) | 		if (handle_dbgopt (hcl, dbgopt) <= -1) goto oops; | ||||||
| 		{ |  | ||||||
| 			hcl_close (hcl); |  | ||||||
| 			return -1; |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| 	if (hcl_ignite(hcl) <= -1) | 	if (hcl_ignite(hcl) <= -1) | ||||||
| 	{ | 	{ | ||||||
| 		hcl_logbfmt (hcl, HCL_LOG_STDERR, "cannot ignite hcl - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); | 		hcl_logbfmt (hcl, HCL_LOG_STDERR, "cannot ignite hcl - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); | ||||||
| 		hcl_close (hcl); | 		goto oops; | ||||||
| 		return -1; |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (hcl_addbuiltinprims(hcl) <= -1) | 	if (hcl_addbuiltinprims(hcl) <= -1) | ||||||
| 	{ | 	{ | ||||||
| 		hcl_logbfmt (hcl, HCL_LOG_STDERR, "cannot add builtin primitives - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); | 		hcl_logbfmt (hcl, HCL_LOG_STDERR, "cannot add builtin primitives - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); | ||||||
| 		hcl_close (hcl); | 		goto oops; | ||||||
| 		return -1; |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	xtn->read_path = argv[opt.ind++]; | 	xtn->read_path = argv[opt.ind++]; | ||||||
| @ -1848,8 +1842,7 @@ int main (int argc, char* argv[]) | |||||||
| 	if (hcl_attachio(hcl, read_handler, print_handler) <= -1) | 	if (hcl_attachio(hcl, read_handler, print_handler) <= -1) | ||||||
| 	{ | 	{ | ||||||
| 		hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot attach input stream - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); | 		hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot attach input stream - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); | ||||||
| 		hcl_close (hcl); | 		goto oops; | ||||||
| 		return -1; |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	{ | 	{ | ||||||
| @ -1858,8 +1851,7 @@ int main (int argc, char* argv[]) | |||||||
| 		if (!xtn->sym_errstr) | 		if (!xtn->sym_errstr) | ||||||
| 		{ | 		{ | ||||||
| 			hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot create the ERRSTR symbol - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); | 			hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot create the ERRSTR symbol - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); | ||||||
| 			hcl_close (hcl); | 			goto oops; | ||||||
| 			return -1; |  | ||||||
| 		} | 		} | ||||||
| 		HCL_OBJ_SET_FLAGS_KERNEL (xtn->sym_errstr, 1); | 		HCL_OBJ_SET_FLAGS_KERNEL (xtn->sym_errstr, 1); | ||||||
| 	} | 	} | ||||||
| @ -1982,10 +1974,17 @@ count++; | |||||||
| 	 | 	 | ||||||
| 	set_signal_to_default (SIGINT); | 	set_signal_to_default (SIGINT); | ||||||
| 	hcl_close (hcl); | 	hcl_close (hcl); | ||||||
|  |  | ||||||
|  | #if defined(USE_LTDL) | ||||||
|  | 	lt_dlexit (); | ||||||
|  | #endif | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
| oops: | oops: | ||||||
| 	set_signal_to_default (SIGINT); | 	set_signal_to_default (SIGINT); /* harmless to call multiple times without set_signal() */ | ||||||
| 	hcl_close (hcl); | 	if (hcl) hcl_close (hcl); | ||||||
|  | #if defined(USE_LTDL) | ||||||
|  | 	lt_dlexit (); | ||||||
|  | #endif | ||||||
| 	return -1; | 	return -1; | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user