diff --git a/libs/stfu/stfu.c b/libs/stfu/stfu.c index 81b494b8b4..aba9f0803e 100644 --- a/libs/stfu/stfu.c +++ b/libs/stfu/stfu.c @@ -120,7 +120,7 @@ static int32_t stfu_n_measure_interval(stfu_queue_t *queue) track[(d/10)]++; } } - + last = this; } @@ -131,7 +131,6 @@ static int32_t stfu_n_measure_interval(stfu_queue_t *queue) } return most * 10; - } static int16_t stfu_n_process(stfu_instance_t *i, stfu_queue_t *queue) @@ -149,23 +148,22 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, void *data, size_ stfu_frame_t *frame; size_t cplen = 0; - if (last || i->in_queue->array_len == i->in_queue->array_size) { stfu_queue_t *other_queue; - + if (i->out_queue->wr_len < i->out_queue->array_len) { return STFU_IT_FAILED; } - + other_queue = i->in_queue; i->in_queue = i->out_queue; i->out_queue = other_queue; - + i->in_queue->array_len = 0; i->out_queue->wr_len = 0; i->out_queue->last_index = 0; i->miss_count = 0; - + if (stfu_n_process(i, i->out_queue) < 0) { return STFU_IT_FAILED; } @@ -177,7 +175,7 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, void *data, size_ if (last) { return STFU_IM_DONE; } - + index = i->in_queue->array_len++; frame = &i->in_queue->array[index]; @@ -198,7 +196,6 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i) uint32_t index, index2; uint32_t should_have = 0; stfu_frame_t *frame = NULL, *rframe = NULL; - if (((i->out_queue->wr_len == i->out_queue->array_len) || !i->out_queue->array_len)) { return NULL; @@ -216,7 +213,7 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i) } frame = &i->out_queue->array[index]; - + if (frame->ts != should_have) { unsigned int tried = 0; for (index2 = 0; index2 < i->out_queue->array_len; index2++) { @@ -249,7 +246,7 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i) i->out_queue->wr_len = i->out_queue->array_size; return NULL; } - + i->last_ts = should_have; rframe = &i->out_queue->int_frame; rframe->dlen = i->out_queue->array[i->out_queue->last_index].dlen; @@ -265,8 +262,8 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i) goto done; } } - - done: + +done: if (rframe) { i->out_queue->wr_len++; @@ -279,4 +276,13 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i) return rframe; } - +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:nil + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: + */ diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h index 69b7dd34c1..0f0879fe14 100644 --- a/src/include/switch_apr.h +++ b/src/include/switch_apr.h @@ -792,8 +792,22 @@ SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename, switch_ SWITCH_DECLARE(switch_status_t) switch_directory_exists(const char *dirname, switch_memory_pool_t *pool); +/** +* Create a new directory on the file system. +* @param path the path for the directory to be created. (use / on all systems) +* @param perm Permissions for the new direcoty. +* @param pool the pool to use. +*/ SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool); + +/** Creates a new directory on the file system, but behaves like +* 'mkdir -p'. Creates intermediate directories as required. No error +* will be reported if PATH already exists. +* @param path the path for the directory to be created. (use / on all systems) +* @param perm Permissions for the new direcoty. +* @param pool the pool to use. +*/ SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool); diff --git a/src/switch_apr.c b/src/switch_apr.c index 2a7b2235ad..ae653528b0 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -73,36 +73,6 @@ SWITCH_DECLARE(void) switch_pool_clear(switch_memory_pool_t *p) apr_pool_clear(p); } -#if 0 -/* Hash tables */ - -SWITCH_DECLARE(switch_hash_index_t *) switch_hash_first(switch_memory_pool_t *p, switch_hash_t * ht) -{ - return apr_hash_first(p, ht); -} - -SWITCH_DECLARE(switch_hash_index_t *) switch_hash_next(switch_hash_index_t * ht) -{ - return apr_hash_next(ht); -} - -SWITCH_DECLARE(void) switch_hash_this(switch_hash_index_t * hi, const void **key, switch_ssize_t *klen, void **val) -{ - if (key) { - *key = NULL; - } - if (val) { - *val = NULL; - } - apr_hash_this(hi, key, klen, val); -} - -SWITCH_DECLARE(switch_memory_pool_t *) switch_hash_pool_get(switch_hash_t * ht) -{ - return apr_hash_pool_get(ht); -} -#endif - SWITCH_DECLARE(unsigned int) switch_hashfunc_default(const char *key, switch_ssize_t *klen) { return apr_hashfunc_default(key, klen); @@ -259,7 +229,6 @@ SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt(switch_time_exp_t * result, return apr_time_exp_gmt((apr_time_exp_t *) result, input); } - SWITCH_DECLARE(switch_status_t) switch_rfc822_date(char *date_str, switch_time_t t) { return apr_rfc822_date(date_str, t); @@ -352,11 +321,11 @@ SWITCH_DECLARE(switch_status_t) switch_file_write(switch_file_t * thefile, const SWITCH_DECLARE(int) switch_file_printf(switch_file_t *thefile, const char *format, ...) { va_list ap; - int ret; + int ret; va_start(ap, format); ret = apr_file_printf(thefile, format, ap); va_end(ap); - return ret; + return ret; } SWITCH_DECLARE(switch_status_t) switch_file_mktemp(switch_file_t **thefile, char *templ, int32_t flags, switch_memory_pool_t *pool) @@ -384,7 +353,7 @@ SWITCH_DECLARE(switch_status_t) switch_directory_exists(const char *dirname, swi if ((status = apr_dir_open(&dir_handle, dirname, pool)) == APR_SUCCESS) { apr_dir_close(dir_handle); } - + if (our_pool) { switch_core_destroy_memory_pool(&our_pool); } @@ -417,42 +386,12 @@ SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename, switch_ return status; } -/* #define SWITCH_FPROT_USETID 0x8000 /\**< Set user id *\/ */ -/* #define SWITCH_FPROT_UREAD 0x0400 /\**< Read by user *\/ */ -/* #define SWITCH_FPROT_UWRITE 0x0200 /\**< Write by user *\/ */ -/* #define SWITCH_FPROT_UEXECUTE 0x0100 /\**< Execute by user *\/ */ - -/* #define SWITCH_FPROT_GSETID 0x4000 /\**< Set group id *\/ */ -/* #define SWITCH_FPROT_GREAD 0x0040 /\**< Read by group *\/ */ -/* #define SWITCH_FPROT_GWRITE 0x0020 /\**< Write by group *\/ */ -/* #define SWITCH_FPROT_GEXECUTE 0x0010 /\**< Execute by group *\/ */ - -/* #define SWITCH_FPROT_WSTICKY 0x2000 /\**< Sticky bit *\/ */ -/* #define SWITCH_FPROT_WREAD 0x0004 /\**< Read by others *\/ */ -/* #define SWITCH_FPROT_WWRITE 0x0002 /\**< Write by others *\/ */ -/* #define SWITCH_FPROT_WEXECUTE 0x0001 /\**< Execute by others *\/ */ - -/* #define SWITCH_FPROT_OS_DEFAULT 0x0FFF /\**< use OS's default permissions *\/ */ - -/** - * Create a new directory on the file system. - * @param path the path for the directory to be created. (use / on all systems) - * @param perm Permissions for the new direcoty. - * @param pool the pool to use. - */ SWITCH_DECLARE(switch_status_t) switch_dir_make(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool) { return apr_dir_make(path, perm, pool); } -/** Creates a new directory on the file system, but behaves like - * 'mkdir -p'. Creates intermediate directories as required. No error - * will be reported if PATH already exists. - * @param path the path for the directory to be created. (use / on all systems) - * @param perm Permissions for the new direcoty. - * @param pool the pool to use. - */ SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool) @@ -499,7 +438,7 @@ SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *bu const char *fname = NULL; apr_int32_t finfo_flags = APR_FINFO_DIRENT | APR_FINFO_TYPE | APR_FINFO_NAME; const char *name; - + while (apr_dir_read(&(thedir->finfo), finfo_flags, thedir->dir_handle) == SWITCH_STATUS_SUCCESS) { if (thedir->finfo.filetype != APR_REG) { @@ -509,7 +448,7 @@ SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *bu if (!(name = thedir->finfo.fname)) { name = thedir->finfo.name; } - + if (!name) { continue; } @@ -604,10 +543,9 @@ SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t * sock, const } wrote += need; } - + *len = wrote; return status; - } SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t * sock, switch_sockaddr_t * where, int32_t flags, const char *buf, switch_size_t *len) @@ -629,7 +567,6 @@ SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t ** sa return apr_sockaddr_info_get(sa, hostname, family, port, flags, pool); } - SWITCH_DECLARE(switch_status_t) switch_socket_opt_set(switch_socket_t * sock, int32_t opt, int32_t on) { return apr_socket_opt_set(sock, opt, on); @@ -661,7 +598,6 @@ SWITCH_DECLARE(const char *) switch_get_addr(char *buf, switch_size_t len, switc return get_addr(buf, len, &in->sa.sin.sin_addr); } - SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t * sa) { return sa->port; @@ -679,12 +615,11 @@ SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t * from, if ((r = apr_socket_recvfrom(from, sock, flags, buf, len)) == APR_SUCCESS) { from->port = ntohs(from->sa.sin.sin_port); /* from->ipaddr_ptr = &(from->sa.sin.sin_addr); - * from->ipaddr_ptr = inet_ntoa(from->sa.sin.sin_addr); - */ + * from->ipaddr_ptr = inet_ntoa(from->sa.sin.sin_addr); + */ } return r; - } /* poll stubs */ @@ -776,7 +711,7 @@ SWITCH_DECLARE(switch_status_t) switch_queue_push(switch_queue_t * queue, void * do { s = apr_queue_push(queue, data); } while (s == APR_EINTR); - + return s; } @@ -829,7 +764,6 @@ SWITCH_DECLARE(int) switch_vasprintf(char **ret, const char *fmt, va_list ap) va_end(ap2); return len; - #endif }