add func sf_alloc_init_task_ex to specify reffer_count

support_rdma
YuQing 2023-09-21 09:03:45 +08:00
parent 3c7ebd14d9
commit 3a413408ad
2 changed files with 6 additions and 4 deletions

View File

@ -245,7 +245,7 @@ struct idempotency_client_channel *idempotency_client_channel_get(
IdempotencyClientChannel *current; IdempotencyClientChannel *current;
IdempotencyClientChannel *channel; IdempotencyClientChannel *channel;
key_len = snprintf(key, sizeof(key), "%s_%u", server_ip, server_port); key_len = snprintf(key, sizeof(key), "%s-%u", server_ip, server_port);
hash_code = fc_simple_hash(key, key_len); hash_code = fc_simple_hash(key, key_len);
bucket = channel_context.htable.buckets + bucket = channel_context.htable.buckets +
hash_code % channel_context.htable.capacity; hash_code % channel_context.htable.capacity;

View File

@ -139,8 +139,9 @@ void sf_set_sig_quit_handler(sf_sig_quit_handler quit_handler);
int sf_init_task(struct fast_task_info *task); int sf_init_task(struct fast_task_info *task);
static inline struct fast_task_info *sf_alloc_init_task( static inline struct fast_task_info *sf_alloc_init_task_ex(
SFNetworkHandler *handler, const int fd) SFNetworkHandler *handler, const int fd,
const int reffer_count)
{ {
struct fast_task_info *task; struct fast_task_info *task;
@ -153,7 +154,7 @@ static inline struct fast_task_info *sf_alloc_init_task(
return NULL; return NULL;
} }
__sync_add_and_fetch(&task->reffer_count, 1); __sync_add_and_fetch(&task->reffer_count, reffer_count);
__sync_bool_compare_and_swap(&task->canceled, 1, 0); __sync_bool_compare_and_swap(&task->canceled, 1, 0);
task->handler = handler; task->handler = handler;
task->event.fd = fd; task->event.fd = fd;
@ -161,6 +162,7 @@ static inline struct fast_task_info *sf_alloc_init_task(
} }
#define sf_hold_task(task) __sync_add_and_fetch(&task->reffer_count, 1) #define sf_hold_task(task) __sync_add_and_fetch(&task->reffer_count, 1)
#define sf_alloc_init_task(handler, fd) sf_alloc_init_task_ex(handler, fd, 1)
static inline void sf_release_task(struct fast_task_info *task) static inline void sf_release_task(struct fast_task_info *task)
{ {