common_blocked_queue_return_nodes
parent
6d88bb980d
commit
da4c9a2581
3
HISTORY
3
HISTORY
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Version 1.44 2020-03-22
|
||||
Version 1.44 2020-03-23
|
||||
* add test file src/tests/test_pthread_lock.c
|
||||
* add uniq_skiplist.[hc]
|
||||
* add function split_string_ex
|
||||
|
|
@ -21,6 +21,7 @@ Version 1.44 2020-03-22
|
|||
* nio_thread_data support thread notify
|
||||
* pthread_func.[hc] add functions: create_work_threads_ex and fc_create_thread
|
||||
* sched_add_entries use temp ScheduleArray for rare case
|
||||
* add function common_blocked_queue_return_nodes
|
||||
|
||||
Version 1.43 2019-12-25
|
||||
* replace function call system to getExecResult,
|
||||
|
|
|
|||
|
|
@ -104,6 +104,31 @@ int common_blocked_queue_push(struct common_blocked_queue *queue, void *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void common_blocked_queue_return_nodes(struct common_blocked_queue *queue,
|
||||
struct common_blocked_node *node)
|
||||
{
|
||||
struct common_blocked_node *last;
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
last = node;
|
||||
while (last->next != NULL) {
|
||||
last = last->next;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&(queue->lock));
|
||||
last->next = queue->head;
|
||||
queue->head = node;
|
||||
if (queue->tail == NULL)
|
||||
{
|
||||
queue->tail = last;
|
||||
}
|
||||
pthread_mutex_unlock(&(queue->lock));
|
||||
}
|
||||
|
||||
void *common_blocked_queue_pop_ex(struct common_blocked_queue *queue,
|
||||
const bool blocked)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ static inline void common_blocked_queue_terminate_all(
|
|||
|
||||
int common_blocked_queue_push(struct common_blocked_queue *queue, void *data);
|
||||
|
||||
void common_blocked_queue_return_nodes(struct common_blocked_queue *queue,
|
||||
struct common_blocked_node *node);
|
||||
|
||||
void *common_blocked_queue_pop_ex(struct common_blocked_queue *queue,
|
||||
const bool blocked);
|
||||
|
||||
|
|
|
|||
|
|
@ -1558,3 +1558,28 @@ int fc_server_make_connection_ex(FCAddressPtrArray *addr_array,
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
const FCAddressInfo *fc_server_get_address_by_peer(
|
||||
FCAddressPtrArray *addr_array, const char *peer_ip)
|
||||
{
|
||||
FCAddressInfo **addr;
|
||||
FCAddressInfo **end;
|
||||
int net_type;
|
||||
|
||||
if (addr_array->count == 1) {
|
||||
return *(addr_array->addrs);
|
||||
}
|
||||
if (addr_array->count == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
net_type = fc_get_net_type_by_ip(peer_ip);
|
||||
end = addr_array->addrs + addr_array->count;
|
||||
for (addr=addr_array->addrs; addr<end; addr++) {
|
||||
if ((*addr)->net_type == net_type) {
|
||||
return *addr;
|
||||
}
|
||||
}
|
||||
|
||||
return *(addr_array->addrs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,6 +182,8 @@ ConnectionInfo *fc_server_check_connect_ex(FCAddressPtrArray *addr_array,
|
|||
|
||||
void fc_server_disconnect(FCAddressPtrArray *addr_array);
|
||||
|
||||
const FCAddressInfo *fc_server_get_address_by_peer(
|
||||
FCAddressPtrArray *addr_array, const char *peer_ip);
|
||||
|
||||
int fc_server_make_connection_ex(FCAddressPtrArray *addr_array,
|
||||
ConnectionInfo *conn, const int connect_timeout,
|
||||
|
|
|
|||
Loading…
Reference in New Issue