- syslog(LOG_DEBUG, "%s", clnt_spcreateerror("clntudp_create"));
- syslog(LOG_DEBUG, "Unable to contact %s",
- inet_ntoa(((struct sockaddr_in *)host_addr)->sin_addr));
- return NULL;
+ /* We couldn't get a new CLIENT* */
+ if (!cached_client) {
+ syslog(LOG_WARNING, "Unable to contact %s: %s",
+ inet_ntoa(((struct sockaddr_in *)host_addr)->sin_addr),
+ clnt_spcreateerror("clntudp_create"));
+ return NULL;
+ }
+ /*
+ * We couldn't get updated info from portmapper, but we did
+ * still have the stale cached data. So we might as well try
+ * to use it.
+ */
+ client = cached_client;
+ syslog(LOG_WARNING, "Unable to update contact info for %s: %s",
+ inet_ntoa(((struct sockaddr_in *)host_addr)->sin_addr),
+ clnt_spcreateerror("clntudp_create"));
+ } else {
+ /*
+ * We've got a new/updated CLIENT* for this host.
+ * So, destroy any previously cached CLIENT*.
+ */
+ if (cached_client)
+ clnt_destroy(cached_client);
+
+ /*
+ * Disable the default timeout, so we can specify our own in calls
+ * to clnt_call(). (Note that the timeout is a different concept
+ * from the retry period set in clnt_udp_create() above.)
+ */
+ retry_time.tv_sec = -1;
+ retry_time.tv_usec = -1;
+ clnt_control(client, CLSET_TIMEOUT, (char *)&retry_time);
+
+ if (debug_level > 3)
+ syslog(LOG_DEBUG, "Created CLIENT* for %s",
+ inet_ntoa(((struct sockaddr_in *)host_addr)->sin_addr));
+
+ /* make sure the new entry gets the current timestamp */
+ cache_time = time_now.tv_sec;