[Pvfs2-cvs] commit by slang in pvfs2/src/server: pvfs2-server.c

CVS commit program cvs at parl.clemson.edu
Fri Apr 4 11:39:47 EST 2008


Update of /projects/cvsroot/pvfs2/src/server
In directory parlweb1:/tmp/cvs-serv9169/src/server

Modified Files:
	pvfs2-server.c 
Log Message:
fixes the migrate collection utility to work with the single config file format.


Index: pvfs2-server.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/server/pvfs2-server.c,v
diff -p -u -r1.251 -r1.252
--- pvfs2-server.c	12 Mar 2008 14:45:12 -0000	1.251
+++ pvfs2-server.c	4 Apr 2008 16:39:47 -0000	1.252
@@ -43,6 +43,7 @@
 #include "pint-cached-config.h"
 #include "pvfs2-internal.h"
 #include "src/server/request-scheduler/request-scheduler.h"
+#include "pint-util.h"
 
 #ifndef PVFS2_VERSION
 #define PVFS2_VERSION "Unknown"
@@ -156,7 +157,6 @@ static int create_pidfile(char *pidfile)
 static void write_pidfile(int fd);
 static void remove_pidfile(void);
 static int generate_shm_key_hint(void);
-static char *guess_alias(void);
 
 static TROVE_method_id trove_coll_to_method_callback(TROVE_coll_id);
 
@@ -1464,7 +1464,7 @@ static int server_parse_cmd_line_args(in
     if (s_server_options.server_alias == NULL)
     {
         /* Try to guess the alias from the hostname */
-        s_server_options.server_alias = guess_alias();
+        s_server_options.server_alias = PINT_util_guess_alias();
     }
     return 0;
 }
@@ -1838,32 +1838,65 @@ void PINT_server_access_debug(PINT_serve
 }
 #endif
 
-static char *guess_alias(void)
+/*
+ * PINT_map_server_op_to_string()
+ *
+ * provides a string representation of the server operation number
+ *
+ * returns a pointer to a static string (DONT FREE IT) on success,
+ * null on failure
+ */
+const char* PINT_map_server_op_to_string(enum PVFS_server_op op)
 {
-    char tmp_alias[1024];
-    char *tmpstr;
-    char *alias;
-    int ret;
+    const char *s = NULL;
 
-    /* hmm...failed to find alias as part of the server config filename,
-     * use the hostname to guess
-     */
-    ret = gethostname(tmp_alias, 1024);
-    if(ret != 0)
-    {
-        gossip_err("Failed to get hostname while attempting to guess "
-                   "alias.  Use -a to specify the alias for this server "
-                   "process directly\n");
-        return NULL;
-    }
-    alias = tmp_alias;
+    if (op >= 0 && op < PVFS_SERV_NUM_OPS)
+        s = PINT_server_req_table[op].string_name;
+    return s;
+}
+
+/* generate_shm_key_hint()
+ *
+ * Makes a best effort to produce a unique shm key (for Trove's Berkeley
+ * DB use) for each server.  By default it will base this on the server's
+ * position in the fs.conf, but it will fall back to using a random number
+ *
+ * returns integer key
+ */
+static int generate_shm_key_hint(void)
+{
+    int server_index = 1;
+    struct host_alias_s *cur_alias = NULL;
 
-    tmpstr = strstr(tmp_alias, ".");
-    if(tmpstr)
+    PINT_llist *cur = server_config.host_aliases;
+
+    /* iterate through list of aliases in configuration file */
+    while(cur)
     {
-        *tmpstr = 0;
+        cur_alias = PINT_llist_head(cur);
+        if(!cur_alias)
+        {
+            break;
+        }
+        if(strcmp(cur_alias->bmi_address, server_config.host_id) == 0)
+        {
+            /* match */
+            /* space the shm keys out by 10 to allow for Berkeley DB using 
+             * using more than one key on each server
+             */
+            return(server_index*10);        
+        }
+
+        server_index++;
+        cur = PINT_llist_next(cur);
     }
-    return strdup(tmp_alias);
+    
+    /* If we reach this point, we didn't find this server in the alias list.
+     * This is not a normal situation, but fall back to using a random
+     * number for the key just to be safe.
+     */
+    srand((unsigned int)time(NULL));
+    return(rand());
 }
 
 /* generate_shm_key_hint()



More information about the Pvfs2-cvs mailing list