]> git.openfabrics.org - ~ardavis/dapl.git/commitdiff
Current static registration (SR) assumes DAT_OVERRIDE or /etc/dat.conf.
authorArlin Davis <arlin.r.davis@intel.com>
Tue, 14 Oct 2008 18:56:35 +0000 (11:56 -0700)
committerArlin Davis <arlin.r.davis@intel.com>
Tue, 14 Oct 2008 18:56:35 +0000 (11:56 -0700)
Change SR to include sysconfdir. SR file access in the following order:

- DAT_OVERRIDE
- sysconfdir
- /etc

if DAT_OVERRIDE is set, assume administration override
and do not failover to other locations. Add debug
messages for each failure and retries.

Signed-off-by: Arlin Davis <ardavis@ichips.intel.com>
Acked-by: Doug Ledford <dledford@redhat.com>
Makefile.am
dat/udat/udat_sr_parser.c

index 4929f83808f23df46161f4dc9eb3e5702fda76e5..bfc93f72562cecdcb0bcf25f3bb7dcb3c3f3d5b8 100755 (executable)
@@ -22,9 +22,9 @@ XPROGRAMS_SCM =
 endif
 
 if DEBUG
-AM_CFLAGS = -g -Wall -D_GNU_SOURCE -DDAPL_DBG
+AM_CFLAGS = -g -Wall -D_GNU_SOURCE -DDAPL_DBG -DDAT_CONF="\"$(sysconfdir)/dat.conf\""
 else
-AM_CFLAGS = -g -Wall -D_GNU_SOURCE
+AM_CFLAGS = -g -Wall -D_GNU_SOURCE -DDAT_CONF="\"$(sysconfdir)/dat.conf\""
 endif
 
 datlibdir = $(libdir)
index 644e1c9c337b351439423732eb5501f61ea1a90b..ddd96bf0263fa39e8cb6764c53c89ca120a74cc3 100644 (file)
@@ -285,21 +285,52 @@ dat_sr_load (void)
     char                       *sr_path;
     DAT_OS_FILE                *sr_file;
 
-    sr_path = dat_os_getenv (DAT_SR_CONF_ENV);
-    if ( sr_path == NULL )
-    {
-       sr_path = DAT_SR_CONF_DEFAULT;
-    }
-
-    dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
-                    "DAT Registry: static registry file <%s> \n", sr_path);
+    sr_path = dat_os_getenv(DAT_SR_CONF_ENV);
 
-    sr_file = dat_os_fopen (sr_path);
-    if ( sr_file == NULL )
+    /* environment override */
+    if ((sr_path != NULL) && ((sr_file = dat_os_fopen(sr_path)) == NULL)) 
     {
-       goto bail;
+        dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+                         "DAT Registry: DAT_OVERRIDE, "
+                         "bad filename - %s, aborting\n",
+                         sr_path);
+        goto bail;
+    } 
+    
+    if (sr_path == NULL) { 
+
+#ifdef DAT_CONF
+        sr_path = DAT_CONF;
+#else
+        sr_path = DAT_SR_CONF_DEFAULT;
+#endif
+        sr_file = dat_os_fopen (sr_path);
+        if (sr_file == NULL) 
+        {
+#ifdef DAT_CONF
+            dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+                             "DAT Registry: sysconfdir, "
+                             "bad filename - %s, retry default at %s\n",
+                             sr_path, DAT_SR_CONF_DEFAULT);
+           /* try default after sysconfdir fails */
+            sr_path = DAT_SR_CONF_DEFAULT;
+            sr_file = dat_os_fopen(sr_path);
+            if (sr_file == NULL) { 
+#endif
+                dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+                                 "DAT Registry: default, "
+                                 "bad filename - %s, aborting\n",
+                                 sr_path);
+                goto bail;
+#ifdef DAT_CONF
+            }
+#endif
+        }
     }
 
+    dat_os_dbg_print(DAT_OS_DBG_TYPE_GENERIC,
+                    "DAT Registry: using config file %s\n", sr_path);
+
     for (;;)
     {
        if ( DAT_SUCCESS == dat_sr_parse_eof (sr_file) )
@@ -312,20 +343,26 @@ dat_sr_load (void)
        }
        else
        {
+           dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
+                             "DAT Registry: ERROR parsing - %s\n", 
+                             sr_path);
             goto cleanup;
        }
     }
 
-    if (0 != dat_os_fclose (sr_file))
+    if (0 != dat_os_fclose (sr_file)) 
+    {
+        dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
+                         "DAT Registry: ERROR closing - %s\n", 
+                          sr_path);
        goto bail;
+    }
 
     return DAT_SUCCESS;
 
 cleanup:
     dat_os_fclose(sr_file);    
 bail:
-    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
-                    "ERROR: unable to parse static registry file, dat.conf\n");
     return DAT_INTERNAL_ERROR;
 
 }