Compare commits

...

4 Commits

Author SHA1 Message Date
Hongcai Deng 22cec5fcc3
Merge a16fde8070 into e4a9fccddb 2025-01-26 13:03:07 +08:00
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
Hongcai Deng a16fde8070 fix: compile error when build .so using .a
```
src/libfastcommon.a(hash.o): relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC
```

env: Ubuntu 14.04, gcc 4.8
2017-01-29 14:20:18 +08:00
2 changed files with 18 additions and 7 deletions

View File

@ -66,7 +66,7 @@ libfastcommon.a: $(FAST_STATIC_OBJS)
.c:
$(COMPILE) -o $@ $< $(FAST_STATIC_OBJS) $(LIB_PATH) $(INC_PATH)
.c.o:
$(COMPILE) -c -o $@ $< $(INC_PATH)
$(COMPILE) -c -fPIC -o $@ $< $(INC_PATH)
.c.lo:
$(COMPILE) -c -fPIC -o $@ $< $(INC_PATH)
install:

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);