Browse Source

MT#56856 support the new REMG_DEL_TARGET_STATS

Instead of doing two calls to the kernel every time a forwarding stream
is deleted (one to update the stats and one to delete), combine these
two into a single call using REMG_DEL_TARGET_STATS.

Change-Id: I9fcb148930c24bc866f842a50edd613fb6296de0
pull/1657/head
Richard Fuchs 3 years ago
parent
commit
42284d4fa2
3 changed files with 8 additions and 11 deletions
  1. +3
    -5
      daemon/kernel.c
  2. +4
    -5
      daemon/media_socket.c
  3. +1
    -1
      include/kernel.h

+ 3
- 5
daemon/kernel.c View File

@ -176,17 +176,15 @@ int kernel_add_destination(struct rtpengine_destination_info *mdi) {
} }
int kernel_del_stream(const struct re_address *a) {
struct rtpengine_command_del_target cmd;
int kernel_del_stream_stats(struct rtpengine_command_del_target_stats *cmd) {
ssize_t ret; ssize_t ret;
if (!kernel.is_open) if (!kernel.is_open)
return -1; return -1;
cmd.cmd = REMG_DEL_TARGET;
cmd.local = *a;
cmd->cmd = REMG_DEL_TARGET_STATS;
ret = write(kernel.fd, &cmd, sizeof(cmd));
ret = read(kernel.fd, cmd, sizeof(*cmd));
if (ret > 0) if (ret > 0)
return 0; return 0;


+ 4
- 5
daemon/media_socket.c View File

@ -1754,8 +1754,6 @@ static void __stream_update_stats(struct packet_stream *ps, bool have_in_lock) {
/* must be called with in_lock held or call->master_lock held in W */ /* must be called with in_lock held or call->master_lock held in W */
void __unkernelize(struct packet_stream *p, const char *reason) { void __unkernelize(struct packet_stream *p, const char *reason) {
struct re_address rea;
reset_ps_kernel_stats(p); reset_ps_kernel_stats(p);
if (!p->selected_sfd) if (!p->selected_sfd)
@ -1768,9 +1766,10 @@ void __unkernelize(struct packet_stream *p, const char *reason) {
ilog(LOG_INFO, "Removing media stream from kernel: local %s (%s)", ilog(LOG_INFO, "Removing media stream from kernel: local %s (%s)",
endpoint_print_buf(&p->selected_sfd->socket.local), endpoint_print_buf(&p->selected_sfd->socket.local),
reason); reason);
__stream_update_stats(p, true);
__re_address_translate_ep(&rea, &p->selected_sfd->socket.local);
kernel_del_stream(&rea);
struct rtpengine_command_del_target_stats cmd;
__re_address_translate_ep(&cmd.local, &p->selected_sfd->socket.local);
if (kernel_del_stream_stats(&cmd) == 0)
__stream_consume_stats(p, &cmd.stats);
} }
PS_CLEAR(p, KERNELIZED); PS_CLEAR(p, KERNELIZED);


+ 1
- 1
include/kernel.h View File

@ -37,7 +37,7 @@ int kernel_setup_table(unsigned int);
int kernel_add_stream(struct rtpengine_target_info *); int kernel_add_stream(struct rtpengine_target_info *);
int kernel_add_destination(struct rtpengine_destination_info *); int kernel_add_destination(struct rtpengine_destination_info *);
int kernel_del_stream(const struct re_address *);
int kernel_del_stream_stats(struct rtpengine_command_del_target_stats *);
GList *kernel_list(void); GList *kernel_list(void);
int kernel_update_stats(struct rtpengine_command_stats *); int kernel_update_stats(struct rtpengine_command_stats *);


Loading…
Cancel
Save