diff --git a/ChangeLog b/ChangeLog index 22eed45..bb17f8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ 0.4.1 +===== + 19-Oct-2003: - included compiling support for DMALLOC debugging + - fixed memory leak in proxy.c (39 bytes got lost + every proxied message) +0.4.1 ===== 12-Oct-2003: - released 0.4.1 12-Oct-2003: - Local registration of UAs was simply broken. Fixed. diff --git a/configure.in b/configure.in index b63a59c..947dfaf 100644 --- a/configure.in +++ b/configure.in @@ -15,6 +15,7 @@ dnl 7-Apr-2003 tries added siproxd.spec to autoconf process dnl 31-Jul-2003 tries changed to support OSIP2 only dnl 1-Sep-2003 tries check for IPCHAINS dnl 5-Sep-2003 tries test for pthreads before libosip stuff +dnl 19-Sep-2003 tries DMALLOC support dnl dnl dnl @@ -30,7 +31,7 @@ dnl Release Version dnl SPD_MAJOR_VERSION=0 SPD_MINOR_VERSION=4 -SPD_MICRO_VERSION=1 +SPD_MICRO_VERSION=2 SPD_VERSION=$SPD_MAJOR_VERSION.$SPD_MINOR_VERSION.$SPD_MICRO_VERSION @@ -79,6 +80,15 @@ for each in $extra_libs; do LIBS="$LIBS -L$each"; done +dnl +dnl add +dnl --enable-dmalloc + AC_MSG_CHECKING("building with DMALLOC support") + AC_ARG_ENABLE(dmalloc, + [ --enable-dmalloc build with DMALLOC support], + CFLAGS="$CFLAGS -DDMALLOC ";LIBS="-ldmallocth $LIBS"; + AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) + dnl dnl system specific stuff diff --git a/src/proxy.c b/src/proxy.c index c2fdb7c..948c486 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -244,6 +244,7 @@ INFO("stopping RTP proxy stream for: %s@%s", /* clone the masquerading url */ osip_contact_init(&contact); osip_contact_parse(contact,tmp); + osip_free(tmp); osip_uri_free(contact->url); osip_uri_clone(urlmap[i].masq_url, &contact->url); osip_list_add(request->contacts,contact,-1); @@ -602,7 +603,6 @@ if (configuration.debuglevel) /* free content length resource and include new one*/ osip_content_length_free(mymsg->content_length); -// osip_free(mymsg->content_length); mymsg->content_length=NULL; sprintf(clen,"%i",strlen(bodybuff)); sts = osip_message_set_content_length(mymsg, clen); diff --git a/src/siproxd.c b/src/siproxd.c index a1ba1b7..4411f93 100644 --- a/src/siproxd.c +++ b/src/siproxd.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -57,6 +58,18 @@ PACKAGE"-"VERSION"-"BUILDSTR" (c) 2002-2003 Thomas Ries\n" \ +/* + * module local data + */ +static int dmalloc_dump=0; +static int exit_program=0; + +/* + * local prototypes + */ +static void sighandler(int sig); + + int main (int argc, char *argv[]) { int sts; @@ -73,6 +86,25 @@ int main (int argc, char *argv[]) int config_search=1; /* search the config file */ int cmdline_debuglevel=0; + struct sigaction act; + +/* + * setup signal handlers + */ + act.sa_handler=sighandler; + sigemptyset(&act.sa_mask); + act.sa_flags=SA_RESTART; + if (sigaction(SIGTERM, &act, NULL)) { + ERROR("Failed to install SIGTERM handler"); + } + if (sigaction(SIGINT, &act, NULL)) { + ERROR("Failed to install SIGINT handler"); + } + if (sigaction(SIGUSR1, &act, NULL)) { + ERROR("Failed to install SIGUSR1 handler"); + } + + /* * prepare default configuration */ @@ -180,12 +212,26 @@ INFO("daemonizing done (pid=%i)", getpid()); /* * Main loop */ - while (1) { + while (!exit_program) { DEBUGC(DBCLASS_BABBLE,"going into sip_wait\n"); - while (sipsock_wait()==0) { + while (sipsock_wait()<=0) { /* got no input, here by timeout. do aging */ register_agemap(); + + /* dump memory stats if requested to do so */ + if (dmalloc_dump) { + dmalloc_dump=0; +#ifdef DMALLOC + INFO("SIGUSR1 - DMALLOC statistics is dumped"); + dmalloc_log_stats(); + dmalloc_log_unfreed(); +#else + INFO("SIGUSR1 - DMALLOC support is not compiled in"); +#endif + } + + if (exit_program) goto exit_prg; } /* got input, process */ @@ -324,6 +370,22 @@ INFO("got packet [%i bytes]from %s [%s]", i, inet_ntoa(from.sin_addr), tmp);} osip_message_free(my_msg); } /* while TRUE */ + exit_prg: + INFO("properly terminating siproxd"); + return 0; } /* main */ +/* + * Signal handler + * + * this one is called asynchronously whevener a registered + * signal is applied. Just set a flag and don't do any funny + * things here. + */ +static void sighandler(int sig) { + if (sig==SIGTERM) exit_program=1; + if (sig==SIGINT) exit_program=1; + if (sig==SIGUSR1) dmalloc_dump=1; + return; +} diff --git a/src/siproxd.h b/src/siproxd.h index 01a5474..8af1cb9 100644 --- a/src/siproxd.h +++ b/src/siproxd.h @@ -18,6 +18,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef DMALLOC + #include +#endif + /* function returns STS_* status values vvv */ /* sock.c */