Compare commits

...

2 Commits

Author SHA1 Message Date
YuQing e4a9fccddb set extra_params for socket gracefully 2025-01-26 13:02:07 +08:00
YuQing 5477593ce8 log error on thread local hashtable exception 2025-01-26 11:43:38 +08:00
1 changed files with 17 additions and 6 deletions

View File

@ -166,7 +166,7 @@ static ConnectionManager *find_manager(ConnectionPool *cp,
memcpy(cm->key.str, key->str, key->len + 1);
cm->key.len = key->len;
//add to chain
//add to manager chain
cm->next = bucket->head;
bucket->head = cm;
return cm;
@ -297,17 +297,21 @@ int conn_pool_init_ex1(ConnectionPool *cp, const int connect_timeout,
return result;
}
if (extra_params != NULL) {
if (extra_params != NULL && extra_params->rdma.pd != NULL) {
extra_connection_size = G_RDMA_CONNECTION_CALLBACKS.
get_connection_size();
obj_init_func = (fast_mblock_object_init_func)node_init_for_rdma;
cp->extra_params = *extra_params;
} else {
extra_connection_size = 0;
cp->extra_params.tls.enabled = false;
cp->extra_params.tls.htable_capacity = 163;
cp->extra_params.rdma.buffer_size = 0;
cp->extra_params.rdma.pd = NULL;
if (extra_params != NULL) {
cp->extra_params = *extra_params;
} else {
cp->extra_params.tls.enabled = false;
cp->extra_params.tls.htable_capacity = 163;
cp->extra_params.rdma.buffer_size = 0;
cp->extra_params.rdma.pd = NULL;
}
obj_init_func = (fast_mblock_object_init_func)node_init_for_socket;
}
if ((result=fast_mblock_init_ex1(&cp->node_allocator, "cpool-node",
@ -730,6 +734,7 @@ ConnectionInfo *conn_pool_get_connection_ex(ConnectionPool *cp,
return NULL;
}
//add to thread local hashtable
node = (ConnectionNode *)((char *)ci - sizeof(ConnectionNode));
node->next = *bucket;
*bucket = node;
@ -762,6 +767,8 @@ int conn_pool_close_connection_ex(ConnectionPool *cp,
htable = pthread_getspecific(cp->tls_key);
if (htable == NULL) {
logError("file: "__FILE__", line: %d, "
"the thread local key NOT exist!", __LINE__);
return close_connection(cp, conn, &key, hash_code, bForce);
}
@ -791,6 +798,10 @@ int conn_pool_close_connection_ex(ConnectionPool *cp,
} else {
previous->next = node->next;
}
} else {
logError("file: "__FILE__", line: %d, "
"%.*s NOT in the thread local hashtable!",
__LINE__, key.len, key.str);
}
return close_connection(cp, conn, &key, hash_code, bForce);