mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-29 18:37:41 +08:00
Don't show warning for dbuf module.
This commit is contained in:
parent
2a1b89bac6
commit
3f2c682958
@ -47,15 +47,17 @@ ACL_DBUF_POOL *acl_dbuf_pool_create(size_t block_size)
|
||||
memset(&info, 0, sizeof(SYSTEM_INFO));
|
||||
GetSystemInfo(&info);
|
||||
page_size = info.dwPageSize;
|
||||
if (page_size <= 0)
|
||||
if (page_size <= 0) {
|
||||
page_size = 4096;
|
||||
}
|
||||
#else
|
||||
page_size = 4096;
|
||||
#endif
|
||||
|
||||
size = (block_size / (size_t) page_size) * (size_t) page_size;
|
||||
if (size < (size_t) page_size)
|
||||
if (size < (size_t) page_size) {
|
||||
size = page_size;
|
||||
}
|
||||
|
||||
/* xxx: 为了尽量保证在调用 acl_mymalloc 分配内存时为内存页的整数倍,
|
||||
* 需要减去 sizeof(ACL_DBUF) 和 16 字节,其中 16 字节是 acl_mymalloc
|
||||
@ -78,7 +80,7 @@ ACL_DBUF_POOL *acl_dbuf_pool_create(size_t block_size)
|
||||
pool->head = (ACL_DBUF*) pool->buf;
|
||||
pool->head->next = NULL;
|
||||
pool->head->keep = 1;
|
||||
pool->head->used = 0;
|
||||
pool->head->used = 1;
|
||||
pool->head->size = size;
|
||||
pool->head->addr = pool->head->buf;
|
||||
pool->count = 1;
|
||||
@ -93,10 +95,13 @@ void acl_dbuf_pool_destroy(ACL_DBUF_POOL *pool)
|
||||
while (iter) {
|
||||
tmp = iter;
|
||||
iter = iter->next;
|
||||
if ((char*) tmp == pool->buf)
|
||||
if ((char*) tmp == pool->buf) {
|
||||
break;
|
||||
if (tmp->size > pool->block_size)
|
||||
}
|
||||
if (tmp->size > pool->block_size) {
|
||||
pool->huge--;
|
||||
}
|
||||
|
||||
#ifdef USE_VALLOC
|
||||
free(tmp);
|
||||
#else
|
||||
|
@ -1,3 +1,4 @@
|
||||
include ../Makefile_cpp.in
|
||||
#EXTLIBS = -L../../../lib/linux64 -lpolarssl
|
||||
#EXTLIBS = -L../../../test/libmm -lmm -Wl,-rpath,../../../test/libmm
|
||||
PROG = httpd
|
||||
|
@ -9,6 +9,7 @@ static int __rw_timeout = 10;
|
||||
static acl::string __ssl_crt("./ssl_crt.pem");
|
||||
static acl::string __ssl_key("./ssl_key.pem");
|
||||
static acl::sslbase_conf* __ssl_conf;
|
||||
static bool __shared_stack = false;
|
||||
|
||||
static void http_server(ACL_FIBER *, void *ctx)
|
||||
{
|
||||
@ -80,6 +81,14 @@ static void fiber_accept(ACL_FIBER *, void *ctx)
|
||||
{
|
||||
const char* addr = (const char* ) ctx;
|
||||
acl::server_socket server;
|
||||
ACL_FIBER_ATTR attr;
|
||||
|
||||
acl_fiber_attr_init(&attr);
|
||||
|
||||
if (__shared_stack) {
|
||||
acl_fiber_attr_setstacksize(&attr, 4096);
|
||||
acl_fiber_attr_setsharestack(&attr, 1);
|
||||
}
|
||||
|
||||
ssl_init(*__ssl_conf, __ssl_crt, __ssl_key);
|
||||
|
||||
@ -99,7 +108,11 @@ static void fiber_accept(ACL_FIBER *, void *ctx)
|
||||
|
||||
client->set_rw_timeout(__rw_timeout);
|
||||
printf("accept one: %d\r\n", client->sock_handle());
|
||||
acl_fiber_create(http_server, client, STACK_SIZE);
|
||||
if (__shared_stack) {
|
||||
acl_fiber_create2(&attr, http_server, client);
|
||||
} else {
|
||||
acl_fiber_create(http_server, client, STACK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
exit (0);
|
||||
@ -108,6 +121,7 @@ static void fiber_accept(ACL_FIBER *, void *ctx)
|
||||
static void usage(const char* procname)
|
||||
{
|
||||
printf("usage: %s -h [help]\r\n"
|
||||
" -S [use shared stack]\r\n"
|
||||
" -l ssl_lib_path\r\n"
|
||||
" -s listen_addr\r\n"
|
||||
" -r rw_timeout\r\n"
|
||||
@ -128,7 +142,7 @@ int main(int argc, char *argv[])
|
||||
acl::acl_cpp_init();
|
||||
acl::log::stdout_open(true);
|
||||
|
||||
while ((ch = getopt(argc, argv, "hs:r:c:k:l:")) > 0) {
|
||||
while ((ch = getopt(argc, argv, "hs:r:c:k:l:S")) > 0) {
|
||||
switch (ch) {
|
||||
case 'h':
|
||||
usage(argv[0]);
|
||||
@ -148,6 +162,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
libpath = optarg;
|
||||
break;
|
||||
case 'S':
|
||||
__shared_stack =true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user