This commit is contained in:
lixianjing 2022-04-23 18:06:16 +08:00
parent c5a6e7b705
commit 3c99555cab
4 changed files with 28 additions and 1 deletions

View File

@ -1,5 +1,8 @@
# 最新动态
2022/04/23
* 完善 socket\_resolve 防止溢出(感谢叶冬提供补丁)
* 完善 tk\_socket\_close 支持AWorks感谢叶冬提供补丁
* 增加 async\_call\_init\_ex2感谢叶冬提供补丁
* 重构time clock中anchor处理。
* 重构gauge pointer中anchor处理。

View File

@ -78,8 +78,12 @@ ret_t async_call(async_exec_t exec, async_on_result_t on_result, void* ctx) {
}
ret_t async_call_init_ex(uint32_t max_threads, uint32_t min_threads) {
return async_call_init_ex2(max_threads, min_threads, 0);
}
ret_t async_call_init_ex2(uint32_t max_threads, uint32_t min_threads, uint32_t stack_size) {
return_value_if_fail(s_async_thread_pool == NULL, RET_BAD_PARAMS);
s_async_thread_pool = action_thread_pool_create(max_threads, min_threads);
s_async_thread_pool = action_thread_pool_create_ex(max_threads, min_threads, stack_size, TK_THREAD_PRIORITY_NORMAL);
return_value_if_fail(s_async_thread_pool != NULL, RET_BAD_PARAMS);
return RET_OK;

View File

@ -65,6 +65,20 @@ ret_t async_call(async_exec_t exec, async_on_result_t on_result, void* ctx);
*/
ret_t async_call_init_ex(uint32_t max_threads, uint32_t min_threads);
/**
* @method async_call_init_ex2
*
*
* @annotation ["static"]
* @param {uint32_t} max_threads 线
* @param {uint32_t} min_threads 线
* @param {uint32_t} stack_size ()
*
* @return {ret_t} RET_OK表示成功
*
*/
ret_t async_call_init_ex2(uint32_t max_threads, uint32_t min_threads, uint32_t stack_size);
#define async_call_init() async_call_init_ex(5, 1)
/**

View File

@ -62,7 +62,11 @@ ret_t tk_socket_deinit() {
}
ret_t tk_socket_close(int sock) {
#ifdef AWORKS
closesocket(sock);
#else
close(sock);
#endif
return RET_OK;
}
#endif /*WIN32*/
@ -157,6 +161,8 @@ struct sockaddr* socket_resolve(const char* host, int port, struct sockaddr_in*
memset(addr, 0x00, sizeof(*addr));
addr->sin_family = AF_INET;
addr->sin_port = htons(port);
return_value_if_fail(h->h_addrtype == AF_INET, NULL);
memcpy(&(addr->sin_addr.s_addr), h->h_addr, h->h_length);
return (struct sockaddr*)addr;