mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 20:51:58 +00:00
FSCORE-637 - limit - reset rate and release resource apis
Thanks Moy
This commit is contained in:
@@ -76,6 +76,14 @@ SWITCH_DECLARE(switch_status_t) switch_limit_release(const char *backend, switch
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_limit_usage(const char *backend, const char *realm, const char *resource, uint32_t *rcount);
|
||||
|
||||
/*!
|
||||
\brief reset interval usage counter for a given resource
|
||||
\param backend
|
||||
\param realm
|
||||
\param resource
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_limit_interval_reset(const char *backend, const char *realm, const char *resource);
|
||||
|
||||
/*!
|
||||
\brief reset all usage counters
|
||||
\param backend to use
|
||||
@@ -106,6 +114,7 @@ SWITCH_DECLARE(char *) switch_limit_status(const char *backend);
|
||||
#define SWITCH_LIMIT_RELEASE(name) static switch_status_t name (switch_core_session_t *session, const char *realm, const char *resource)
|
||||
#define SWITCH_LIMIT_USAGE(name) static int name (const char *realm, const char *resource, uint32_t *rcount)
|
||||
#define SWITCH_LIMIT_RESET(name) static switch_status_t name (void)
|
||||
#define SWITCH_LIMIT_INTERVAL_RESET(name) static switch_status_t name (const char *realm, const char *resource)
|
||||
#define SWITCH_LIMIT_STATUS(name) static char * name (void)
|
||||
|
||||
#define LIMIT_IGNORE_TRANSFER_VARIABLE "limit_ignore_transfer"
|
||||
|
||||
@@ -324,13 +324,14 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void);
|
||||
break; \
|
||||
}
|
||||
|
||||
#define SWITCH_ADD_LIMIT(limit_int, int_name, incrptr, releaseptr, usageptr, resetptr, statusptr) \
|
||||
#define SWITCH_ADD_LIMIT(limit_int, int_name, incrptr, releaseptr, usageptr, resetptr, statusptr, interval_resetptr) \
|
||||
for (;;) { \
|
||||
limit_int = (switch_limit_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_LIMIT_INTERFACE); \
|
||||
limit_int->incr = incrptr; \
|
||||
limit_int->release = releaseptr; \
|
||||
limit_int->usage = usageptr; \
|
||||
limit_int->reset = resetptr; \
|
||||
limit_int->interval_reset = interval_resetptr; \
|
||||
limit_int->status = statusptr; \
|
||||
limit_int->interface_name = int_name; \
|
||||
break; \
|
||||
|
||||
@@ -526,6 +526,8 @@ struct switch_limit_interface {
|
||||
switch_status_t (*reset) (void);
|
||||
/*! freform status */
|
||||
char * (*status) (void);
|
||||
/*! reset interval counter */
|
||||
switch_status_t (*interval_reset) (const char *realm, const char *resource);
|
||||
/* internal */
|
||||
switch_thread_rwlock_t *rwlock;
|
||||
int refs;
|
||||
|
||||
Reference in New Issue
Block a user