fc_queue.[hc]: add function fc_queue_remove
parent
05f3d62ee1
commit
e0e7b9ef35
3
HISTORY
3
HISTORY
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
Version 1.72 2024-01-07
|
||||
Version 1.72 2024-01-21
|
||||
* call fast_mblock_ref_counter_dec for delay free node correctly
|
||||
* fc_queue.[hc]: add function fc_queue_remove
|
||||
|
||||
Version 1.71 2023-12-23
|
||||
* full support IPv6 by pull request #47
|
||||
|
|
|
|||
4
make.sh
4
make.sh
|
|
@ -222,12 +222,12 @@ done
|
|||
|
||||
if [ -n "$pthread_path" ]; then
|
||||
LIBS="$LIBS -lpthread"
|
||||
line=$(nm $pthread_path 2>/dev/null | fgrep pthread_rwlockattr_setkind_np | fgrep -w T)
|
||||
line=$(nm $pthread_path 2>/dev/null | grep -F pthread_rwlockattr_setkind_np | grep -w T)
|
||||
if [ -n "$line" ]; then
|
||||
CFLAGS="$CFLAGS -DWITH_PTHREAD_RWLOCKATTR_SETKIND_NP=1"
|
||||
fi
|
||||
elif [ -f /usr/lib/libc_r.so ]; then
|
||||
line=$(nm -D /usr/lib/libc_r.so 2>/dev/null | grep pthread_create | grep -w T)
|
||||
line=$(nm -D /usr/lib/libc_r.so 2>/dev/null | grep -F pthread_create | grep -w T)
|
||||
if [ -n "$line" ]; then
|
||||
LIBS="$LIBS -lc_r"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -295,3 +295,49 @@ int fc_queue_free_chain(struct fc_queue *queue, struct fast_mblock_man
|
|||
chain.tail = previous;
|
||||
return fast_mblock_batch_free(mblock, &chain);
|
||||
}
|
||||
|
||||
int fc_queue_remove(struct fc_queue *queue, void *data)
|
||||
{
|
||||
void *previous;
|
||||
void *current;
|
||||
int result;
|
||||
|
||||
pthread_mutex_lock(&queue->lcp.lock);
|
||||
if (queue->head == NULL)
|
||||
{
|
||||
result = ENOENT;
|
||||
}
|
||||
else if (queue->head == data)
|
||||
{
|
||||
queue->head = FC_QUEUE_NEXT_PTR(queue, queue->head);
|
||||
if (queue->head == NULL)
|
||||
{
|
||||
queue->tail = NULL;
|
||||
}
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = ENOENT;
|
||||
previous = queue->head;
|
||||
while ((current=FC_QUEUE_NEXT_PTR(queue, previous)) != NULL)
|
||||
{
|
||||
if (current == data)
|
||||
{
|
||||
FC_QUEUE_NEXT_PTR(queue, previous) =
|
||||
FC_QUEUE_NEXT_PTR(queue, current);
|
||||
if (queue->tail == current)
|
||||
{
|
||||
queue->tail = previous;
|
||||
}
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
previous = current;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&queue->lcp.lock);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,6 +226,8 @@ int fc_queue_alloc_chain(struct fc_queue *queue, struct fast_mblock_man
|
|||
int fc_queue_free_chain(struct fc_queue *queue, struct fast_mblock_man
|
||||
*mblock, struct fc_queue_info *qinfo);
|
||||
|
||||
int fc_queue_remove(struct fc_queue *queue, void *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue