diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-04-26 16:13:45 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-04-26 16:13:45 +0000 |
commit | 21808116e6a8c87e100f0f382bf8d22d61aa75e8 (patch) | |
tree | 417776e0c2bb67e87e9c8dad6fff222db16973e5 /src | |
parent | 3bf68f7cb4609c7288a17f2f2ce0f156a9e634e5 (diff) | |
download | gnunet-21808116e6a8c87e100f0f382bf8d22d61aa75e8.tar.gz gnunet-21808116e6a8c87e100f0f382bf8d22d61aa75e8.zip |
-modified lockmanager and added protocol messages
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_lockmanager_service.h | 95 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 21 |
2 files changed, 80 insertions, 36 deletions
diff --git a/src/include/gnunet_lockmanager_service.h b/src/include/gnunet_lockmanager_service.h index f2952a742..6f63fd529 100644 --- a/src/include/gnunet_lockmanager_service.h +++ b/src/include/gnunet_lockmanager_service.h | |||
@@ -46,15 +46,10 @@ struct GNUNET_LOCKMANAGER_Handle; | |||
46 | * | 46 | * |
47 | * @param cfg the configuration to use | 47 | * @param cfg the configuration to use |
48 | * | 48 | * |
49 | * @param domain_name the name of the locking domain. If the locking domain | ||
50 | * isn't existing in the service it will be created. Clients who want | ||
51 | * to share locks must use the same name for the locking domain | ||
52 | * | ||
53 | * @return upon success the handle to the service; NULL upon error | 49 | * @return upon success the handle to the service; NULL upon error |
54 | */ | 50 | */ |
55 | struct GNUNET_LOCKMANAGER_Handle * | 51 | struct GNUNET_LOCKMANAGER_Handle * |
56 | GNUNET_LOCKMANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 52 | GNUNET_LOCKMANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); |
57 | const char *domain_name); | ||
58 | 53 | ||
59 | 54 | ||
60 | /** | 55 | /** |
@@ -67,15 +62,42 @@ GNUNET_LOCKMANAGER_disconnect (struct GNUNET_LOCKMANAGER_Handle *handle); | |||
67 | 62 | ||
68 | 63 | ||
69 | /** | 64 | /** |
70 | * This callback will be called after a locking operation has been | 65 | * Enumeration for status |
71 | * attempted. This callback will not be called when the LockingRequest has been | 66 | */ |
72 | * cancelled. | 67 | enum GNUNET_LOCKMANAGER_Status |
68 | { | ||
69 | /** | ||
70 | * Signifies a successful operation | ||
71 | */ | ||
72 | GNUNET_LOCKMANAGER_SUCCESS = 1, | ||
73 | |||
74 | /** | ||
75 | * Used to signal that a lock is no longer valid. It must then be released | ||
76 | */ | ||
77 | GNUNET_LOCKMANAGER_RELEASE | ||
78 | }; | ||
79 | |||
80 | |||
81 | /** | ||
82 | * This callback will be called when a lock has been successfully acquired or | ||
83 | * when an acquired lock has been lost (happens when the lockmanager service | ||
84 | * crashes/restarts). | ||
73 | * | 85 | * |
74 | * @param cls the closure from GNUNET_LOCKMANAGER_lock call | 86 | * @param cls the closure from GNUNET_LOCKMANAGER_lock call |
75 | * @param lock the lock for which has been locked successfully | 87 | * |
88 | * @param domain_name the locking domain of the lock | ||
89 | * | ||
90 | * @param lock the lock for which this status is relevant | ||
91 | * | ||
92 | * @param status GNUNET_LOCKMANAGER_SUCCESS if the lock has been successfully | ||
93 | * acquired; GNUNET_LOCKMANAGER_RELEASE when the acquired lock is lost | ||
76 | */ | 94 | */ |
77 | typedef void (*GNUNET_LOCKMANAGER_CompletionCallback) (void *cls, | 95 | typedef void |
78 | unsigned int lock); | 96 | (*GNUNET_LOCKMANAGER_StatusCallback) (void *cls, |
97 | const char *domain_name, | ||
98 | uint32_t lock, | ||
99 | enum GNUNET_LOCKMANAGER_Status | ||
100 | status); | ||
79 | 101 | ||
80 | 102 | ||
81 | /** | 103 | /** |
@@ -85,28 +107,43 @@ struct GNUNET_LOCKMANAGER_LockingRequest; | |||
85 | 107 | ||
86 | 108 | ||
87 | /** | 109 | /** |
88 | * Tries to lock the given lock | 110 | * Tries to acquire the given lock(even if the lock has been lost) until the |
111 | * request is called. If the lock is available the status_cb will be | ||
112 | * called. If the lock is busy then the request is queued and status_cb | ||
113 | * will be called when the lock has been made available and acquired by us. | ||
89 | * | 114 | * |
90 | * @param handle the handle to the lockmanager service | 115 | * @param handle the handle to the lockmanager service |
116 | * | ||
117 | * @param domain_name name of the locking domain. Clients who want to share | ||
118 | * locks must use the same name for the locking domain. Also the | ||
119 | * domain_name should be selected with the prefix | ||
120 | * "GNUNET_<PROGRAM_NAME>_" to avoid domain name collisions. | ||
121 | * | ||
122 | * | ||
91 | * @param lock which lock to lock | 123 | * @param lock which lock to lock |
92 | * @param completion_cb the callback to be called when locking is successful | 124 | * |
93 | * @param completion_cb_cls the closure to the above callback | 125 | * @param status_cb the callback for signalling when the lock is acquired and |
126 | * when it is lost | ||
127 | * | ||
128 | * @param status_cb_cls the closure to the above callback | ||
94 | * | 129 | * |
95 | * @return the locking request handle for this request. It will be invalidated | 130 | * @return the locking request handle for this request. It will be invalidated |
96 | * when completion_cb is called. | 131 | * when status_cb is called. |
97 | */ | 132 | */ |
98 | struct GNUNET_LOCKMANAGER_LockingRequest * | 133 | struct GNUNET_LOCKMANAGER_LockingRequest * |
99 | GNUNET_LOCKMANAGER_try_lock (struct GNUNET_LOCKMANAGER_Handle *handle, | 134 | GNUNET_LOCKMANAGER_acquire_lock (struct GNUNET_LOCKMANAGER_Handle *handle, |
100 | unsigned int lock, | 135 | const char *domain_name, |
101 | GNUNET_LOCKMANAGER_CompletionCallback | 136 | uint32_t lock, |
102 | completion_cb, | 137 | GNUNET_LOCKMANAGER_StatusCallback |
103 | void *completion_cb_cls); | 138 | status_cb, |
139 | void *status_cb_cls); | ||
104 | 140 | ||
105 | 141 | ||
106 | /** | 142 | /** |
107 | * Function to cancel the locking request generated by | 143 | * Function to cancel the locking request generated by |
108 | * GNUNET_LOCKMANAGER_try_lock. This should be used on a LockingRequest before | 144 | * GNUNET_LOCKMANAGER_acquire_lock. If the lock is acquired us then the lock is |
109 | * the completion_cb for the associated lock is called. | 145 | * released. GNUNET_LOCKMANAGER_StatusCallback will not be called upon any |
146 | * status changes resulting due to this call. | ||
110 | * | 147 | * |
111 | * @param request the LockingRequest to cancel | 148 | * @param request the LockingRequest to cancel |
112 | */ | 149 | */ |
@@ -115,18 +152,6 @@ GNUNET_LOCKMANAGER_cancel_request (struct GNUNET_LOCKMANAGER_LockingRequest | |||
115 | *request); | 152 | *request); |
116 | 153 | ||
117 | 154 | ||
118 | /** | ||
119 | * Unlocks a lock which was locked by us. It does nothing when called on a lock | ||
120 | * which wasn't locked or was locked by someone else. | ||
121 | * | ||
122 | * @param handle the handle to the lockmanager service | ||
123 | * @param lock which lock to unlock | ||
124 | */ | ||
125 | void | ||
126 | GNUNET_LOCKMANAGER_unlock (const struct GNUNET_LOCKMANAGER_Handle *handle, | ||
127 | unsigned int lock); | ||
128 | |||
129 | |||
130 | #if 0 /* keep Emacsens' auto-indent happy */ | 155 | #if 0 /* keep Emacsens' auto-indent happy */ |
131 | { | 156 | { |
132 | #endif | 157 | #endif |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index e3f242ff2..db6b36d5a 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -1276,8 +1276,27 @@ extern "C" | |||
1276 | */ | 1276 | */ |
1277 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_START 430 | 1277 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_START 430 |
1278 | 1278 | ||
1279 | /******************************************************************************* | ||
1280 | * LOCKMANAGER message types | ||
1281 | ******************************************************************************/ | ||
1282 | |||
1283 | /** | ||
1284 | * Message to acquire Lock | ||
1285 | */ | ||
1286 | #define GNUNET_MESSAGE_TYPE_LOCKMANAGER_ACQUIRE 440 | ||
1287 | |||
1288 | /** | ||
1289 | * Message to release lock | ||
1290 | */ | ||
1291 | #define GNUNET_MESSAGE_TYPE_LOCKMANAGER_RELEASE 441 | ||
1292 | |||
1293 | /** | ||
1294 | * SUCESS reply from lockmanager | ||
1295 | */ | ||
1296 | #define GNUNET_MESSAGE_TYPE_LOCKMANAGER_SUCCESS 442 | ||
1297 | |||
1279 | /** | 1298 | /** |
1280 | * Next available: 440 | 1299 | * Next available: 450 |
1281 | */ | 1300 | */ |
1282 | 1301 | ||
1283 | /******************************************************************************* | 1302 | /******************************************************************************* |