205 struct timespec timeout = { 0, };
210 ast_log(
LOG_ERROR,
"%sLOCK has no datastore and func_lock is unloading, failing.\n",
211 trylock ?
"TRY" :
"");
217 ast_log(
LOG_ERROR,
"Unable to allocate new datastore. No locks will be obtained.\n");
224 "Unable to allocate datastore list head. %sLOCK will fail.\n",
225 trylock ?
"TRY" :
"");
230 lock_store->
data = list;
237 list = lock_store->
data;
242 if (strcmp(
current->name, lockname) == 0) {
250 "Lock doesn't exist whilst unloading. %sLOCK will fail.\n",
251 trylock ?
"TRY" :
"");
264 strcpy(
current->name, lockname);
272 ast_log(
LOG_ERROR,
"Unable to initialize condition variable: %s\n", strerror(res));
297 "Busy unloading. %sLOCK will fail.\n",
298 trylock ?
"TRY" :
"");
307 if (!(clframe =
ast_calloc(1,
sizeof(*clframe)))) {
309 "Unable to allocate channel lock frame. %sLOCK will fail.\n",
310 trylock ?
"TRY" :
"");
339 timeout.tv_sec = now.tv_sec + 3;
340 timeout.tv_nsec = now.tv_usec * 1000;
345 while (!trylock && !res &&
current->owner) {
388 ast_debug(1,
"This should NEVER happen\n");
452 e->
command =
"dialplan locks show";
454 "Usage: dialplan locks show\n"
455 " List all locks known to func_lock, along with their current status.\n";
461 ast_cli(
a->fd,
"func_lock locks:\n");
462 ast_cli(
a->fd,
"%-40s Requesters Owner\n",
"Name");
472 ast_cli(
a->fd,
"%d total locks listed.\n",
c);
Asterisk main include file. File version handling, generic pbx functions.
#define ast_calloc(num, len)
A wrapper for calloc()
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Standard Command Line Interface.
int ast_cli_unregister(struct ast_cli_entry *e)
Unregisters a command or an array of commands.
#define ast_cli_register(e)
Registers a command or an array of commands.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Generic File Format Support. Should be included by clients of the file handling routines....
static struct ast_custom_function trylock_function
static struct ast_custom_function lock_function
static struct ast_cli_entry cli_locks_show
static const struct ast_datastore_info lock_info
static void lock_free(void *data)
static struct ast_custom_function unlock_function
static int unlock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int trylock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int lock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static void lock_fixup(void *data, struct ast_channel *oldchan, struct ast_channel *newchan)
static int get_lock(struct ast_channel *chan, char *lockname, int trylock)
static int load_module(void)
static char * handle_cli_locks_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int unload_module(void)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_debug(level,...)
Log a DEBUG message.
A set of macros to manage forward-linked lists.
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_HEAD_DESTROY(head)
Destroys a list head structure.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
#define AST_LIST_LOCK(head)
Locks a list.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
Asterisk locking-related definitions:
#define ast_cond_destroy(cond)
#define ast_cond_wait(cond, mutex)
#define ast_cond_init(cond, attr)
#define ast_cond_timedwait(cond, mutex, time)
#define ast_mutex_init(pmutex)
#define ast_mutex_unlock(a)
pthread_cond_t ast_cond_t
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
#define ast_cond_signal(cond)
Asterisk module definitions.
#define ast_module_unref(mod)
Release a reference to the module.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ast_module_ref(mod)
Hold a reference to the module.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Core PBX routines and definitions.
#define ast_custom_function_register_escalating(acf, escalation)
Register a custom function which requires escalated privileges.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Main Channel structure associated with a channel.
descriptor for a cli entry.
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
Structure for mutex and tracking information.
struct channel_lock_frame::@174 list
struct ast_channel * channel
struct lock_frame * lock_frame
struct lock_frame::@173 entries
struct ast_channel * owner
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().