From: Abhishek Lekshmanan Date: Wed, 19 Jul 2017 13:21:07 +0000 (+0200) Subject: rgw: rgw_common introduce `rgw_to_asctime` X-Git-Tag: v12.1.2~141^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5342d7c590677d33a2d57ea73fd116a337ef1967;p=ceph.git rgw: rgw_common introduce `rgw_to_asctime` Basically a function that accepts a `utime_t` and spits out a asctime string representation (without newline) Signed-off-by: Abhishek Lekshmanan --- diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index d7fb6cfdcf2..5d26d1bd67e 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -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 */ diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 1ca88ebb99a..2e96758d881 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -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 */ diff --git a/src/rgw/rgw_loadgen.cc b/src/rgw/rgw_loadgen.cc index edf95cc2ca9..0badc78e84b 100644 --- a/src/rgw/rgw_loadgen.cc +++ b/src/rgw/rgw_loadgen.cc @@ -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) diff --git a/src/rgw/rgw_rest_client.cc b/src/rgw/rgw_rest_client.cc index ad9daaab6f4..fb61f326bd2 100644 --- a/src/rgw/rgw_rest_client.cc +++ b/src/rgw/rgw_rest_client.cc @@ -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)