Re: Why is "PROT P" issued twice?
"Alexander V. Lukyanov" <[email protected]>
| Newsgroups | gmane.network.lftp.user |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Sep 10, 2014 at 12:35:03PM +0400, Alexander V. Lukyanov wrote: > On Tue, Sep 09, 2014 at 09:37:16PM -0400, Stephen Powell wrote: > > But now I'm having a different problem, which I don't think I was > > having before. It appears to be trying to close the control socket > > twice. Or maybe it's just printing out garbage from a message > > buffer that it shouldn't be printing. (I've also upgraded to > > lftp 4.5.5, by the way.) Here is what the tail end of the debug > > output looks like now: > > > > ----- > > > > ---- Got EOF on data connection > > ---- Closing data socket > > <--- 226 Transfer complete. > > ---> QUIT > > ---- Closing control socket > > ng control socket > > Goodbye. > > ---- Closing control socket > > t > > > > ----- > > Looks like garbage after end of the string. I'll look into the problem. Please try this patch. -- Alexander. _______________________________________________ lftp mailing list [email protected] http://univ.uniyar.ac.ru/mailman/listinfo/lftp
diff
(text/plain, 2.2 KB)
diff --git a/src/ProtoLog.cc b/src/ProtoLog.cc
index 2b5e08b..0d55c95 100644
--- a/src/ProtoLog.cc
+++ b/src/ProtoLog.cc
@@ -21,9 +21,14 @@
#include "log.h"
#include "ProtoLog.h"
+bool ProtoLog::WillOutput(int level)
+{
+ return Log::global && Log::global->WillOutput(level);
+}
+
void ProtoLog::Log2(int level,xstring& str)
{
- if(!Log::global)
+ if(!WillOutput(level))
return;
str.chomp('\n');
str.chomp('\r');
@@ -32,26 +37,26 @@ void ProtoLog::Log2(int level,xstring& str)
}
void ProtoLog::Log3(int level,const char *prefix,const char *str0)
{
- xstring &str=xstring::get_tmp(prefix);
- str.append(str0);
- Log2(level,str);
+ if(!WillOutput(level))
+ return;
+ Log2(level,xstring(prefix).append(str0));
}
void ProtoLog::LogError(int level,const char *fmt,...)
{
+ if(!WillOutput(level))
+ return;
va_list v;
va_start(v,fmt);
- xstring &str=xstring::get_tmp("**** ");
- str.vappendf(fmt,v);
- Log2(level,str);
+ Log2(level,xstring("**** ").vappendf(fmt,v));
va_end(v);
}
void ProtoLog::LogNote(int level,const char *fmt,...)
{
+ if(!WillOutput(level))
+ return;
va_list v;
va_start(v,fmt);
- xstring &str=xstring::get_tmp("---- ");
- str.vappendf(fmt,v);
- Log2(level,str);
+ Log2(level,xstring("---- ").vappendf(fmt,v));
va_end(v);
}
void ProtoLog::LogRecv(int level,const char *line)
diff --git a/src/ProtoLog.h b/src/ProtoLog.h
index 1fcbcce..2a5d9d1 100644
--- a/src/ProtoLog.h
+++ b/src/ProtoLog.h
@@ -22,6 +22,7 @@
class ProtoLog
{
+ static bool WillOutput(int level);
public:
static void Log2(int level,xstring& str);
static void Log3(int level,const char *prefix,const char *str);
diff --git a/src/log.h b/src/log.h
index 537e09d..55ff4a9 100644
--- a/src/log.h
+++ b/src/log.h
@@ -44,14 +44,14 @@ class Log : public SMTask
output=-1;
need_close_output=false;
}
- bool WillOutput(int l);
-
-public:
- static SMTaskRef<Log> global;
bool enabled;
int level;
+public:
+ static SMTaskRef<Log> global;
+
+ bool WillOutput(int l);
void DoWrite(const char *str);
void Write(int l,const char *str);
void Format(int l,const char *fmt,...) PRINTF_LIKE(3,4);