[Libwebsockets] 回复： 答复: A question about libwebsockets dns resolve
huangkaicheng at huawei.com
Mon May 11 13:30:40 CEST 2020
I update the code of master, and set "timeout in the context info" time is 5s(default timeout (secs): 5). and it seem that it does not take effect. See more in attachment.
发件人: Andy Green [mailto:andy at warmcat.com]
发送时间: 2020年5月11日 16:53
收件人: o_O凌雲 <550470999 at qq.com>; libwebsockets <libwebsockets at ml.libwebsockets.org>
抄送: huangkaicheng <huangkaicheng at huawei.com>; Chenyake <chenyake at huawei.com>
主题: Re: 回复： 回复： [Libwebsockets] 答复: A question about libwebsockets dns resolve
On 5/11/20 7:56 AM, o_O凌雲 wrote:
> I have made some changes to lws to limit wait time , and I make
> mychanges.diff as your said. please help to review my code. thanks. I
> add "PENDING_TIMEOUT_DNS_RESOLVER_TRY" to limit wait time. and using
> "onevalid.bogus.warmcat.com" to test.see more in attachments.
Thanks. I could look at it and quickly see what's changed... basically what you're trying to do in there is not unreasonable. But there's a lot of added / cut-and-pasted code introduced, the client connection path has already become overcomplicated and needs refactoring and cleaning rather than more code piled on.
I made a different patch that repurposes the timeout sul in the wsi to protect the connect similar to the lws_set_timeout() approach. But instead of using the normal timeout flow, since it's pre connect() it sets a different callback that can directly call into connect3 and go to the next DNS result. I checked this with blackhole.bogus.warmcat.com
(184.108.40.206 blackhole twice and one correct IP) and onevalid.bogus.warmcat.com (some 127.0.0.x and one correct IP) and he seems to act well. For 220.127.116.11 he waits for 20s (the default timeout in the context info) and then tries the next.
$ ./bin/lws-minimal-http-client --server onevalid.bogus.warmcat.com -d
$ ./bin/lws-minimal-http-client --server blackhole.bogus.warmcat.com -d
Please give it a try.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the Libwebsockets