Remove few memory leaks. Close the files where we're done with them.
This commit was SVN r16125.
Этот коммит содержится в:
родитель
41ed50f901
Коммит
921d79c2b8
@ -216,6 +216,7 @@ static int opal_ifinit(void)
|
||||
opal_output(0, "opal_ifinit: ioctl(SIOCGIFCONF) \
|
||||
failed with errno=%d",
|
||||
errno);
|
||||
free(ifconf.ifc_req);
|
||||
close(sd);
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
@ -240,7 +241,6 @@ static int opal_ifinit(void)
|
||||
return OPAL_ERR_FATAL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Setup indexes
|
||||
*/
|
||||
@ -345,6 +345,8 @@ static int opal_ifinit(void)
|
||||
OMPI_DEBUG_ZERO(*intf_ptr);
|
||||
if(intf_ptr == 0) {
|
||||
opal_output(0, "opal_ifinit: unable to allocated %lu bytes\n", (unsigned long)sizeof(opal_if_t));
|
||||
free(ifconf.ifc_req);
|
||||
close(sd);
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
memcpy(intf_ptr, &intf, sizeof(intf));
|
||||
@ -374,6 +376,10 @@ static int opal_ifinit(void)
|
||||
opal_if_t intf;
|
||||
opal_if_t *intf_ptr;
|
||||
|
||||
/* we don't want any other scope than global */
|
||||
if (scope != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
OMPI_DEBUG_ZERO(intf);
|
||||
OBJ_CONSTRUCT(&intf, opal_list_item_t);
|
||||
@ -382,11 +388,6 @@ static int opal_ifinit(void)
|
||||
a6.s6_addr[iter] = addrbyte[iter];
|
||||
}
|
||||
|
||||
/* we don't want any other scope than global */
|
||||
if (scope != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* now construct the opal_if_t */
|
||||
strncpy(intf.if_name, ifname, IF_NAMESIZE);
|
||||
intf.if_index = opal_list_get_size(&opal_if_list)+1;
|
||||
@ -409,11 +410,14 @@ static int opal_ifinit(void)
|
||||
if(NULL == intf_ptr) {
|
||||
opal_output(0, "opal_ifinit: unable to allocate %lu bytes\n",
|
||||
(unsigned long)sizeof(opal_if_t));
|
||||
OBJ_DESTRUCT(&intf);
|
||||
fclose(f);
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
memcpy(intf_ptr, &intf, sizeof(intf));
|
||||
opal_list_append(&opal_if_list, (opal_list_item_t*)intf_ptr);
|
||||
} /* of while */
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -491,7 +495,6 @@ static int opal_ifinit(void)
|
||||
|
||||
sin_addr = (struct sockaddr_in6 *) cur_ifaddrs->ifa_addr;
|
||||
|
||||
|
||||
/*
|
||||
* skip IPv6 address starting with fe80:, as this is supposed to be
|
||||
* link-local scope. sockaddr_in6->sin6_scope_id doesn't always work
|
||||
@ -552,10 +555,12 @@ static int opal_ifinit(void)
|
||||
if(NULL == intf_ptr) {
|
||||
opal_output(0, "opal_ifinit: unable to allocate %lu bytes\n",
|
||||
sizeof(opal_if_t));
|
||||
OBJ_DESTRUCT(&intf);
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
memcpy(intf_ptr, &intf, sizeof(intf));
|
||||
opal_list_append(&opal_if_list, (opal_list_item_t*) intf_ptr);
|
||||
OBJ_DESTRUCT(&intf);
|
||||
} /* of for loop over ifaddrs list */
|
||||
|
||||
}
|
||||
@ -667,10 +672,12 @@ static int opal_ifinit(void)
|
||||
opal_output (0,
|
||||
"opal_ifinit: unable to allocate %d bytes\n",
|
||||
sizeof (opal_if_t));
|
||||
OBJ_DESTRUCT(&intf);
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
memcpy (intf_ptr, &intf, sizeof (intf));
|
||||
opal_list_append (&opal_if_list, (opal_list_item_t*) intf_ptr);
|
||||
OBJ_DESTRUCT(&intf);
|
||||
}
|
||||
}
|
||||
} /* for */
|
||||
@ -684,7 +691,7 @@ static int opal_ifinit(void)
|
||||
#endif /* OPAL_WANT_IPV6 */
|
||||
|
||||
#else /* __WINDOWS__ implementation begins */
|
||||
|
||||
{
|
||||
/*
|
||||
1. check if the interface info list is already populated. If so, return
|
||||
2. get the interface information which is required using WSAIoctl
|
||||
@ -734,7 +741,6 @@ static int opal_ifinit(void)
|
||||
/* create and populate opal_if_list */
|
||||
OBJ_CONSTRUCT (&opal_if_list, opal_list_t);
|
||||
|
||||
|
||||
/* loop through all the interfaces and create the list */
|
||||
num_interfaces = num_bytes_returned / sizeof (INTERFACE_INFO);
|
||||
for (i = 0; i < num_interfaces; ++i) {
|
||||
@ -772,14 +778,16 @@ static int opal_ifinit(void)
|
||||
intf_ptr = (opal_if_t *) malloc(sizeof(opal_if_t));
|
||||
if (NULL == intf_ptr) {
|
||||
opal_output (0,"opal_ifinit: Unable to malloc %d bytes",sizeof(opal_list_t));
|
||||
OBJ_DESTRUCT(&intf);
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
|
||||
memcpy (intf_ptr, &intf, sizeof(intf));
|
||||
opal_list_append(&opal_if_list, (opal_list_item_t *)intf_ptr);
|
||||
OBJ_DESTRUCT(&intf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user