"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mpl/src/sock/mpl_host.c" between
hydra-3.3.1.tar.gz and hydra-3.3.2.tar.gz

About: Hydra (MPICH) is a process management system for starting parallel jobs. Hydra is designed to natively work with existing launcher daemons (such as ssh, rsh, fork), as well as natively integrate with resource management systems (such as slurm, pbs, sge).

mpl_host.c  (hydra-3.3.1):mpl_host.c  (hydra-3.3.2)
skipping to change at line 38 skipping to change at line 38
lhost_count++; lhost_count++;
} }
static void init_lhost_list(void) static void init_lhost_list(void)
{ {
/* if the local host list is already initialized, return */ /* if the local host list is already initialized, return */
if (lhost_count) if (lhost_count)
return; return;
#if defined(MPL_HAVE_GETIFADDRS) && defined (MPL_HAVE_INET_NTOP) #if defined(MPL_HAVE_GETIFADDRS) && defined (MPL_HAVE_INET_NTOP)
char tmp_lhost[MAX_HOSTNAME_LEN], *lhost_ip; char tmp_lhost[MAX_HOSTNAME_LEN];
struct hostent *ht; int ret;
struct sockaddr_in sa; MPL_sockaddr_t addr;
struct ifaddrs *ifaddr, *ifa; struct ifaddrs *ifaddr, *ifa;
char buf[MAX_HOSTNAME_LEN]; char buf[MAX_HOSTNAME_LEN];
if (gethostname(tmp_lhost, MAX_HOSTNAME_LEN) < 0) { if (gethostname(tmp_lhost, MAX_HOSTNAME_LEN) < 0) {
/* we can't figure out our local hostname. *sigh* */ /* we can't figure out our local hostname. *sigh* */
goto common_names; goto common_names;
} }
append_lhost(tmp_lhost); append_lhost(tmp_lhost);
/* we have our host name; try gethostbyname */ /* we have our host name; try gethostbyname */
if ((ht = gethostbyname(tmp_lhost))) { ret = MPL_get_sockaddr(tmp_lhost, &addr);
memset((char *) &sa, 0, sizeof(struct sockaddr_in)); if (ret == 0) {
memcpy(&sa.sin_addr, ht->h_addr_list[0], ht->h_length);
/* Find the IP address of the host */ /* Find the IP address of the host */
lhost_ip = (char *) inet_ntop(AF_INET, (const void *) &sa.sin_addr, buf, ret = MPL_sockaddr_to_str(&addr, buf, MAX_HOSTNAME_LEN);
MAX_HOSTNAME_LEN); if (ret == 0)
append_lhost(buf);
if (lhost_ip)
append_lhost(lhost_ip);
} }
/* try getifaddrs to see if we can get additional IPs */ /* try getifaddrs to see if we can get additional IPs */
if (getifaddrs(&ifaddr) == -1) if (getifaddrs(&ifaddr) == -1)
goto common_names; goto common_names;
/* Find the IP addresses of all local interfaces */ /* Find the IP addresses of all local interfaces */
for (ifa = ifaddr; ifa; ifa = ifa->ifa_next) { for (ifa = ifaddr; ifa; ifa = ifa->ifa_next) {
/* FIXME: IPv4 only local addresses */
if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) { if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) {
struct sockaddr_in *sa_ptr = (struct sockaddr_in *) ifa->ifa_addr; ret = MPL_sockaddr_to_str((MPL_sockaddr_t *) ifa->ifa_addr, buf, MAX
_HOSTNAME_LEN);
lhost_ip = (char *) if (ret == 0)
inet_ntop(AF_INET, (const void *) &(sa_ptr->sin_addr), buf, MAX_ append_lhost(buf);
HOSTNAME_LEN);
if (lhost_ip)
append_lhost(lhost_ip);
} }
} }
freeifaddrs(ifaddr); freeifaddrs(ifaddr);
#endif #endif
common_names: common_names:
/* list the common localhost names */ /* list the common localhost names */
append_lhost("localhost"); append_lhost("localhost");
append_lhost("127.0.0.1"); append_lhost("127.0.0.1");
append_lhost("127.0.1.1"); append_lhost("127.0.1.1");
 End of changes. 5 change blocks. 
19 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)