|
@@ -69,7 +69,11 @@ public:
|
|
|
|
|
|
for(auto entry : _attn_list)
|
|
|
{
|
|
|
- entry->submit();
|
|
|
+ if(entry->_op_count == 0) {
|
|
|
+ // printf("before epoll_wait submit: %d\n", entry->_op_count);
|
|
|
+ //no focus any event, then submit keep attn, otherwise cause op leak
|
|
|
+ entry->submit();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
_attn_list.clear();
|
|
@@ -135,10 +139,15 @@ epoll_op_t::epoll_op_t(epoll_sock_data_t *sock_data, uint32_t afd_events)
|
|
|
|
|
|
_sock_data = sock_data;
|
|
|
_sock_data->_op_count++;
|
|
|
+
|
|
|
+ // printf("submit new: %p, %d\n", this, _sock_data->_op_count);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
epoll_op_t::~epoll_op_t()
|
|
|
{
|
|
|
+ // printf("~epoll_op_t: %p, %d\n", this, _sock_data->_op_count );
|
|
|
+
|
|
|
_sock_data->_op_count--;
|
|
|
assert(_sock_data->_op_count >= 0);
|
|
|
}
|
|
@@ -302,6 +311,7 @@ int epoll_port_data_t::epoll_add(SOCKET sock, struct epoll_event *ev)
|
|
|
SetLastError(ERROR_OUTOFMEMORY);
|
|
|
return -1;
|
|
|
}
|
|
|
+ // printf("add new, %d\n", sock_data->_op_count);
|
|
|
|
|
|
add(sock_data);
|
|
|
|
|
@@ -321,6 +331,7 @@ int epoll_port_data_t::epoll_mod(SOCKET sock, struct epoll_event *ev)
|
|
|
SetLastError(ERROR_NOT_FOUND);
|
|
|
return -1;
|
|
|
}
|
|
|
+ // printf("mod new, %d\n", sock_data->_op_count);
|
|
|
|
|
|
sock_data->_registered_events = ev->events | EPOLLERR | EPOLLHUP;
|
|
|
sock_data->_user_data = ev->data.u64;
|
|
@@ -331,6 +342,8 @@ int epoll_port_data_t::epoll_del(SOCKET sock, struct epoll_event *ev)
|
|
|
{
|
|
|
std::lock_guard<std::mutex> lck (_mutex);
|
|
|
|
|
|
+ // printf("del new\n");
|
|
|
+
|
|
|
epoll_sock_data_t *sock_data = get(sock);
|
|
|
if(sock_data == NULL)
|
|
|
{
|
|
@@ -473,6 +486,8 @@ int epoll_port_data_t::epoll_wait(OVERLAPPED_ENTRY *entries, ULONG count, struct
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ delete op;
|
|
|
+
|
|
|
// int registered_events = sock_data->_registered_events;
|
|
|
int reported_events = 0;
|
|
|
/* Convert afd events to epoll events. */
|
|
@@ -588,6 +603,7 @@ int epoll_wait(epoll_t port_handle, struct epoll_event *events, int maxevents, i
|
|
|
}
|
|
|
|
|
|
epoll_port_data_t *port_data = (epoll_port_data_t *)port_handle;
|
|
|
+
|
|
|
port_data->submit();
|
|
|
|
|
|
OVERLAPPED_ENTRY entries[64];
|
|
@@ -603,7 +619,7 @@ int epoll_wait(epoll_t port_handle, struct epoll_event *events, int maxevents, i
|
|
|
DWORD error = GetLastError();
|
|
|
if (error == WAIT_TIMEOUT)
|
|
|
{
|
|
|
- // printf("%d, GetQueuedCompletionStatusEx:%d\n", std::this_thread::get_id() , count);
|
|
|
+ // printf("%d, GetQueuedCompletionStatusEx:%d\n", std::this_thread::get_id() , count);
|
|
|
|
|
|
return 0;
|
|
|
}
|