1
0
mirror of https://github.com/lxsang/ant-http synced 2024-06-29 11:59:48 +02:00

use both readable event and timeout event

This commit is contained in:
lxsang 2021-01-30 22:38:43 +01:00
parent 1883330bba
commit 899687d255
2 changed files with 14 additions and 6 deletions

View File

@ -785,7 +785,7 @@ static void *proxy_monitor(void *data)
ret = 0;
break;
}
sz2 = read_buf(proxy, buf, BUFFLEN);
sz2 = antd_recv_upto(proxy, buf, BUFFLEN);
if (sz2 < 0 || (sz2 > 0 && antd_send(rq->client, buf, sz2) != sz2))
{
ret = 0;
@ -812,9 +812,17 @@ static void *proxy_monitor(void *data)
return task;
}
}
if(pfd[0].revents & POLLIN)
{
antd_task_bind_event(task, proxy->sock, 0, TASK_EVT_ON_READABLE);
}
else
{
antd_task_bind_event(task, proxy->sock, 100u, TASK_EVT_ON_TIMEOUT);
}
task->handle = proxy_monitor;
task->access_time = rq->client->last_io;
antd_task_bind_event(task, proxy->sock, 0, TASK_EVT_ON_READABLE);
antd_task_bind_event(task, rq->client->sock, 0, TASK_EVT_ON_READABLE);
return task;
}

View File

@ -308,12 +308,12 @@ void antd_scheduler_destroy_data(void *data)
int antd_task_data_id(void *data)
{
/*antd_request_t *rq = (antd_request_t *)data;
antd_request_t *rq = (antd_request_t *)data;
if(!rq)
return 0;
return antd_scheduler_next_id(scheduler,rq->client->sock);*/
UNUSED(data);
return antd_scheduler_next_id(scheduler,0);
return antd_scheduler_next_id(scheduler,rq->client->sock);
/*UNUSED(data);
return antd_scheduler_next_id(scheduler,0);*/
}
int main(int argc, char *argv[])