Browse Source

rearranged thread-related code (#761)

pull/768/head
Logan oos Even 3 years ago
committed by GitHub
parent
commit
e13c9a01a5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      include/n2n.h
  2. 5
      src/edge.c
  3. 5
      src/edge_utils.c
  4. 4
      src/example_sn_embed.c
  5. 6
      src/sn.c
  6. 12
      src/sn_utils.c

1
include/n2n.h

@ -269,6 +269,7 @@ int quick_edge_init (char *device_name, char *community_name,
char *supernode_ip_address_port,
int *keep_on_running);
int comm_init (struct sn_community *comm, char *cmn);
int sn_init_defaults (n2n_sn_t *sss);
int sn_init (n2n_sn_t *sss);
void sn_term (n2n_sn_t *sss);
int supernode2sock (n2n_sock_t * sn, const n2n_sn_name_t addrIn);

5
src/edge.c

@ -50,7 +50,6 @@ int supernode_disconnect (n2n_edge_t *eee);
int fetch_and_eventually_process_data (n2n_edge_t *eee, SOCKET sock,
uint8_t *pktbuf, uint16_t *expected, uint16_t *position,
time_t now);
int resolve_create_thread (n2n_resolve_parameter_t **param, struct peer_info *sn_list);
int resolve_check (n2n_resolve_parameter_t *param, uint8_t resolution_request, time_t now);
int edge_init_routes (n2n_edge_t *eee, n2n_route_t *routes, uint16_t num_routes);
@ -1041,10 +1040,6 @@ int main (int argc, char* argv[]) {
exit(1);
}
if(resolve_create_thread(&(eee->resolve_parameter), eee->conf.supernodes) == 0) {
traceEvent(TRACE_NORMAL, "successfully created resolver thread");
}
memcpy(&(eee->tuntap_priv_conf), &ec, sizeof(ec));
if((0 == strcmp("static", eee->tuntap_priv_conf.ip_mode)) ||

5
src/edge_utils.c

@ -26,6 +26,7 @@ static HEAP_ALLOC (wrkmem, LZO1X_1_MEM_COMPRESS);
/* ************************************** */
int resolve_create_thread (n2n_resolve_parameter_t **param, struct peer_info *sn_list);
int resolve_check (n2n_resolve_parameter_t *param, uint8_t resolution_request, time_t now);
int resolve_cancel_thread (n2n_resolve_parameter_t *param);
@ -418,6 +419,10 @@ n2n_edge_t* edge_init (const n2n_edge_conf_t *conf, int *rv) {
goto edge_init_error;
}
if(resolve_create_thread(&(eee->resolve_parameter), eee->conf.supernodes) == 0) {
traceEvent(TRACE_NORMAL, "successfully created resolver thread");
}
eee->network_traffic_filter = create_network_traffic_filter();
network_traffic_filter_add_rule(eee->network_traffic_filter, eee->conf.network_traffic_filter_rules);

4
src/example_sn_embed.c

@ -25,7 +25,7 @@ int main () {
n2n_sn_t sss_node;
int rc;
sn_init(&sss_node);
sn_init_defaults(&sss_node);
sss_node.daemon = 0; // Whether to daemonize
sss_node.lport = 1234; // Main UDP listen port
@ -39,6 +39,8 @@ int main () {
exit(-2);
}
sn_init(&sss_node);
keep_running = 1;
rc = run_sn_loop(&sss_node, &keep_running);

6
src/sn.c

@ -527,7 +527,7 @@ int main (int argc, char * const argv[]) {
struct peer_info *scan, *tmp;
sn_init(&sss_node);
sn_init_defaults(&sss_node);
add_federation_to_communities(&sss_node);
if((argc >= 2) && (argv[1][0] != '-')) {
@ -635,9 +635,7 @@ int main (int argc, char * const argv[]) {
}
#endif
if(resolve_create_thread(&(sss_node.resolve_parameter), sss_node.federation->edges) == 0) {
traceEvent(TRACE_NORMAL, "successfully created resolver thread");
}
sn_init(&sss_node);
traceEvent(TRACE_NORMAL, "supernode started");

12
src/sn_utils.c

@ -20,6 +20,7 @@
#define HASH_FIND_COMMUNITY(head, name, out) HASH_FIND_STR(head, name, out)
int resolve_create_thread (n2n_resolve_parameter_t **param, struct peer_info *sn_list);
int resolve_check (n2n_resolve_parameter_t *param, uint8_t resolution_request, time_t now);
int resolve_cancel_thread (n2n_resolve_parameter_t *param);
@ -727,7 +728,7 @@ int comm_init (struct sn_community *comm, char *cmn) {
/** Initialise the supernode structure */
int sn_init(n2n_sn_t *sss) {
int sn_init_defaults (n2n_sn_t *sss) {
int i;
size_t idx;
@ -787,6 +788,15 @@ int sn_init(n2n_sn_t *sss) {
}
/** Initialise the supernode */
int sn_init (n2n_sn_t *sss) {
if(resolve_create_thread(&(sss->resolve_parameter), sss->federation->edges) == 0) {
traceEvent(TRACE_NORMAL, "successfully created resolver thread");
}
}
/** Deinitialise the supernode structure and deallocate any memory owned by
* it. */
void sn_term (n2n_sn_t *sss) {

Loading…
Cancel
Save