]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephtool: only initialize the tokenizer once
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 28 Oct 2010 22:26:05 +0000 (15:26 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 28 Oct 2010 22:51:19 +0000 (15:51 -0700)
Only initialize the tokenizer once. It gets cranky if it we call
tok_init more than once.

Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/tools/ceph.cc

index d0cc82d0654fddd28300965afce88fb066e05b11..627dcbf80d09367b429fec06b3eac0ba934689c1 100644 (file)
@@ -56,6 +56,7 @@ struct ceph_tool_data g;
 static Cond cmd_cond;
 static SimpleMessenger *messenger = 0;
 static SafeTimer timer(g.lock);
+static Tokenizer *tok;
 
 static const char *outfile = 0;
 
@@ -449,10 +450,8 @@ int run_command(const char *line)
 
   int argc;
   const char **argv;
-  Tokenizer *tok = tok_init(NULL);
   tok_str(tok, line, &argc, &argv);
   tok_reset(tok);
-  tok_end(tok);
 
   vector<string> cmd;
   const char *infile = 0;
@@ -595,6 +594,9 @@ int main(int argc, const char **argv)
   if (g.mc.build_initial_monmap() < 0)
     return -1;
   
+  // initialize tokenizer
+  tok = tok_init(NULL);
+
   // start up network
   messenger = new SimpleMessenger();
   messenger->register_entity(entity_name_t::CLIENT());
@@ -680,5 +682,6 @@ int main(int argc, const char **argv)
   // wait for messenger to finish
   messenger->wait();
   messenger->destroy();
+  tok_end(tok);
   return ret;
 }