diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-13 21:01:22 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-13 21:01:22 +0000 |
commit | 0b66a17293953e905668cc5b5764068b65b9f4c1 (patch) | |
tree | 9ead8563d8e8d744553c81305997c34a9af1d9df | |
parent | f84a545ddf6cfb8b4cf59c9ef40117cd23d836b4 (diff) | |
download | gnunet-0b66a17293953e905668cc5b5764068b65b9f4c1.tar.gz gnunet-0b66a17293953e905668cc5b5764068b65b9f4c1.zip |
more client disconnect code
-rw-r--r-- | src/ats/gnunet-service-ats.c | 1 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_performance.c | 21 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_scheduling.c | 33 |
3 files changed, 48 insertions, 7 deletions
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c index 3e1a5e5ad..19a5d4380 100644 --- a/src/ats/gnunet-service-ats.c +++ b/src/ats/gnunet-service-ats.c | |||
@@ -60,7 +60,6 @@ handle_ats_start (void *cls, struct GNUNET_SERVER_Client *client, | |||
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | |||
64 | /** | 63 | /** |
65 | * A client disconnected from us. Tear down the local client | 64 | * A client disconnected from us. Tear down the local client |
66 | * record. | 65 | * record. |
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index fa60e4973..edad22512 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -48,6 +48,18 @@ static struct PerformanceClient *pc_head; | |||
48 | * Tail of linked list of all clients to this service. | 48 | * Tail of linked list of all clients to this service. |
49 | */ | 49 | */ |
50 | static struct PerformanceClient *pc_tail; | 50 | static struct PerformanceClient *pc_tail; |
51 | |||
52 | |||
53 | static struct PerformanceClient * | ||
54 | find_client (struct GNUNET_SERVER_Client *client) | ||
55 | { | ||
56 | struct PerformanceClient * pc; | ||
57 | |||
58 | for (pc = pc_head; pc != NULL; pc = pc->next) | ||
59 | if (pc->client == client) | ||
60 | return pc; | ||
61 | return NULL; | ||
62 | } | ||
51 | 63 | ||
52 | 64 | ||
53 | void | 65 | void |
@@ -55,6 +67,7 @@ GAS_add_performance_client (struct GNUNET_SERVER_Client *client) | |||
55 | { | 67 | { |
56 | struct PerformanceClient * pc; | 68 | struct PerformanceClient * pc; |
57 | 69 | ||
70 | GNUNET_break (NULL == find_client (client)); | ||
58 | pc = GNUNET_malloc (sizeof (struct PerformanceClient)); | 71 | pc = GNUNET_malloc (sizeof (struct PerformanceClient)); |
59 | pc->client = client; | 72 | pc->client = client; |
60 | GNUNET_CONTAINER_DLL_insert(pc_head, pc_tail, pc); | 73 | GNUNET_CONTAINER_DLL_insert(pc_head, pc_tail, pc); |
@@ -64,6 +77,14 @@ GAS_add_performance_client (struct GNUNET_SERVER_Client *client) | |||
64 | void | 77 | void |
65 | GAS_remove_performance_client (struct GNUNET_SERVER_Client *client) | 78 | GAS_remove_performance_client (struct GNUNET_SERVER_Client *client) |
66 | { | 79 | { |
80 | struct PerformanceClient * pc; | ||
81 | |||
82 | pc = find_client (client); | ||
83 | if (NULL == pc) | ||
84 | return; | ||
85 | GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc); | ||
86 | GNUNET_SERVER_client_drop (client); | ||
87 | GNUNET_free (pc); | ||
67 | } | 88 | } |
68 | 89 | ||
69 | 90 | ||
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c index 9400e12ff..bf2c6187a 100644 --- a/src/ats/gnunet-service-ats_scheduling.c +++ b/src/ats/gnunet-service-ats_scheduling.c | |||
@@ -42,29 +42,50 @@ struct SchedulingClient | |||
42 | /** | 42 | /** |
43 | * Head of linked list of all clients to this service. | 43 | * Head of linked list of all clients to this service. |
44 | */ | 44 | */ |
45 | static struct SchedulingClient *ac_head; | 45 | static struct SchedulingClient *sc_head; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Tail of linked list of all clients to this service. | 48 | * Tail of linked list of all clients to this service. |
49 | */ | 49 | */ |
50 | static struct SchedulingClient *ac_tail; | 50 | static struct SchedulingClient *sc_tail; |
51 | |||
52 | |||
53 | static struct SchedulingClient * | ||
54 | find_client (struct GNUNET_SERVER_Client *client) | ||
55 | { | ||
56 | struct SchedulingClient * sc; | ||
57 | |||
58 | for (sc = sc_head; sc != NULL; sc = sc->next) | ||
59 | if (sc->client == client) | ||
60 | return sc; | ||
61 | return NULL; | ||
62 | } | ||
51 | 63 | ||
52 | 64 | ||
53 | void | 65 | void |
54 | GAS_add_scheduling_client (struct GNUNET_SERVER_Client *client) | 66 | GAS_add_scheduling_client (struct GNUNET_SERVER_Client *client) |
55 | { | 67 | { |
56 | struct SchedulingClient *ac; | 68 | struct SchedulingClient *sc; |
57 | 69 | ||
58 | ac = GNUNET_malloc (sizeof (struct SchedulingClient)); | 70 | GNUNET_break (NULL == find_client (client)); |
59 | ac->client = client; | 71 | sc = GNUNET_malloc (sizeof (struct SchedulingClient)); |
72 | sc->client = client; | ||
60 | GNUNET_SERVER_client_keep (client); | 73 | GNUNET_SERVER_client_keep (client); |
61 | GNUNET_CONTAINER_DLL_insert(ac_head, ac_tail, ac); | 74 | GNUNET_CONTAINER_DLL_insert(sc_head, sc_tail, sc); |
62 | } | 75 | } |
63 | 76 | ||
64 | 77 | ||
65 | void | 78 | void |
66 | GAS_remove_scheduling_client (struct GNUNET_SERVER_Client *client) | 79 | GAS_remove_scheduling_client (struct GNUNET_SERVER_Client *client) |
67 | { | 80 | { |
81 | struct SchedulingClient * sc; | ||
82 | |||
83 | sc = find_client (client); | ||
84 | if (NULL == sc) | ||
85 | return; | ||
86 | GNUNET_CONTAINER_DLL_remove (sc_head, sc_tail, sc); | ||
87 | GNUNET_SERVER_client_drop (client); | ||
88 | GNUNET_free (sc); | ||
68 | } | 89 | } |
69 | 90 | ||
70 | 91 | ||