[asterisk-commits] russell: branch russell/events r84548 - /team/russell/events/res/ais/lck.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 3 13:48:13 CDT 2007
Author: russell
Date: Wed Oct 3 13:48:13 2007
New Revision: 84548
URL: http://svn.digium.com/view/asterisk?view=rev&rev=84548
Log:
Add DEADLOCK as one of the possible return values from the DLOCK_*LOCK
functions for implementations that support the optional deadlock detection
feature
Modified:
team/russell/events/res/ais/lck.c
Modified: team/russell/events/res/ais/lck.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/res/ais/lck.c?view=diff&rev=84548&r1=84547&r2=84548
==============================================================================
--- team/russell/events/res/ais/lck.c (original)
+++ team/russell/events/res/ais/lck.c Wed Oct 3 13:48:13 2007
@@ -107,7 +107,7 @@
return NULL;
}
-static void lock_unref_cb(void *data)
+static void lock_datastore_destroy(void *data)
{
struct lock_resource *lock = data;
SaAisErrorT ais_res;
@@ -163,7 +163,7 @@
const struct ast_datastore_info dlock_datastore_info = {
.type = "DLOCK",
- .destroy = lock_unref_cb,
+ .destroy = lock_datastore_destroy,
};
static void add_lock_to_chan(struct ast_channel *chan, struct lock_resource *lock,
@@ -214,8 +214,10 @@
case SA_LCK_LOCK_GRANTED:
ast_copy_string(buf, "SUCCESS", len);
break;
+ case SA_LCK_LOCK_DEADLOCK:
+ ast_copy_string(buf, "DEADLOCK", len);
+ return;
/*! XXX \todo Need to look at handling these other cases in a different way */
- case SA_LCK_LOCK_DEADLOCK:
case SA_LCK_LOCK_NOT_QUEUED:
case SA_LCK_LOCK_ORPHANED:
case SA_LCK_LOCK_NO_MORE:
@@ -362,6 +364,18 @@
return res;
}
+#define LOCK_DESC_COMMON \
+" The name of the lock can be anything. The first time a named lock gets\n" \
+"used, it will be automatically created and maintained amongst the cluster.\n" \
+" The result of this function will be one of the following:\n" \
+" SUCCESS | TIMEOUT | FAILURE | DEADLOCK\n" DEADLOCK_DESC
+
+#define DEADLOCK_DESC \
+" The result, DEADLOCK, can only be provided if the AIS implementation in\n" \
+"use provides the optional feature of deadlock detection. If the lock fails\n" \
+"with the result of DEADLOCK, it means that the AIS implementation has\n" \
+"determined that if this lock were acquired, it would cause a deadlock.\n"
+
static struct ast_custom_function dlock_rdlock = {
.name = "DLOCK_RDLOCK",
.synopsis = "Read-lock a distributed lock",
@@ -370,10 +384,7 @@
"service of AIS. This is a blocking operation. However, a timeout can be\n"
"specified to avoid deadlocks. The default timeout used if one is not\n"
"provided as an argument is 3 seconds.\n"
-" The name of the lock can be anything. The first time a named lock gets\n"
-"used, it will be automatically created and maintained amongst the cluster.\n"
-" The result of this function will be one of the following:\n"
-" SUCCESS | TIMEOUT | FAILURE\n"
+LOCK_DESC_COMMON
"",
.syntax = "DLOCK_RDLOCK(<lock_name>,[timeout])",
.read = handle_rdlock,
@@ -387,10 +398,7 @@
"service of AIS. This is a blocking operation. However, a timeout can be\n"
"specified to avoid deadlocks. The default timeout used if one is not\n"
"provided as an argument is 3 seconds.\n"
-" The name of the lock can be anything. The first time a named lock gets\n"
-"used, it will be automatically created and maintained amongst the cluster.\n"
-" The result of this function will be one of the following:\n"
-" SUCCESS | TIMEOUT | FAILURE\n"
+LOCK_DESC_COMMON
"",
.syntax = "DLOCK_WRLOCK(<lock_name>,[timeout])",
.read = handle_wrlock,
@@ -405,7 +413,8 @@
" The name of the lock can be anything. The first time a named lock gets\n"
"used, it will be automatically created and maintained amongst the cluster.\n"
" The result of this function will be one of the following:\n"
-" SUCCESS | FAILURE\n"
+" SUCCESS | FAILURE | DEADLOCK\n"
+DEADLOCK_DESC
"",
.syntax = "DLOCK_TRYRDLOCK(<lock_name>)",
.read = handle_tryrdlock,
@@ -420,7 +429,8 @@
" The name of the lock can be anything. The first time a named lock gets\n"
"used, it will be automatically created and maintained amongst the cluster.\n"
" The result of this function will be one of the following:\n"
-" SUCCESS | FAILURE\n"
+" SUCCESS | FAILURE | DEADLOCK\n"
+DEADLOCK_DESC
"",
.syntax = "DLOCK_TRYWRLOCK(<lock_name>)",
.read = handle_trywrlock,
More information about the asterisk-commits
mailing list