This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch 3.6.x in repository nx-libs. from fcb41e3 nx-X11/programs/Xserver/hw/nxagent/Screen.c: re-enable normal error/warning output. new 5ff87ca nxcomp/src/Log.h: use initializer lists instead of initializing member variables in-block. new b30cfaa nxcomp/src/Log.h: NXLogStamp constructor should actually take a size_t-typed line parameter. new dccf590 nxcomp/src/Log.{cpp,h}: provide infrastructure for appending to already existing log lines. new fe447bb nxcomp/src/Loop.cpp: whitespace only. new 970704c nxcomp/src/Loop.cpp: use new log continuation mechanism. The 5 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: nxcomp/src/Log.cpp | 53 ++++++++++++++++++++++++++++++------ nxcomp/src/Log.h | 78 ++++++++++++++++++++++++++++++++--------------------- nxcomp/src/Loop.cpp | 42 ++++++++++++++--------------- 3 files changed, 113 insertions(+), 60 deletions(-) -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch 3.6.x in repository nx-libs. commit 5ff87ca9eeeacf469edd3cebbd1998173976c192 Author: Mihai Moldovan <ionic@ionic.de> Date: Sun Dec 24 20:07:44 2017 +0100 nxcomp/src/Log.h: use initializer lists instead of initializing member variables in-block. --- nxcomp/src/Log.h | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/nxcomp/src/Log.h b/nxcomp/src/Log.h index 3e355a9..68f06bc 100644 --- a/nxcomp/src/Log.h +++ b/nxcomp/src/Log.h @@ -105,12 +105,8 @@ class NXLogStamp } - NXLogStamp(const char *file, const char *function, int line, NXLogLevel level) + NXLogStamp(const char *file, const char *function, int line, NXLogLevel level) : file_(file), function_(function), line_(line), level_(level) { - file_ = std::string(file); - function_ = std::string(function); - line_ = line; - level_ = level; gettimeofday(×tamp_, NULL); } @@ -273,18 +269,9 @@ class NXLog public: - NXLog() - { - stream_ = &std::cerr; - level_ = NXWARNING; - synchronized_ = true; - thread_buffer_size_ = 1024; - log_level_ = false; - log_time_ = false; - log_unix_time_ = false; - log_location_ = false; - log_thread_id_ = false; - + NXLog() : level_(NXWARNING), stream_(&std::cerr), synchronized_(true), thread_buffer_size_(1024), + log_level_(false), log_time_(false), log_unix_time_(false), log_location_(false), log_thread_id_(false) + { if ( pthread_key_create(&tls_key_, free_thread_data) != 0 ) { std::cerr << "pthread_key_create failed" << std::endl; -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch 3.6.x in repository nx-libs. commit b30cfaa24d28dfcf5ee67d33cb614c9800bbddd2 Author: Mihai Moldovan <ionic@ionic.de> Date: Sun Dec 24 20:17:18 2017 +0100 nxcomp/src/Log.h: NXLogStamp constructor should actually take a size_t-typed line parameter. --- nxcomp/src/Log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nxcomp/src/Log.h b/nxcomp/src/Log.h index 68f06bc..6868069 100644 --- a/nxcomp/src/Log.h +++ b/nxcomp/src/Log.h @@ -105,7 +105,7 @@ class NXLogStamp } - NXLogStamp(const char *file, const char *function, int line, NXLogLevel level) : file_(file), function_(function), line_(line), level_(level) + NXLogStamp(const char *file, const char *function, size_t line, NXLogLevel level) : file_(file), function_(function), line_(line), level_(level) { gettimeofday(×tamp_, NULL); } -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch 3.6.x in repository nx-libs. commit dccf5901ec1bbdcd5523169ca20751d9b7569e7d Author: Mihai Moldovan <ionic@ionic.de> Date: Sun Dec 24 22:16:38 2017 +0100 nxcomp/src/Log.{cpp,h}: provide infrastructure for appending to already existing log lines. Also handle errors due to missing buffers gracefully. This error is surprisingly easy to trigger, so we should make sure that the program does not crash. --- nxcomp/src/Log.cpp | 53 ++++++++++++++++++++++++++++++++++++++++-------- nxcomp/src/Log.h | 59 ++++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 89 insertions(+), 23 deletions(-) diff --git a/nxcomp/src/Log.cpp b/nxcomp/src/Log.cpp index 24f6605..a3a7222 100644 --- a/nxcomp/src/Log.cpp +++ b/nxcomp/src/Log.cpp @@ -106,16 +106,53 @@ std::string NXLog::stamp_to_string(const NXLogStamp& stamp) const NXLog& operator<< (NXLog& out, const NXLogStamp& value) { - out.current_level( value.level() ); - out.current_file( value.file() ); + /* + * If appending, the file and function names must be empty and + * the line set to zero. + */ + const bool looks_like_append = ((value.file().empty()) || (value.function().empty()) || (0 == value.line())); + const bool append = ((looks_like_append) && ((value.file().empty()) && (value.function().empty()) && (0 == value.line()))); + + if ((looks_like_append) && (!append)) + { + std::cerr << "WARNING: At least one element in logstamp invalid, but this is not supposed to be an append operation. " + << "Internal state error!\n" << "Log line will be discarded!" << std::endl; + } + else if (append) + { + /* Appending means that the log object's internal level and the message level must match. */ + if (out.current_level() == value.level()) + { + /* And the buffer must of course be non-empty. */ + if (out.has_buffer()) + { + out << " (cont.) "; + } + else + { + std::cerr << "WARNING: Append operation requested, but no queued data available. " + << "Internal state error!\n" << "Log line will be discarded!" << std::endl; + } + } + else + { + std::cerr << "WARNING: Append operation requested, but internal log level not matching line level. " + << "Internal state error!\n" << "Log line will be discarded!" << std::endl; + } + } + else + { + out.current_level( value.level() ); + out.current_file( value.file() ); - // Writing an NXLogStamp to the stream indicates the start of a new entry. - // If there's any content in the buffer and we actually intend to keep that line, - // create a new entry in the output queue. - if ( out.synchronized() && out.will_log() ) - out.new_stack_entry(); + // Writing an NXLogStamp to the stream indicates the start of a new entry. + // If there's any content in the buffer and we actually intend to keep that line, + // create a new entry in the output queue. + if ( out.synchronized() && out.will_log() ) + out.new_stack_entry(); - out << out.stamp_to_string(value); + out << out.stamp_to_string(value); + } return out; } diff --git a/nxcomp/src/Log.h b/nxcomp/src/Log.h index 6868069..9781ec8 100644 --- a/nxcomp/src/Log.h +++ b/nxcomp/src/Log.h @@ -105,7 +105,7 @@ class NXLogStamp } - NXLogStamp(const char *file, const char *function, size_t line, NXLogLevel level) : file_(file), function_(function), line_(line), level_(level) + NXLogStamp(NXLogLevel level, const char *file = "", const char *function = "", size_t line = 0) : file_(file), function_(function), line_(line), level_(level) { gettimeofday(×tamp_, NULL); } @@ -432,6 +432,11 @@ class NXLog */ bool will_log() const; + bool has_buffer() const + { + return (!(get_data()->buffer.empty ())); + } + /** * This catches std::flush @@ -442,10 +447,19 @@ class NXLog { if ( synchronized() ) { - per_thread_data *pdt = get_data(); - assert (!pdt->buffer.empty ()); - (*pdt->buffer.top()) << F; - flush(); + /* Verbosely discard data if we don't have a buffer. */ + if (!(has_buffer())) + { + std::cerr << "WARNING: no buffer available! " + << "Internal state error!\n" << "Log hunk will be discarded!" << std::endl; + } + else + { + per_thread_data *pdt = get_data(); + assert (!pdt->buffer.empty ()); + (*pdt->buffer.top()) << F; + flush(); + } } else { @@ -466,7 +480,8 @@ class NXLog extern NXLog nx_log; -#define nxstamp(l) NXLogStamp(__FILE__, __func__, __LINE__, l) +#define nxstamp(l) NXLogStamp(l, __FILE__, __func__, __LINE__) +#define nxstamp_append(l) NXLogStamp(l) #define nxdbg nx_log << nxstamp(NXDEBUG) @@ -475,6 +490,12 @@ extern NXLog nx_log; #define nxerr nx_log << nxstamp(NXERROR) #define nxfatal nx_log << nxstamp(NXFATAL) +/* Append data to already existing (i.e., same-level) line. */ +#define nxdbg_append nx_log << nxstamp_append(NXDEBUG) +#define nxinfo_append nx_log << nxstamp_append(NXINFO) +#define nxwarn_append nx_log << nxstamp_append(NXWARNING) +#define nxerr_append nx_log << nxstamp_append(NXERROR) +#define nxfatal_append nx_log << nxstamp_append(NXFATAL) NXLog& operator<< (NXLog& out, const NXLogStamp& value); @@ -520,16 +541,24 @@ NXLog& operator<<(NXLog& out, const T& value) { if ( out.synchronized() ) { - // In synchronized mode, we buffer data until a newline, std::flush, or the buffer - // gets full. Then we dump the whole thing at once to the output stream, synchronizing - // with a mutex. - NXLog::per_thread_data *pdt = out.get_data(); - assert (!pdt->buffer.empty ()); - (*pdt->buffer.top()) << value; - - if ( ss_length(pdt->buffer.top()) >= out.thread_buffer_size_ || has_newline(value) ) - out.flush(); + /* Verbosely discard data if we don't have a buffer. */ + if (!(out.has_buffer())) + { + std::cerr << "WARNING: no buffer available! " + << "Internal state error!\n" << "Log hunk will be discarded!" << std::endl; + } + else + { + // In synchronized mode, we buffer data until a newline, std::flush, or the buffer + // gets full. Then we dump the whole thing at once to the output stream, synchronizing + // with a mutex. + NXLog::per_thread_data *pdt = out.get_data(); + assert (!pdt->buffer.empty ()); + (*pdt->buffer.top()) << value; + if ( ss_length(pdt->buffer.top()) >= out.thread_buffer_size_ || has_newline(value) ) + out.flush(); + } } else { -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch 3.6.x in repository nx-libs. commit fe447bb6d26dceff743797548d24e3b854e3a104 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Dec 25 02:18:46 2017 +0100 nxcomp/src/Loop.cpp: whitespace only. --- nxcomp/src/Loop.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index d05c229..b886154 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -6262,7 +6262,7 @@ int WaitForRemote(ChannelEndPoint &socketAddress) continue; } - + nxfatal << "Loop: PANIC! Call to select failed. Error is " << EGET() << " '" << ESTR() << "'.\n" << std::flush; @@ -6340,7 +6340,7 @@ int WaitForRemote(ChannelEndPoint &socketAddress) cerr << "Warning" << ": Refusing connection from '" << connectedHost << "'.\n"; - } + } // // Not the best way to elude a DOS attack... @@ -10860,7 +10860,7 @@ int SetLogs() S_IWGRP | S_IROTH | S_IWOTH); #endif - + if (OpenLogFile(errorsFileName, logofs) < 0) { HandleCleanup(); -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch 3.6.x in repository nx-libs. commit 970704ca404b8f47f929154cf4eade1019ff8ebb Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Dec 25 02:19:17 2017 +0100 nxcomp/src/Loop.cpp: use new log continuation mechanism. Especially don't flush data out mid-append. Doing so will lead to the next append operation failing. Should fix messages queuing up indefinitely (until they are discarded at program termination, at least) and missing messages in general. Fixes: ArcticaProject/nx-libs#577 Fixes: ArcticaProject/nx-libs#611 --- nxcomp/src/Loop.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index b886154..cfa175b 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -13449,12 +13449,12 @@ int ParseArg(const char *type, const char *name, const char *value) case 'm': case 'g': { - nxinfo << (char) toupper(*id); + nxinfo_append << (char) toupper(*id); break; } } - nxinfo << ".\n" << std::flush; + nxinfo_append << ".\n" << std::flush; double result = atof(string) * base; @@ -14028,13 +14028,13 @@ static void handleCheckSelectInLoop(int &setFDs, fd_set &readSet, { i = 0; - nxinfo << "Loop: Selected for read are "; + nxinfo << "Loop: Selected for read are"; for (int j = 0; j < setFDs; j++) { if (FD_ISSET(j, &readSet)) { - nxinfo << "[" << j << "]" << std::flush; + nxinfo_append << " [" << j << "]"; i++; } @@ -14042,22 +14042,22 @@ static void handleCheckSelectInLoop(int &setFDs, fd_set &readSet, if (i > 0) { - nxinfo << ".\n" << std::flush; + nxinfo_append << ".\n" << std::flush; } else { - nxinfo << "[none].\n" << std::flush; + nxinfo_append << "[none].\n" << std::flush; } i = 0; - nxinfo << "Loop: Selected for write are "; + nxinfo << "Loop: Selected for write are"; for (int j = 0; j < setFDs; j++) { if (FD_ISSET(j, &writeSet)) { - nxinfo << "[" << j << "]" << std::flush; + nxinfo_append << " [" << j << "]"; i++; } @@ -14065,11 +14065,11 @@ static void handleCheckSelectInLoop(int &setFDs, fd_set &readSet, if (i > 0) { - nxinfo << ".\n" << std::flush; + nxinfo_append << ".\n" << std::flush; } else { - nxinfo << "[none].\n" << std::flush; + nxinfo_append << "[none].\n" << std::flush; } } @@ -14109,13 +14109,13 @@ static void handleCheckResultInLoop(int &resultFDs, int &errorFDs, int &setFDs, { i = 0; - nxinfo << "Loop: Selected for read are "; + nxinfo << "Loop: Selected for read are"; for (int j = 0; j < setFDs; j++) { if (FD_ISSET(j, &readSet)) { - nxinfo << "[" << j << "]" << std::flush; + nxinfo_append << " [" << j << "]"; i++; } @@ -14123,22 +14123,22 @@ static void handleCheckResultInLoop(int &resultFDs, int &errorFDs, int &setFDs, if (i > 0) { - nxinfo << ".\n" << std::flush; + nxinfo_append << ".\n" << std::flush; } else { - nxinfo << "[none].\n" << std::flush; + nxinfo_append << "[none].\n" << std::flush; } i = 0; - nxinfo << "Loop: Selected for write are "; + nxinfo << "Loop: Selected for write are"; for (int j = 0; j < setFDs; j++) { if (FD_ISSET(j, &writeSet)) { - nxinfo << "[" << j << "]" << std::flush; + nxinfo_append << " [" << j << "]"; i++; } @@ -14146,11 +14146,11 @@ static void handleCheckResultInLoop(int &resultFDs, int &errorFDs, int &setFDs, if (i > 0) { - nxinfo << ".\n" << std::flush; + nxinfo_append << ".\n" << std::flush; } else { - nxinfo << "[none].\n" << std::flush; + nxinfo_append << "[none].\n" << std::flush; } } } -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git