diff --git a/src/idempotency/client/client_channel.c b/src/idempotency/client/client_channel.c index ae752de..822f008 100644 --- a/src/idempotency/client/client_channel.c +++ b/src/idempotency/client/client_channel.c @@ -245,7 +245,7 @@ struct idempotency_client_channel *idempotency_client_channel_get( IdempotencyClientChannel *current; 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); bucket = channel_context.htable.buckets + hash_code % channel_context.htable.capacity; diff --git a/src/sf_service.h b/src/sf_service.h index de3328b..b94b88e 100644 --- a/src/sf_service.h +++ b/src/sf_service.h @@ -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); -static inline struct fast_task_info *sf_alloc_init_task( - SFNetworkHandler *handler, const int fd) +static inline struct fast_task_info *sf_alloc_init_task_ex( + SFNetworkHandler *handler, const int fd, + const int reffer_count) { struct fast_task_info *task; @@ -153,7 +154,7 @@ static inline struct fast_task_info *sf_alloc_init_task( 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); task->handler = handler; 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_alloc_init_task(handler, fd) sf_alloc_init_task_ex(handler, fd, 1) static inline void sf_release_task(struct fast_task_info *task) {