]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rgw_common introduce `rgw_to_asctime`
authorAbhishek Lekshmanan <abhishek@suse.com>
Wed, 19 Jul 2017 13:21:07 +0000 (15:21 +0200)
committerAbhishek Lekshmanan <abhishek@suse.com>
Wed, 19 Jul 2017 17:44:39 +0000 (19:44 +0200)
Basically a function that accepts a `utime_t` and spits out a asctime
string representation (without newline)

Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_loadgen.cc
src/rgw/rgw_rest_client.cc

index d7fb6cfdcf2ff1611372d1ec626da0d0070bfc79..5d26d1bd67e7024ab5d067f3aec2fea17f0cdb2c 100644 (file)
@@ -662,6 +662,14 @@ void rgw_to_iso8601(const real_time& t, string *dest)
   *dest = buf;
 }
 
+
+string rgw_to_asctime(const utime_t& t)
+{
+  stringstream s;
+  t.asctime(s);
+  return s.str();
+}
+
 /*
  * calculate the sha1 value of a given msg and key
  */
index 1ca88ebb99a788722b96b999c6c89c951341c2e4..2e96758d881ac775c0b8d499288dbb2f35080d27 100644 (file)
@@ -2182,6 +2182,7 @@ extern string rgw_trim_quotes(const string& val);
 
 extern void rgw_to_iso8601(const real_time& t, char *dest, int buf_size);
 extern void rgw_to_iso8601(const real_time& t, string *dest);
+extern std::string rgw_to_asctime(const utime_t& t);
 
 /** Check if the req_state's user has the necessary permissions
  * to do the requested action */
index edf95cc2ca9c1f5fbf5934995404b7f272ac1210..0badc78e84beb7ff252fdf73766ac755f8041ce1 100644 (file)
@@ -13,9 +13,7 @@
 
 void RGWLoadGenRequestEnv::set_date(utime_t& tm)
 {
-  stringstream s;
-  tm.asctime(s);
-  date_str = s.str();
+  date_str = rgw_to_asctime(tm);
 }
 
 int RGWLoadGenRequestEnv::sign(RGWAccessKey& access_key)
index ad9daaab6f4343842277156f0ad8a84a43a3b58b..fb61f326bd2f87d33d18b8972ebacac4b124fed7 100644 (file)
@@ -99,10 +99,7 @@ int RGWRESTSimpleRequest::receive_header(void *ptr, size_t len)
 
 static void get_new_date_str(string& date_str)
 {
-  utime_t tm = ceph_clock_now();
-  stringstream s;
-  tm.asctime(s);
-  date_str = s.str();
+  date_str = rgw_to_asctime(ceph_clock_now());
 }
 
 int RGWRESTSimpleRequest::execute(RGWAccessKey& key, const char *method, const char *resource)