diff options
| author | Andrew Stitcher <astitcher@apache.org> | 2009-05-12 19:50:45 +0000 |
|---|---|---|
| committer | Andrew Stitcher <astitcher@apache.org> | 2009-05-12 19:50:45 +0000 |
| commit | 8ad39ce15e81423e635c4e4425fc71674e878ce5 (patch) | |
| tree | a10df9f0a74ff1db1b7573c0b06a3d07cca35d77 /cpp | |
| parent | f215e6224b30b0ae10151b6d0cd063bdeb812b30 (diff) | |
| download | qpid-python-8ad39ce15e81423e635c4e4425fc71674e878ce5.tar.gz | |
QPID-1852 Removed thread unsafe code in Logger
Fixed some potentially iffy code in Connector.h if a derived Connector
doesn't have activateSecurityLayer()
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@774051 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
| -rw-r--r-- | cpp/src/qpid/agent/QmfAgentImportExport.h | 2 | ||||
| -rw-r--r-- | cpp/src/qpid/client/Connector.cpp | 4 | ||||
| -rw-r--r-- | cpp/src/qpid/client/Connector.h | 2 | ||||
| -rw-r--r-- | cpp/src/qpid/log/Logger.cpp | 21 | ||||
| -rw-r--r-- | cpp/src/qpid/sys/Time.h | 3 | ||||
| -rw-r--r-- | cpp/src/qpid/sys/posix/Time.cpp | 35 | ||||
| -rw-r--r-- | cpp/src/qpid/sys/windows/Time.cpp | 13 | ||||
| -rw-r--r-- | cpp/src/qpid/sys/windows/Time.h | 2 |
8 files changed, 44 insertions, 38 deletions
diff --git a/cpp/src/qpid/agent/QmfAgentImportExport.h b/cpp/src/qpid/agent/QmfAgentImportExport.h index e614e09d6d..9eee4a18fd 100644 --- a/cpp/src/qpid/agent/QmfAgentImportExport.h +++ b/cpp/src/qpid/agent/QmfAgentImportExport.h @@ -20,7 +20,7 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) && !defined(qpidbroker_EXPORTS) +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) #if defined(QMF_AGENT_EXPORT) || defined (qmfagent_EXPORTS) #define QMF_AGENT_EXTERN __declspec(dllexport) #else diff --git a/cpp/src/qpid/client/Connector.cpp b/cpp/src/qpid/client/Connector.cpp index 8cca36c571..3d7fdc089b 100644 --- a/cpp/src/qpid/client/Connector.cpp +++ b/cpp/src/qpid/client/Connector.cpp @@ -77,6 +77,10 @@ void Connector::registerFactory(const std::string& proto, Factory* connectorFact theProtocolRegistry()[proto] = connectorFactory; } +void Connector::activateSecurityLayer(std::auto_ptr<qpid::sys::SecurityLayer>) +{ +} + class TCPConnector : public Connector, public sys::Codec, private sys::Runnable { typedef std::deque<framing::AMQFrame> Frames; diff --git a/cpp/src/qpid/client/Connector.h b/cpp/src/qpid/client/Connector.h index 2966166d28..78ddaa33cd 100644 --- a/cpp/src/qpid/client/Connector.h +++ b/cpp/src/qpid/client/Connector.h @@ -72,7 +72,7 @@ class Connector : public framing::OutputHandler virtual framing::OutputHandler* getOutputHandler() = 0; virtual const std::string& getIdentifier() const = 0; - virtual void activateSecurityLayer(std::auto_ptr<qpid::sys::SecurityLayer>) {} + virtual void activateSecurityLayer(std::auto_ptr<qpid::sys::SecurityLayer>); }; diff --git a/cpp/src/qpid/log/Logger.cpp b/cpp/src/qpid/log/Logger.cpp index 07e4245399..fe16fcc232 100644 --- a/cpp/src/qpid/log/Logger.cpp +++ b/cpp/src/qpid/log/Logger.cpp @@ -21,6 +21,7 @@ #include "SinkOptions.h" #include "qpid/memory.h" #include "qpid/sys/Thread.h" +#include "qpid/sys/Time.h" #include <boost/pool/detail/singleton.hpp> #include <boost/bind.hpp> #include <boost/function.hpp> @@ -73,25 +74,7 @@ void Logger::log(const Statement& s, const std::string& msg) { if (!prefix.empty()) os << prefix << ": "; if (flags&TIME) - { - const char * month_abbrevs[] = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" }; - time_t rawtime; - struct tm * timeinfo; - - time ( & rawtime ); - timeinfo = localtime ( &rawtime ); - char time_string[100]; - sprintf ( time_string, - "%d-%s-%02d %02d:%02d:%02d", - 1900 + timeinfo->tm_year, - month_abbrevs[timeinfo->tm_mon], - timeinfo->tm_mday, - timeinfo->tm_hour, - timeinfo->tm_min, - timeinfo->tm_sec - ); - os << time_string << " "; - } + qpid::sys::outputFormattedNow(os); if (flags&LEVEL) os << LevelTraits::name(s.level) << " "; if (flags&THREAD) diff --git a/cpp/src/qpid/sys/Time.h b/cpp/src/qpid/sys/Time.h index b7173406ca..ca229c2f27 100644 --- a/cpp/src/qpid/sys/Time.h +++ b/cpp/src/qpid/sys/Time.h @@ -165,6 +165,9 @@ QPID_COMMON_EXTERN void sleep(int secs); /** Portable sleep for a number of microseconds */ QPID_COMMON_EXTERN void usleep(uint64_t usecs); +/** Output formatted date/time for now*/ +void outputFormattedNow(std::ostream&); + }} #endif /*!_sys_Time_h*/ diff --git a/cpp/src/qpid/sys/posix/Time.cpp b/cpp/src/qpid/sys/posix/Time.cpp index d8d0a58d2e..5eb65357f6 100644 --- a/cpp/src/qpid/sys/posix/Time.cpp +++ b/cpp/src/qpid/sys/posix/Time.cpp @@ -79,25 +79,28 @@ std::ostream& operator<<(std::ostream& o, const Duration& d) { return o << int64_t(d) << "ns"; } -std::ostream& operator<<(std::ostream& o, const AbsTime& t) { - static const char * month_abbrevs[] = { - "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" - }; - struct tm * timeinfo; - time_t rawtime(t.timepoint/TIME_SEC); - timeinfo = localtime (&rawtime); +namespace { +inline std::ostream& outputFormattedTime(std::ostream& o, const ::time_t* time) { + ::tm timeinfo; char time_string[100]; - sprintf ( time_string, - "%d-%s-%02d %02d:%02d:%02d", - 1900 + timeinfo->tm_year, - month_abbrevs[timeinfo->tm_mon], - timeinfo->tm_mday, - timeinfo->tm_hour, - timeinfo->tm_min, - timeinfo->tm_sec - ); + ::strftime(time_string, 100, + "%Y-%m-%d %H:%M:%S", + localtime_r(time, &timeinfo)); return o << time_string; } +} + +std::ostream& operator<<(std::ostream& o, const AbsTime& t) { + ::time_t rawtime(t.timepoint/TIME_SEC); + return outputFormattedTime(&rawtime); +} + +void outputFormattedNow(std::ostream& o) { + ::time_t rawtime; + ::time(&rawtime); + outputFormattedTime(o, &rawtime); + o << " "; +} void sleep(int secs) { ::sleep(secs); diff --git a/cpp/src/qpid/sys/windows/Time.cpp b/cpp/src/qpid/sys/windows/Time.cpp index 2390826831..1d7b94e8d7 100644 --- a/cpp/src/qpid/sys/windows/Time.cpp +++ b/cpp/src/qpid/sys/windows/Time.cpp @@ -72,6 +72,7 @@ std::ostream& operator<<(std::ostream& o, const AbsTime& t) { return o << time_string; } + void toPtime(ptime& pt, const AbsTime& t) { pt = t.getPrivate(); } @@ -87,4 +88,16 @@ void usleep(uint64_t usecs) { ::Sleep(msecs); } +void outputFormattedNow(std::ostream& o) { + ::time_t rawtime; + ::tm timeinfo; + char time_string[100]; + + ::time( &rawtime ); + ::localtime_s(&timeinfo, &rawtime); + ::strftime(time_string, 100, + "%Y-%m-%d %H:%M:%S", + &timeinfo); + o << time_string << " "; +} }} diff --git a/cpp/src/qpid/sys/windows/Time.h b/cpp/src/qpid/sys/windows/Time.h index 49b3c4bab3..2987b1c8b2 100644 --- a/cpp/src/qpid/sys/windows/Time.h +++ b/cpp/src/qpid/sys/windows/Time.h @@ -19,7 +19,7 @@ * */ -#include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/date_time/posix_time/posix_time_types.hpp> namespace qpid { namespace sys { |
