From 5d0b0bb590d0ab7f81dbe4293b9c99b4b481fc00 Mon Sep 17 00:00:00 2001 From: paulc Date: Thu, 21 Oct 2004 23:11:46 +0000 Subject: [PATCH] Fixed minor bug in watchdog routine. Fixed memory leak in tone generator. Can preserve module symbols (make modules MODSTRIP=). git-svn-id: http://voip.null.ro/svn/yate@90 acf43c95-373e-0410-b603-e72c3f656dc1 --- configure.in | 4 +++- engine/Engine.cpp | 2 +- engine/TelEngine.cpp | 10 ++++++++++ modules/Makefile.in | 5 +++-- modules/tonegen.cpp | 14 +++++++------- test/Makefile.in | 5 +++-- yate-config.in | 2 +- yate.pc.in | 2 +- 8 files changed, 29 insertions(+), 15 deletions(-) diff --git a/configure.in b/configure.in index 9f815298..a1a76851 100644 --- a/configure.in +++ b/configure.in @@ -385,9 +385,11 @@ fi fi MODULE_CFLAGS="-fno-exceptions -fno-check-new $RTTI_OPT -fPIC $HAVE_GCC_FORMAT_CHECK" -MODULE_LDFLAGS="-export-dynamic -shared -Wl,--retain-symbols-file,/dev/null" +MODULE_LDFLAGS="-export-dynamic -shared" +MODULE_SYMBOLS="-Wl,--retain-symbols-file,/dev/null" AC_SUBST(MODULE_CFLAGS) AC_SUBST(MODULE_LDFLAGS) +AC_SUBST(MODULE_SYMBOLS) AC_CONFIG_FILES([yate.spec yate.pc diff --git a/engine/Engine.cpp b/engine/Engine.cpp index bfa6fb74..19ea9bc4 100644 --- a/engine/Engine.cpp +++ b/engine/Engine.cpp @@ -198,7 +198,7 @@ int Engine::run() { Debug(DebugAll,"Engine::run()"); install(new EngineStatusHandler); - if (s_super_handle) + if (s_super_handle >= 0) install(new EngineSuperHandler); loadPlugins(); Debug(DebugInfo,"plugins.count() = %d",plugins.count()); diff --git a/engine/TelEngine.cpp b/engine/TelEngine.cpp index 2adcf3eb..c3a12d40 100644 --- a/engine/TelEngine.cpp +++ b/engine/TelEngine.cpp @@ -163,7 +163,9 @@ Debugger::Debugger(const char *name, const char *format, ...) va_start(va,format); dbg_output(buf,format,va); va_end(va); + out_mux.lock(); s_indent++; + out_mux.unlock(); } else m_name = 0; @@ -179,7 +181,9 @@ Debugger::Debugger(int level, const char *name, const char *format, ...) va_start(va,format); dbg_output(buf,format,va); va_end(va); + out_mux.lock(); s_indent++; + out_mux.unlock(); } else m_name = 0; @@ -188,7 +192,9 @@ Debugger::Debugger(int level, const char *name, const char *format, ...) Debugger::~Debugger() { if (m_name) { + out_mux.lock(); s_indent--; + out_mux.unlock(); if (s_debugging) { char buf[64]; ::snprintf(buf,sizeof(buf),"<<< %s",m_name); @@ -201,12 +207,16 @@ Debugger::~Debugger() void Debugger::setOutput(void (*outFunc)(const char *)) { + out_mux.lock(); s_output = outFunc ? outFunc : dbg_stderr_func; + out_mux.unlock(); } void Debugger::setIntOut(void (*outFunc)(const char *)) { + out_mux.lock(); s_intout = outFunc; + out_mux.unlock(); } void Debugger::enableOutput(bool enable) diff --git a/modules/Makefile.in b/modules/Makefile.in index 99d4c0ae..fccc9e85 100644 --- a/modules/Makefile.in +++ b/modules/Makefile.in @@ -14,6 +14,7 @@ INCLUDES := -I@top_srcdir@ CFLAGS := -O2 @MODULE_CFLAGS@ LDFLAGS:= -L.. -lyate MODFLAGS:= @MODULE_LDFLAGS@ +MODSTRIP:= @MODULE_SYMBOLS@ INCFILES := @top_srcdir@/telengine.h @top_srcdir@/telephony.h @top_srcdir@/yateversn.h SUBDIRS := @@ -59,8 +60,8 @@ LOCALFLAGS = LOCALLIBS = COMPILE = $(CC) $(DEFS) $(DEBUG) $(INCLUDES) $(CFLAGS) LINK = $(CC) $(LDFLAGS) -MODLINK = $(CC) $(MODFLAGS) $(LDFLAGS) -MODCOMP = $(COMPILE) $(MODFLAGS) $(LDFLAGS) +MODLINK = $(CC) $(MODFLAGS) $(MODSTRIP) $(LDFLAGS) +MODCOMP = $(COMPILE) $(MODFLAGS) $(MODSTRIP) $(LDFLAGS) prefix = @prefix@ exec_prefix = @exec_prefix@ diff --git a/modules/tonegen.cpp b/modules/tonegen.cpp index 7b7f2c87..6ff3fa4f 100644 --- a/modules/tonegen.cpp +++ b/modules/tonegen.cpp @@ -34,6 +34,7 @@ private: static const Tone *getBlock(const String &tone); String m_name; const Tone *m_tone; + DataBlock m_data; unsigned m_brate; unsigned m_total; unsigned long long m_time; @@ -94,7 +95,7 @@ static const Tone t_specdial[] = { { 7600, tone421hz }, { 400, 0 }, { 0, 0 } }; static const Tone t_ring[] = { { 8000, tone421hz }, { 32000, 0 }, { 0, 0 } }; ToneSource::ToneSource(const String &tone) - : m_name(tone), m_tone(0), m_brate(16000), m_total(0), m_time(0) + : m_name(tone), m_tone(0), m_data(0,480), m_brate(16000), m_total(0), m_time(0) { Debug(DebugAll,"ToneSource::ToneSource(\"%s\") [%p]",tone.c_str(),this); m_tone = getBlock(tone); @@ -148,14 +149,13 @@ void ToneSource::run() Debug(DebugAll,"ToneSource::run() [%p]",this); unsigned long long tpos = Time::now(); m_time = tpos; - DataBlock data(0,480); int samp = 0; // sample number int dpos = 1; // position in data const Tone *tone = m_tone; int nsam = tone->nsamples; while (m_tone) { - short *d = (short *) data.data(); - for (unsigned int i = data.length()/2; i--; samp++,dpos++) { + short *d = (short *) m_data.data(); + for (unsigned int i = m_data.length()/2; i--; samp++,dpos++) { if (samp >= nsam) { samp = 0; const Tone *otone = tone; @@ -181,9 +181,9 @@ void ToneSource::run() #endif ::usleep((unsigned long)dly); } - Forward(data,data.length()/2); - m_total += data.length(); - tpos += (data.length()*1000000ULL/m_brate); + Forward(m_data,m_data.length()/2); + m_total += m_data.length(); + tpos += (m_data.length()*1000000ULL/m_brate); }; m_time = Time::now() - m_time; m_time = (m_total*1000000ULL + m_time/2) / m_time; diff --git a/test/Makefile.in b/test/Makefile.in index eb5a6b2f..f02679d6 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -8,6 +8,7 @@ INCLUDES := -I@top_srcdir@ CFLAGS := -O0 @MODULE_CFLAGS@ LDFLAGS:= -L.. -lyate MODFLAGS:= @MODULE_LDFLAGS@ +MODSTRIP:= @MODULE_SYMBOLS@ PROGS = msgsniff.yate randcall.yate LIBS = @@ -17,8 +18,8 @@ LOCALFLAGS = LOCALLIBS = COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CFLAGS) LINK = $(CC) $(LDFLAGS) -MODLINK = $(CC) $(MODFLAGS) $(LDFLAGS) -MODCOMP = $(COMPILE) $(MODFLAGS) $(LDFLAGS) +MODLINK = $(CC) $(MODFLAGS) $(MODSTRIP) $(LDFLAGS) +MODCOMP = $(COMPILE) $(MODFLAGS) $(MODSTRIP) $(LDFLAGS) prefix = @prefix@ exec_prefix = @exec_prefix@ diff --git a/yate-config.in b/yate-config.in index 34dfa7a8..89a68d78 100644 --- a/yate-config.in +++ b/yate-config.in @@ -13,7 +13,7 @@ moddir="@libdir@/yate" confdir="@sysconfdir@/yate" s1="@MODULE_CFLAGS@" s2="-I@includedir@/yate" -s3="@MODULE_LDFLAGS@" +s3="@MODULE_LDFLAGS@ @MODULE_SYMBOLS@" s4="-lyate" while [ "$#" != 0 ]; do diff --git a/yate.pc.in b/yate.pc.in index 625cc565..5ac631de 100644 --- a/yate.pc.in +++ b/yate.pc.in @@ -9,5 +9,5 @@ yate-config=yate-config Name: Yate Description: Yet Another Telephony Engine Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lyate @MODULE_LDFLAGS@ +Libs: -L${libdir} -lyate @MODULE_LDFLAGS@ @MODULE_SYMBOLS@ Cflags: -I${includedir}/yate @MODULE_CFLAGS@