Git Product home page Git Product logo

Comments (12)

linyacool avatar linyacool commented on August 31, 2024

@JsonJsons 每次事件来的时候(不管什么事件),都会分离定时器和事件,其实就是把定时器关了,然后你说的是对滴,我没有更新,是直接添加了新的,你可以试着看怎么优化一下

from webserver.

linyacool avatar linyacool commented on August 31, 2024

@JsonJsons 这个是不好的地方,事件频繁的时候,频繁创建和删除定时器

from webserver.

linyacool avatar linyacool commented on August 31, 2024

@JsonJsons 微信:linyacool

from webserver.

JsonJsons avatar JsonJsons commented on August 31, 2024

@JsonJsons 微信:linyacool

加你了,谢谢

from webserver.

tiankaijin avatar tiankaijin commented on August 31, 2024

@linyacool 你好,我能不能加你的微信,谢谢!

from webserver.

linyacool avatar linyacool commented on August 31, 2024

@linyacool 你好,我能不能加你的微信,谢谢!

可以的哇

from webserver.

yinzhengxin avatar yinzhengxin commented on August 31, 2024

你好,我想问一下定时器是有事件来的时候,之后才进行一个判断小根堆是吗?
如果长时间没有事件到来,是不会主动断开链接的,是这样的吗

from webserver.

yinzhengxin avatar yinzhengxin commented on August 31, 2024

我看的版本是前第0.5版。timer_manager.handle_expired_event();函数是在epoll_wait函数最下面执行。不知道理解的对吗?谢谢!

from webserver.

linyacool avatar linyacool commented on August 31, 2024

@yinzhengxin 是这样的,不是精准的时间控制

from webserver.

LLBRYU avatar LLBRYU commented on August 31, 2024

这个定时器实现逻辑是什么样子的,我知道超时他会删除优先队列里面的对象,可是他如何影响具体的连接呢?

from webserver.

linyacool avatar linyacool commented on August 31, 2024

@LLBRYU 一个连接超时了,不会马上就他这个连接剔除,而是等下一次的任何一个连接到来的时候,顺便去检查定时器,如果发现超时请求,一并剔除

from webserver.

Hanwn avatar Hanwn commented on August 31, 2024

楼主你好,如果客户端主动关闭,定时器队列里对应的定时器是在哪里剔除掉的?我只找到在将关闭的连接通过runInLoop函数加入到队列,从而自动执行httpClose函数,但是在httpClose函数中只是剔除掉了与之对应的channel对象,没有找到在哪里剔除掉对应的定时器队列中的对应的定时器。
还有一个问题就是,当有新的请求来的时候,在执行handleConn()函数时,是怎么更新的对应的定时器?我顺着程序找,怎么发现是往定时器队列中添加的新的定时器呢?不是应该更新对应的定时器队列中对应的那个定时器吗?
楼主辛苦了!

针对第二个问题,其实没有必要对堆中的定时器进行更新,因为对其更新的话需要找到定时器->修改->调整堆结构,这还是一个比较耗时的过程,因此这个文件描述符被封装在了HttpData类中,而整个server是通过shared_ptrHttpData进行使用的,因此对于加入定时器的连接,即使第二次刷新,只要添加第二次的shared_ptr<HttpData>定时器,第一次的定时器直接pop就好了,不会析构这个HttpData对象,所以就不会关闭文件描述符,只是在这个对象内部减少了一次引用计数而已。

from webserver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.