sf_nio_task_is_idle rename to sf_nio_task_send_done

support_rdma
YuQing 2023-09-26 15:26:42 +08:00
parent f8e3fcdc55
commit 17c99cdd55
4 changed files with 14 additions and 15 deletions

View File

@ -352,7 +352,7 @@ static int receipt_deal_task(struct fast_task_info *task, const int stage)
result = 0; result = 0;
break; break;
} else if (stage == SF_NIO_STAGE_CONTINUE) { } else if (stage == SF_NIO_STAGE_CONTINUE) {
if (sf_nio_task_is_idle(task)) { if (sf_nio_task_send_done(task)) {
if (((IdempotencyClientChannel *)task->arg)->established) { if (((IdempotencyClientChannel *)task->arg)->established) {
report_req_receipt_request(task, true); report_req_receipt_request(task, true);
} else if (task->req_count > 0) { } else if (task->req_count > 0) {
@ -408,7 +408,8 @@ static int receipt_deal_task(struct fast_task_info *task, const int stage)
if (result == 0) { if (result == 0) {
update_lru_chain(task); update_lru_chain(task);
sf_nio_reset_task_length(task); task->recv.ptr->length = 0;
task->recv.ptr->offset = 0;
report_req_receipt_request(task, false); report_req_receipt_request(task, false);
} }
} while (0); } while (0);
@ -429,7 +430,7 @@ static void receipt_thread_check_heartbeat(
break; break;
} }
if (sf_nio_task_is_idle(channel->task)) { if (sf_nio_task_send_done(channel->task)) {
channel->last_pkg_time = g_current_time; channel->last_pkg_time = g_current_time;
active_test_request(channel->task); active_test_request(channel->task);
} }
@ -443,7 +444,7 @@ static void receipt_thread_close_idle_channel(
IdempotencyClientChannel *tmp; IdempotencyClientChannel *tmp;
fc_list_for_each_entry_safe(channel, tmp, &thread_ctx->head, dlink) { fc_list_for_each_entry_safe(channel, tmp, &thread_ctx->head, dlink) {
if (!sf_nio_task_is_idle(channel->task)) { if (!sf_nio_task_send_done(channel->task)) {
continue; continue;
} }

View File

@ -582,6 +582,10 @@ ssize_t sf_socket_send_data(struct fast_task_info *task, SFCommAction *action)
task->send.ptr->offset += bytes; task->send.ptr->offset += bytes;
if (task->send.ptr->offset >= task->send.ptr->length) { if (task->send.ptr->offset >= task->send.ptr->length) {
if (task->send.ptr != task->recv.ptr) { //double buffers
task->send.ptr->offset = 0;
task->send.ptr->length = 0;
}
*action = sf_comm_action_finish; *action = sf_comm_action_finish;
} else { } else {
*action = sf_comm_action_continue; *action = sf_comm_action_continue;
@ -979,6 +983,7 @@ int sf_client_sock_write(int sock, short event, void *arg)
total_write = 0; total_write = 0;
action = sf_comm_action_continue; action = sf_comm_action_continue;
length = task->send.ptr->length;
while (1) { while (1) {
fast_timer_modify(&task->thread_data->timer, fast_timer_modify(&task->thread_data->timer,
&task->event.timer, g_current_time + &task->event.timer, g_current_time +
@ -992,12 +997,6 @@ int sf_client_sock_write(int sock, short event, void *arg)
total_write += bytes; total_write += bytes;
if (action == sf_comm_action_finish) { if (action == sf_comm_action_finish) {
release_iovec_buffer(task); release_iovec_buffer(task);
length = task->send.ptr->length;
if (task->free_queue->double_buffers) {
task->send.ptr->offset = 0;
task->send.ptr->length = 0;
}
if (sf_set_read_event(task) != 0) { if (sf_set_read_event(task) != 0) {
return -1; return -1;
} }

View File

@ -85,15 +85,14 @@ static inline TaskCleanUpCallback sf_get_task_cleanup_callback_ex(
#define sf_get_task_cleanup_callback() \ #define sf_get_task_cleanup_callback() \
sf_get_task_cleanup_callback_ex(&g_sf_context) sf_get_task_cleanup_callback_ex(&g_sf_context)
#define sf_nio_task_is_idle(task) \ #define sf_nio_task_send_done(task) \
((task->send.ptr->offset == 0 && task->send.ptr->length == 0) && \ (task->send.ptr->offset == 0 && task->send.ptr->length == 0)
(task->recv.ptr->offset == 0 && task->recv.ptr->length == 0))
static inline void sf_nio_reset_task_length(struct fast_task_info *task) static inline void sf_nio_reset_task_length(struct fast_task_info *task)
{ {
task->send.ptr->length = 0; task->send.ptr->length = 0;
task->send.ptr->offset = 0; task->send.ptr->offset = 0;
if (task->free_queue->double_buffers) { if (task->recv.ptr != task->send.ptr) {
task->recv.ptr->length = 0; task->recv.ptr->length = 0;
task->recv.ptr->offset = 0; task->recv.ptr->offset = 0;
} }

View File

@ -296,7 +296,7 @@ static inline void sf_proto_init_task_magic(struct fast_task_info *task)
{ {
SF_PROTO_SET_MAGIC(((SFCommonProtoHeader *) SF_PROTO_SET_MAGIC(((SFCommonProtoHeader *)
task->send.ptr->data)->magic); task->send.ptr->data)->magic);
if (task->free_queue->double_buffers) { if (task->recv.ptr != task->send.ptr) {
SF_PROTO_SET_MAGIC(((SFCommonProtoHeader *) SF_PROTO_SET_MAGIC(((SFCommonProtoHeader *)
task->recv.ptr->data)->magic); task->recv.ptr->data)->magic);
} }