gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r21175 - gnunet/src/include


From: gnunet
Subject: [GNUnet-SVN] r21175 - gnunet/src/include
Date: Thu, 26 Apr 2012 18:13:45 +0200

Author: harsha
Date: 2012-04-26 18:13:45 +0200 (Thu, 26 Apr 2012)
New Revision: 21175

Modified:
   gnunet/src/include/gnunet_lockmanager_service.h
   gnunet/src/include/gnunet_protocols.h
Log:
-modified lockmanager and added protocol messages

Modified: gnunet/src/include/gnunet_lockmanager_service.h
===================================================================
--- gnunet/src/include/gnunet_lockmanager_service.h     2012-04-26 15:15:03 UTC 
(rev 21174)
+++ gnunet/src/include/gnunet_lockmanager_service.h     2012-04-26 16:13:45 UTC 
(rev 21175)
@@ -46,15 +46,10 @@
  *
  * @param cfg the configuration to use
  *
- * @param domain_name the name of the locking domain. If the locking domain
- *          isn't existing in the service it will be created. Clients who want
- *          to share locks must use the same name for the locking domain
- *
  * @return upon success the handle to the service; NULL upon error
  */
 struct GNUNET_LOCKMANAGER_Handle *
-GNUNET_LOCKMANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                            const char *domain_name);
+GNUNET_LOCKMANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
 
 
 /**
@@ -67,15 +62,42 @@
 
 
 /**
- * This callback will be called after a locking operation has been
- * attempted. This callback will not be called when the LockingRequest has been
- * cancelled.
+ * Enumeration for status
+ */
+enum GNUNET_LOCKMANAGER_Status
+  {
+    /**
+     * Signifies a successful operation
+     */
+    GNUNET_LOCKMANAGER_SUCCESS = 1,
+
+    /**
+     * Used to signal that a lock is no longer valid. It must then be released
+     */
+    GNUNET_LOCKMANAGER_RELEASE
+  };
+
+
+/**
+ * This callback will be called when a lock has been successfully acquired or
+ * when an acquired lock has been lost (happens when the lockmanager service
+ * crashes/restarts).
  *
  * @param cls the closure from GNUNET_LOCKMANAGER_lock call
- * @param lock the lock for which has been locked successfully
+ *
+ * @param domain_name the locking domain of the lock 
+ *
+ * @param lock the lock for which this status is relevant
+ *
+ * @param status GNUNET_LOCKMANAGER_SUCCESS if the lock has been successfully
+ *          acquired; GNUNET_LOCKMANAGER_RELEASE when the acquired lock is lost
  */
-typedef void (*GNUNET_LOCKMANAGER_CompletionCallback) (void *cls,
-                                                       unsigned int lock);
+typedef void 
+(*GNUNET_LOCKMANAGER_StatusCallback) (void *cls,
+                                      const char *domain_name,
+                                      uint32_t lock,
+                                      enum GNUNET_LOCKMANAGER_Status 
+                                      status);
 
 
 /**
@@ -85,28 +107,43 @@
 
 
 /**
- * Tries to lock the given lock
+ * Tries to acquire the given lock(even if the lock has been lost) until the
+ * request is called. If the lock is available the status_cb will be
+ * called. If the lock is busy then the request is queued and status_cb
+ * will be called when the lock has been made available and acquired by us.
  *
  * @param handle the handle to the lockmanager service
+ *
+ * @param domain_name name of the locking domain. Clients who want to share
+ *          locks must use the same name for the locking domain. Also the
+ *          domain_name should be selected with the prefix
+ *          "GNUNET_<PROGRAM_NAME>_" to avoid domain name collisions.
+ *
+ *
  * @param lock which lock to lock
- * @param completion_cb the callback to be called when locking is successful
- * @param completion_cb_cls the closure to the above callback
  *
+ * @param status_cb the callback for signalling when the lock is acquired and
+ *          when it is lost
+ *
+ * @param status_cb_cls the closure to the above callback
+ *
  * @return the locking request handle for this request. It will be invalidated
- *           when completion_cb is called.
+ *           when status_cb is called.
  */
 struct GNUNET_LOCKMANAGER_LockingRequest *
-GNUNET_LOCKMANAGER_try_lock (struct GNUNET_LOCKMANAGER_Handle *handle,
-                             unsigned int lock,
-                             GNUNET_LOCKMANAGER_CompletionCallback
-                             completion_cb,
-                             void *completion_cb_cls);
+GNUNET_LOCKMANAGER_acquire_lock (struct GNUNET_LOCKMANAGER_Handle *handle,
+                                 const char *domain_name,
+                                 uint32_t lock,
+                                 GNUNET_LOCKMANAGER_StatusCallback
+                                 status_cb,
+                                 void *status_cb_cls);
 
 
 /**
  * Function to cancel the locking request generated by
- * GNUNET_LOCKMANAGER_try_lock. This should be used on a LockingRequest before
- * the completion_cb for the associated lock is called.
+ * GNUNET_LOCKMANAGER_acquire_lock. If the lock is acquired us then the lock is
+ * released. GNUNET_LOCKMANAGER_StatusCallback will not be called upon any
+ * status changes resulting due to this call.
  *
  * @param request the LockingRequest to cancel
  */
@@ -115,18 +152,6 @@
                                    *request);
 
 
-/**
- * Unlocks a lock which was locked by us. It does nothing when called on a lock
- * which wasn't locked or was locked by someone else.
- *
- * @param handle the handle to the lockmanager service
- * @param lock which lock to unlock
- */
-void
-GNUNET_LOCKMANAGER_unlock (const struct GNUNET_LOCKMANAGER_Handle *handle,
-                           unsigned int lock);
-
-
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif

Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h       2012-04-26 15:15:03 UTC (rev 
21174)
+++ gnunet/src/include/gnunet_protocols.h       2012-04-26 16:13:45 UTC (rev 
21175)
@@ -1276,10 +1276,29 @@
  */
 #define GNUNET_MESSAGE_TYPE_NAMESTORE_START 430
 
+/*******************************************************************************
+ * LOCKMANAGER message types
+ 
******************************************************************************/
+
 /**
- *  Next available: 440
+ * Message to acquire Lock
  */
+#define GNUNET_MESSAGE_TYPE_LOCKMANAGER_ACQUIRE 440
 
+/**
+ * Message to release lock
+ */
+#define GNUNET_MESSAGE_TYPE_LOCKMANAGER_RELEASE 441
+
+/**
+ * SUCESS reply from lockmanager
+ */
+#define GNUNET_MESSAGE_TYPE_LOCKMANAGER_SUCCESS 442
+
+/**
+ *  Next available: 450
+ */
+
 
/*******************************************************************************
  * TODO: we need a way to register message types centrally (via some webpage).
  * For now: unofficial extensions should start at 48k, internal extensions




reply via email to

[Prev in Thread] Current Thread [Next in Thread]