[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23535 - gnunet/src/lockmanager
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23535 - gnunet/src/lockmanager |
Date: |
Fri, 31 Aug 2012 13:07:37 +0200 |
Author: harsha
Date: 2012-08-31 13:07:36 +0200 (Fri, 31 Aug 2012)
New Revision: 23535
Modified:
gnunet/src/lockmanager/gnunet-service-lockmanager.c
gnunet/src/lockmanager/lockmanager_api.c
gnunet/src/lockmanager/test_lockmanager_api.c
gnunet/src/lockmanager/test_lockmanager_api_acquireretry.c
gnunet/src/lockmanager/test_lockmanager_api_lockrelease.c
gnunet/src/lockmanager/test_lockmanager_api_servercrash.c
Log:
indentation standard
Modified: gnunet/src/lockmanager/gnunet-service-lockmanager.c
===================================================================
--- gnunet/src/lockmanager/gnunet-service-lockmanager.c 2012-08-31 11:03:24 UTC
(rev 23534)
+++ gnunet/src/lockmanager/gnunet-service-lockmanager.c 2012-08-31 11:07:36 UTC
(rev 23535)
@@ -58,7 +58,7 @@
* The next client structure
*/
struct WaitList *next;
-
+
/**
* The prev client structure
*/
@@ -204,15 +204,12 @@
* @param key set to the key
*/
static void
-get_key (const char *domain_name,
- uint32_t lock_number,
- struct GNUNET_HashCode *key)
+get_key (const char *domain_name, uint32_t lock_number,
+ struct GNUNET_HashCode *key)
{
uint32_t *last_32;
- GNUNET_CRYPTO_hash (domain_name,
- strlen (domain_name),
- key);
+ GNUNET_CRYPTO_hash (domain_name, strlen (domain_name), key);
last_32 = (uint32_t *) key;
*last_32 ^= lock_number;
}
@@ -226,7 +223,7 @@
* @param value value in the hash map (struct Lock)
* @return GNUNET_YES if we should continue to
* iterate,
- * GNUNET_NO if not.
+ * GNUNET_NO if not.
*/
static int
match_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
@@ -234,10 +231,10 @@
struct LockMatch *match = cls;
struct Lock *lock = value;
- if ( (match->lock_num == lock->lock_num)
- && (0 == strcmp (match->domain_name, lock->domain_name)) )
+ if ((match->lock_num == lock->lock_num) &&
+ (0 == strcmp (match->domain_name, lock->domain_name)))
{
- match->matched_entry = lock;
+ match->matched_entry = lock;
return GNUNET_NO;
}
return GNUNET_YES;
@@ -252,9 +249,7 @@
* @return the lock if found; NULL if not
*/
static struct Lock *
-find_lock (const char *domain_name,
- const uint32_t lock_num)
-
+find_lock (const char *domain_name, const uint32_t lock_num)
{
struct LockMatch match;
struct GNUNET_HashCode key;
@@ -263,9 +258,7 @@
match.domain_name = domain_name;
match.matched_entry = NULL;
get_key (domain_name, lock_num, &key);
- GNUNET_CONTAINER_multihashmap_get_multiple (lock_map,
- &key,
- &match_iterator,
+ GNUNET_CONTAINER_multihashmap_get_multiple (lock_map, &key, &match_iterator,
&match);
return match.matched_entry;
}
@@ -279,8 +272,7 @@
* @return pointer to the lock structure which is added to lock map
*/
static struct Lock *
-add_lock (const char *domain_name,
- uint32_t lock_num)
+add_lock (const char *domain_name, uint32_t lock_num)
{
struct Lock *lock;
struct GNUNET_HashCode key;
@@ -295,9 +287,7 @@
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Adding a lock with num: %d and domain: %s to the lock map\n",
lock->lock_num, lock->domain_name);
- GNUNET_CONTAINER_multihashmap_put (lock_map,
- &key,
- lock,
+ GNUNET_CONTAINER_multihashmap_put (lock_map, &key, lock,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
return lock;
}
@@ -312,16 +302,14 @@
remove_lock (struct Lock *lock)
{
struct GNUNET_HashCode key;
-
+
GNUNET_assert (NULL == lock->wl_head);
- get_key (lock->domain_name,
- lock->lock_num,
- &key);
+ get_key (lock->domain_name, lock->lock_num, &key);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Removing lock with num: %u, domain: %s from lock map\n",
- lock->lock_num, lock->domain_name);
- GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove
- (lock_map, &key, lock));
+ "Removing lock with num: %u, domain: %s from lock map\n",
lock->lock_num,
+ lock->domain_name);
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (lock_map, &key, lock));
GNUNET_free (lock->domain_name);
GNUNET_free (lock);
}
@@ -336,13 +324,12 @@
* @return the matching LockList entry; NULL if no match is found
*/
static struct LockList *
-cl_ll_find_lock (struct ClientList *cl_entry,
- const struct Lock *lock)
+cl_ll_find_lock (struct ClientList *cl_entry, const struct Lock *lock)
{
struct LockList *ll_entry;
- for (ll_entry = cl_entry->ll_head;
- NULL != ll_entry; ll_entry = ll_entry->next)
+ for (ll_entry = cl_entry->ll_head; NULL != ll_entry;
+ ll_entry = ll_entry->next)
{
if (lock == ll_entry->lock)
return ll_entry;
@@ -358,8 +345,7 @@
* @param lock the lock to be added to the cl_entry's lock list
*/
static void
-cl_ll_add_lock (struct ClientList *cl_entry,
- struct Lock *lock)
+cl_ll_add_lock (struct ClientList *cl_entry, struct Lock *lock)
{
struct LockList *ll_entry;
@@ -368,8 +354,7 @@
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Adding a lock with num: %u and domain: %s to lock list\n",
lock->lock_num, lock->domain_name);
- GNUNET_CONTAINER_DLL_insert_tail (cl_entry->ll_head,
- cl_entry->ll_tail,
+ GNUNET_CONTAINER_DLL_insert_tail (cl_entry->ll_head, cl_entry->ll_tail,
ll_entry);
}
@@ -381,17 +366,13 @@
* @param ll_entry the LockList entry to be deleted
*/
static void
-cl_ll_remove_lock (struct ClientList *cl_entry,
- struct LockList *ll_entry)
+cl_ll_remove_lock (struct ClientList *cl_entry, struct LockList *ll_entry)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Removing lock with num: %u, domain: %s from lock list of a client\n",
- ll_entry->lock->lock_num,
- ll_entry->lock->domain_name);
+ ll_entry->lock->lock_num, ll_entry->lock->domain_name);
GNUNET_assert (NULL != cl_entry->ll_head);
- GNUNET_CONTAINER_DLL_remove (cl_entry->ll_head,
- cl_entry->ll_tail,
- ll_entry);
+ GNUNET_CONTAINER_DLL_remove (cl_entry->ll_head, cl_entry->ll_tail, ll_entry);
GNUNET_free (ll_entry);
}
@@ -405,14 +386,11 @@
* was found
*/
static struct WaitList *
-lock_wl_find (const struct Lock *lock,
- const struct ClientList *cl_entry)
+lock_wl_find (const struct Lock *lock, const struct ClientList *cl_entry)
{
struct WaitList *wl_entry;
- for (wl_entry = lock->wl_head;
- NULL != wl_entry;
- wl_entry = wl_entry->next)
+ for (wl_entry = lock->wl_head; NULL != wl_entry; wl_entry = wl_entry->next)
{
if (cl_entry == wl_entry->cl_entry)
return wl_entry;
@@ -428,20 +406,16 @@
* @param cl_entry the client to queue for the lock's wait list
*/
static void
-lock_wl_add_client (struct Lock *lock,
- struct ClientList *cl_entry)
+lock_wl_add_client (struct Lock *lock, struct ClientList *cl_entry)
{
struct WaitList *wl_entry;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Adding a client to lock's wait list (lock num: %u, domain: %s)\n",
- lock->lock_num,
- lock->domain_name);
+ lock->lock_num, lock->domain_name);
wl_entry = GNUNET_malloc (sizeof (struct WaitList));
wl_entry->cl_entry = cl_entry;
- GNUNET_CONTAINER_DLL_insert_tail (lock->wl_head,
- lock->wl_tail,
- wl_entry);
+ GNUNET_CONTAINER_DLL_insert_tail (lock->wl_head, lock->wl_tail, wl_entry);
}
@@ -452,15 +426,12 @@
* @param wl_entry the wait list entry to be removed
*/
static void
-lock_wl_remove (struct Lock *lock,
- struct WaitList *wl_entry)
+lock_wl_remove (struct Lock *lock, struct WaitList *wl_entry)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Removing client from wait list of lock with num: %u, domain: %s\n",
lock->lock_num, lock->domain_name);
- GNUNET_CONTAINER_DLL_remove (lock->wl_head,
- lock->wl_tail,
- wl_entry);
+ GNUNET_CONTAINER_DLL_remove (lock->wl_head, lock->wl_tail, wl_entry);
GNUNET_free (wl_entry);
}
@@ -472,7 +443,7 @@
* @return the ClientList entry; NULL if the client is not found
*/
static struct ClientList *
-cl_find_client (const struct GNUNET_SERVER_Client *client)
+cl_find_client (const struct GNUNET_SERVER_Client *client)
{
struct ClientList *current;
@@ -493,15 +464,12 @@
cl_add_client (struct GNUNET_SERVER_Client *client)
{
struct ClientList *new_client;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Adding a client to the client list\n");
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding a client to the client list\n");
new_client = GNUNET_malloc (sizeof (struct ClientList));
GNUNET_SERVER_client_keep (client);
new_client->client = client;
- GNUNET_CONTAINER_DLL_insert_tail (cl_head,
- cl_tail,
- new_client);
+ GNUNET_CONTAINER_DLL_insert_tail (cl_head, cl_tail, new_client);
return new_client;
}
@@ -515,12 +483,9 @@
cl_remove_client (struct ClientList *cl_entry)
{
GNUNET_assert (NULL == cl_entry->ll_head);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Removing a client from the client list\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Removing a client from the client list\n");
GNUNET_SERVER_client_drop (cl_entry->client);
- GNUNET_CONTAINER_DLL_remove (cl_head,
- cl_tail,
- cl_entry);
+ GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl_entry);
GNUNET_free (cl_entry);
}
@@ -533,7 +498,7 @@
* @param buf where the callee should write the message
* @return number of bytes written to buf
*/
-static size_t
+static size_t
transmit_notify (void *cls, size_t size, void *buf)
{
struct GNUNET_LOCKMANAGER_Message *msg = cls;
@@ -548,8 +513,7 @@
GNUNET_assert (size >= msg_size);
memcpy (buf, msg, msg_size);
GNUNET_free (msg);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Message of size %u sent\n", msg_size);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Message of size %u sent\n", msg_size);
return msg_size;
}
@@ -562,8 +526,7 @@
* @param lock_num the number of the successfully acquired lock
*/
static void
-send_success_msg (struct GNUNET_SERVER_Client *client,
- const char *domain_name,
+send_success_msg (struct GNUNET_SERVER_Client *client, const char *domain_name,
int lock_num)
{
struct GNUNET_LOCKMANAGER_Message *reply;
@@ -578,13 +541,10 @@
reply->lock = htonl (lock_num);
strncpy ((char *) &reply[1], domain_name, domain_name_len);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Sending SUCCESS message for lock with num: %u, domain: %s\n",
- lock_num, domain_name);
- GNUNET_SERVER_notify_transmit_ready (client,
- reply_size,
- TIMEOUT,
- &transmit_notify,
- reply);
+ "Sending SUCCESS message for lock with num: %u, domain: %s\n", lock_num,
+ domain_name);
+ GNUNET_SERVER_notify_transmit_ready (client, reply_size, TIMEOUT,
+ &transmit_notify, reply);
}
@@ -596,8 +556,7 @@
* @param message GNUNET_MESSAGE_TYPE_LOCKMANAGER_ACQUIRE message
*/
static void
-handle_acquire (void *cls,
- struct GNUNET_SERVER_Client *client,
+handle_acquire (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_LOCKMANAGER_Message *request;
@@ -625,14 +584,14 @@
}
lock_num = ntohl (request->lock);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received an ACQUIRE message for lock num: %u domain: %s\n",
- lock_num, domain_name);
- if (NULL == (cl_entry = cl_find_client (client)))
- cl_entry = cl_add_client (client); /* Add client if not in client list */
- if (NULL != (lock = find_lock (domain_name,lock_num)))
+ "Received an ACQUIRE message for lock num: %u domain: %s\n", lock_num,
+ domain_name);
+ if (NULL == (cl_entry = cl_find_client (client)))
+ cl_entry = cl_add_client (client); /* Add client if not in client list */
+ if (NULL != (lock = find_lock (domain_name, lock_num)))
{
if (lock->cl_entry == cl_entry)
- { /* Client is requesting a lock it already owns */
+ { /* Client is requesting a lock it already owns
*/
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
@@ -669,16 +628,13 @@
wl_entry = lock->wl_head;
if (NULL == wl_entry)
{
- remove_lock (lock); /* No clients waiting for this lock - delete */
+ remove_lock (lock); /* No clients waiting for this lock - delete */
return;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Giving lock to a client from wait list\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Giving lock to a client from wait list\n");
lock->cl_entry = wl_entry->cl_entry;
- lock_wl_remove(lock, wl_entry);
- send_success_msg (lock->cl_entry->client,
- lock->domain_name,
- lock->lock_num);
+ lock_wl_remove (lock, wl_entry);
+ send_success_msg (lock->cl_entry->client, lock->domain_name, lock->lock_num);
return;
}
@@ -691,8 +647,7 @@
* @param message the LOCKMANAGER_RELEASE message
*/
static void
-handle_release (void *cls,
- struct GNUNET_SERVER_Client *client,
+handle_release (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_LOCKMANAGER_Message *request;
@@ -706,7 +661,7 @@
msize = ntohs (message->size);
if (msize <= sizeof (struct GNUNET_LOCKMANAGER_Message))
- {
+ {
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
@@ -714,27 +669,27 @@
request = (const struct GNUNET_LOCKMANAGER_Message *) message;
domain_name = (const char *) &request[1];
msize -= sizeof (struct GNUNET_LOCKMANAGER_Message);
- if ('\0' != domain_name[msize-1])
+ if ('\0' != domain_name[msize - 1])
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
-
+
}
lock_num = ntohl (request->lock);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received RELEASE message for lock with num: %d, domain: %s\n",
- lock_num, domain_name);
+ "Received RELEASE message for lock with num: %d, domain: %s\n",
lock_num,
+ domain_name);
if (NULL == (cl_entry = cl_find_client (client)))
{
- GNUNET_break(0);
+ GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
lock = find_lock (domain_name, lock_num);
- if(NULL == lock)
- {
+ if (NULL == lock)
+ {
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
@@ -777,7 +732,7 @@
if (NULL == client)
return;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "A client has been disconnected -- freeing its locks and resources\n");
+ "A client has been disconnected -- freeing its locks and resources\n");
cl_entry = cl_find_client (client);
if (NULL == cl_entry)
return;
@@ -801,10 +756,8 @@
* iterate,
* GNUNET_NO if not.
*/
-static int
-lock_delete_iterator (void *cls,
- const struct GNUNET_HashCode * key,
- void *value)
+static int
+lock_delete_iterator (void *cls, const struct GNUNET_HashCode *key, void
*value)
{
struct Lock *lock = value;
@@ -813,10 +766,8 @@
{
lock_wl_remove (lock, lock->wl_head);
}
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove(lock_map,
- key,
- lock));
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (lock_map, key, lock));
GNUNET_free (lock->domain_name);
GNUNET_free (lock);
return GNUNET_YES;
@@ -830,24 +781,20 @@
* @param tc the TaskContext from scheduler
*/
static void
-shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Shutting down lock manager\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down lock manager\n");
/* Clean the global ClientList */
while (NULL != cl_head)
{
- while (NULL != cl_head->ll_head) /* Clear the LockList */
+ while (NULL != cl_head->ll_head) /* Clear the LockList */
{
cl_ll_remove_lock (cl_head, cl_head->ll_head);
}
cl_remove_client (cl_head);
}
/* Clean the global hash table */
- GNUNET_CONTAINER_multihashmap_iterate (lock_map,
- &lock_delete_iterator,
- NULL);
+ GNUNET_CONTAINER_multihashmap_iterate (lock_map, &lock_delete_iterator,
NULL);
GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (lock_map));
GNUNET_CONTAINER_multihashmap_destroy (lock_map);
}
@@ -860,25 +807,19 @@
* @param server the initialized server
* @param cfg configuration to use
*/
-static void
-lockmanager_run (void *cls,
- struct GNUNET_SERVER_Handle * server,
+static void
+lockmanager_run (void *cls, struct GNUNET_SERVER_Handle *server,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- static const struct GNUNET_SERVER_MessageHandler message_handlers[] =
- {
- {&handle_acquire, NULL, GNUNET_MESSAGE_TYPE_LOCKMANAGER_ACQUIRE, 0},
- {&handle_release, NULL, GNUNET_MESSAGE_TYPE_LOCKMANAGER_RELEASE, 0},
- {NULL}
- };
- GNUNET_SERVER_add_handlers (server,
- message_handlers);
- GNUNET_SERVER_disconnect_notify (server,
- &client_disconnect_cb,
- NULL);
+ static const struct GNUNET_SERVER_MessageHandler message_handlers[] = {
+ {&handle_acquire, NULL, GNUNET_MESSAGE_TYPE_LOCKMANAGER_ACQUIRE, 0},
+ {&handle_release, NULL, GNUNET_MESSAGE_TYPE_LOCKMANAGER_RELEASE, 0},
+ {NULL}
+ };
+ GNUNET_SERVER_add_handlers (server, message_handlers);
+ GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL);
lock_map = GNUNET_CONTAINER_multihashmap_create (30);
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &shutdown_task,
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
NULL);
}
@@ -886,16 +827,13 @@
/**
* The starting point of execution
*/
-int main (int argc, char *const *argv)
+int
+main (int argc, char *const *argv)
{
- return
- (GNUNET_OK ==
- GNUNET_SERVICE_run (argc,
- argv,
- "lockmanager",
- GNUNET_SERVICE_OPTION_NONE,
- &lockmanager_run,
- NULL)) ? 0 : 1;
+ return (GNUNET_OK ==
+ GNUNET_SERVICE_run (argc, argv, "lockmanager",
+ GNUNET_SERVICE_OPTION_NONE, &lockmanager_run,
+ NULL)) ? 0 : 1;
}
/* end of gnunet-service-lockmanager.c */
Modified: gnunet/src/lockmanager/lockmanager_api.c
===================================================================
--- gnunet/src/lockmanager/lockmanager_api.c 2012-08-31 11:03:24 UTC (rev
23534)
+++ gnunet/src/lockmanager/lockmanager_api.c 2012-08-31 11:07:36 UTC (rev
23535)
@@ -58,7 +58,7 @@
* The prev pointer for doubly linked list
*/
struct MessageQueue *prev;
-
+
/**
* The LOCKMANAGER Message
*/
@@ -139,7 +139,7 @@
* The locking domain of this request
*/
char *domain;
-
+
/**
* The lock
*/
@@ -149,7 +149,7 @@
* The status of the lock
*/
enum GNUNET_LOCKMANAGER_Status status;
-
+
/**
* set to GNUNET_YES if acquire message for this lock is till in messga queue
*/
@@ -185,9 +185,8 @@
* @param cls the LOCKMANAGER_Handle
* @param msg received message, NULL on timeout or fatal error
*/
-static void
-handle_replies (void *cls,
- const struct GNUNET_MessageHeader *msg);
+static void
+handle_replies (void *cls, const struct GNUNET_MessageHeader *msg);
/**
@@ -198,7 +197,7 @@
* @param buf where the callee should write the message
* @return number of bytes written to buf
*/
-static size_t
+static size_t
transmit_notify (void *cls, size_t size, void *buf)
{
struct GNUNET_LOCKMANAGER_Handle *handle = cls;
@@ -211,50 +210,42 @@
if ((0 == size) || (NULL == buf))
{
handle->transmit_handle =
- GNUNET_CLIENT_notify_transmit_ready (handle->conn,
- ntohs
- (queue_entity->msg->header.size),
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_YES,
- &transmit_notify,
- handle);
+ GNUNET_CLIENT_notify_transmit_ready (handle->conn,
+ ntohs (queue_entity->msg->
+ header.size),
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_YES, &transmit_notify,
+ handle);
return 0;
- }
+ }
msg_size = ntohs (queue_entity->msg->header.size);
GNUNET_assert (size >= msg_size);
memcpy (buf, queue_entity->msg, msg_size);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Message of size %u sent\n", msg_size);
- if (GNUNET_MESSAGE_TYPE_LOCKMANAGER_ACQUIRE
- == ntohs (queue_entity->msg->header.type))
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Message of size %u sent\n", msg_size);
+ if (GNUNET_MESSAGE_TYPE_LOCKMANAGER_ACQUIRE ==
+ ntohs (queue_entity->msg->header.type))
{
GNUNET_break (GNUNET_NO == queue_entity->lr->acquire_sent);
queue_entity->lr->acquire_sent = GNUNET_YES;
queue_entity->lr->mqe = NULL;
}
- GNUNET_free (queue_entity->msg);
- GNUNET_CONTAINER_DLL_remove (handle->mq_head,
- handle->mq_tail,
- queue_entity);
+ GNUNET_free (queue_entity->msg);
+ GNUNET_CONTAINER_DLL_remove (handle->mq_head, handle->mq_tail, queue_entity);
GNUNET_free (queue_entity);
queue_entity = handle->mq_head;
if (NULL != queue_entity)
{
handle->transmit_handle =
- GNUNET_CLIENT_notify_transmit_ready (handle->conn,
- ntohs
- (queue_entity->msg->header.size),
- TIMEOUT,
- GNUNET_YES,
- &transmit_notify,
- handle);
+ GNUNET_CLIENT_notify_transmit_ready (handle->conn,
+ ntohs (queue_entity->msg->
+ header.size), TIMEOUT,
+ GNUNET_YES, &transmit_notify,
+ handle);
}
if (GNUNET_NO == handle->in_replies)
{
handle->in_replies = GNUNET_YES;
- GNUNET_CLIENT_receive (handle->conn,
- &handle_replies,
- handle,
+ GNUNET_CLIENT_receive (handle->conn, &handle_replies, handle,
GNUNET_TIME_UNIT_FOREVER_REL);
}
return msg_size;
@@ -280,18 +271,15 @@
queue_entity = GNUNET_malloc (sizeof (struct MessageQueue));
queue_entity->msg = msg;
queue_entity->lr = request;
- GNUNET_CONTAINER_DLL_insert_tail (handle->mq_head,
- handle->mq_tail,
+ GNUNET_CONTAINER_DLL_insert_tail (handle->mq_head, handle->mq_tail,
queue_entity);
if (NULL == handle->transmit_handle)
{
handle->transmit_handle =
- GNUNET_CLIENT_notify_transmit_ready (handle->conn,
- ntohs (msg->header.size),
- TIMEOUT,
- GNUNET_YES,
- &transmit_notify,
- handle);
+ GNUNET_CLIENT_notify_transmit_ready (handle->conn,
+ ntohs (msg->header.size), TIMEOUT,
+ GNUNET_YES, &transmit_notify,
+ handle);
}
return queue_entity;
}
@@ -305,15 +293,12 @@
* @param key set to the key
*/
static void
-get_key (const char *domain_name,
- uint32_t lock_number,
- struct GNUNET_HashCode *key)
+get_key (const char *domain_name, uint32_t lock_number,
+ struct GNUNET_HashCode *key)
{
uint32_t *last_32;
- GNUNET_CRYPTO_hash (domain_name,
- strlen (domain_name),
- key);
+ GNUNET_CRYPTO_hash (domain_name, strlen (domain_name), key);
last_32 = (uint32_t *) key;
*last_32 ^= lock_number;
}
@@ -327,7 +312,7 @@
* @param value value in the hash map (struct
GNUNET_LOCKMANAGER_LockingRequest)
* @return GNUNET_YES if we should continue to
* iterate,
- * GNUNET_NO if not.
+ * GNUNET_NO if not.
*/
static int
match_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
@@ -335,7 +320,7 @@
struct LockingRequestMatch *match = cls;
struct GNUNET_LOCKMANAGER_LockingRequest *lr = value;
- if ( (match->lock == lr->lock) && (0 == strcmp (match->domain, lr->domain)) )
+ if ((match->lock == lr->lock) && (0 == strcmp (match->domain, lr->domain)))
{
match->matched_entry = lr;
return GNUNET_NO;
@@ -352,12 +337,11 @@
* @param domain the locking domain name
* @param lock the lock number
* @return the found LockingRequest; NULL if a matching LockingRequest wasn't
- * found
+ * found
*/
static struct GNUNET_LOCKMANAGER_LockingRequest *
hashmap_find_lockingrequest (const struct GNUNET_CONTAINER_MultiHashMap *map,
- const char *domain,
- uint32_t lock)
+ const char *domain, uint32_t lock)
{
struct GNUNET_HashCode hash;
struct LockingRequestMatch lock_match;
@@ -366,9 +350,7 @@
lock_match.domain = domain;
lock_match.lock = lock;
get_key (domain, lock, &hash);
- GNUNET_CONTAINER_multihashmap_get_multiple (map,
- &hash,
- &match_iterator,
+ GNUNET_CONTAINER_multihashmap_get_multiple (map, &hash, &match_iterator,
&lock_match);
return lock_match.matched_entry;
}
@@ -390,10 +372,7 @@
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Calling status change for SUCCESS on lock num: %d, domain: %s\n",
r->lock, r->domain);
- r->status_cb (r->status_cb_cls,
- r->domain,
- r->lock,
- r->status);
+ r->status_cb (r->status_cb_cls, r->domain, r->lock, r->status);
}
}
@@ -410,8 +389,8 @@
{
struct GNUNET_LOCKMANAGER_Message *msg;
size_t domain_name_len;
- uint16_t msg_size;
-
+ uint16_t msg_size;
+
domain_name_len = strlen (domain_name) + 1;
msg_size = sizeof (struct GNUNET_LOCKMANAGER_Message) + domain_name_len;
msg = GNUNET_malloc (msg_size);
@@ -436,15 +415,14 @@
* GNUNET_NO if not.
*/
static int
-release_n_retry_iterator (void *cls,
- const struct GNUNET_HashCode * key,
+release_n_retry_iterator (void *cls, const struct GNUNET_HashCode *key,
void *value)
{
struct GNUNET_LOCKMANAGER_LockingRequest *r = value;
struct GNUNET_LOCKMANAGER_Handle *h = cls;
struct GNUNET_LOCKMANAGER_Message *msg;
- if (GNUNET_NO == r->acquire_sent) /* an acquire is still in queue */
+ if (GNUNET_NO == r->acquire_sent) /* an acquire is still in queue */
return GNUNET_YES;
r->acquire_sent = GNUNET_NO;
msg = generate_acquire_msg (r->domain, r->lock);
@@ -457,9 +435,7 @@
"Calling status change for RELEASE on lock num: %d, domain: %s\n",
r->lock, r->domain);
r->status = GNUNET_LOCKMANAGER_RELEASE;
- r->status_cb (r->status_cb_cls,
- r->domain,
- r->lock,
+ r->status_cb (r->status_cb_cls, r->domain, r->lock,
GNUNET_LOCKMANAGER_RELEASE);
}
return GNUNET_YES;
@@ -472,9 +448,8 @@
* @param cls the LOCKMANAGER_Handle
* @param msg received message, NULL on timeout or fatal error
*/
-static void
-handle_replies (void *cls,
- const struct GNUNET_MessageHeader *msg)
+static void
+handle_replies (void *cls, const struct GNUNET_MessageHeader *msg)
{
struct GNUNET_LOCKMANAGER_Handle *handle = cls;
const struct GNUNET_LOCKMANAGER_Message *m;
@@ -488,19 +463,16 @@
if (NULL == msg)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Lockmanager service not available or went down\n");
+ "Lockmanager service not available or went down\n");
/* Should release all locks and retry to acquire them */
GNUNET_CONTAINER_multihashmap_iterate (handle->hashmap,
- &release_n_retry_iterator,
- handle);
+ &release_n_retry_iterator, handle);
return;
}
handle->in_replies = GNUNET_YES;
- GNUNET_CLIENT_receive (handle->conn,
- &handle_replies,
- handle,
+ GNUNET_CLIENT_receive (handle->conn, &handle_replies, handle,
GNUNET_TIME_UNIT_FOREVER_REL);
- if (GNUNET_MESSAGE_TYPE_LOCKMANAGER_SUCCESS != ntohs(msg->type))
+ if (GNUNET_MESSAGE_TYPE_LOCKMANAGER_SUCCESS != ntohs (msg->type))
{
GNUNET_break (0);
return;
@@ -514,20 +486,18 @@
m = (const struct GNUNET_LOCKMANAGER_Message *) msg;
domain = (const char *) &m[1];
msize -= sizeof (struct GNUNET_LOCKMANAGER_Message);
- if ('\0' != domain[msize-1])
+ if ('\0' != domain[msize - 1])
{
GNUNET_break (0);
return;
}
lock = ntohl (m->lock);
- get_key (domain, lock, &hash);
+ get_key (domain, lock, &hash);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received SUCCESS message for lock: %d, domain %s\n",
- lock, domain);
- if (NULL == (lr = hashmap_find_lockingrequest (handle->hashmap,
- domain,
- lock)))
+ "Received SUCCESS message for lock: %d, domain %s\n", lock, domain);
+ if (NULL ==
+ (lr = hashmap_find_lockingrequest (handle->hashmap, domain, lock)))
{
GNUNET_break (0);
return;
@@ -538,11 +508,10 @@
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Changing status for lock: %d in domain: %s to SUCCESS\n",
- lr->lock, lr->domain);
+ "Changing status for lock: %d in domain: %s to SUCCESS\n", lr->lock,
+ lr->domain);
lr->status = GNUNET_LOCKMANAGER_SUCCESS;
- GNUNET_SCHEDULER_add_continuation (&call_status_cb_task,
- lr,
+ GNUNET_SCHEDULER_add_continuation (&call_status_cb_task, lr,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
}
@@ -558,19 +527,14 @@
* GNUNET_NO if not.
*/
static int
-free_iterator(void *cls,
- const struct GNUNET_HashCode * key,
- void *value)
+free_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
{
struct GNUNET_LOCKMANAGER_Handle *h = cls;
struct GNUNET_LOCKMANAGER_LockingRequest *r = value;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Clearing locking request\n");
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (h->hashmap,
- key,
- value));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Clearing locking request\n");
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (h->hashmap, key,
value));
GNUNET_free (r->domain);
GNUNET_free (r);
return GNUNET_YES;
@@ -602,14 +566,12 @@
GNUNET_free (h);
LOG (GNUNET_ERROR_TYPE_DEBUG, "%s() END\n", __func__);
return NULL;
- }
+ }
h->hashmap = GNUNET_CONTAINER_multihashmap_create (15);
GNUNET_assert (NULL != h->hashmap);
h->in_replies = GNUNET_YES;
- GNUNET_CLIENT_receive (h->conn,
- &handle_replies,
- h,
- GNUNET_TIME_UNIT_FOREVER_REL);
+ GNUNET_CLIENT_receive (h->conn, &handle_replies, h,
+ GNUNET_TIME_UNIT_FOREVER_REL);
LOG (GNUNET_ERROR_TYPE_DEBUG, "%s() END\n", __func__);
return h;
}
@@ -631,8 +593,7 @@
LOG (GNUNET_ERROR_TYPE_WARNING,
"Some locking requests are still present. Cancel them before "
"calling %s\n", __func__);
- GNUNET_CONTAINER_multihashmap_iterate (handle->hashmap,
- &free_iterator,
+ GNUNET_CONTAINER_multihashmap_iterate (handle->hashmap, &free_iterator,
handle);
}
GNUNET_CONTAINER_multihashmap_destroy (handle->hashmap);
@@ -644,9 +605,7 @@
head = handle->mq_head;
while (NULL != head)
{
- GNUNET_CONTAINER_DLL_remove (handle->mq_head,
- handle->mq_tail,
- head);
+ GNUNET_CONTAINER_DLL_remove (handle->mq_head, handle->mq_tail, head);
GNUNET_free (head->msg);
GNUNET_free (head);
head = handle->mq_head;
@@ -682,17 +641,15 @@
*/
struct GNUNET_LOCKMANAGER_LockingRequest *
GNUNET_LOCKMANAGER_acquire_lock (struct GNUNET_LOCKMANAGER_Handle *handle,
- const char *domain_name,
- uint32_t lock,
- GNUNET_LOCKMANAGER_StatusCallback
- status_cb,
+ const char *domain_name, uint32_t lock,
+ GNUNET_LOCKMANAGER_StatusCallback status_cb,
void *status_cb_cls)
{
struct GNUNET_LOCKMANAGER_LockingRequest *r;
struct GNUNET_LOCKMANAGER_Message *msg;
struct GNUNET_HashCode hash;
size_t domain_name_length;
-
+
LOG (GNUNET_ERROR_TYPE_DEBUG, "%s()\n", __func__);
r = GNUNET_malloc (sizeof (struct GNUNET_LOCKMANAGER_LockingRequest));
domain_name_length = strlen (domain_name) + 1;
@@ -705,14 +662,13 @@
r->acquire_sent = GNUNET_NO;
memcpy (r->domain, domain_name, domain_name_length);
msg = generate_acquire_msg (r->domain, r->lock);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Queueing ACQUIRE message\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Queueing ACQUIRE message\n");
r->mqe = queue_message (handle, msg, r);
get_key (r->domain, r->lock, &hash);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put (r->handle->hashmap,
- &hash,
- r,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONTAINER_multihashmap_put (r->handle->hashmap, &hash,
+ r,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
LOG (GNUNET_ERROR_TYPE_DEBUG, "%s() END\n", __func__);
return r;
}
@@ -739,16 +695,15 @@
if (GNUNET_NO == request->acquire_sent)
{
GNUNET_assert (NULL != request->mqe);
- if ((NULL != request->handle->transmit_handle)
- && (request->handle->mq_head == request->mqe))
+ if ((NULL != request->handle->transmit_handle) &&
+ (request->handle->mq_head == request->mqe))
{
- GNUNET_CLIENT_notify_transmit_ready_cancel
- (request->handle->transmit_handle);
+ GNUNET_CLIENT_notify_transmit_ready_cancel (request->
+ handle->transmit_handle);
request->handle->transmit_handle = NULL;
- }
+ }
GNUNET_CONTAINER_DLL_remove (request->handle->mq_head,
- request->handle->mq_tail,
- request->mqe);
+ request->handle->mq_tail, request->mqe);
GNUNET_free (request->mqe->msg);
GNUNET_free (request->mqe);
request->status = GNUNET_LOCKMANAGER_RELEASE;
@@ -756,8 +711,7 @@
if (GNUNET_LOCKMANAGER_SUCCESS == request->status)
{
domain_name_length = strlen (request->domain) + 1;
- msg_size = sizeof (struct GNUNET_LOCKMANAGER_Message)
- + domain_name_length;
+ msg_size = sizeof (struct GNUNET_LOCKMANAGER_Message) + domain_name_length;
msg = GNUNET_malloc (msg_size);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_LOCKMANAGER_RELEASE);
msg->header.size = htons (msg_size);
@@ -768,8 +722,8 @@
}
get_key (request->domain, request->lock, &hash);
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove
- (request->handle->hashmap, &hash, request));
+ GNUNET_CONTAINER_multihashmap_remove
(request->handle->hashmap,
+ &hash, request));
GNUNET_free (request->domain);
GNUNET_free (request);
LOG (GNUNET_ERROR_TYPE_DEBUG, "%s() END\n", __func__);
Modified: gnunet/src/lockmanager/test_lockmanager_api.c
===================================================================
--- gnunet/src/lockmanager/test_lockmanager_api.c 2012-08-31 11:03:24 UTC
(rev 23534)
+++ gnunet/src/lockmanager/test_lockmanager_api.c 2012-08-31 11:07:36 UTC
(rev 23535)
@@ -43,15 +43,15 @@
* Enumeration of testing steps
*/
enum Test
- {
- TEST_FAIL,
+{
+ TEST_FAIL,
- TEST_INIT,
+ TEST_INIT,
- LOCK1_ACQUIRE,
+ LOCK1_ACQUIRE,
- LOCK2_ACQUIRE
- };
+ LOCK2_ACQUIRE
+};
/**
@@ -94,10 +94,10 @@
do_shutdown (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
{
if (GNUNET_SCHEDULER_NO_TASK != abort_task_id)
- {
- GNUNET_SCHEDULER_cancel (abort_task_id);
- abort_task_id = GNUNET_SCHEDULER_NO_TASK;
- }
+ {
+ GNUNET_SCHEDULER_cancel (abort_task_id);
+ abort_task_id = GNUNET_SCHEDULER_NO_TASK;
+ }
if (NULL != request)
GNUNET_LOCKMANAGER_cancel_request (request);
if (NULL != request2)
@@ -127,22 +127,20 @@
*
* @param cls the closure from GNUNET_LOCKMANAGER_lock call
*
- * @param domain_name the locking domain of the lock
+ * @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
*/
-static void
-status_cb (void *cls,
- const char *domain_name,
- uint32_t lock,
+static void
+status_cb (void *cls, const char *domain_name, uint32_t lock,
enum GNUNET_LOCKMANAGER_Status status)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Status change callback called on lock: %d of domain: %s\n",
- lock, domain_name);
+ "Status change callback called on lock: %d of domain: %s\n", lock,
+ domain_name);
switch (result)
{
case LOCK1_ACQUIRE:
@@ -151,23 +149,19 @@
//GNUNET_LOCKMANAGER_cancel_request (request);
//request = NULL;
result = LOCK2_ACQUIRE;
- request2 = GNUNET_LOCKMANAGER_acquire_lock (handle,
- "GNUNET_LOCKMANAGER_TESTING",
- 100,
- &status_cb,
- NULL);
+ request2 =
+ GNUNET_LOCKMANAGER_acquire_lock (handle, "GNUNET_LOCKMANAGER_TESTING",
+ 100, &status_cb, NULL);
GNUNET_assert (NULL != request2);
break;
case LOCK2_ACQUIRE:
GNUNET_assert (GNUNET_LOCKMANAGER_SUCCESS == status);
GNUNET_assert (NULL != request);
- GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (1),
- &do_shutdown,
- NULL);
+ GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (1), &do_shutdown, NULL);
break;
default:
GNUNET_break (0);
- }
+ }
}
@@ -175,8 +169,7 @@
* Main point of test execution
*/
static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
+run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Peer *peer)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting test...\n");
@@ -184,26 +177,24 @@
handle = GNUNET_LOCKMANAGER_connect (config);
GNUNET_assert (NULL != handle);
result = LOCK1_ACQUIRE;
- request = GNUNET_LOCKMANAGER_acquire_lock (handle,
- "GNUNET_LOCKMANAGER_TESTING",
- 99,
- &status_cb,
- NULL);
- abort_task_id = GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (30),
- &do_abort,
- NULL);
+ request =
+ GNUNET_LOCKMANAGER_acquire_lock (handle, "GNUNET_LOCKMANAGER_TESTING",
99,
+ &status_cb, NULL);
+ abort_task_id =
+ GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (30), &do_abort, NULL);
}
/**
* Main function
*/
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- if (0 != GNUNET_TESTING_peer_run ("test_lockmanager_api",
- "test_lockmanager_api.conf",
- &run, NULL))
+ if (0 !=
+ GNUNET_TESTING_peer_run ("test_lockmanager_api",
+ "test_lockmanager_api.conf", &run, NULL))
return 1;
return (TEST_FAIL == result) ? 1 : 0;
}
Modified: gnunet/src/lockmanager/test_lockmanager_api_acquireretry.c
===================================================================
--- gnunet/src/lockmanager/test_lockmanager_api_acquireretry.c 2012-08-31
11:03:24 UTC (rev 23534)
+++ gnunet/src/lockmanager/test_lockmanager_api_acquireretry.c 2012-08-31
11:07:36 UTC (rev 23535)
@@ -46,32 +46,32 @@
* Various stages in test
*/
enum Test
- {
+{
/**
* Signal test failure
*/
- TEST_FAIL,
-
+ TEST_FAIL,
+
/**
* Testing just began
*/
- TEST_INIT,
-
+ TEST_INIT,
+
/**
* Client has successfully acquired the lock
*/
- TEST_CLIENT_LOCK_SUCCESS,
+ TEST_CLIENT_LOCK_SUCCESS,
/**
* Client has lost the lock
*/
- TEST_CLIENT_LOCK_RELEASE,
+ TEST_CLIENT_LOCK_RELEASE,
/**
* Client has again acquired the lock
*/
- TEST_CLIENT_LOCK_AGAIN_SUCCESS
- };
+ TEST_CLIENT_LOCK_AGAIN_SUCCESS
+};
/**
* Configuration Handle
@@ -143,22 +143,20 @@
*
* @param cls the handle
*
- * @param domain_name the locking domain of the lock
+ * @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
*/
-static void
-status_cb (void *cls,
- const char *domain_name,
- uint32_t lock,
+static void
+status_cb (void *cls, const char *domain_name, uint32_t lock,
enum GNUNET_LOCKMANAGER_Status status)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Status change callback called on lock: %d of domain: %s\n",
- lock, domain_name);
+ "Status change callback called on lock: %d of domain: %s\n", lock,
+ domain_name);
switch (result)
{
case TEST_INIT:
@@ -181,7 +179,7 @@
result = TEST_CLIENT_LOCK_AGAIN_SUCCESS;
GNUNET_LOCKMANAGER_cancel_request (request);
request = NULL;
- GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS(1), &do_shutdown, NULL);
+ GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (1), &do_shutdown, NULL);
break;
default:
GNUNET_assert (0); /* We should never reach here */
@@ -193,8 +191,7 @@
* Main point of test execution
*/
static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
+run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Peer *peer)
{
config = cfg;
@@ -202,26 +199,24 @@
result = TEST_INIT;
handle = GNUNET_LOCKMANAGER_connect (config);
GNUNET_assert (NULL != handle);
- request = GNUNET_LOCKMANAGER_acquire_lock (handle,
- "GNUNET_LOCKMANAGER_TESTING",
- 99,
- &status_cb,
- handle);
+ request =
+ GNUNET_LOCKMANAGER_acquire_lock (handle, "GNUNET_LOCKMANAGER_TESTING",
99,
+ &status_cb, handle);
GNUNET_assert (NULL != request);
- abort_task_id = GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (30),
- &do_abort,
- NULL);
+ abort_task_id =
+ GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (30), &do_abort, NULL);
}
/**
* Main function
*/
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- if (0 != GNUNET_TESTING_peer_run ("test_lockmanager_api_acquireretry",
- "test_lockmanager_api.conf",
- &run, NULL))
+ if (0 !=
+ GNUNET_TESTING_peer_run ("test_lockmanager_api_acquireretry",
+ "test_lockmanager_api.conf", &run, NULL))
return 1;
return (TEST_CLIENT_LOCK_AGAIN_SUCCESS != result) ? 1 : 0;
}
Modified: gnunet/src/lockmanager/test_lockmanager_api_lockrelease.c
===================================================================
--- gnunet/src/lockmanager/test_lockmanager_api_lockrelease.c 2012-08-31
11:03:24 UTC (rev 23534)
+++ gnunet/src/lockmanager/test_lockmanager_api_lockrelease.c 2012-08-31
11:07:36 UTC (rev 23535)
@@ -45,28 +45,28 @@
* Various steps of the test
*/
enum Test
- {
+{
/**
* Signal test failure
*/
- TEST_FAIL,
+ TEST_FAIL,
/**
* Testing just began
*/
- TEST_INIT,
+ TEST_INIT,
/**
* Client 1 has got the lock successfully; Client 2 should try to acquire
* the lock now; after some time client 1 has to release the lock
*/
- TEST_CLIENT1_LOCK_SUCCESS,
+ TEST_CLIENT1_LOCK_SUCCESS,
/**
* Client 2 has got the lock; Should release it and call shutdown
*/
- TEST_CLIENT2_LOCK_SUCCESS,
- };
+ TEST_CLIENT2_LOCK_SUCCESS,
+};
/**
* The testing result
@@ -117,7 +117,7 @@
{
GNUNET_SCHEDULER_cancel (abort_task_id);
abort_task_id = GNUNET_SCHEDULER_NO_TASK;
- }
+ }
GNUNET_LOCKMANAGER_disconnect (handle);
GNUNET_LOCKMANAGER_disconnect (handle2);
}
@@ -144,33 +144,29 @@
*
* @param cls the handle
*
- * @param domain_name the locking domain of the lock
+ * @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
*/
-static void
-status_cb (void *cls,
- const char *domain_name,
- uint32_t lock,
+static void
+status_cb (void *cls, const char *domain_name, uint32_t lock,
enum GNUNET_LOCKMANAGER_Status status)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Status change callback called on lock: %d of domain: %s\n",
- lock, domain_name);
+ "Status change callback called on lock: %d of domain: %s\n", lock,
+ domain_name);
GNUNET_assert (GNUNET_LOCKMANAGER_SUCCESS == status);
switch (result)
{
case TEST_INIT:
GNUNET_assert (handle == cls);
result = TEST_CLIENT1_LOCK_SUCCESS;
- request2 = GNUNET_LOCKMANAGER_acquire_lock (handle2,
- "GNUNET_LOCKMANAGER_TESTING",
- 99,
- &status_cb,
- handle2);
+ request2 =
+ GNUNET_LOCKMANAGER_acquire_lock (handle2, "GNUNET_LOCKMANAGER_TESTING",
+ 99, &status_cb, handle2);
GNUNET_assert (NULL != request2);
GNUNET_LOCKMANAGER_cancel_request (request);
request = NULL;
@@ -179,9 +175,7 @@
GNUNET_assert (handle2 == cls);
result = TEST_CLIENT2_LOCK_SUCCESS;
GNUNET_LOCKMANAGER_cancel_request (request2);
- GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (1),
- &do_shutdown,
- NULL);
+ GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (1), &do_shutdown, NULL);
break;
default:
GNUNET_assert (0); /* We should never reach here */
@@ -194,8 +188,7 @@
* Main point of test execution
*/
static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
+run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Peer *peer)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting test...\n");
@@ -204,27 +197,25 @@
handle = GNUNET_LOCKMANAGER_connect (config);
GNUNET_assert (NULL != handle);
handle2 = GNUNET_LOCKMANAGER_connect (config);
-
- request = GNUNET_LOCKMANAGER_acquire_lock (handle,
- "GNUNET_LOCKMANAGER_TESTING",
- 99,
- &status_cb,
- handle);
+
+ request =
+ GNUNET_LOCKMANAGER_acquire_lock (handle, "GNUNET_LOCKMANAGER_TESTING",
99,
+ &status_cb, handle);
GNUNET_assert (NULL != request);
- abort_task_id = GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (10),
- &do_abort,
- NULL);
+ abort_task_id =
+ GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (10), &do_abort, NULL);
}
/**
* Main function
*/
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- if (0 != GNUNET_TESTING_peer_run ("test_lockmanager_api_lockrelease",
- "test_lockmanager_api.conf",
- &run, NULL))
+ if (0 !=
+ GNUNET_TESTING_peer_run ("test_lockmanager_api_lockrelease",
+ "test_lockmanager_api.conf", &run, NULL))
return 1;
return (TEST_CLIENT2_LOCK_SUCCESS != result) ? 1 : 0;
}
Modified: gnunet/src/lockmanager/test_lockmanager_api_servercrash.c
===================================================================
--- gnunet/src/lockmanager/test_lockmanager_api_servercrash.c 2012-08-31
11:03:24 UTC (rev 23534)
+++ gnunet/src/lockmanager/test_lockmanager_api_servercrash.c 2012-08-31
11:07:36 UTC (rev 23535)
@@ -45,34 +45,34 @@
* Various steps of the test
*/
enum Test
- {
+{
/**
* Signal test failure
*/
- TEST_FAIL,
+ TEST_FAIL,
/**
* Testing just began
*/
- TEST_INIT,
+ TEST_INIT,
/**
* Client 1 has got the lock successfully; Client 2 should try to acquire
* the lock now; after some time client 1 has to release the lock
*/
- TEST_CLIENT1_LOCK_SUCCESS,
+ TEST_CLIENT1_LOCK_SUCCESS,
/**
* Client 2 has got the lock; Server should crash now;
*/
- TEST_CLIENT2_LOCK_SUCCESS,
+ TEST_CLIENT2_LOCK_SUCCESS,
/**
* Client 2 should get lock release due to server crash; Should call
* shutdown now
*/
- TEST_CLIENT2_SERVER_CRASH_SUCCESS
- };
+ TEST_CLIENT2_SERVER_CRASH_SUCCESS
+};
/**
* The testing result
@@ -157,33 +157,29 @@
*
* @param cls the handle
*
- * @param domain_name the locking domain of the lock
+ * @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
*/
-static void
-status_cb (void *cls,
- const char *domain_name,
- uint32_t lock,
+static void
+status_cb (void *cls, const char *domain_name, uint32_t lock,
enum GNUNET_LOCKMANAGER_Status status)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Status change callback called on lock: %d of domain: %s\n",
- lock, domain_name);
+ "Status change callback called on lock: %d of domain: %s\n", lock,
+ domain_name);
switch (result)
{
case TEST_INIT:
GNUNET_assert (handle == cls);
GNUNET_assert (GNUNET_LOCKMANAGER_SUCCESS == status);
result = TEST_CLIENT1_LOCK_SUCCESS;
- request2 = GNUNET_LOCKMANAGER_acquire_lock (handle2,
- "GNUNET_LOCKMANAGER_TESTING",
- 99,
- &status_cb,
- handle2);
+ request2 =
+ GNUNET_LOCKMANAGER_acquire_lock (handle2, "GNUNET_LOCKMANAGER_TESTING",
+ 99, &status_cb, handle2);
GNUNET_assert (NULL != request2);
GNUNET_LOCKMANAGER_cancel_request (request);
request = NULL;
@@ -203,9 +199,7 @@
result = TEST_CLIENT2_SERVER_CRASH_SUCCESS;
GNUNET_LOCKMANAGER_cancel_request (request2);
request2 = NULL;
- GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (1),
- &do_shutdown,
- NULL);
+ GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (1), &do_shutdown, NULL);
break;
default:
GNUNET_assert (0); /* We should never reach here */
@@ -217,8 +211,7 @@
* Main point of test execution
*/
static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
+run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Peer *peer)
{
config = cfg;
@@ -227,27 +220,25 @@
handle = GNUNET_LOCKMANAGER_connect (config);
GNUNET_assert (NULL != handle);
handle2 = GNUNET_LOCKMANAGER_connect (config);
-
- request = GNUNET_LOCKMANAGER_acquire_lock (handle,
- "GNUNET_LOCKMANAGER_TESTING",
- 99,
- &status_cb,
- handle);
+
+ request =
+ GNUNET_LOCKMANAGER_acquire_lock (handle, "GNUNET_LOCKMANAGER_TESTING",
99,
+ &status_cb, handle);
GNUNET_assert (NULL != request);
- abort_task_id = GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (10),
- &do_abort,
- NULL);
+ abort_task_id =
+ GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (10), &do_abort, NULL);
}
/**
* Main function
*/
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- if (0 != GNUNET_TESTING_peer_run ("test_lockmanager_api_servercrash",
- "test_lockmanager_api.conf",
- &run, NULL))
+ if (0 !=
+ GNUNET_TESTING_peer_run ("test_lockmanager_api_servercrash",
+ "test_lockmanager_api.conf", &run, NULL))
return 1;
return (TEST_CLIENT2_SERVER_CRASH_SUCCESS != result) ? 1 : 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23535 - gnunet/src/lockmanager,
gnunet <=