add macro function fc_string_equals_ex
parent
ddf6b5dfe9
commit
511b1066c4
|
|
@ -455,6 +455,14 @@ static inline int fc_string_compare(const string_t *s1, const string_t *s2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool fc_string_equal_ex(const char *str1,
|
||||||
|
const int len1, const char *str2, const int len2)
|
||||||
|
{
|
||||||
|
return (len1 == len2) && (memcmp(str1, str2, len1) == 0);
|
||||||
|
}
|
||||||
|
#define fc_string_equals_ex(str1, len1, str2, len2) \
|
||||||
|
fc_string_equal_ex(str1, len1, str2, len2)
|
||||||
|
|
||||||
static inline bool fc_string_equal(const string_t *s1, const string_t *s2)
|
static inline bool fc_string_equal(const string_t *s1, const string_t *s2)
|
||||||
{
|
{
|
||||||
return (s1->len == s2->len) && (memcmp(s1->str, s2->str, s1->len) == 0);
|
return (s1->len == s2->len) && (memcmp(s1->str, s2->str, s1->len) == 0);
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,20 @@
|
||||||
#include "server_id_func.h"
|
#include "server_id_func.h"
|
||||||
#include "connection_pool.h"
|
#include "connection_pool.h"
|
||||||
|
|
||||||
|
static void conn_pool_disconnect_server_cb(ConnectionInfo *conn)
|
||||||
|
{
|
||||||
|
conn_pool_disconnect_server(conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool conn_pool_is_connected_cb(ConnectionInfo *conn)
|
||||||
|
{
|
||||||
|
return conn_pool_is_connected(conn);
|
||||||
|
}
|
||||||
|
|
||||||
ConnectionCallbacks g_connection_callbacks = {
|
ConnectionCallbacks g_connection_callbacks = {
|
||||||
false, {{conn_pool_connect_server_ex1,
|
false, {{conn_pool_connect_server_ex1,
|
||||||
conn_pool_disconnect_server,
|
conn_pool_disconnect_server_cb,
|
||||||
conn_pool_is_connected},
|
conn_pool_is_connected_cb},
|
||||||
{NULL, NULL, NULL}}, {NULL}
|
{NULL, NULL, NULL}}, {NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -411,20 +421,6 @@ void conn_pool_destroy(ConnectionPool *cp)
|
||||||
fast_mblock_destroy(&cp->node_allocator);
|
fast_mblock_destroy(&cp->node_allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void conn_pool_disconnect_server(ConnectionInfo *conn)
|
|
||||||
{
|
|
||||||
if (conn->sock >= 0)
|
|
||||||
{
|
|
||||||
close(conn->sock);
|
|
||||||
conn->sock = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool conn_pool_is_connected(ConnectionInfo *conn)
|
|
||||||
{
|
|
||||||
return (conn->sock >= 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int conn_pool_connect_server_ex1(ConnectionInfo *conn,
|
int conn_pool_connect_server_ex1(ConnectionInfo *conn,
|
||||||
const char *service_name, const int connect_timeout_ms,
|
const char *service_name, const int connect_timeout_ms,
|
||||||
const char *bind_ipaddr, const bool log_connect_error)
|
const char *bind_ipaddr, const bool log_connect_error)
|
||||||
|
|
|
||||||
|
|
@ -331,9 +331,19 @@ int conn_pool_close_connection_ex(ConnectionPool *cp,
|
||||||
* conn: the connection
|
* conn: the connection
|
||||||
* return 0 for success, != 0 for error
|
* return 0 for success, != 0 for error
|
||||||
*/
|
*/
|
||||||
void conn_pool_disconnect_server(ConnectionInfo *conn);
|
static inline void conn_pool_disconnect_server(ConnectionInfo *conn)
|
||||||
|
{
|
||||||
|
if (conn->sock >= 0)
|
||||||
|
{
|
||||||
|
close(conn->sock);
|
||||||
|
conn->sock = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool conn_pool_is_connected(ConnectionInfo *conn);
|
static inline bool conn_pool_is_connected(ConnectionInfo *conn)
|
||||||
|
{
|
||||||
|
return (conn->sock >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* connect to the server
|
* connect to the server
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue