diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/transport/test_transport_api_disconnect.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/transport/test_transport_api_disconnect.c')
-rw-r--r-- | src/transport/test_transport_api_disconnect.c | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c index 47e52b67e..76e0325af 100644 --- a/src/transport/test_transport_api_disconnect.c +++ b/src/transport/test_transport_api_disconnect.c | |||
@@ -32,7 +32,7 @@ | |||
32 | /** | 32 | /** |
33 | * How long until we give up on transmitting the message? | 33 | * How long until we give up on transmitting the message? |
34 | */ | 34 | */ |
35 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120) | 35 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) |
36 | 36 | ||
37 | 37 | ||
38 | static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc; | 38 | static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc; |
@@ -41,69 +41,70 @@ static int shutdown_; | |||
41 | 41 | ||
42 | 42 | ||
43 | static void | 43 | static void |
44 | notify_disconnect(void *cls, | 44 | notify_disconnect (void *cls, |
45 | struct GNUNET_TRANSPORT_TESTING_PeerContext *me, | 45 | struct GNUNET_TRANSPORT_TESTING_PeerContext *me, |
46 | const struct GNUNET_PeerIdentity *other) | 46 | const struct GNUNET_PeerIdentity *other) |
47 | { | 47 | { |
48 | if (me != ccc->p[0]) | 48 | if (me != ccc->p[0]) |
49 | return; | 49 | return; |
50 | GNUNET_TRANSPORT_TESTING_log_disconnect(cls, | 50 | GNUNET_TRANSPORT_TESTING_log_disconnect (cls, |
51 | me, | 51 | me, |
52 | other); | 52 | other); |
53 | if (GNUNET_YES == shutdown_) | 53 | if (GNUNET_YES == shutdown_) |
54 | { | 54 | { |
55 | ccc->global_ret = GNUNET_OK; | 55 | ccc->global_ret = GNUNET_OK; |
56 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 56 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
57 | "Test good, shutting down...\n"); | 57 | "Test good, shutting down...\n"); |
58 | GNUNET_SCHEDULER_shutdown(); | 58 | GNUNET_SCHEDULER_shutdown (); |
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | static void | 63 | static void |
64 | stop_peer(void *cls) | 64 | stop_peer (void *cls) |
65 | { | 65 | { |
66 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 66 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
67 | "Shutting down peer %u (`%s')\n", | 67 | "Shutting down peer %u (`%s')\n", |
68 | ccc->p[1]->no, | 68 | ccc->p[1]->no, |
69 | GNUNET_i2s(&ccc->p[1]->id)); | 69 | GNUNET_i2s (&ccc->p[1]->id)); |
70 | shutdown_ = GNUNET_YES; | 70 | shutdown_ = GNUNET_YES; |
71 | GNUNET_TRANSPORT_TESTING_stop_peer(ccc->p[1]); | 71 | GNUNET_TRANSPORT_TESTING_stop_peer (ccc->p[1]); |
72 | ccc->p[1] = NULL; | 72 | ccc->p[1] = NULL; |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | static void | 76 | static void |
77 | notify_receive(void *cls, | 77 | notify_receive (void *cls, |
78 | struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, | 78 | struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, |
79 | const struct GNUNET_PeerIdentity *sender, | 79 | const struct GNUNET_PeerIdentity *sender, |
80 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | 80 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) |
81 | { | 81 | { |
82 | { | 82 | { |
83 | char *ps = GNUNET_strdup(GNUNET_i2s(&receiver->id)); | 83 | char *ps = GNUNET_strdup (GNUNET_i2s (&receiver->id)); |
84 | 84 | ||
85 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 85 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
86 | "Peer %u (`%s') received message of type %d and size %u size from peer %s!\n", | 86 | "Peer %u (`%s') received message of type %d and size %u size from peer %s!\n", |
87 | receiver->no, | 87 | receiver->no, |
88 | ps, | 88 | ps, |
89 | ntohs(message->header.type), | 89 | ntohs (message->header.type), |
90 | ntohs(message->header.size), | 90 | ntohs (message->header.size), |
91 | GNUNET_i2s(sender)); | 91 | GNUNET_i2s (sender)); |
92 | GNUNET_free(ps); | 92 | GNUNET_free (ps); |
93 | } | ||
94 | if ((GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE == ntohs (message->header.type)) && | ||
95 | (sizeof(struct GNUNET_TRANSPORT_TESTING_TestMessage) == ntohs ( | ||
96 | message->header.size))) | ||
97 | { | ||
98 | GNUNET_SCHEDULER_add_now (&stop_peer, | ||
99 | NULL); | ||
100 | return; | ||
93 | } | 101 | } |
94 | if ((GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE == ntohs(message->header.type)) && | ||
95 | (sizeof(struct GNUNET_TRANSPORT_TESTING_TestMessage) == ntohs(message->header.size))) | ||
96 | { | ||
97 | GNUNET_SCHEDULER_add_now(&stop_peer, | ||
98 | NULL); | ||
99 | return; | ||
100 | } | ||
101 | } | 102 | } |
102 | 103 | ||
103 | 104 | ||
104 | int | 105 | int |
105 | main(int argc, | 106 | main (int argc, |
106 | char *argv[]) | 107 | char *argv[]) |
107 | { | 108 | { |
108 | struct GNUNET_TRANSPORT_TESTING_SendClosure sc = { | 109 | struct GNUNET_TRANSPORT_TESTING_SendClosure sc = { |
109 | .num_messages = 1 | 110 | .num_messages = 1 |
@@ -122,9 +123,9 @@ main(int argc, | |||
122 | ccc = &my_ccc; | 123 | ccc = &my_ccc; |
123 | sc.ccc = ccc; | 124 | sc.ccc = ccc; |
124 | if (GNUNET_OK != | 125 | if (GNUNET_OK != |
125 | GNUNET_TRANSPORT_TESTING_main(2, | 126 | GNUNET_TRANSPORT_TESTING_main (2, |
126 | &GNUNET_TRANSPORT_TESTING_connect_check, | 127 | &GNUNET_TRANSPORT_TESTING_connect_check, |
127 | ccc)) | 128 | ccc)) |
128 | return 1; | 129 | return 1; |
129 | return 0; | 130 | return 0; |
130 | } | 131 | } |