diff --git a/src/partition_allocator/partition_allocator.c b/src/partition_allocator/partition_allocator.c index 5c42c0dbffc914870fa3a19f014fef79aca5790a..2d31323202b5f881ba77aa1b6fe2057408d9d5d9 100644 --- a/src/partition_allocator/partition_allocator.c +++ b/src/partition_allocator/partition_allocator.c @@ -30,7 +30,6 @@ #endif #include <stdio.h> -#include <dlfcn.h> #include <stdlib.h> #include <math.h> #include "partition_allocator.h" @@ -49,7 +48,7 @@ int DIM_SIZE[PA_SYSTEM_DIMENSIONS] = {0}; #endif bool _initialized = false; -bool _have_db2 = false; +bool have_db2 = false; /* _pa_system is the "current" system that the structures will work * on */ @@ -415,7 +414,7 @@ static void _db2_check(void) if (dlsym(handle, "SQLAllocHandle") == NULL) debug("SQLAllocHandle not found in libdb2.so"); else - _have_db2 = true; + have_db2 = true; dlclose(handle); } @@ -495,7 +494,7 @@ extern void pa_init(node_info_msg_t *node_info_ptr) } #ifdef HAVE_BGL_FILES - if (_have_db2 + if (have_db2 && (DIM_SIZE[X]==0) && (DIM_SIZE[X]==0) && (DIM_SIZE[X]==0)) { if ((rc = rm_set_serial(BGL_SERIAL)) != STATUS_OK) { error("rm_set_serial(%s): %d", BGL_SERIAL, rc); @@ -1148,7 +1147,7 @@ extern int set_bp_map(void) bp_map_list = list_create(_bp_map_list_del); - if (!_have_db2) { + if (!have_db2) { error("Can't access DB2 library, run from service node"); return -1; } diff --git a/src/partition_allocator/partition_allocator.h b/src/partition_allocator/partition_allocator.h index de9f09b2c6495a5cae1f5de575f26bce2ac216c5..c3f78895058f0411d50e9e5514b1f0e04deb66de 100644 --- a/src/partition_allocator/partition_allocator.h +++ b/src/partition_allocator/partition_allocator.h @@ -52,6 +52,7 @@ #include "src/common/bitstring.h" #include "src/common/xstring.h" #include "src/common/xmalloc.h" +#include <dlfcn.h> // #define DEBUG_PA #define BIG_MAX 9999 @@ -66,6 +67,7 @@ #define NUM_PORTS_PER_NODE 6 extern bool _initialized; +extern bool have_db2; enum {X, Y, Z}; diff --git a/src/plugins/select/bluegene/sfree.c b/src/plugins/select/bluegene/sfree.c index 30e24f792328143017a48cad8e830122a4604dac..2f2549e6dda7ddd15d3633e7198299262c5b9fd7 100644 --- a/src/plugins/select/bluegene/sfree.c +++ b/src/plugins/select/bluegene/sfree.c @@ -42,7 +42,7 @@ int all_parts = 0; static int num_part_to_free = 0; static int num_part_freed = 0; static pthread_mutex_t freed_cnt_mutex = PTHREAD_MUTEX_INITIALIZER; - +static bool _have_db2 = true; /************ * Functions * @@ -70,6 +70,20 @@ static void *_mult_free_part(void *args) return NULL; } +static void _db2_check(void) +{ + void *handle; + + handle = dlopen("libdb2.so", RTLD_LAZY); + if (!handle) + return; + + if (dlsym(handle, "SQLAllocHandle")) + _have_db2 = true; + + dlclose(handle); +} + int main(int argc, char *argv[]) { log_options_t opts = LOG_OPTS_STDERR_ONLY; @@ -82,6 +96,12 @@ int main(int argc, char *argv[]) pthread_t thread_agent; int retries; + _db2_check(); + if (!_have_db2) { + printf("must be on BGL SN to resolve.\n"); + exit(0); + } + log_init(xbasename(argv[0]), opts, SYSLOG_FACILITY_DAEMON, NULL); parse_command_line(argc, argv); if(!all_parts) { diff --git a/src/smap/smap.c b/src/smap/smap.c index e527db7c7e605496b65403888356d451fa4b337b..8bbd93c21b369faa93038a237e3996e5a0a8327c 100644 --- a/src/smap/smap.c +++ b/src/smap/smap.c @@ -29,7 +29,6 @@ #include "config.h" #include <stdio.h> -#include <dlfcn.h> #include <signal.h> #include "src/smap/smap.h" @@ -43,7 +42,6 @@ smap_parameters_t params; int quiet_flag = 0; int line_cnt = 0; int max_display; -bool have_db2 = false; /************ * Functions * @@ -56,20 +54,6 @@ static int _set_pairs(); static int _scroll_grid(int dir); #endif /* HAVE_BGL */ -static void _db2_check(void) -{ - void *handle; - - handle = dlopen("libdb2.so", RTLD_LAZY); - if (!handle) - return; - - if (dlsym(handle, "SQLAllocHandle")) - have_db2 = true; - - dlclose(handle); -} - int main(int argc, char *argv[]) { log_options_t opts = LOG_OPTS_STDERR_ONLY; @@ -106,8 +90,6 @@ int main(int argc, char *argv[]) pa_init(new_node_ptr); } - _db2_check(); - if(params.partition) { #ifdef HAVE_BGL_FILES diff --git a/src/smap/smap.h b/src/smap/smap.h index 378471be8b91c19f73592b86bab42422ddcb3e39..d24185c1aefda1b93382cc2f414ac88e0b6d21f5 100644 --- a/src/smap/smap.h +++ b/src/smap/smap.h @@ -100,7 +100,6 @@ typedef struct { extern smap_parameters_t params; extern int DIM_SIZE[PA_SYSTEM_DIMENSIONS]; -extern bool have_db2; void parse_command_line(int argc, char *argv[]);