invoke send done callback correctly
parent
5f5db2b998
commit
71e7066c81
14
src/sf_nio.c
14
src/sf_nio.c
|
|
@ -542,6 +542,7 @@ static inline int check_task(struct fast_task_info *task,
|
||||||
ssize_t sf_socket_send_data(struct fast_task_info *task, SFCommAction *action)
|
ssize_t sf_socket_send_data(struct fast_task_info *task, SFCommAction *action)
|
||||||
{
|
{
|
||||||
int bytes;
|
int bytes;
|
||||||
|
int length;
|
||||||
|
|
||||||
if (task->iovec_array.iovs != NULL) {
|
if (task->iovec_array.iovs != NULL) {
|
||||||
bytes = writev(task->event.fd, task->iovec_array.iovs,
|
bytes = writev(task->event.fd, task->iovec_array.iovs,
|
||||||
|
|
@ -584,10 +585,16 @@ 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) {
|
||||||
|
length = task->send.ptr->length;
|
||||||
if (task->send.ptr != task->recv.ptr) { //double buffers
|
if (task->send.ptr != task->recv.ptr) { //double buffers
|
||||||
task->send.ptr->offset = 0;
|
task->send.ptr->offset = 0;
|
||||||
task->send.ptr->length = 0;
|
task->send.ptr->length = 0;
|
||||||
}
|
}
|
||||||
|
if (SF_CTX->callbacks.send_done != NULL) {
|
||||||
|
if (SF_CTX->callbacks.send_done(task, length) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
*action = sf_comm_action_finish;
|
*action = sf_comm_action_finish;
|
||||||
} else {
|
} else {
|
||||||
*action = sf_comm_action_continue;
|
*action = sf_comm_action_continue;
|
||||||
|
|
@ -1018,13 +1025,6 @@ int sf_client_sock_write(int sock, short event, void *arg)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SF_CTX->callbacks.send_done != NULL) {
|
|
||||||
if (SF_CTX->callbacks.send_done(task, length) != 0) {
|
|
||||||
ioevent_add_to_deleted_list(task);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else if (action == sf_comm_action_break) {
|
} else if (action == sf_comm_action_break) {
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue