Browse Source

Fix a mem leak

Add a call simulator test script
git.mgm/mediaproxy-ng/2.0
Richard Fuchs 15 years ago
parent
commit
f8e33506a2
3 changed files with 48 additions and 5 deletions
  1. +4
    -4
      daemon/call.c
  2. +1
    -1
      iptables-extension/libipt_MEDIAPROXY-1.4.c
  3. +43
    -0
      tests/simulator.sh

+ 4
- 4
daemon/call.c View File

@ -416,7 +416,7 @@ good:
static void callmaster_timer(void *ptr) {
struct callmaster *m = ptr;
struct iterator_helper hlp;
GList *i;
GList *i, *n;
struct call *c;
struct mediaproxy_list_entry *ke;
struct streamrelay *sr;
@ -453,12 +453,12 @@ next:
i = g_list_delete_link(i, i);
}
for (i = hlp.del; i; i = i->next) {
for (i = hlp.del; i; i = n) {
n = i->next;
c = i->data;
call_destroy(c);
g_list_free_1(i);
}
g_list_free(i);
}
#undef DS


+ 1
- 1
iptables-extension/libipt_MEDIAPROXY-1.4.c View File

@ -1,4 +1,4 @@
/* gcc -O2 -Wall -shared -o libipt_MEDIAPROXY.so libipt_MEDIAPROXY.c */
/* gcc -O2 -Wall -shared -fPIC -o libipt_MEDIAPROXY.so libipt_MEDIAPROXY-1.4.c */
#include <stdio.h>
#include <stdlib.h>


+ 43
- 0
tests/simulator.sh View File

@ -0,0 +1,43 @@
#!/bin/bash
# # G_SLICE=always-malloc valgrind --leak-check=full --track-origins=yes --show-possibly-lost=yes ./mediaproxy-ng -t 0 -i $IP -l 25060 -f
pipe_o() {
nc localhost 25060
}
pipe() {
pipe_o > /dev/null
}
ip() {
echo $(($RANDOM % 254 + 1)).$(($RANDOM % 254 + 1)).$(($RANDOM % 254 + 1)).$(($RANDOM % 254 + 1))
}
port() {
echo $(($RANDOM % 64000 + 1024))
}
ids=""
for i in $(seq 1 1000); do
callid=`uuid`
test -z "$callid" && exit 1
src=`ip`:`port`
dst=`ip`:`port`
gw=`ip`
fromtag=`uuid`
totag=`uuid`
src_rel=`echo "request $callid $src:audio $gw voip.inode.at local unknown unknown unknown-agent info=domain:voip.sipwise.local,from:number@voip.inode.at,totag:,to:othernumber@voip.inode.at,fromtag:$fromtag" | pipe_o`
dst_rel=`echo "lookup $callid $dst:audio $gw voip.inode.at local unknown unknown unknown-agent info=domain:voip.sipwise.local,from:number@voip.inode.at,totag:$totag,to:othernumber@voip.inode.at,fromtag:$fromtag" | pipe_o`
echo "lookup $callid $dst:audio $gw voip.inode.at local unknown unknown unknown-agent info=domain:voip.sipwise.local,from:number@voip.inode.at,totag:$totag,to:othernumber@voip.inode.at,fromtag:$fromtag" | pipe
echo version | pipe
echo status | pipe
echo foo > /dev/udp/${src_rel/ //}
echo bar > /dev/udp/${dst_rel/ //}
ids="$ids $callid"
done
sleep 10
for id in $ids; do
echo "delete $id info=" | pipe
done

Loading…
Cancel
Save