Skip to content

read不满一个http包就返回EAGAIN,怎么办? #1

@zyearn

Description

@zyearn

你好。

对于一个新的connection,就创建一个thread:tyhp_thread_func

然后对这个fd读,读到EAGAIN就break,接下来就调用tyhp_parse_http_request来处理这个http包,但是这个函数是假设http包已经完全读进来了。那么问题来了,如果网络有延迟或者其它原因,导致http包最后几个字节没有到达client,那么read也会返回EAGAIN,那么这次调tyhp_parse_http_request就不对了。这几个剩余的字节会伴随着下一次http请求的到来,那么下一次调tyhp_parse_http_request解析request line的时候也会出错。

所以有什么好的解决方案?可以把http包先buffer住,等到可以解析了再解析?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions