Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

old_version_0.1中handle_events()如何执行到threadpool_add()函数 #15

Open
wangyazhao001 opened this issue May 14, 2019 · 2 comments

Comments

@wangyazhao001
Copy link

    大佬!您好!  我想请问下,在old_version_0.1的handle_events()中,到底如何才能执行threadpool_add()函数啊?我才用单步调试的时候一直执行if语句,无法执行到这个函数,但全速运行的时候却执行了!请大佬指点以下!万分感谢!  函数如下所示:

`// 分发处理函数
void handle_events(int epoll_fd, int listen_fd, struct epoll_event* events, int events_num, const string &path, threadpool_t* tp)
{
for(int i = 0; i < events_num; i++)
{
// 获取有事件产生的描述符
requestData* request = (requestData*)(events[i].data.ptr); //从events结构体的ptr指针中获取传递的参数
int fd = request->getFd();

    // 有事件发生的描述符为监听描述符
    if(fd == listen_fd)
    {
        //cout << "This is listen_fd" << endl;
        acceptConnection(listen_fd, epoll_fd, path);
    }
    else
    {
        // 排除错误事件
        if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP)
            || (!(events[i].events & EPOLLIN)))
        {
            printf("error event\n");
            delete request;
            continue;
        }

        // 将请求任务加入到线程池中
        // 加入线程池之前将Timer和request分离
        request->seperateTimer();
        int rc = threadpool_add(tp, myHandler, events[i].data.ptr, 0);         // 怎么才会执行这一步函数?感觉无法执行到!
    }
}

}`

@linyacool
Copy link
Owner

要有个请求来了,并且有消息过来了,不如你把断点就打到threadpool_add上

@wangyazhao001
Copy link
Author

要有个请求来了,并且有消息过来了,不如你把断点就打到threadpool_add上

这一块理解啦 谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants