aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-12-05 14:15:25 +0000
committerBart Polot <bart@net.in.tum.de>2013-12-05 14:15:25 +0000
commit44d957c38051c6e778595b74f4a831da8ad1a179 (patch)
tree235e33b27ba570e6e857f306ff4ed27791d21d14 /src/set
parentb83fc2e7baf2713881c1ff59971e6dbd4609e771 (diff)
downloadgnunet-44d957c38051c6e778595b74f4a831da8ad1a179.tar.gz
gnunet-44d957c38051c6e778595b74f4a831da8ad1a179.zip
- change mesh channel creation/notification API
Diffstat (limited to 'src/set')
-rw-r--r--src/set/gnunet-service-set.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index 749154010..27c8d3bc0 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -237,7 +237,7 @@ listener_destroy (struct Listener *listener)
237 * Collect and destroy elements that are not needed anymore, because 237 * Collect and destroy elements that are not needed anymore, because
238 * their lifetime (as determined by their generation) does not overlap with any active 238 * their lifetime (as determined by their generation) does not overlap with any active
239 * set operation. 239 * set operation.
240 * 240 *
241 * We hereby replace the old element hashmap with a new one, instead of removing elements. 241 * We hereby replace the old element hashmap with a new one, instead of removing elements.
242 */ 242 */
243void 243void
@@ -252,7 +252,7 @@ collect_generation_garbage (struct Set *set)
252 new_elements = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); 252 new_elements = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
253 iter = GNUNET_CONTAINER_multihashmap_iterator_create (set->elements); 253 iter = GNUNET_CONTAINER_multihashmap_iterator_create (set->elements);
254 while (GNUNET_OK == 254 while (GNUNET_OK ==
255 (res = GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, (const void **) &ee))) 255 (res = GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, (const void **) &ee)))
256 { 256 {
257 if (GNUNET_NO == ee->removed) 257 if (GNUNET_NO == ee->removed)
258 goto still_needed; 258 goto still_needed;
@@ -449,7 +449,7 @@ incoming_destroy (struct Operation *incoming)
449 449
450/** 450/**
451 * remove & free state of the operation from the incoming list 451 * remove & free state of the operation from the incoming list
452 * 452 *
453 * @param incoming the element to remove 453 * @param incoming the element to remove
454 */ 454 */
455 455
@@ -510,7 +510,7 @@ incoming_suggest (struct Operation *incoming, struct Listener *listener)
510 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != incoming->state->timeout_task); 510 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != incoming->state->timeout_task);
511 GNUNET_SCHEDULER_cancel (incoming->state->timeout_task); 511 GNUNET_SCHEDULER_cancel (incoming->state->timeout_task);
512 incoming->state->timeout_task = GNUNET_SCHEDULER_NO_TASK; 512 incoming->state->timeout_task = GNUNET_SCHEDULER_NO_TASK;
513 513
514 mqm = GNUNET_MQ_msg_nested_mh (cmsg, GNUNET_MESSAGE_TYPE_SET_REQUEST, 514 mqm = GNUNET_MQ_msg_nested_mh (cmsg, GNUNET_MESSAGE_TYPE_SET_REQUEST,
515 incoming->spec->context_msg); 515 incoming->spec->context_msg);
516 GNUNET_assert (NULL != mqm); 516 GNUNET_assert (NULL != mqm);
@@ -524,9 +524,9 @@ incoming_suggest (struct Operation *incoming, struct Listener *listener)
524 524
525/** 525/**
526 * Handle a request for a set operation from 526 * Handle a request for a set operation from
527 * another peer. 527 * another peer.
528 * 528 *
529 * This msg is expected as the first and only msg handled through the 529 * This msg is expected as the first and only msg handled through the
530 * non-operation bound virtual table, acceptance of this operation replaces 530 * non-operation bound virtual table, acceptance of this operation replaces
531 * our virtual table and subsequent msgs would be routed differently. 531 * our virtual table and subsequent msgs would be routed differently.
532 * 532 *
@@ -685,7 +685,7 @@ handle_client_create_set (void *cls,
685 ntohs (msg->operation)); 685 ntohs (msg->operation));
686 686
687 // max. one set per client! 687 // max. one set per client!
688 if (NULL != set_get (client)) 688 if (NULL != set_get (client))
689 { 689 {
690 GNUNET_break (0); 690 GNUNET_break (0);
691 GNUNET_SERVER_client_disconnect (client); 691 GNUNET_SERVER_client_disconnect (client);
@@ -742,7 +742,7 @@ handle_client_listen (void *cls,
742 GNUNET_SERVER_client_disconnect (client); 742 GNUNET_SERVER_client_disconnect (client);
743 return; 743 return;
744 } 744 }
745 745
746 listener = GNUNET_new (struct Listener); 746 listener = GNUNET_new (struct Listener);
747 listener->client = client; 747 listener->client = client;
748 listener->client_mq = GNUNET_MQ_queue_for_server_client (client); 748 listener->client_mq = GNUNET_MQ_queue_for_server_client (client);
@@ -751,7 +751,7 @@ handle_client_listen (void *cls,
751 GNUNET_CONTAINER_DLL_insert_tail (listeners_head, listeners_tail, listener); 751 GNUNET_CONTAINER_DLL_insert_tail (listeners_head, listeners_tail, listener);
752 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "new listener created (op %u, app %s)\n", 752 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "new listener created (op %u, app %s)\n",
753 listener->operation, GNUNET_h2s (&listener->app_id)); 753 listener->operation, GNUNET_h2s (&listener->app_id));
754 754
755 /* check for incoming requests the listener is interested in */ 755 /* check for incoming requests the listener is interested in */
756 for (op = incoming_head; NULL != op; op = op->next) 756 for (op = incoming_head; NULL != op; op = op->next)
757 { 757 {
@@ -805,7 +805,7 @@ handle_client_reject (void *cls,
805 return; 805 return;
806 } 806 }
807 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer request rejected by client\n"); 807 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer request rejected by client\n");
808 808
809 GNUNET_MESH_channel_destroy (incoming->channel); 809 GNUNET_MESH_channel_destroy (incoming->channel);
810 //channel destruction handler called immediately upon destruction 810 //channel destruction handler called immediately upon destruction
811 GNUNET_SERVER_receive_done (client, GNUNET_OK); 811 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -925,7 +925,7 @@ handle_client_evaluate (void *cls,
925 spec->result_mode = ntohs (msg->result_mode); 925 spec->result_mode = ntohs (msg->result_mode);
926 spec->client_request_id = ntohl (msg->request_id); 926 spec->client_request_id = ntohl (msg->request_id);
927 spec->context_msg = GNUNET_MQ_extract_nested_mh (msg); 927 spec->context_msg = GNUNET_MQ_extract_nested_mh (msg);
928 928
929 // for simplicity we just backup the context msg instead of rebuilding it later on 929 // for simplicity we just backup the context msg instead of rebuilding it later on
930 if (NULL != spec->context_msg) 930 if (NULL != spec->context_msg)
931 spec->context_msg = GNUNET_copy_message (spec->context_msg); 931 spec->context_msg = GNUNET_copy_message (spec->context_msg);
@@ -938,8 +938,7 @@ handle_client_evaluate (void *cls,
938 938
939 op->channel = GNUNET_MESH_channel_create (mesh, op, &msg->target_peer, 939 op->channel = GNUNET_MESH_channel_create (mesh, op, &msg->target_peer,
940 GNUNET_APPLICATION_TYPE_SET, 940 GNUNET_APPLICATION_TYPE_SET,
941 GNUNET_YES, 941 GNUNET_MESH_OPTION_RELIABLE);
942 GNUNET_YES);
943 942
944 op->mq = GNUNET_MESH_mq_create (op->channel); 943 op->mq = GNUNET_MESH_mq_create (op->channel);
945 944
@@ -950,7 +949,7 @@ handle_client_evaluate (void *cls,
950 949
951/** 950/**
952 * Handle an ack from a client, and send the next element. 951 * Handle an ack from a client, and send the next element.
953 * 952 *
954 * @param cls unused 953 * @param cls unused
955 * @param client the client 954 * @param client the client
956 * @param m the message 955 * @param m the message
@@ -1027,7 +1026,7 @@ handle_client_cancel (void *cls,
1027 GNUNET_SERVER_client_disconnect (client); 1026 GNUNET_SERVER_client_disconnect (client);
1028 return; 1027 return;
1029 } 1028 }
1030 1029
1031 _GSS_operation_destroy (op); 1030 _GSS_operation_destroy (op);
1032} 1031}
1033 1032
@@ -1036,7 +1035,7 @@ handle_client_cancel (void *cls,
1036 * Handle a request from the client to accept 1035 * Handle a request from the client to accept
1037 * a set operation that came from a remote peer. 1036 * a set operation that came from a remote peer.
1038 * We forward the accept to the associated operation for handling 1037 * We forward the accept to the associated operation for handling
1039 * 1038 *
1040 * @param cls unused 1039 * @param cls unused
1041 * @param client the client 1040 * @param client the client
1042 * @param mh the message 1041 * @param mh the message
@@ -1066,7 +1065,7 @@ handle_client_accept (void *cls,
1066 1065
1067 // client without a set requested an operation 1066 // client without a set requested an operation
1068 set = set_get (client); 1067 set = set_get (client);
1069 1068
1070 if (NULL == set) 1069 if (NULL == set)
1071 { 1070 {
1072 GNUNET_break (0); 1071 GNUNET_break (0);
@@ -1126,7 +1125,7 @@ shutdown_task (void *cls,
1126 1125
1127/** 1126/**
1128 * Timeout happens iff: 1127 * Timeout happens iff:
1129 * - we suggested an operation to our listener, 1128 * - we suggested an operation to our listener,
1130 * but did not receive a response in time 1129 * but did not receive a response in time
1131 * - we got the channel from a peer but no GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST 1130 * - we got the channel from a peer but no GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST
1132 * - shutdown (obviously) 1131 * - shutdown (obviously)
@@ -1152,14 +1151,14 @@ incoming_timeout_cb (void *cls,
1152/** 1151/**
1153 * Terminates an incoming operation in case we have not yet received an 1152 * Terminates an incoming operation in case we have not yet received an
1154 * operation request. Called by the channel destruction handler. 1153 * operation request. Called by the channel destruction handler.
1155 * 1154 *
1156 * @param op the channel context 1155 * @param op the channel context
1157 */ 1156 */
1158static void 1157static void
1159handle_incoming_disconnect (struct Operation *op) 1158handle_incoming_disconnect (struct Operation *op)
1160{ 1159{
1161 GNUNET_assert (GNUNET_YES == op->is_incoming); 1160 GNUNET_assert (GNUNET_YES == op->is_incoming);
1162 1161
1163 if (NULL == op->channel) 1162 if (NULL == op->channel)
1164 return; 1163 return;
1165 1164
@@ -1171,16 +1170,17 @@ handle_incoming_disconnect (struct Operation *op)
1171 * Method called whenever another peer has added us to a channel 1170 * Method called whenever another peer has added us to a channel
1172 * the other peer initiated. 1171 * the other peer initiated.
1173 * Only called (once) upon reception of data with a message type which was 1172 * Only called (once) upon reception of data with a message type which was
1174 * subscribed to in GNUNET_MESH_connect. 1173 * subscribed to in GNUNET_MESH_connect.
1175 * 1174 *
1176 * The channel context represents the operation itself and gets added to a DLL, 1175 * The channel context represents the operation itself and gets added to a DLL,
1177 * from where it gets looked up when our local listener client responds 1176 * from where it gets looked up when our local listener client responds
1178 * to a proposed/suggested operation or connects and associates with this operation. 1177 * to a proposed/suggested operation or connects and associates with this operation.
1179 * 1178 *
1180 * @param cls closure 1179 * @param cls closure
1181 * @param channel new handle to the channel 1180 * @param channel new handle to the channel
1182 * @param initiator peer that started the channel 1181 * @param initiator peer that started the channel
1183 * @param port Port this channel is for. 1182 * @param port Port this channel is for.
1183 * @param options Unused.
1184 * @return initial channel context for the channel 1184 * @return initial channel context for the channel
1185 * (can be NULL -- that's not an error) 1185 * (can be NULL -- that's not an error)
1186 */ 1186 */
@@ -1188,7 +1188,7 @@ static void *
1188channel_new_cb (void *cls, 1188channel_new_cb (void *cls,
1189 struct GNUNET_MESH_Channel *channel, 1189 struct GNUNET_MESH_Channel *channel,
1190 const struct GNUNET_PeerIdentity *initiator, 1190 const struct GNUNET_PeerIdentity *initiator,
1191 uint32_t port) 1191 uint32_t port, enum MeshOption options)
1192{ 1192{
1193 struct Operation *incoming; 1193 struct Operation *incoming;
1194 static const struct SetVT incoming_vt = { 1194 static const struct SetVT incoming_vt = {
@@ -1202,7 +1202,7 @@ channel_new_cb (void *cls,
1202 { 1202 {
1203 GNUNET_break (0); 1203 GNUNET_break (0);
1204 GNUNET_MESH_channel_destroy (channel); 1204 GNUNET_MESH_channel_destroy (channel);
1205 return; 1205 return NULL;
1206 } 1206 }
1207 1207
1208 incoming = GNUNET_new (struct Operation); 1208 incoming = GNUNET_new (struct Operation);
@@ -1225,12 +1225,12 @@ channel_new_cb (void *cls,
1225 * any associated state. 1225 * any associated state.
1226 * GNUNET_MESH_channel_destroy. It must NOT call GNUNET_MESH_channel_destroy on 1226 * GNUNET_MESH_channel_destroy. It must NOT call GNUNET_MESH_channel_destroy on
1227 * the channel. 1227 * the channel.
1228 * 1228 *
1229 * The peer_disconnect function is part of a a virtual table set initially either 1229 * The peer_disconnect function is part of a a virtual table set initially either
1230 * when a peer creates a new channel with us (channel_new_cb), or once we create 1230 * when a peer creates a new channel with us (channel_new_cb), or once we create
1231 * a new channel ourselves (evaluate). 1231 * a new channel ourselves (evaluate).
1232 * 1232 *
1233 * Once we know the exact type of operation (union/intersection), the vt is 1233 * Once we know the exact type of operation (union/intersection), the vt is
1234 * replaced with an operation specific instance (_GSS_[op]_vt). 1234 * replaced with an operation specific instance (_GSS_[op]_vt).
1235 * 1235 *
1236 * @param cls closure (set from GNUNET_MESH_connect) 1236 * @param cls closure (set from GNUNET_MESH_connect)
@@ -1259,11 +1259,11 @@ channel_end_cb (void *cls,
1259 * Functions with this signature are called whenever any message is 1259 * Functions with this signature are called whenever any message is
1260 * received via the mesh channel. 1260 * received via the mesh channel.
1261 * 1261 *
1262 * The msg_handler is a virtual table set in initially either when a peer 1262 * The msg_handler is a virtual table set in initially either when a peer
1263 * creates a new channel with us (channel_new_cb), or once we create a new channel 1263 * creates a new channel with us (channel_new_cb), or once we create a new channel
1264 * ourselves (evaluate). 1264 * ourselves (evaluate).
1265 * 1265 *
1266 * Once we know the exact type of operation (union/intersection), the vt is 1266 * Once we know the exact type of operation (union/intersection), the vt is
1267 * replaced with an operation specific instance (_GSS_[op]_vt). 1267 * replaced with an operation specific instance (_GSS_[op]_vt).
1268 * 1268 *
1269 * @param cls Closure (set from GNUNET_MESH_connect). 1269 * @param cls Closure (set from GNUNET_MESH_connect).