Przeglądaj źródła

Hardcoded rules for hostname modifications.

If running on RIPPLE or Graham, modify the hostname so that the faster network interfaces are used.
Steven Engler 8 lat temu
rodzic
commit
d8d46482b9
1 zmienionych plików z 13 dodań i 1 usunięć
  1. 13 1
      evutils.cc

+ 13 - 1
evutils.cc

@@ -5,6 +5,8 @@ extern "C" {
 
 
 #include "evutils.h"
 #include "evutils.h"
 
 
+#include <iostream>
+
 #include <string.h>
 #include <string.h>
 #include <netdb.h>
 #include <netdb.h>
 #include <unistd.h>
 #include <unistd.h>
@@ -22,12 +24,22 @@ unsigned int hostlookup(const char *hostname)
 
 
 static unsigned int getlocalIP(void)
 static unsigned int getlocalIP(void)
 {
 {
-    char hostname[257];
+    unsigned int const hostname_len = 257+50;
+    char hostname[hostname_len];
     if (gethostname(hostname, 256)) {
     if (gethostname(hostname, 256)) {
 	// Could not determine hostname
 	// Could not determine hostname
 	return 0;
 	return 0;
     }
     }
     hostname[256] = '\0';
     hostname[256] = '\0';
+#if defined(RIPPLE)
+    // Use the 4*40Gbps bonded interface on RIPPLE
+    strcat(hostname, "-data0");
+#elif defined(GRAHAM)
+    // Use the Infiniband interface on GRAHAM
+    char temp_hostname[hostname_len];
+    strcpy(temp_hostname, hostname);
+    snprintf(hostname, sizeof(hostname), "%s%s", "ic-", temp_hostname);
+#endif
     return hostlookup(hostname);
     return hostlookup(hostname);
 }
 }