Compare commits

..

1 Commits

Author SHA1 Message Date
Hongcai Deng 22cec5fcc3
Merge a16fde8070 into e4a9fccddb 2025-01-26 13:03:07 +08:00
5 changed files with 13 additions and 25 deletions

View File

@ -1,9 +1,8 @@
Version 1.76 2025-01-27
Version 1.76 2024-11-01
* get_mounted_filesystems act as program df
* add function get_statfs_by_path
* add function is_rotational_device_by_path
* conn_pool_get_connection_ex add parameter: shared
Version 1.75 2024-09-22
* task init callback support extra argument

View File

@ -651,8 +651,7 @@ static ConnectionInfo *get_conn(ConnectionPool *cp,
static ConnectionInfo *get_connection(ConnectionPool *cp,
const ConnectionInfo *conn, const string_t *key,
const uint32_t hash_code, const char *service_name,
const bool shared, int *err_no)
const uint32_t hash_code, const char *service_name, int *err_no)
{
ConnectionBucket *bucket;
ConnectionManager *cm;
@ -663,10 +662,6 @@ static ConnectionInfo *get_connection(ConnectionPool *cp,
if ((cm=find_manager(cp, bucket, key, true)) != NULL)
{
ci = get_conn(cp, cm, &bucket->lock, conn, service_name, err_no);
if (ci != NULL)
{
ci->shared = shared;
}
}
else
{
@ -678,8 +673,7 @@ static ConnectionInfo *get_connection(ConnectionPool *cp,
}
ConnectionInfo *conn_pool_get_connection_ex(ConnectionPool *cp,
const ConnectionInfo *conn, const char *service_name,
const bool shared, int *err_no)
const ConnectionInfo *conn, const char *service_name, int *err_no)
{
string_t key;
int bytes;
@ -693,9 +687,8 @@ ConnectionInfo *conn_pool_get_connection_ex(ConnectionPool *cp,
key.str = key_buff;
conn_pool_get_key(conn, key.str, &key.len);
hash_code = fc_simple_hash(key.str, key.len);
if (!cp->extra_params.tls.enabled || !shared) {
return get_connection(cp, conn, &key, hash_code,
service_name, shared, err_no);
if (!cp->extra_params.tls.enabled) {
return get_connection(cp, conn, &key, hash_code, service_name, err_no);
}
htable = pthread_getspecific(cp->tls_key);
@ -736,7 +729,7 @@ ConnectionInfo *conn_pool_get_connection_ex(ConnectionPool *cp,
return node->conn;
} else {
if ((ci=get_connection(cp, conn, &key, hash_code,
service_name, shared, err_no)) == NULL)
service_name, err_no)) == NULL)
{
return NULL;
}
@ -764,11 +757,10 @@ int conn_pool_close_connection_ex(ConnectionPool *cp,
key.str = key_buff;
conn_pool_get_key(conn, key.str, &key.len);
hash_code = fc_simple_hash(key.str, key.len);
if (!cp->extra_params.tls.enabled || !conn->shared) {
if (!cp->extra_params.tls.enabled) {
return close_connection(cp, conn, &key, hash_code, bForce);
}
//thread local logic
if (!bForce) {
return 0;
}

View File

@ -50,8 +50,7 @@ typedef enum {
typedef struct {
int sock;
uint16_t port;
uint8_t af; //address family, AF_INET, AF_INET6 or AF_UNSPEC for auto dedect
bool shared; //for connection pool
short af; //address family, AF_INET, AF_INET6 or AF_UNSPEC for auto dedect
FCCommunicationType comm_type;
bool validate_flag; //for connection pool
char ip_addr[IP_ADDRESS_SIZE];
@ -300,16 +299,14 @@ void conn_pool_destroy(ConnectionPool *cp);
* cp: the ConnectionPool
* conn: the connection
* service_name: the service name to log
* shared: if the connection shared
* err_no: return the the errno, 0 for success
* return != NULL for success, NULL for error
*/
ConnectionInfo *conn_pool_get_connection_ex(ConnectionPool *cp,
const ConnectionInfo *conn, const char *service_name,
const bool shared, int *err_no);
const ConnectionInfo *conn, const char *service_name, int *err_no);
#define conn_pool_get_connection(cp, conn, err_no) \
conn_pool_get_connection_ex(cp, conn, NULL, false, err_no)
conn_pool_get_connection_ex(cp, conn, NULL, err_no)
#define conn_pool_close_connection(cp, conn) \
conn_pool_close_connection_ex(cp, conn, false)

View File

@ -1201,7 +1201,7 @@ char *getHostnameByIp(const char *szIpAddr, char *buff, const int bufferSize)
}
in_addr_64_t getIpaddrByNameEx(const char *name, char *buff,
const int bufferSize, uint8_t *af)
const int bufferSize, short *af)
{
struct addrinfo hints, *res, *p;
struct in_addr addr4;

View File

@ -391,12 +391,12 @@ char *getHostnameByIp(const char *szIpAddr, char *buff, const int bufferSize);
* return: in_addr_64_t, INADDR_NONE for fail
*/
in_addr_64_t getIpaddrByNameEx(const char *name, char *buff,
const int bufferSize, uint8_t *af);
const int bufferSize, short *af);
static inline in_addr_64_t getIpaddrByName(const char *name,
char *buff, const int bufferSize)
{
uint8_t af;
short af;
return getIpaddrByNameEx(name, buff, bufferSize, &af);
}