-
Notifications
You must be signed in to change notification settings - Fork 13.3k
MDNS.queryService() seems to be not flushing buffer #3068
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
Comments
I made a patch #3076 which resolves this problem and hopefully to be merged. |
@kdsoo your patch may cause a mem leak on _query. You should not NULL the pointers blindly. Instead, you should e.g.: zero out the first byte in case of a string. |
Wouldn't it be enough to add
EDIT: I quickly tested it and it does seem to fix the issue. |
@joernweissenborn at first glance, I think that would also cause a memleak, because _answers is a ptr to the head of a linked list. As a side note to whoever looks at this, the String objects in the linked lists should be reserved for size before assignment. |
Thanks for the hint. I think I understand the problem. One thing which puzzles me is, that when you have 2 or more responders for a query and all of them go away, you are left of with one response. So the list of answers get flushed, but there seams to be one element remaining. Since you stated, Background: For me it is a crucial bug since I I want my stuff to be self healing. This means, that whenever there is a connection failure, I restart the the cycle (Lookup -> TcpConnect). I want to avoid the prone to fail TcpConnect on the old record. |
I looked deeper into it. It seams like the answers are supposed to be cleaned up by Question: Is there any reason not to perform the cleanup in |
I dug deeper into problem: At the moment, when there is an Rx event, I guess my PR would introduce undefined behavior in case we have an Rx while cleanup. I closed it. Another possible fix of this I thought about is rather simple: in the |
Feel free to propose a new solution. Unfortunately, I can't dig into it myself right now. |
My idea would be to add:
here. I am coming from go, so I am not veryfamiliar with manual mem managment. But fo me it seams to be a good solution, since it does not touch the current logic and just reports the users that there have been no responses. The old list will still be cleaned up upon next successfull query (untouched otherwise). |
Closing in view of #5442 with a full rewrite of mdns. |
I'm using huzzah esp8266 board with esp8266 arduino version 2.3.0
I made a http endpoint to test mdns service query and here is the piece of code:
`
void queryMDNS() {
}
`
To invoke this query I access to the url like follows:
http://ESP_IP_ADDR/mdns?service=SERVICENAME
and this query returns hostname and port.
But the problem is when the query fails.
Even the query failed, MDNS.queryService and MDNS.hostname() , IP(), port()...
they still return previously discovered servie host information.
And after the query gets the right response with service information, those hostname(), IP(), port()... are refreshed with proper answer right away.
The text was updated successfully, but these errors were encountered: