FreeRTOS_gethostbyname max delay

What is the maximum block time caused by gethostbyname? I was under the impression that this is defined by ipconfigSOCKDEFAULTRECEIVEBLOCKTIME however I am getting blocks at least twice this time. The blocks happen when the network is down, but I would like some idea how to estimate or reduce this time.

FreeRTOS_gethostbyname max delay

Before I getting into those details, have you considered using FreeRTOS_gethostbyname_a()? It will be available if you define ipconfigDNS_USE_CALLBACKS as 1. It allows you to find an IP-address without waiting for it. You will receive an application call-back

FreeRTOS_gethostbyname max delay

Callbacks and state machines don’t play very well together in this case.

FreeRTOS_gethostbyname max delay

Looking at the code for byname_a, it would appear to fall through to prvGetHostByName anyway, so how does this avoid blocking?

FreeRTOS_gethostbyname max delay

I was under the impression that this is defined by ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME however I am getting blocks at least twice this time
The DNS requests are sent repeatedly, up to ipconfigDNS_REQUEST_ATTEMPTS times. Have you defined this macro? It defaults to: ~~~ /* The maximum number of times a DNS request should be sent out if a response is not received, before giving up. */

ifndef ipconfigDNSREQUESTATTEMPTS

#define ipconfigDNS_REQUEST_ATTEMPTS        5

endif

~~~
Looking at the code for byname_a, it would appear to fall through to prvGetHostByName anyway, so how does this avoid blocking?
prvGetHostByName() will be called in a non-blocking way because the parameter xReadTimeOut_ms has been set to zero. If you are using the latest FreeRTOS+TCP from github, unfortunately, FreeRTOS_gethostbyname_a() will not work properly. I repaired it in my own branch on Github Please use FreeRTOS_DNS.c and FreeRTOS_UDP_IP.c. The idea of the call-back is as follows: Send out a DNS request. Do not wait for an answer. When the DNS reply comes in, call the registered call-back routine.

FreeRTOS_gethostbyname max delay

Thank you for that clarification, I’ll give this a try.

FreeRTOS_gethostbyname max delay

How exactly is pvSearchID used internally? This doesn’t have any examples, so it would appear that this is just some pointer, it isn’t actively checking the value in any way, is this right?

FreeRTOS_gethostbyname max delay

Also, I am getting an exception when I call FreeRTOSgethostbynamecancel(&somevar) at vListInsertEnd. Another problem, why isn’t dhcpDNSSERVEROPTIONS_CODE in the ucDHCPRequestOptions on line 907? It seems that this should rather be defined in the headers as an option.

FreeRTOS_gethostbyname max delay

How exactly is pvSearchID used internally?
It is a pointer which has only meaning to the application, for instance a pointer to an object.
Also, I am getting an exception when I call FreeRTOSgethostbynamecancel(&somevar) at vListInsertEnd.
FreeRTOS_gethostbyname_cancel() calls vDNSCheckCallBack(), which will call uxListRemove(). You’re saying that you see an exception occurring in vListInsertEnd(). I don’t see how it can get there?
why isn’t dhcpDNS_SERVER_OPTIONS_CODE in the ucDHCPRequestOptions[] on line 907? It seems that this should rather be defined in the headers as an option.
The DNS server option is already included in ucDHCPDiscoverOptions[]. Would you like to make this configurable?

FreeRTOS_gethostbyname max delay

I won’t claim to completely understand how the list is implemented, but the stackpointer location at the crash crash pointed me to this being caused somehow by my use of either FreeRTOS_gethostbyname_a or FreeRTOS_gethostbyname_cancel. I figured it had something to do with calling these with a parameter rather than letting it time out, and the list getting removed twice perhaps. I’ll do some more digging here on the DHCP, I should have started a different thread for that. I am having trouble getting dns settings through dhcp from a sonicwall tz105.

FreeRTOS_gethostbyname max delay

This is happening in FreeRTOS_gethostbyname_a -> vDNSSetCallBack at vListInsertEnd I’m a bit unclear what I am doing wrong. I am calling it like ~~~ FreeRTOSgethostbynamea(urlstart, DNS_Callback, &hostaddr, 25000); ~~~

FreeRTOS_gethostbyname max delay

Erik, could it be that you’re calling FreeRTOS_gethostbyname_a() before the network it up? I mean, before vIPNetworkUpCalls() is called? If so, the list that gathers the call-backs has not been initialised by vDNSInitialise() yet.

FreeRTOS_gethostbyname max delay

Its likely. Is there any way this could get patched though?

FreeRTOS_gethostbyname max delay

Yes, I wouldn’t mind if vDNSInitialise() get called much earlier ( in FreeRTOS_IPInit() ) and only once. I will propose this change.