- included compiling support for DMALLOC debugging

- fixed memory leak in proxy.c (39 bytes got lost
  every proxied message)
This commit is contained in:
Thomas Ries
2003-10-19 10:31:37 +00:00
parent b58a815b71
commit 1aada28a60
5 changed files with 85 additions and 4 deletions

View File

@@ -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);

View File

@@ -25,6 +25,7 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -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;
}

View File

@@ -18,6 +18,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef DMALLOC
#include <dmalloc.h>
#endif
/* function returns STS_* status values vvv */
/* sock.c */