sf_nio_task_is_idle rename to sf_nio_task_send_done
parent
f8e3fcdc55
commit
17c99cdd55
|
|
@ -352,7 +352,7 @@ static int receipt_deal_task(struct fast_task_info *task, const int stage)
|
|||
result = 0;
|
||||
break;
|
||||
} 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) {
|
||||
report_req_receipt_request(task, true);
|
||||
} 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) {
|
||||
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);
|
||||
}
|
||||
} while (0);
|
||||
|
|
@ -429,7 +430,7 @@ static void receipt_thread_check_heartbeat(
|
|||
break;
|
||||
}
|
||||
|
||||
if (sf_nio_task_is_idle(channel->task)) {
|
||||
if (sf_nio_task_send_done(channel->task)) {
|
||||
channel->last_pkg_time = g_current_time;
|
||||
active_test_request(channel->task);
|
||||
}
|
||||
|
|
@ -443,7 +444,7 @@ static void receipt_thread_close_idle_channel(
|
|||
IdempotencyClientChannel *tmp;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
11
src/sf_nio.c
11
src/sf_nio.c
|
|
@ -582,6 +582,10 @@ ssize_t sf_socket_send_data(struct fast_task_info *task, SFCommAction *action)
|
|||
|
||||
task->send.ptr->offset += bytes;
|
||||
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;
|
||||
} else {
|
||||
*action = sf_comm_action_continue;
|
||||
|
|
@ -979,6 +983,7 @@ int sf_client_sock_write(int sock, short event, void *arg)
|
|||
|
||||
total_write = 0;
|
||||
action = sf_comm_action_continue;
|
||||
length = task->send.ptr->length;
|
||||
while (1) {
|
||||
fast_timer_modify(&task->thread_data->timer,
|
||||
&task->event.timer, g_current_time +
|
||||
|
|
@ -992,12 +997,6 @@ int sf_client_sock_write(int sock, short event, void *arg)
|
|||
total_write += bytes;
|
||||
if (action == sf_comm_action_finish) {
|
||||
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) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,15 +85,14 @@ static inline TaskCleanUpCallback sf_get_task_cleanup_callback_ex(
|
|||
#define sf_get_task_cleanup_callback() \
|
||||
sf_get_task_cleanup_callback_ex(&g_sf_context)
|
||||
|
||||
#define sf_nio_task_is_idle(task) \
|
||||
((task->send.ptr->offset == 0 && task->send.ptr->length == 0) && \
|
||||
(task->recv.ptr->offset == 0 && task->recv.ptr->length == 0))
|
||||
#define sf_nio_task_send_done(task) \
|
||||
(task->send.ptr->offset == 0 && task->send.ptr->length == 0)
|
||||
|
||||
static inline void sf_nio_reset_task_length(struct fast_task_info *task)
|
||||
{
|
||||
task->send.ptr->length = 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->offset = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ static inline void sf_proto_init_task_magic(struct fast_task_info *task)
|
|||
{
|
||||
SF_PROTO_SET_MAGIC(((SFCommonProtoHeader *)
|
||||
task->send.ptr->data)->magic);
|
||||
if (task->free_queue->double_buffers) {
|
||||
if (task->recv.ptr != task->send.ptr) {
|
||||
SF_PROTO_SET_MAGIC(((SFCommonProtoHeader *)
|
||||
task->recv.ptr->data)->magic);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue