需改ebpf程序探测内核,测试性能,验证想法,更新笔记。
This commit is contained in:
@@ -243,8 +243,6 @@ int send_cb(int fd) {
|
||||
struct conn *c = &conn_list[fd];
|
||||
int sent_total = 0;
|
||||
|
||||
pthread_mutex_lock(&c->g_sync_lock);
|
||||
|
||||
while (c->wlength > 0) {
|
||||
ssize_t n = send(fd, c->wbuffer, (size_t)c->wlength, MSG_NOSIGNAL);
|
||||
if (n > 0) {
|
||||
@@ -268,14 +266,12 @@ int send_cb(int fd) {
|
||||
if (n < 0) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
/* 暂时发不出去,等下一次可写事件 */
|
||||
pthread_mutex_unlock(&c->g_sync_lock);
|
||||
set_event(fd, EPOLLOUT, 0);
|
||||
return sent_total;
|
||||
}
|
||||
|
||||
/* 对端断开 / 其他错误 */
|
||||
int e = errno;
|
||||
pthread_mutex_unlock(&c->g_sync_lock);
|
||||
|
||||
printf("send fd=%d errno=%d %s\n", fd, e, strerror(e));
|
||||
epoll_ctl(epfd, EPOLL_CTL_DEL, fd, NULL);
|
||||
@@ -285,9 +281,8 @@ int send_cb(int fd) {
|
||||
|
||||
break;
|
||||
}
|
||||
pthread_mutex_unlock(&c->g_sync_lock);
|
||||
|
||||
if (c->wlength > 0) {
|
||||
if (c->wlength > 0) {
|
||||
/* 还有没发完,继续监听可写 */
|
||||
set_event(fd, EPOLLOUT, 0);
|
||||
} else {
|
||||
@@ -295,6 +290,8 @@ int send_cb(int fd) {
|
||||
set_event(fd, EPOLLIN, 0);
|
||||
}
|
||||
|
||||
// printf("send_total :%d; remain: %d\n", sent_total, c->wlength);
|
||||
|
||||
return sent_total;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user