diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-12-21 16:29:06 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-12-21 16:29:06 +0000 |
commit | 9c0883d6655ae2e3f1a303f59c9b5cfd448c43ca (patch) | |
tree | 6bc17de41f9b13d9ceb788fa8ad327faf56692a1 | |
parent | ca9385bded21d5cc87ed29e683cf9e3a69b4e27d (diff) | |
download | gnunet-9c0883d6655ae2e3f1a303f59c9b5cfd448c43ca.tar.gz gnunet-9c0883d6655ae2e3f1a303f59c9b5cfd448c43ca.zip |
remove disconnecting client from waitling lists of other locks
-rw-r--r-- | src/lockmanager/gnunet-service-lockmanager.c | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/src/lockmanager/gnunet-service-lockmanager.c b/src/lockmanager/gnunet-service-lockmanager.c index 56a9b6bc6..e509fc68f 100644 --- a/src/lockmanager/gnunet-service-lockmanager.c +++ b/src/lockmanager/gnunet-service-lockmanager.c | |||
@@ -595,7 +595,7 @@ handle_acquire (void *cls, struct GNUNET_SERVER_Client *client, | |||
595 | { | 595 | { |
596 | if (lock->cl_entry == cl_entry) | 596 | if (lock->cl_entry == cl_entry) |
597 | { /* Client is requesting a lock it already owns */ | 597 | { /* Client is requesting a lock it already owns */ |
598 | GNUNET_break (0); | 598 | GNUNET_break_op (0); |
599 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 599 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
600 | return; | 600 | return; |
601 | } | 601 | } |
@@ -718,32 +718,6 @@ handle_release (void *cls, struct GNUNET_SERVER_Client *client, | |||
718 | } | 718 | } |
719 | 719 | ||
720 | 720 | ||
721 | static int | ||
722 | stop_lock_attempt (void *cls, | ||
723 | const struct GNUNET_HashCode *key, | ||
724 | void *value) | ||
725 | { | ||
726 | struct ClientList *cl_entry = cls; | ||
727 | struct Lock *lock = value; | ||
728 | struct WaitList *wl; | ||
729 | struct WaitList *next; | ||
730 | |||
731 | next = lock->wl_head; | ||
732 | while (NULL != (wl = next)) | ||
733 | { | ||
734 | next = wl->next; | ||
735 | if (wl->cl_entry == cl_entry) | ||
736 | { | ||
737 | GNUNET_CONTAINER_DLL_remove (lock->wl_head, | ||
738 | lock->wl_tail, | ||
739 | wl); | ||
740 | GNUNET_free (wl); | ||
741 | } | ||
742 | } | ||
743 | return GNUNET_OK; | ||
744 | } | ||
745 | |||
746 | |||
747 | /** | 721 | /** |
748 | * Callback for client disconnect | 722 | * Callback for client disconnect |
749 | * | 723 | * |
@@ -756,6 +730,7 @@ client_disconnect_cb (void *cls, struct GNUNET_SERVER_Client *client) | |||
756 | struct ClientList *cl_entry; | 730 | struct ClientList *cl_entry; |
757 | struct LockList *ll_entry; | 731 | struct LockList *ll_entry; |
758 | struct Lock *lock; | 732 | struct Lock *lock; |
733 | struct WaitList *wl_entry; | ||
759 | 734 | ||
760 | if (NULL == client) | 735 | if (NULL == client) |
761 | return; | 736 | return; |
@@ -768,11 +743,15 @@ client_disconnect_cb (void *cls, struct GNUNET_SERVER_Client *client) | |||
768 | { | 743 | { |
769 | lock = ll_entry->lock; | 744 | lock = ll_entry->lock; |
770 | cl_ll_remove_lock (cl_entry, ll_entry); | 745 | cl_ll_remove_lock (cl_entry, ll_entry); |
771 | process_lock_release (lock); | 746 | if (lock->cl_entry == cl_entry) |
747 | process_lock_release (lock); | ||
748 | else | ||
749 | { | ||
750 | wl_entry = lock_wl_find (lock, cl_entry); | ||
751 | GNUNET_assert (NULL != wl_entry); | ||
752 | lock_wl_remove (lock, wl_entry); | ||
753 | } | ||
772 | } | 754 | } |
773 | GNUNET_CONTAINER_multihashmap_iterate (lock_map, | ||
774 | &stop_lock_attempt, | ||
775 | cl_entry); | ||
776 | cl_remove_client (cl_entry); | 755 | cl_remove_client (cl_entry); |
777 | } | 756 | } |
778 | 757 | ||