Hello community, here is the log from the commit of package commoncpp2 for openSUSE:Factory checked in at 2012-09-26 16:10:22 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/commoncpp2 (Old) and /work/SRC/openSUSE:Factory/.commoncpp2.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "commoncpp2", Maintainer is "[email protected]" Changes: -------- --- /work/SRC/openSUSE:Factory/commoncpp2/commoncpp2.changes 2012-05-22 08:12:37.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.commoncpp2.new/commoncpp2.changes 2012-09-26 16:10:24.000000000 +0200 @@ -1,0 +2,7 @@ +Thu Sep 6 21:28:48 UTC 2012 - [email protected] + +- Updated to upstream version 1.8.1 +- Deleted all no more needed patches +- Applied patch based on trunk commit of applog.cpp + +------------------------------------------------------------------- Old: ---- commoncpp-charptr.diff commoncpp-libtool.diff commoncpp-socketmemcpy.dif commoncpp-stdlib.diff commoncpp2-1.6.1-memset-with-zero-length.patch commoncpp2-1.6.1.tar.bz2 New: ---- commoncpp2-1.8.1.tar.gz commoncpp2-applog.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ commoncpp2.spec ++++++ --- /var/tmp/diff_new_pack.LYOD3i/_old 2012-09-26 16:10:25.000000000 +0200 +++ /var/tmp/diff_new_pack.LYOD3i/_new 2012-09-26 16:10:25.000000000 +0200 @@ -29,16 +29,12 @@ Summary: A GNU package for creating portable C++ program License: GPL-2.0+ Group: Development/Libraries/C and C++ -Version: 1.6.1 +Version: 1.8.1 Release: 0 Url: http://www.gnu.org/software/commoncpp/ -Source: %{name}-%{version}.tar.bz2 -Patch: commoncpp-socketmemcpy.dif -Patch1: commoncpp-libtool.diff -Patch2: commoncpp-charptr.diff -Patch3: commoncpp-stdlib.diff -Patch4: commoncpp2-1.6.1-memset-with-zero-length.patch -Patch5: commoncpp2-overflow.patch +Source: %{name}-%{version}.tar.gz +Patch: commoncpp2-overflow.patch +Patch1: commoncpp2-applog.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %description @@ -102,12 +98,8 @@ %prep %setup -q -%patch -p1 +%patch %patch1 -%patch2 -%patch -P 3 -p1 -%patch4 -%patch5 -p1 %build autoreconf --install --force -v ++++++ commoncpp2-applog.patch ++++++ --- src/applog.cpp.orig 2012-09-07 00:06:52.116623618 +0200 +++ src/applog.cpp 2012-09-07 00:06:56.294734349 +0200 @@ -38,6 +38,10 @@ #include <cc++/thread.h> #include <cc++/slog.h> #include <cc++/buffer.h> +#ifndef WIN32 +#include <sys/types.h> +#include <sys/stat.h> +#endif #include <string> #include <iomanip> #include <iostream> @@ -115,6 +119,7 @@ string _nomeFile; std::fstream _logfs; bool _usePipe; + bool _closedByApplog; protected: // to dequeue log messages and write them to file if not log_directly @@ -123,7 +128,8 @@ virtual void stopQueue(void); virtual void onTimer(void); virtual void final(void); - + void _openFile(); + public: logger(const char* logFileName = NULL, bool usePipe = false); virtual ~logger(); @@ -131,6 +137,9 @@ // To change log file name void logFileName(const char* FileName, bool usePipe = false); + void openFile(); + void closeFile(); + }; @@ -281,35 +290,14 @@ } // class logger -logger::logger(const char* logFileName, bool usePipe) : ThreadQueue(NULL, 0, 0), _usePipe(usePipe) +logger::logger(const char* logFileName, bool usePipe) : ThreadQueue(NULL, 0, 0), _usePipe(usePipe), _closedByApplog(false) { _nomeFile = ""; if (logFileName) _nomeFile = logFileName; - if (!_nomeFile.empty()) - { - if (!_usePipe) - { - _logfs.open(_nomeFile.c_str(), std::ofstream::out | std::ofstream::app | std::ofstream::ate); - } -#ifndef WIN32 - else - { - // create pipe - int err = mkfifo(_nomeFile.c_str(), S_IREAD | S_IWRITE); - if (err == 0 || errno == EEXIST) - { - // and open it - _logfs.open(_nomeFile.c_str(), std::fstream::in | std::fstream::out); - } - else - THROW(AppLogException("Can't create pipe")); - } -#endif - if (_logfs.fail()) - THROW(AppLogException("Can't open log file name")); - } + + openFile(); } logger::~logger() @@ -332,37 +320,73 @@ if (_logfs.is_open()) _logfs.close(); - if (!_nomeFile.empty()) + openFile(); +} + +/// open also logger if applog->open() is invoked +void logger::openFile() +{ + _closedByApplog=false; +} + +///internal logger openFile needed to use pipe and avoid stream buffering in the case +/// the consumer is not connected to pipe +void logger::_openFile() +{ + if (!_closedByApplog && !_logfs.is_open()) { - if (!_usePipe) - { - _logfs.open(_nomeFile.c_str(), std::ofstream::out | std::ofstream::app | std::ofstream::ate); - } -#ifndef WIN32 - else + if (!_nomeFile.empty()) { - // create pipe - int err = mkfifo(_nomeFile.c_str(), S_IREAD | S_IWRITE); - if (err == 0 || errno == EEXIST) + _logfs.clear(); + if (!_usePipe) { - // and open it - _logfs.open(_nomeFile.c_str(), std::fstream::in | std::fstream::out); + _logfs.open(_nomeFile.c_str(), std::ofstream::out | std::ofstream::app | std::ofstream::ate); } +#ifndef WIN32 else - THROW(AppLogException("Can't create pipe")); - } + { + // create pipe + int err = mkfifo(_nomeFile.c_str(), S_IREAD | S_IWRITE); + if (err == 0 || errno == EEXIST) + { + // and open it + _logfs.open(_nomeFile.c_str(), std::fstream::in | std::fstream::out); + } + else + THROW(AppLogException("Can't create pipe")); + } #endif - if (_logfs.fail()) - THROW(AppLogException("Can't open log file name")); + if (_logfs.fail()) + THROW(AppLogException("Can't open log file name")); + } } +} +/// close also logger if applog->close() is invoked +void logger::closeFile() +{ + _closedByApplog = true; } + // writes into filename enqueued messages void logger::runQueue(void * data) { char *str = (char *) data; + // if for some internal reasons file has been closed + // reopen it + try + { + _openFile(); + } + catch (AppLogException e) + { + std::cerr << e.what() << std::endl; + slog.emerg("%s\n", e.what()); + std::cerr.flush(); + } + if (_logfs.is_open()) { Thread::setCancel(cancelDisabled); @@ -370,6 +394,14 @@ _logfs.flush(); Thread::setCancel(cancelImmediate); } + + //if we use a pipe to avoid increasing of stream buffer + // without a consumer, we open, use and close it + if ((_usePipe || _closedByApplog) && _logfs.is_open()) + { + _logfs.flush(); + _logfs.close(); + } } void logger::startQueue() @@ -541,7 +573,6 @@ #endif if (!d->_logDirectly) { - d->_nomeFile = FileName; if (d->_pLogger) d->_pLogger->logFileName(FileName, d->_logPipe); else @@ -724,6 +755,11 @@ } d->_lock.leaveMutex(); } + else + { + if (d->_pLogger) + d->_pLogger->closeFile(); + } } void AppLog::open(const char *ident) @@ -756,6 +792,11 @@ } d->_lock.leaveMutex(); } + else + { + if (d->_pLogger) + d->_pLogger->openFile(); + } if (ident != NULL) logIt->second._ident = ident; ++++++ commoncpp2-overflow.patch ++++++ --- /var/tmp/diff_new_pack.LYOD3i/_old 2012-09-26 16:10:25.000000000 +0200 +++ /var/tmp/diff_new_pack.LYOD3i/_new 2012-09-26 16:10:25.000000000 +0200 @@ -1,13 +1,11 @@ -Index: commoncpp2-1.6.1/src/inaddr.cpp -=================================================================== ---- commoncpp2-1.6.1.orig/src/inaddr.cpp -+++ commoncpp2-1.6.1/src/inaddr.cpp -@@ -328,7 +328,7 @@ void IPV4Address::setAddress(const char - if(ipaddr) - delete[] ipaddr; - ipaddr = new struct in_addr[1]; -- memset((void *)&ipaddr[0], 0, sizeof(ipaddr)); -+ memset((void *)&ipaddr[0], 0, sizeof(struct in_addr[1])); - return; - } +--- src/inaddr.cpp.orig 2012-09-06 23:45:58.295527284 +0200 ++++ src/inaddr.cpp 2012-09-06 23:47:06.148311928 +0200 +@@ -333,7 +333,7 @@ + if(ipaddr) + delete[] ipaddr; + ipaddr = new struct in_addr[1]; +- memset((void *)&ipaddr[0], 0, sizeof(ipaddr)); ++ memset((void *)&ipaddr[0], 0, sizeof(struct in_addr[1])); + return; + } -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
