1
This commit is contained in:
parent
fc4a7d7d24
commit
f6748a84c8
@ -89,6 +89,7 @@ namespace a8
|
|||||||
top_node_ = p;
|
top_node_ = p;
|
||||||
bot_node_ = p;
|
bot_node_ = p;
|
||||||
}
|
}
|
||||||
|
NotifyEpollSend();
|
||||||
} else {
|
} else {
|
||||||
if (work_node_) {
|
if (work_node_) {
|
||||||
abort();
|
abort();
|
||||||
@ -101,6 +102,7 @@ namespace a8
|
|||||||
case 0:
|
case 0:
|
||||||
case -2:
|
case -2:
|
||||||
{
|
{
|
||||||
|
assert(ret == 0);
|
||||||
if (p->buff) {
|
if (p->buff) {
|
||||||
free(p->buff);
|
free(p->buff);
|
||||||
}
|
}
|
||||||
@ -320,7 +322,8 @@ namespace a8
|
|||||||
work_node_->bufflen - work_node_->sent_bytes,
|
work_node_->bufflen - work_node_->sent_bytes,
|
||||||
0);
|
0);
|
||||||
if (sentbytes <= 0) {
|
if (sentbytes <= 0) {
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
auto err_code = errno;
|
||||||
|
if (err_code == EAGAIN || err_code == EWOULDBLOCK) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
abort();
|
abort();
|
||||||
@ -357,30 +360,32 @@ namespace a8
|
|||||||
sending_ = true;
|
sending_ = true;
|
||||||
struct epoll_event ev;
|
struct epoll_event ev;
|
||||||
ev.data.fd = socket_;
|
ev.data.fd = socket_;
|
||||||
ev.events = EPOLLIN | EPOLLOUT | EPOLLET | EPOLLRDHUP;
|
ev.events = EPOLLIN | EPOLLET | EPOLLOUT | EPOLLRDHUP;
|
||||||
ev.data.ptr = this;
|
ev.data.ptr = this;
|
||||||
::epoll_ctl(epoll_fd, EPOLL_CTL_MOD, socket_, &ev);
|
::epoll_ctl(epoll_fd, EPOLL_CTL_MOD, socket_, &ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TcpSession::DirectSend(a8::SendQueueNode* p)
|
int TcpSession::DirectSend(a8::SendQueueNode* p)
|
||||||
{
|
{
|
||||||
int sentbytes = ::send(socket_,
|
++direct_send_times;
|
||||||
p->buff,
|
while (true) {
|
||||||
p->bufflen,
|
int sentbytes = ::send(socket_,
|
||||||
0);
|
p->buff + p->sent_bytes,
|
||||||
if (sentbytes >= p->bufflen) {
|
p->bufflen - p->sent_bytes,
|
||||||
return 0;
|
0);
|
||||||
}
|
if (sentbytes <= 0) {
|
||||||
if (sentbytes <= 0) {
|
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
return -1;
|
||||||
return -1;
|
} else {
|
||||||
|
Close();
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Close();
|
p->sent_bytes += sentbytes;
|
||||||
return -2;
|
if (p->sent_bytes >= p->bufflen) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
p->sent_bytes += sentbytes;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ namespace a8
|
|||||||
int max_packet_len_ = 0;
|
int max_packet_len_ = 0;
|
||||||
volatile long long epoll_out_times = 0;
|
volatile long long epoll_out_times = 0;
|
||||||
volatile long long epoll_in_times = 0;
|
volatile long long epoll_in_times = 0;
|
||||||
|
volatile long long direct_send_times = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int socket_ = 0;
|
int socket_ = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user