Hi Alexandre,

My version of RTP-Proxy is following:

bock@bock-tde:~/ims/rtpproxy$ ./rtpproxy -v
Basic version: 20040107
Extension 20050322: Support for multiple RTP streams and MOH
Extension 20060704: Support for extra parameter in the V command
Extension 20071116: Support for RTP re-packetization
Extension 20071218: Support for forking (copying) RTP stream
Extension 20080403: Support for RTP statistics querying
Extension 20081102: Support for setting codecs in the update/lookup command
Extension 20081224: Support for session timeout notifications
Extension 20090810: Support for automatic bridging
Extension 20100819: Support for timeout notifications using XML-RPC
towards Kamailio/sip-router.org

Please find attached a modified rtpp_notify.c file. I have just added
some tiny debug output in order to see some points.
Now you should see the following Debug-Outputs:

rtpproxy: >>> Running Timeout-Process

Then the notifier process is running. That would be good. If not,
that's the reason why it is not working. When the request comes in,
you should see the following:

INFO:handle_command: setting custom timeout handler
(xmlrpc:http://localhost:8000/RPC2)

Then the Timeout-Socket was properly set, that would be good as well.
Now the timeout:

INFO:process_rtp: session timeout
[...]
ERR:do_timeout_notification: Timeout socket is:
xmlrpc:http://localhost:8000/RPC2

That would be great, because then the Timeout towards the Kamailio
should be triggerd.
If these parts are ok, then there must be some issue either in the
XML-RPC client library or in the communication between the RTP-Proxy
and Kamailio. I hope you did a trace on the XML-RPC Port both on the
RTPproxy and on the Kamailio? What distro are you using? My tests were
only on Ubuntu and Debian, which are quite similar.

Hope we find this issue,

Kind regards,
Carsten

P.S.: I think i removed that check for the port for testing, that's
why my version accepted the socket without port... (now i'm using "-n
tcp:127.0.0.1:9999")

2011/3/16 Alexandre Abreu <alexandre.ab...@redt.com.br>:
> Carsten,
>
> Indeed. Very strange.
>
> Are we running the same RTPPROXY version? How can you start using '-n
> tcp:127.0.0.1' without specifying a port?
>
> [root@devel rtpproxy-carsten]# ./rtpproxy -T 10 -f -F -i -l 192.168.200.90
> -s udp:*:7722 -d DBUG ERR INFO -n tcp:127.0.0.1
> rtpproxy: can't parse host:port in TCP address
> rtpproxy: can't start notification thread
>
> [root@devel rtpproxy-carsten]# ./rtpproxy -T 10 -f -F -i -l 192.168.200.90
> -s udp:*:7722 -d DBUG ERR INFO -n tcp:127.0.0.1:7723
> INFO:main: rtpproxy started, pid 21169
>
> DBUG:handle_command: received command "17828_9 Uc0,8,101 4b10ce04de4f8818
> 192.168.200.114 6380 9c4b6265;1"
> INFO:handle_command: new session 4b10ce04de4f8818, tag 9c4b6265;1 requested,
> type strong
> INFO:handle_command: new session on a port 43750 created, tag 9c4b6265;1
> INFO:handle_command: pre-filling caller's address with 192.168.200.114:6380
> DBUG:doreply: sending reply "17828_9 43750 192.168.200.90
> "
> DBUG:handle_command: received command "17847_9 Lc0,8,101 4b10ce04de4f8818
> 192.168.200.149 7386 9c4b6265;1 dd69ab1d;1
> xmlrpc:http://localhost:8000/RPC2";
> INFO:handle_command: lookup on ports 43750/55796, session timer restarted
> INFO:handle_command: setting custom timeout handler
> (xmlrpc:http://localhost:8000/RPC2)
> INFO:handle_command: pre-filling callee's address with 192.168.200.149:7386
> DBUG:doreply: sending reply "17847_9 55796 192.168.200.90
> "
> INFO:process_rtp: session timeout
> INFO:remove_session: RTP stats: 548 in from callee, 5 in from caller, 553
> relayed, 0 dropped
> INFO:remove_session: RTCP stats: 3 in from callee, 1 in from caller, 4
> relayed, 0 dropped
> INFO:remove_session: session on ports 43750/55796 is cleaned up
> DBUG:reconnect_timeout_handler: reconnecting timeout socket
> ERR:reconnect_timeout_handler: can't create timeout socket: Address family
> not supported by protocol
> ERR:do_timeout_notification: unable to send timeout notification
>
> Above the error message.
>
> [root@devel ~]# md5sum rtpproxy-carsten.tar.gz
> c02b1e2ac57d39562e86bcfc4ee592b8  rtpproxy-carsten.tar.gz
>
> Thanks,
> Alexandre.
>
> -----Mensagem original-----
> De: kaiserbo...@googlemail.com [mailto:kaiserbo...@googlemail.com] Em nome
> de Carsten Bock
> Enviada em: quarta-feira, 16 de março de 2011 13:03
> Para: Alexandre Abreu
> Cc: sr-users@lists.sip-router.org
> Assunto: Re: RTPPROXY timeout patch.
>
> Hi Alexandre,
>
> That is strange:
>
> I run the RTP-Proxy like this (directly from the TAR-File, i sent you)
> and Kamailio with attached config-file.
>
> bock@bock-tde:~/ims/rtpproxy$ sudo ./rtpproxy -T 10 -f -F -i -l
> 127.0.0.1 -s udp:*:22222 -d DBUG -n tcp:127.0.0.1
> rtpproxy: Timer started.
> INFO:main: rtpproxy started, pid 4203
> [... Kamailio connects to RTP-Proxy...]
> DBUG:handle_command: received command "4259_8
> UAc98,97,99,104,3,0,8,9,96 56f0f83a-5373-46a1-b6f6-9ce2f93e68d5
> 195.71.4.203 4008 5371f039-40d0-4944-aae7-6f75071a2f8c;1"
> INFO:handle_command: new session 56f0f83a-5373-46a1-b6f6-9ce2f93e68d5,
> tag 5371f039-40d0-4944-aae7-6f75071a2f8c;1 requested, type strong
> INFO:handle_command: new session on a port 45508 created, tag
> 5371f039-40d0-4944-aae7-6f75071a2f8c;1
> INFO:handle_command: pre-filling caller's address with 195.71.4.203:4008
> DBUG:doreply: sending reply "4259_8 45508 127.0.0.1
> "
> DBUG:handle_command: received command "4259_9 LAc98,96
> 56f0f83a-5373-46a1-b6f6-9ce2f93e68d5 195.71.4.203 4000
> 5371f039-40d0-4944-aae7-6f75071a2f8c;1
> 9915df0c-30fc-49c5-aa8a-c86b4242c094;1
> xmlrpc:http://localhost:8000/RPC2";
> INFO:handle_command: lookup on ports 45508/45238, session timer restarted
> INFO:handle_command: setting custom timeout handler
> (xmlrpc:http://localhost:8000/RPC2)
> INFO:handle_command: pre-filling callee's address with 195.71.4.203:4000
> DBUG:doreply: sending reply "4259_9 45238 127.0.0.1
> "
> INFO:process_rtp: session timeout
> ERR:rtpp_notify_schedule: XMLRPC xmlrpc:http://localhost:8000/RPC2
> INFO:remove_session: RTP stats: 0 in from callee, 0 in from caller, 0
> relayed, 0 dropped
> INFO:remove_session: RTCP stats: 0 in from callee, 0 in from caller, 0
> relayed, 0 dropped
> INFO:remove_session: session on ports 45508/45238 is cleaned up
> ERR:do_timeout_notification: Timeout socket:
> xmlrpc:http://localhost:8000/RPC2
>
> And it works for me:
>
> U 2011/03/16 16:50:14.350721 127.0.0.1:5060 -> 127.0.0.1:15061
> BYE sip:2@127.0.0.1:15061;ob SIP/2.0.
> Via: SIP/2.0/UDP 127.0.0.1;branch=z9hG4bK06e9.245e2dd7.0.
> To: sip:2@localhost;tag=5371f039-40d0-4944-aae7-6f75071a2f8c.
> From: sip:1@localhost;tag=9915df0c-30fc-49c5-aa8a-c86b4242c094.
> CSeq: 7905 BYE.
> Call-ID: 56f0f83a-5373-46a1-b6f6-9ce2f93e68d5.
> Content-Length: 0.
> User-Agent: kamailio (3.2.0-dev2 (x86_64/linux)).
> Max-Forwards: 70.
> .
>
> U 2011/03/16 16:50:14.350801 127.0.0.1:5060 -> 127.0.0.1:15060
> BYE sip:1@127.0.0.1:15060;transport=UDP;ob SIP/2.0.
> Via: SIP/2.0/UDP 127.0.0.1;branch=z9hG4bK06e9.345e2dd7.0.
> To: sip:1@localhost;tag=9915df0c-30fc-49c5-aa8a-c86b4242c094.
> From: sip:2@localhost;tag=5371f039-40d0-4944-aae7-6f75071a2f8c.
> CSeq: 7905 BYE.
> Call-ID: 56f0f83a-5373-46a1-b6f6-9ce2f93e68d5.
> Content-Length: 0.
> User-Agent: kamailio (3.2.0-dev2 (x86_64/linux)).
> Max-Forwards: 70.
> .
> [...]
>
> Maybe, you can add some more debug-info from RTP-Proxy...
> And can you verify, that the RTP-Proxy is not trying to send the request?
>
> Kind regards,
> Carsten
>
> 2011/3/16 Alexandre Abreu <alexandre.ab...@redt.com.br>:
>> Hi Carsten,
>>
>> Even with your RTPPROXY tarball I was unable to get this working. Session
>> remains after RTPPROXY timeout.
>> I am using KAMAILIO 3.1 branch from GIT and as I told you, I moved the
>> rtpproxy/ from GIT-MASTER to the Kamailio branch (waiting your backport).
> Is
>> there anything else regarding this feature that should also should be
> moved
>> (beyond rtpproxy/)?
>>
>> Thanks,
>> Alexandre
>>
>
> --
> Carsten Bock
> http://www.ng-voice.com
> mailto:cars...@ng-voice.com
>
>



-- 
Carsten Bock
http://www.ng-voice.com
mailto:cars...@ng-voice.com
/*
 * Copyright (c) 2010 Sippy Software, Inc., http://www.sippysoft.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include "rtpp_log.h"
#include "rtpp_network.h"
#include "rtpp_notify.h"
#include "rtpp_session.h"
#include "rtpp_util.h"

#ifdef ENABLE_XMLRPC
#include <xmlrpc.h>
#include <xmlrpc_client.h>
#define XMLRPC_CLIENT_NAME       "XML-RPC RTPProxy Client"
#define XMLRPC_CLIENT_VERSION    "0.2"
#endif

struct rtpp_notify_wi
{
    char *notify_buf;
    int len;
#ifdef ENABLE_XMLRPC
    char *call_id;
    int call_id_len;
    char *param;
    int param_len;
#endif
    struct rtpp_timeout_handler *th;
    rtpp_log_t glog;
    struct rtpp_notify_wi *next;
};

static pthread_t rtpp_notify_queue;
static pthread_cond_t rtpp_notify_queue_cond;
static pthread_mutex_t rtpp_notify_queue_mutex;
static pthread_mutex_t rtpp_notify_wi_free_mutex;

static int rtpp_notify_dropped_items;

static struct rtpp_notify_wi *rtpp_notify_wi_free;
static struct rtpp_notify_wi *rtpp_notify_wi_queue, *rtpp_notify_wi_queue_tail;

static struct rtpp_notify_wi *rtpp_notify_queue_get_free_item(void);
static void rtpp_notify_queue_put_item(struct rtpp_notify_wi *);
static void do_timeout_notification(struct rtpp_notify_wi *, int);

struct rtpp_notify_wi *
rtpp_notify_queue_get_free_item(void)
{
    struct rtpp_notify_wi *wi;

    pthread_mutex_lock(&rtpp_notify_wi_free_mutex);
    if (rtpp_notify_wi_free == NULL) {
        /* no free work items, allocate one now */
        wi = malloc(sizeof(*wi));
        if (wi == NULL)
            rtpp_notify_dropped_items++;
        memset(wi, '\0', sizeof(*wi));

        pthread_mutex_unlock(&rtpp_notify_wi_free_mutex);
        return wi;
    }

    wi = rtpp_notify_wi_free;

    /* move up rtpp_notify_wi_free */
    rtpp_notify_wi_free = rtpp_notify_wi_free->next;
    pthread_mutex_unlock(&rtpp_notify_wi_free_mutex);

    return wi;
}

static void
rtpp_notify_queue_return_free_item(struct rtpp_notify_wi *wi)
{

    pthread_mutex_lock(&rtpp_notify_wi_free_mutex);

    wi->next = rtpp_notify_wi_free;
    rtpp_notify_wi_free = wi;

    pthread_mutex_unlock(&rtpp_notify_wi_free_mutex);
}

static void
rtpp_notify_queue_put_item(struct rtpp_notify_wi *wi)
{

    pthread_mutex_lock(&rtpp_notify_queue_mutex);

    wi->next = NULL;
    if (rtpp_notify_wi_queue == NULL) {
        rtpp_notify_wi_queue = wi;
        rtpp_notify_wi_queue_tail = wi;
    } else {
        rtpp_notify_wi_queue_tail->next = wi;
        rtpp_notify_wi_queue_tail = wi;
    }

    /* notify worker thread */
    pthread_cond_signal(&rtpp_notify_queue_cond);

    pthread_mutex_unlock(&rtpp_notify_queue_mutex);
}

void
rtpp_notify_queue_run(void)
{
    struct rtpp_notify_wi *wi;

 warnx(">>> Running Timeout-Process\n");

    for (;;) {
        pthread_mutex_lock(&rtpp_notify_queue_mutex);
        while (rtpp_notify_wi_queue == NULL) {
            pthread_cond_wait(&rtpp_notify_queue_cond, &rtpp_notify_queue_mutex);
        }
        wi = rtpp_notify_wi_queue;
        rtpp_notify_wi_queue = wi->next;
        pthread_mutex_unlock(&rtpp_notify_queue_mutex);

        /* main work here */
        do_timeout_notification(wi, 1);

        /* put wi into rtpp_notify_wi_free' tail */
        rtpp_notify_queue_return_free_item(wi);
    }
}

int
parse_hostport(const char *hostport, char *host, int hsize, char *port, int psize, int testonly)
{
    const char *cp;
    int myport;

    cp = strrchr(hostport, ':');
    if (cp == NULL || cp[1] == '\0' || cp == hostport) {
        /* warnx("invalid tcp/udp address");*/
        return -1;
    }
    myport = atoi(cp + 1);
    if (myport <= 0 || myport > 65535) {
        /*warnx("%s: invalid port", cp + 1);*/
        return -1;
    }

    if (testonly != 0)
        return 0;

    if (cp - hostport + 1 > hsize || psize < 6) {
        /*warnx("supplied buffers are too small");*/
        return -1;
    }

    memcpy(host, hostport, cp - hostport);
    host[cp - hostport] = '\0';
    snprintf(port, psize, "%d", myport);
    return 0;
}

static int
parse_timeout_sock(const char *sock_name, struct rtpp_timeout_handler *timeout_handler)
{

    if (strncmp("unix:", sock_name, 5) == 0) {
        sock_name += 5;
        timeout_handler->socket_type = PF_LOCAL;
    } else if (strncmp("tcp:", sock_name, 4) == 0) {
        sock_name += 4;
        if (parse_hostport(sock_name, NULL, 0, NULL, 0, 1) != 0) {
            warnx("can't parse host:port in TCP address");
            return -1;
        }
        timeout_handler->socket_type = PF_INET;
    } else {
        timeout_handler->socket_type = PF_LOCAL;
    }
    if (strlen(sock_name) == 0) {
        warnx("timeout notification socket name too short");
        return -1;
    }
    timeout_handler->socket_name = strdup(sock_name);
    if (timeout_handler->socket_name == NULL) {
        warnx("can't allocate memory");
        return -1;
    }

    return 0;
}

struct rtpp_timeout_handler *
rtpp_notify_init(const char *socket_name)
{
    struct rtpp_timeout_handler *th;

    rtpp_notify_wi_free = NULL;
    rtpp_notify_wi_queue = NULL;
    rtpp_notify_wi_queue_tail = NULL;

    rtpp_notify_dropped_items = 0;

    th = malloc(sizeof(*th));
    if (th == NULL)
        return NULL;
    memset(th, '\0', sizeof(*th));
    if (parse_timeout_sock(socket_name, th) != 0) {
        free(th);
        return NULL;
    }
    th->fd = -1;
    th->connected = 0;

    pthread_cond_init(&rtpp_notify_queue_cond, NULL);
    pthread_mutex_init(&rtpp_notify_queue_mutex, NULL);
    pthread_mutex_init(&rtpp_notify_wi_free_mutex, NULL);

    if (pthread_create(&rtpp_notify_queue, NULL, (void *(*)(void *))&rtpp_notify_queue_run, NULL) != 0) {
        free(th);
        return NULL;
    }

    return th;
}

int
rtpp_notify_schedule(struct cfg *cf, struct rtpp_session *sp)
{
    struct rtpp_notify_wi *wi;
    struct rtpp_timeout_handler *th = sp->timeout_data.handler;
    int len;
    char *notify_buf;

    if (th == NULL) {
        /* Not an error, just nothing to do */
        return 0;
    }

    wi = rtpp_notify_queue_get_free_item();
    if (wi == NULL)
        return -1;

    wi->th = th;
    if (sp->timeout_data.notify_tag == NULL) {
        /* two 5-digit numbers, space, \0 and \n */
        len = 5 + 5 + 3;
    } else {
        /* string, \0 and \n */
        len = strlen(sp->timeout_data.notify_tag) + 2;
    }
    if (wi->notify_buf == NULL) {
        wi->notify_buf = malloc(len);
        if (wi->notify_buf == NULL) {
            rtpp_notify_queue_return_free_item(wi);
            return -1;
        }
    } else {
        notify_buf = realloc(wi->notify_buf, len);
        if (notify_buf == NULL) {
            rtpp_notify_queue_return_free_item(wi);
            return -1;
        }
        wi->notify_buf = notify_buf;
    }
    wi->len = len;

    if (sp->timeout_data.notify_tag == NULL) {
        len = snprintf(wi->notify_buf, len, "%d %d\n",
          sp->ports[0], sp->ports[1]);
    } else {
        len = snprintf(wi->notify_buf, len, "%s\n",
          sp->timeout_data.notify_tag);
    }
#ifdef ENABLE_XMLRPC
    if (strncmp("xmlrpc:", wi->th->socket_name, 7) == 0) {
	    // Copy the Socket-Name
	    len = strlen(wi->th->socket_name)+1;
	    if (wi->param == NULL) {
		wi->param = malloc(len);
		if (wi->param == NULL) {
		    rtpp_notify_queue_return_free_item(wi);
		    return -1;
		}
	    } else {
		notify_buf = realloc(wi->param, len);
		if (notify_buf == NULL) {
		    rtpp_notify_queue_return_free_item(wi);
		    return -1;
		}
		wi->param = notify_buf;
	    }
	    memset(wi->param, '\0', len);
	    len = snprintf(wi->param, len, "%s",
		  wi->th->socket_name);
	    wi->param_len = len;

	    // Copy the Call-ID:
	    len = strlen(sp->call_id)+1;
	    if (wi->call_id == NULL) {
		wi->call_id = malloc(len);
		if (wi->call_id == NULL) {
		    rtpp_notify_queue_return_free_item(wi);
		    return -1;
		}
	    } else {
		notify_buf = realloc(wi->call_id, len);
		if (notify_buf == NULL) {
		    rtpp_notify_queue_return_free_item(wi);
		    return -1;
		}
		wi->call_id = notify_buf;
	    }
	    memset(wi->call_id, '\0', len);
	    len = snprintf(wi->call_id, len, "%s",
		  sp->call_id);
	    wi->call_id_len = len;
    }
#endif

    wi->glog = cf->stable.glog;

    rtpp_notify_queue_put_item(wi);
    return 0;
}

static void
reconnect_timeout_handler(rtpp_log_t log, struct rtpp_timeout_handler *th)
{
    union {
        struct sockaddr_un u;
        struct sockaddr_storage i;
    } remote;
    char host[512], port[10];
    int remote_len, n;

    assert (th->socket_name != NULL && th->connected == 0);

    if (th->fd == -1) {
        rtpp_log_write(RTPP_LOG_DBUG, log, "connecting timeout socket");
    } else {
        rtpp_log_write(RTPP_LOG_DBUG, log, "reconnecting timeout socket");
        close(th->fd);
    }
    th->fd = socket(th->socket_type, SOCK_STREAM, 0);
    if (th->fd == -1) {
        rtpp_log_ewrite(RTPP_LOG_ERR, log, "can't create timeout socket");
        return;
    }
    memset(&remote, '\0', sizeof(remote));
    if (th->socket_type == PF_UNIX) {
        remote.u.sun_family = AF_LOCAL;
        strncpy(remote.u.sun_path, th->socket_name, sizeof(remote.u.sun_path) - 1);
#if defined(HAVE_SOCKADDR_SUN_LEN)
        remote.u.sun_len = strlen(remote.u.sun_path);
#endif
        remote_len = sizeof(remote);
    } else {
        assert (parse_hostport(th->socket_name, host, sizeof(host), port, sizeof(port), 0) == 0);
        n = resolve(sstosa(&remote.i), AF_INET, host, port, AI_PASSIVE);
        if (n != 0) {
            rtpp_log_write(RTPP_LOG_ERR, log, "reconnect_timeout_handler: getaddrinfo('%s:s'): %s",
              host, port, gai_strerror(n));
            return;
        }
        remote_len = SA_LEN(sstosa(&remote.i));
    }

    if (connect(th->fd, (struct sockaddr *)&remote, remote_len) == -1) {
        rtpp_log_ewrite(RTPP_LOG_ERR, log, "can't connect to timeout socket");
    } else {
        th->connected = 1;
    }
}

#ifdef ENABLE_XMLRPC
static int
do_xmlrpc_timeout_notification(rtpp_log_t log, struct rtpp_notify_wi *wi) {
    xmlrpc_env env;
    xmlrpc_value *result;
    
    /* Start up our XML-RPC client library. */
    xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, XMLRPC_CLIENT_NAME, XMLRPC_CLIENT_VERSION);
    xmlrpc_env_init(&env);

    /* Get the dialog-Info: */
    result = xmlrpc_client_call(&env, wi->param+7,
                                "dlg_terminate_dlg", "(s)",
                                wi->call_id);
    if (env.fault_occurred) {
        rtpp_log_write(RTPP_LOG_ERR, wi->glog, "XML-RPC Fault: %s (%d)\n", env.fault_string, env.fault_code);
        return -1;
    }
    
    /* Dispose of our result value. */
    xmlrpc_DECREF(result);

    /* Shutdown our XML-RPC client library. */
    xmlrpc_env_clean(&env);
    xmlrpc_client_cleanup();

    return 0;
}
#endif

static void
do_timeout_notification(struct rtpp_notify_wi *wi, int retries)
{
    int result;

    rtpp_log_write(RTPP_LOG_ERR, wi->glog, "Timeout socket is: %s\n", wi->th->socket_name);

    if (strncmp("xmlrpc:", wi->th->socket_name, 7) == 0) {
	result = do_xmlrpc_timeout_notification(wi->glog, wi);
    } else {
	    if (wi->th->connected == 0) {
		reconnect_timeout_handler(wi->glog, wi->th);

		/* If connect fails, no notification will be sent */
		if (wi->th->connected == 0) {
		    rtpp_log_write(RTPP_LOG_ERR, wi->glog, "unable to send timeout notification");
		    return;
		}
	    }

	    do {
		result = send(wi->th->fd, wi->notify_buf, wi->len - 1, 0);
	    } while (result == -1 && errno == EINTR);
    }

    if (result < 0) {
        wi->th->connected = 0;
        rtpp_log_ewrite(RTPP_LOG_ERR, wi->glog, "failed to send timeout notification");
        if (retries > 0)
            do_timeout_notification(wi, retries - 1);
    }
}
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to