Allow IP address to be passed into gethostbyname().

Ensure xNetworkBuffersInitialise() doesn't use a semaphore before it has been tested against NULL.
This commit is contained in:
Richard Barry 2018-02-18 19:58:26 +00:00
parent 7ddb8b342d
commit ff74e7aa63
2 changed files with 35 additions and 23 deletions

View File

@ -404,9 +404,19 @@ TickType_t xReadTimeOut_ms = 1200U;
as gethostbyname() may be called from different threads */
TickType_t xIdentifier = ( TickType_t )usIdentifier++;
/* If the supplied hostname is IP address, convert it to uint32_t
and return. */
#if( ipconfigINCLUDE_FULL_INET_ADDR == 1 )
{
ulIPAddress = FreeRTOS_inet_addr( pcHostName );
}
#endif /* ipconfigINCLUDE_FULL_INET_ADDR == 1 */
/* If a DNS cache is used then check the cache before issuing another DNS
request. */
#if( ipconfigUSE_DNS_CACHE == 1 )
{
if( ulIPAddress == 0UL )
{
ulIPAddress = FreeRTOS_dnslookup( pcHostName );
if( ulIPAddress != 0 )
@ -415,7 +425,8 @@ TickType_t xIdentifier = ( TickType_t )usIdentifier++;
}
else
{
/* prvGetHostByName will be called to start a DNS lookup. */
/* prvGetHostByName will be called to start a DNS lookup */
}
}
}
#endif /* ipconfigUSE_DNS_CACHE == 1 */

View File

@ -103,6 +103,9 @@ BaseType_t xReturn, x;
{
xNetworkBufferSemaphore = xSemaphoreCreateCounting( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS );
configASSERT( xNetworkBufferSemaphore );
if( xNetworkBufferSemaphore != NULL )
{
#if ( configQUEUE_REGISTRY_SIZE > 0 )
{
vQueueAddToRegistry( xNetworkBufferSemaphore, "NetBufSem" );
@ -119,8 +122,6 @@ BaseType_t xReturn, x;
}
#endif /* ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 */
if( xNetworkBufferSemaphore != NULL )
{
vListInitialise( &xFreeBuffersList );
/* Initialise all the network buffers. No storage is allocated to