fix memory leak in quality reporting

This commit is contained in:
Simon Morlat 2016-10-11 11:00:47 +02:00
parent 38c95f6b2a
commit 219f5dbf07
4 changed files with 22 additions and 3 deletions

View file

@ -135,6 +135,7 @@ void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState s
linphone_event_release(lev);
break;
case LinphonePublishOk:
if (lev->oneshot) linphone_event_release(lev);
break;
case LinphonePublishError:
linphone_event_release(lev);
@ -275,6 +276,12 @@ LinphoneEvent *linphone_core_create_publish(LinphoneCore *lc, const LinphoneAddr
return lev;
}
LinphoneEvent *linphone_core_create_one_shot_publish(LinphoneCore *lc, const LinphoneAddress *resource, const char *event){
LinphoneEvent *lev = linphone_core_create_publish(lc, resource, event, -1);
lev->oneshot = TRUE;
return lev;
}
static int _linphone_event_send_publish(LinphoneEvent *lev, const LinphoneContent *body, bool_t notify_err){
SalBodyHandler *body_handler;
int err;

View file

@ -204,6 +204,19 @@ LINPHONE_PUBLIC LinphoneEvent *linphone_core_publish(LinphoneCore *lc, const Lin
**/
LINPHONE_PUBLIC LinphoneEvent *linphone_core_create_publish(LinphoneCore *lc, const LinphoneAddress *resource, const char *event, int expires);
/**
* Create a publish context for a one-shot publish.
* After being created, the publish must be sent using linphone_event_send_publish().
* The LinphoneEvent is automatically terminated when the publish transaction is finished, either with success or failure.
* The application must not call linphone_event_terminate() for such one-shot publish.
* @param lc the #LinphoneCore
* @param resource the resource uri for the event
* @param event the event name
* @return the LinphoneEvent holding the context of the publish.
**/
LINPHONE_PUBLIC LinphoneEvent *linphone_core_create_one_shot_publish(LinphoneCore *lc, const LinphoneAddress *resource, const char *event);
/**
* Send a publish created by linphone_core_create_publish().
* @param lev the #LinphoneEvent

View file

@ -1085,6 +1085,7 @@ struct _LinphoneEvent{
bool_t terminating;
bool_t is_out_of_dialog_op; /*used for out of dialog notify*/
bool_t internal;
bool_t oneshot;
};
BELLE_SIP_DECLARE_VPTR(LinphoneEvent);

View file

@ -264,7 +264,6 @@ static void append_metrics_to_buffer(char ** buffer, size_t * size, size_t * off
static int send_report(LinphoneCall* call, reporting_session_report_t * report, const char * report_event) {
LinphoneContent *content;
int expires = -1;
size_t offset = 0;
size_t size = 2048;
char * buffer;
@ -357,7 +356,7 @@ static int send_report(LinphoneCall* call, reporting_session_report_t * report,
collector_uri = ms_strdup_printf("sip:%s", linphone_proxy_config_get_domain(call->dest_proxy));
}
request_uri = linphone_address_new(collector_uri);
lev=linphone_core_create_publish(call->core, request_uri, "vq-rtcpxr", expires);
lev = linphone_core_create_one_shot_publish(call->core, request_uri, "vq-rtcpxr");
/* Special exception for quality report PUBLISH: if the collector_uri has any transport related parameters
* (port, transport, maddr), then it is sent directly.
* Otherwise it is routed as any LinphoneEvent publish, following proxy config policy.
@ -370,7 +369,6 @@ static int send_report(LinphoneCall* call, reporting_session_report_t * report,
}
if (linphone_event_send_publish(lev, content) != 0){
linphone_event_unref(lev);
lev=NULL;
ret=4;
} else {