bug?
==20381== Process terminating with default action of signal 11 (SIGSEGV) ==20381== Access not within mapped region at address 0x100108 ==20381== at 0x404BB6: __list_del (list.h:91) ==20381== by 0x404BEC: list_del (list.h:97)
if (nfds < 0) {
perror("epoll");
continue;
}
应该改为if (nfds <= 0)
==20381== Process terminating with default action of signal 11 (SIGSEGV) ==20381== Access not within mapped region at address 0x100108 ==20381== at 0x404BB6: __list_del (list.h:91) ==20381== by 0x404BEC: list_del (list.h:97)
if (nfds < 0) {
perror("epoll");
continue;
}
应该改为if (nfds <= 0)
==20381== Process terminating with default action of signal 11 (SIGSEGV) ==20381== Access not within mapped region at address 0x100108 ==20381== at 0x404BB6: __list_del (list.h:91) ==20381== by 0x404BEC: list_del (list.h:97)
此外还有一个地方需要修改: 因为每次都会讲conn和other添加至全局链表,在关闭过程中遍历链表,此处不应释放两次
void closeconn(int efd, struct conn *conn)
{
if (conn->other)
delconn(efd, conn->other);
delconn(efd, conn);
}
应该为:
void closeconn(int efd, struct conn *conn)
{
delconn(efd, conn);
}