--- bsdSockResource.c_orig Mon Jul 15 13:06:01 2002 +++ bsdSockResource.c Mon Jul 15 13:07:10 2002 @@ -39,6 +39,8 @@ #include "bsdSocketResource.h" #include "epicsAssert.h" +#define MAX_HOSTNAME_LENGTH 64 + /* * NOOP */ @@ -77,13 +79,25 @@ pBuf[bufSize-1] = '\0'; } else { - ent = gethostbyaddr((char *) &paddr->sin_addr, - sizeof(paddr->sin_addr), AF_INET); - if(ent){ - pString = ent->h_name; - } - else{ - pString = inet_ntoa (paddr->sin_addr); + static char lastHost[MAX_HOSTNAME_LENGTH+1]; + static struct sockaddr_in lastAddr; + + /* There should be a mutex lock here... */ + + if (memcmp(&paddr->sin_addr, &lastAddr.sin_addr, sizeof(paddr->sin_addr)) == 0) { + pString = lastHost; + } else { + ent = gethostbyaddr((char *) &paddr->sin_addr, + sizeof(paddr->sin_addr), AF_INET); + if(ent){ + pString = ent->h_name; + } + else{ + pString = inet_ntoa (paddr->sin_addr); + } + strncpy(lastHost, pString, MAX_HOSTNAME_LENGTH); + lastHost[MAX_HOSTNAME_LENGTH] = '\0'; + lastAddr.sin_addr = paddr->sin_addr; } /* @@ -96,6 +110,8 @@ else { sprintf (pBuf, "%.*s", (int) (bufSize-1), pString); } + + /* There should be a mutex unlock here... */ } }