Browse Source

MT#55283 refactor loop thread creation

Change-Id: Id94a6bfc69ad5b49a3ffd9ac7a655d81dfc07a07
pull/1676/head
Richard Fuchs 3 years ago
parent
commit
15709a62a6
7 changed files with 23 additions and 45 deletions
  1. +17
    -0
      daemon/aux.c
  2. +0
    -14
      daemon/ice.c
  3. +3
    -3
      daemon/main.c
  4. +1
    -24
      daemon/media_socket.c
  5. +1
    -0
      include/aux.h
  6. +0
    -2
      include/ice.h
  7. +1
    -2
      include/media_socket.h

+ 17
- 0
daemon/aux.c View File

@ -303,3 +303,20 @@ void thread_create_detach_prio(void (*f)(void *), void *d, const char *scheduler
if (thread_create(thread_detach_func, dt, 1, NULL, name))
abort();
}
static void thread_looper_helper(void *fp) {
void (*f)(void) = fp;
while (!rtpe_shutdown) {
gettimeofday(&rtpe_now, NULL);
f();
thread_cancel_enable();
usleep(1000000); /* sleep for 1 second in each iteration */
thread_cancel_disable();
}
}
void thread_create_looper(void (*f)(void), const char *scheduler, int priority, const char *name) {
thread_create_detach_prio(thread_looper_helper, f, scheduler, priority, name);
}

+ 0
- 14
daemon/ice.c View File

@ -762,20 +762,6 @@ void ice_slow_timer(void) {
fragments_cleanup(false);
}
/**
* Separate thread for for ice slow timer functionality.
*/
void ice_slow_timer_iterator(void * dummy) {
while (!rtpe_shutdown) {
gettimeofday(&rtpe_now, NULL);
ice_slow_timer();
thread_cancel_enable();
usleep(1000000); /* sleep for 1 second in each iteration */
thread_cancel_disable();
}
}
static void __fail_pair(struct ice_candidate_pair *pair) {
ilogs(ice, LOG_DEBUG, "Setting ICE candidate pair "PAIR_FORMAT" as failed", PAIR_FMT(pair));
PAIR_SET(pair, FAILED);


+ 3
- 3
daemon/main.c View File

@ -1347,7 +1347,7 @@ int main(int argc, char **argv) {
rtpe_config.idle_priority, "load monitor");
/* separate thread for releasing ports (sockets), which are scheduled for clearing */
thread_create_detach_prio(sockets_releaser, NULL, rtpe_config.idle_scheduling,
thread_create_looper(release_closed_sockets, rtpe_config.idle_scheduling,
rtpe_config.idle_priority, "release closed sockets");
/* separate thread for update of running min/max call counters */
@ -1355,11 +1355,11 @@ int main(int argc, char **argv) {
rtpe_config.idle_priority, "call rate stats");
/* separate thread for ports iterations (stats update from the kernel) functionality */
thread_create_detach_prio(kernel_stats_updater_iterator, NULL, rtpe_config.idle_scheduling,
thread_create_looper(kernel_stats_updater, rtpe_config.idle_scheduling,
rtpe_config.idle_priority, "kernel stats updater");
/* separate thread for ice slow timer functionality */
thread_create_detach_prio(ice_slow_timer_iterator, NULL, rtpe_config.idle_scheduling,
thread_create_looper(ice_slow_timer, rtpe_config.idle_scheduling,
rtpe_config.idle_priority, "ice slow timer");
if (!is_addr_unspecified(&rtpe_config.redis_ep.address) && initial_rtpe_config.redis_delete_async)


+ 1
- 24
daemon/media_socket.c View File

@ -1002,19 +1002,6 @@ void append_thread_lpr_to_glob_lpr(void) {
mutex_unlock(&ports_to_release_glob_lock);
}
/**
* Separate thread for releasing sockets scheduled for closing.
*/
void sockets_releaser(void * dummy) {
while (!rtpe_shutdown) {
release_closed_sockets();
thread_cancel_enable();
usleep(1000000); /* sleep for 1 second in each iteration */
thread_cancel_disable();
}
}
/**
* Puts a list of `socket_t` objects into the `out`.
*
@ -3340,7 +3327,7 @@ struct interface_stats_block *interface_sampled_rate_stats_get(struct interface_
/**
* Ports iterations (stats update from the kernel) functionality.
*/
static void kernel_stats_updater(void) {
void kernel_stats_updater(void) {
struct rtpengine_list_entry *ke;
struct packet_stream *ps;
int j;
@ -3507,13 +3494,3 @@ next:
}
}
void kernel_stats_updater_iterator(void * dummy) {
while (!rtpe_shutdown) {
gettimeofday(&rtpe_now, NULL);
kernel_stats_updater();
thread_cancel_enable();
usleep(1000000); /* sleep for 1 second in each iteration */
thread_cancel_disable();
}
}

+ 1
- 0
include/aux.h View File

@ -327,6 +327,7 @@ void thread_waker_add(struct thread_waker *);
void thread_waker_del(struct thread_waker *);
void threads_join_all(bool cancel);
void thread_create_detach_prio(void (*)(void *), void *, const char *, int, const char *);
void thread_create_looper(void (*f)(void), const char *scheduler, int priority, const char *name);
INLINE void thread_create_detach(void (*f)(void *), void *a, const char *name) {
thread_create_detach_prio(f, a, NULL, 0, name);
}


+ 0
- 2
include/ice.h View File

@ -176,8 +176,6 @@ bool trickle_ice_update(struct ng_buffer *ngbuf, struct call *call, struct sdp_n
void ice_slow_timer(void);
void ice_slow_timer_iterator(void * dummy);
#include "call.h"


+ 1
- 2
include/media_socket.h View File

@ -300,7 +300,6 @@ struct stream_fd *stream_fd_new(socket_t *fd, struct call *call, struct local_in
struct stream_fd *stream_fd_lookup(const endpoint_t *);
void stream_fd_release(struct stream_fd *);
void release_closed_sockets(void);
void sockets_releaser(void * dummy);
void append_thread_lpr_to_glob_lpr(void);
void free_intf_list(struct intf_list *il);
@ -334,7 +333,7 @@ const struct transport_protocol *transport_protocol(const str *s);
//void play_buffered(struct packet_stream *sink, struct codec_packet *cp, int buffered);
void play_buffered(struct jb_packet *cp);
void kernel_stats_updater_iterator(void * dummy);
void kernel_stats_updater(void);
INLINE int proto_is_rtp(const struct transport_protocol *protocol) {
// known to be RTP? therefore unknown is not RTP


Loading…
Cancel
Save