diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-08-26 11:42:39 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-08-26 11:42:39 +0000 |
commit | 07a8a7388c5e4bf6aa92f2e70d8c808ceb28174c (patch) | |
tree | e25db55af5d0346e34fd6b44714b835556cc641e /src/util | |
parent | b9d7efb884f57f888673ddd8499f36ed987d47bc (diff) | |
download | gnunet-07a8a7388c5e4bf6aa92f2e70d8c808ceb28174c.tar.gz gnunet-07a8a7388c5e4bf6aa92f2e70d8c808ceb28174c.zip |
changes to server lib
Added a unique ID to struct GNUNET_SERVER_Client to be able to distinguish between different clients
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/server.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/util/server.c b/src/util/server.c index 31d298e3a..ddbae4410 100644 --- a/src/util/server.c +++ b/src/util/server.c | |||
@@ -247,6 +247,11 @@ struct GNUNET_SERVER_Client | |||
247 | * Type of last message processed (for warn_no_receive_done). | 247 | * Type of last message processed (for warn_no_receive_done). |
248 | */ | 248 | */ |
249 | uint16_t warn_type; | 249 | uint16_t warn_type; |
250 | |||
251 | /** | ||
252 | * unique identifier to distinguish between clients | ||
253 | */ | ||
254 | uint64_t id; | ||
250 | }; | 255 | }; |
251 | 256 | ||
252 | 257 | ||
@@ -933,6 +938,18 @@ client_message_tokenizer_callback (void *cls, void *client, | |||
933 | 938 | ||
934 | 939 | ||
935 | /** | 940 | /** |
941 | * Get a unique identifier for each GNUNET_SERVER_Client | ||
942 | */ | ||
943 | static uint64_t | ||
944 | get_client_id (void) | ||
945 | { | ||
946 | static uint64_t id; | ||
947 | |||
948 | GNUNET_assert (id < ULONG_LONG_MAX); | ||
949 | return (id++); | ||
950 | } | ||
951 | |||
952 | /** | ||
936 | * Add a TCP socket-based connection to the set of handles managed by | 953 | * Add a TCP socket-based connection to the set of handles managed by |
937 | * this server. Use this function for outgoing (P2P) connections that | 954 | * this server. Use this function for outgoing (P2P) connections that |
938 | * we initiated (and where this server should process incoming | 955 | * we initiated (and where this server should process incoming |
@@ -963,6 +980,7 @@ GNUNET_SERVER_connect_socket (struct GNUNET_SERVER_Handle *server, | |||
963 | client->receive_pending = GNUNET_YES; | 980 | client->receive_pending = GNUNET_YES; |
964 | client->callback = NULL; | 981 | client->callback = NULL; |
965 | client->callback_cls = NULL; | 982 | client->callback_cls = NULL; |
983 | client->id = get_client_id (); | ||
966 | GNUNET_CONNECTION_receive (client->connection, | 984 | GNUNET_CONNECTION_receive (client->connection, |
967 | GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, | 985 | GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, |
968 | client->idle_timeout, &process_incoming, client); | 986 | client->idle_timeout, &process_incoming, client); |
@@ -1275,6 +1293,18 @@ GNUNET_SERVER_client_persist_ (struct GNUNET_SERVER_Client *client) | |||
1275 | 1293 | ||
1276 | 1294 | ||
1277 | /** | 1295 | /** |
1296 | * Retrieve the unique id from the opaque defined GNUNET_SERVER_Client | ||
1297 | * | ||
1298 | * @param client the client | ||
1299 | * @return the unique id | ||
1300 | */ | ||
1301 | uint64_t | ||
1302 | GNUNET_SERVER_client_get_id (struct GNUNET_SERVER_Client *client) | ||
1303 | { | ||
1304 | return client->id; | ||
1305 | } | ||
1306 | |||
1307 | /** | ||
1278 | * Resume receiving from this client, we are done processing the | 1308 | * Resume receiving from this client, we are done processing the |
1279 | * current request. This function must be called from within each | 1309 | * current request. This function must be called from within each |
1280 | * GNUNET_SERVER_MessageCallback (or its respective continuations). | 1310 | * GNUNET_SERVER_MessageCallback (or its respective continuations). |