1
1

* It appears that in their infinite wisdom, Apple removed the

__DARWIN_ALIGN_POWER define from the last release of the OS X compiler
    toolchain.  The bug in net/if.h, however, is still there.  So look
    for the hints that we're on a 64 bit Apple PowerPC instead.
  * If we don't find a buffer size that works by 10MB, we're never
    going to.  So add some code to limit the buffer size we'll try
    so that we don't fall into an infinite loop
  * Detect errors in opal_ifcount in the oob init code

Refs trac:420

This commit was SVN r11825.

The following Trac tickets were found above:
  Ticket 420 --> https://svn.open-mpi.org/trac/ompi/ticket/420
Этот коммит содержится в:
Brian Barrett 2006-09-26 16:37:04 +00:00
родитель 85cc94f634
Коммит d00a0de716
2 изменённых файлов: 11 добавлений и 4 удалений

Просмотреть файл

@ -41,14 +41,14 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#ifdef HAVE_NET_IF_H #ifdef HAVE_NET_IF_H
#if defined(__DARWIN_ALIGN_POWER) && __DARWIN_ALIGN_POWER #if defined(__APPLE__) && defined(__POWERPC__) && defined(_LP64)
/* Apple engineering suggested this as a workaround for a bug in OS X /* Apple engineering suggested this as a workaround for a bug in OS X
* 10.4 (Tiger) that prevented ioctl(..., SIOCGIFCONF, ...) from * 10.4 (Tiger) that prevented ioctl(..., SIOCGIFCONF, ...) from
* working properly in 64 bit mode */ * working properly in 64 bit mode */
#pragma options align=power #pragma options align=power
#endif #endif
#include <net/if.h> #include <net/if.h>
#if defined(__DARWIN_ALIGN_POWER) && __DARWIN_ALIGN_POWER #if defined(__APPLE__) && defined(__POWERPC__) && defined(_LP64)
#pragma options align=reset #pragma options align=reset
#endif #endif
#endif #endif
@ -103,6 +103,7 @@ static opal_list_t opal_if_list;
static bool already_done = false; static bool already_done = false;
#define DEFAULT_NUMBER_INTERFACES 10 #define DEFAULT_NUMBER_INTERFACES 10
#define MAX_IFCONF_SIZE 10 * 1024 * 1024
/* /*
* Discover the list of configured interfaces. Don't care about any * Discover the list of configured interfaces. Don't care about any
@ -117,6 +118,7 @@ static int opal_ifinit(void)
char *ptr; char *ptr;
struct ifconf ifconf; struct ifconf ifconf;
int ifc_len; int ifc_len;
bool successful_locate = false;
if (already_done) { if (already_done) {
return OPAL_SUCCESS; return OPAL_SUCCESS;
@ -178,6 +180,7 @@ static int opal_ifinit(void)
call to ioctl, try again with a bigger buffer. else stop */ call to ioctl, try again with a bigger buffer. else stop */
if (ifconf.ifc_len == lastlen && ifconf.ifc_len > 0) { if (ifconf.ifc_len == lastlen && ifconf.ifc_len > 0) {
/* we didn't expand. we're done */ /* we didn't expand. we're done */
successful_locate = true;
break; break;
} }
lastlen = ifconf.ifc_len; lastlen = ifconf.ifc_len;
@ -187,7 +190,11 @@ static int opal_ifinit(void)
back around and try again with a bigger buffer */ back around and try again with a bigger buffer */
free(ifconf.ifc_req); free(ifconf.ifc_req);
ifc_len = (ifc_len == 0) ? 1 : ifc_len * 2; ifc_len = (ifc_len == 0) ? 1 : ifc_len * 2;
} while (1); } while (ifc_len < MAX_IFCONF_SIZE);
if (!successful_locate) {
opal_output(0, "opal_ifinit: unable to find network interfaces.");
return OPAL_ERR_FATAL;
}
/* /*

Просмотреть файл

@ -788,7 +788,7 @@ mca_oob_t* mca_oob_tcp_component_init(int* priority)
*priority = 1; *priority = 1;
/* are there any interfaces? */ /* are there any interfaces? */
if(opal_ifcount() == 0) if(opal_ifcount() <= 0)
return NULL; return NULL;
/* initialize data structures */ /* initialize data structures */