timerfd timing interface  
More...
Go to the source code of this file.
◆ TIMERFD_MAX_RATE
      
        
          | #define TIMERFD_MAX_RATE   1000 | 
      
 
 
◆ __reg_module()
  
  | 
        
          | static void __reg_module | ( | void |  | ) |  |  | static | 
 
 
◆ __unreg_module()
  
  | 
        
          | static void __unreg_module | ( | void |  | ) |  |  | static | 
 
 
◆ AST_MODULE_SELF_SYM()
◆ load_module()
  
  | 
        
          | static int load_module | ( | void |  | ) |  |  | static | 
 
Definition at line 251 of file res_timing_timerfd.c.
  252{
  253    int fd;
  254 
  255    
  256    if ((fd = timerfd_create(CLOCK_MONOTONIC, 0)) < 0) {
  257        ast_log(
LOG_ERROR, 
"timerfd_create() not supported by the kernel.  Not loading.\n");
 
  259    }
  260 
  261    close(fd);
  262 
  265    }
  266 
  268}
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
static struct ast_timing_interface timerfd_timing
static void * timing_funcs_handle
#define ast_register_timing_interface(i)
Register a set of timing functions.
References ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_timing_interface, timerfd_timer::fd, LOG_ERROR, timerfd_timing, and timing_funcs_handle.
 
 
◆ timer_destroy()
  
  | 
        
          | static void timer_destroy | ( | void * | obj | ) |  |  | static | 
 
 
◆ timerfd_timer_ack()
  
  | 
        
          | static int timerfd_timer_ack | ( | void * | data, |  
          |  |  | unsigned int | quantity |  
          |  | ) |  |  |  | static | 
 
Definition at line 127 of file res_timing_timerfd.c.
  128{
  130    uint64_t expirations;
  131    int read_result = 0;
  132    int res = 0;
  133 
  135 
  136    do {
  137        struct itimerspec timer_status;
  138 
  139        if (timerfd_gettime(
timer->fd, &timer_status)) {
 
  141            expirations = 0;
  142            res = -1;
  143            break;
  144        }
  145 
  146        if (timer_status.it_value.tv_sec == 0 && timer_status.it_value.tv_nsec == 0) {
  147            ast_debug(1, 
"Avoiding read on disarmed timerfd %d\n", 
timer->fd);
 
  148            expirations = 0;
  149            break;
  150        }
  151 
  152        read_result = read(
timer->fd, &expirations, 
sizeof(expirations));
 
  153        if (read_result == -1) {
  155                continue;
  156            } else {
  158                res = -1;
  159                break;
  160            }
  161        }
  162    } while (read_result != sizeof(expirations));
  163 
  165 
  166    if (expirations != quantity) {
  167        ast_debug(2, 
"Expected to acknowledge %u ticks but got %llu instead\n", quantity, (
unsigned long long) expirations);
 
  168    }
  169 
  170    return res;
  171}
#define ast_debug(level,...)
Log a DEBUG message.
References ao2_lock, ao2_unlock, ast_debug, ast_log, errno, LOG_ERROR, and timer.
 
 
◆ timerfd_timer_close()
  
  | 
        
          | static void timerfd_timer_close | ( | void * | data | ) |  |  | static | 
 
Definition at line 101 of file res_timing_timerfd.c.
  102{
  104}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
References ao2_ref.
 
 
◆ timerfd_timer_disable_continuous()
  
  | 
        
          | static int timerfd_timer_disable_continuous | ( | void * | data | ) |  |  | static | 
 
 
◆ timerfd_timer_enable_continuous()
  
  | 
        
          | static int timerfd_timer_enable_continuous | ( | void * | data | ) |  |  | static | 
 
Definition at line 173 of file res_timing_timerfd.c.
  174{
  176    int res;
  177    static const struct itimerspec continuous_timer = {
  178        .it_value.tv_nsec = 1L,
  179    };
  180 
  182 
  183    if (
timer->is_continuous) {
 
  184        
  185
  186
  188        return 0;
  189    }
  190 
  191    res = timerfd_settime(
timer->fd, 0, &continuous_timer, &
timer->saved_timer);
 
  192    timer->is_continuous = 1;
 
  194 
  195    return res;
  196}
References ao2_lock, ao2_unlock, and timer.
 
 
◆ timerfd_timer_fd()
  
  | 
        
          | static int timerfd_timer_fd | ( | void * | data | ) |  |  | static | 
 
 
◆ timerfd_timer_get_event()
◆ timerfd_timer_get_max_rate()
  
  | 
        
          | static unsigned int timerfd_timer_get_max_rate | ( | void * | data | ) |  |  | static | 
 
 
◆ timerfd_timer_open()
  
  | 
        
          | static void * timerfd_timer_open | ( | void |  | ) |  |  | static | 
 
Definition at line 84 of file res_timing_timerfd.c.
   85{
   87 
   89        ast_log(
LOG_ERROR, 
"Could not allocate memory for timerfd_timer structure\n");
 
   91    }
   92    if ((
timer->fd = timerfd_create(CLOCK_MONOTONIC, 0)) < 0) {
 
   96    }
   97 
   99}
#define ao2_alloc(data_size, destructor_fn)
static void timer_destroy(void *obj)
References ao2_alloc, ao2_ref, ast_log, errno, LOG_ERROR, NULL, timer, and timer_destroy().
 
 
◆ timerfd_timer_set_rate()
  
  | 
        
          | static int timerfd_timer_set_rate | ( | void * | data, |  
          |  |  | unsigned int | rate |  
          |  | ) |  |  |  | static | 
 
Definition at line 106 of file res_timing_timerfd.c.
  107{
  109    int res = 0;
  110 
  112 
  113    timer->saved_timer.it_value.tv_sec = 0;
 
  114    timer->saved_timer.it_value.tv_nsec = rate ? (long) (1000000000 / rate) : 0L;
 
  115    timer->saved_timer.it_interval.tv_sec = 
timer->saved_timer.it_value.tv_sec;
 
  116    timer->saved_timer.it_interval.tv_nsec = 
timer->saved_timer.it_value.tv_nsec;
 
  117 
  118    if (!
timer->is_continuous) {
 
  120    }
  121 
  123 
  124    return res;
  125}
References ao2_lock, ao2_unlock, NULL, and timer.
 
 
◆ unload_module()
  
  | 
        
          | static int unload_module | ( | void |  | ) |  |  | static | 
 
 
◆ __mod_info
◆ ast_module_info
◆ timerfd_timing
Definition at line 54 of file res_timing_timerfd.c.
   54                                                    {
   55    .name = "timerfd",
   56    .priority = 200,
   66};
static int timerfd_timer_enable_continuous(void *data)
static int timerfd_timer_disable_continuous(void *data)
static unsigned int timerfd_timer_get_max_rate(void *data)
static enum ast_timer_event timerfd_timer_get_event(void *data)
static int timerfd_timer_ack(void *data, unsigned int quantity)
static void timerfd_timer_close(void *data)
static int timerfd_timer_fd(void *data)
static void * timerfd_timer_open(void)
static int timerfd_timer_set_rate(void *data, unsigned int rate)
Referenced by load_module().
 
 
◆ timing_funcs_handle
  
  | 
        
          | void* timing_funcs_handle |  | static |