diff options
Diffstat (limited to 'src/testbed-logger/gnunet-service-testbed-logger.c')
-rw-r--r-- | src/testbed-logger/gnunet-service-testbed-logger.c | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/src/testbed-logger/gnunet-service-testbed-logger.c b/src/testbed-logger/gnunet-service-testbed-logger.c index e2f71070b..4e0a3cd34 100644 --- a/src/testbed-logger/gnunet-service-testbed-logger.c +++ b/src/testbed-logger/gnunet-service-testbed-logger.c | |||
@@ -31,13 +31,13 @@ | |||
31 | * Generic logging shorthand | 31 | * Generic logging shorthand |
32 | */ | 32 | */ |
33 | #define LOG(type, ...) \ | 33 | #define LOG(type, ...) \ |
34 | GNUNET_log(type, __VA_ARGS__) | 34 | GNUNET_log (type, __VA_ARGS__) |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Debug logging shorthand | 37 | * Debug logging shorthand |
38 | */ | 38 | */ |
39 | #define LOG_DEBUG(...) \ | 39 | #define LOG_DEBUG(...) \ |
40 | LOG(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | 40 | LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Handle for buffered writing. | 43 | * Handle for buffered writing. |
@@ -63,8 +63,8 @@ static int in_shutdown; | |||
63 | * @return #GNUNET_OK (they are all always OK) | 63 | * @return #GNUNET_OK (they are all always OK) |
64 | */ | 64 | */ |
65 | static int | 65 | static int |
66 | check_log_msg(void *cls, | 66 | check_log_msg (void *cls, |
67 | const struct GNUNET_MessageHeader *msg) | 67 | const struct GNUNET_MessageHeader *msg) |
68 | { | 68 | { |
69 | return GNUNET_OK; | 69 | return GNUNET_OK; |
70 | } | 70 | } |
@@ -77,17 +77,17 @@ check_log_msg(void *cls, | |||
77 | * @param msg the actual message | 77 | * @param msg the actual message |
78 | */ | 78 | */ |
79 | static void | 79 | static void |
80 | handle_log_msg(void *cls, | 80 | handle_log_msg (void *cls, |
81 | const struct GNUNET_MessageHeader *msg) | 81 | const struct GNUNET_MessageHeader *msg) |
82 | { | 82 | { |
83 | struct GNUNET_SERVICE_Client *client = cls; | 83 | struct GNUNET_SERVICE_Client *client = cls; |
84 | uint16_t ms; | 84 | uint16_t ms; |
85 | 85 | ||
86 | ms = ntohs(msg->size) - sizeof(struct GNUNET_MessageHeader); | 86 | ms = ntohs (msg->size) - sizeof(struct GNUNET_MessageHeader); |
87 | GNUNET_BIO_write(bio, | 87 | GNUNET_BIO_write (bio, |
88 | &msg[1], | 88 | &msg[1], |
89 | ms); | 89 | ms); |
90 | GNUNET_SERVICE_client_continue(client); | 90 | GNUNET_SERVICE_client_continue (client); |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
@@ -97,18 +97,18 @@ handle_log_msg(void *cls, | |||
97 | * @param cls NULL | 97 | * @param cls NULL |
98 | */ | 98 | */ |
99 | static void | 99 | static void |
100 | shutdown_task(void *cls) | 100 | shutdown_task (void *cls) |
101 | { | 101 | { |
102 | in_shutdown = GNUNET_YES; | 102 | in_shutdown = GNUNET_YES; |
103 | if (0 != nconn) | 103 | if (0 != nconn) |
104 | { | 104 | { |
105 | /* Delay shutdown if there are active connections */ | 105 | /* Delay shutdown if there are active connections */ |
106 | GNUNET_SCHEDULER_add_shutdown(&shutdown_task, | 106 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
107 | NULL); | 107 | NULL); |
108 | return; | 108 | return; |
109 | } | 109 | } |
110 | GNUNET_break(GNUNET_OK == | 110 | GNUNET_break (GNUNET_OK == |
111 | GNUNET_BIO_write_close(bio)); | 111 | GNUNET_BIO_write_close (bio)); |
112 | } | 112 | } |
113 | 113 | ||
114 | 114 | ||
@@ -121,12 +121,12 @@ shutdown_task(void *cls) | |||
121 | * @return @a c | 121 | * @return @a c |
122 | */ | 122 | */ |
123 | static void * | 123 | static void * |
124 | client_connect_cb(void *cls, | 124 | client_connect_cb (void *cls, |
125 | struct GNUNET_SERVICE_Client *c, | 125 | struct GNUNET_SERVICE_Client *c, |
126 | struct GNUNET_MQ_Handle *mq) | 126 | struct GNUNET_MQ_Handle *mq) |
127 | { | 127 | { |
128 | /* FIXME: is this really what we want here? */ | 128 | /* FIXME: is this really what we want here? */ |
129 | GNUNET_SERVICE_client_persist(c); | 129 | GNUNET_SERVICE_client_persist (c); |
130 | nconn++; | 130 | nconn++; |
131 | return c; | 131 | return c; |
132 | } | 132 | } |
@@ -140,14 +140,14 @@ client_connect_cb(void *cls, | |||
140 | * @param internal_cls should be equal to @a c | 140 | * @param internal_cls should be equal to @a c |
141 | */ | 141 | */ |
142 | static void | 142 | static void |
143 | client_disconnect_cb(void *cls, | 143 | client_disconnect_cb (void *cls, |
144 | struct GNUNET_SERVICE_Client *c, | 144 | struct GNUNET_SERVICE_Client *c, |
145 | void *internal_cls) | 145 | void *internal_cls) |
146 | { | 146 | { |
147 | nconn--; | 147 | nconn--; |
148 | if (GNUNET_YES == in_shutdown) | 148 | if (GNUNET_YES == in_shutdown) |
149 | GNUNET_SCHEDULER_shutdown(); | 149 | GNUNET_SCHEDULER_shutdown (); |
150 | GNUNET_assert(c == internal_cls); | 150 | GNUNET_assert (c == internal_cls); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
@@ -159,9 +159,9 @@ client_disconnect_cb(void *cls, | |||
159 | * @param service the initialized service | 159 | * @param service the initialized service |
160 | */ | 160 | */ |
161 | static void | 161 | static void |
162 | logger_run(void *cls, | 162 | logger_run (void *cls, |
163 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 163 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
164 | struct GNUNET_SERVICE_Handle *service) | 164 | struct GNUNET_SERVICE_Handle *service) |
165 | { | 165 | { |
166 | char *dir; | 166 | char *dir; |
167 | char *fn; | 167 | char *fn; |
@@ -170,48 +170,48 @@ logger_run(void *cls, | |||
170 | pid_t pid; | 170 | pid_t pid; |
171 | 171 | ||
172 | if (GNUNET_OK != | 172 | if (GNUNET_OK != |
173 | GNUNET_CONFIGURATION_get_value_filename(cfg, | 173 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
174 | "TESTBED-LOGGER", | 174 | "TESTBED-LOGGER", |
175 | "DIR", | 175 | "DIR", |
176 | &dir)) | 176 | &dir)) |
177 | { | 177 | { |
178 | GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, | 178 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
179 | "TESTBED-LOGGER", | 179 | "TESTBED-LOGGER", |
180 | "DIR"); | 180 | "DIR"); |
181 | GNUNET_SCHEDULER_shutdown(); | 181 | GNUNET_SCHEDULER_shutdown (); |
182 | return; | 182 | return; |
183 | } | 183 | } |
184 | pid = getpid(); | 184 | pid = getpid (); |
185 | hname_len = GNUNET_OS_get_hostname_max_length(); | 185 | hname_len = GNUNET_OS_get_hostname_max_length (); |
186 | hname = GNUNET_malloc(hname_len); | 186 | hname = GNUNET_malloc (hname_len); |
187 | if (0 != gethostname(hname, | 187 | if (0 != gethostname (hname, |
188 | hname_len)) | 188 | hname_len)) |
189 | { | 189 | { |
190 | LOG(GNUNET_ERROR_TYPE_ERROR, | 190 | LOG (GNUNET_ERROR_TYPE_ERROR, |
191 | "Cannot get hostname. Exiting\n"); | 191 | "Cannot get hostname. Exiting\n"); |
192 | GNUNET_free(hname); | 192 | GNUNET_free (hname); |
193 | GNUNET_free(dir); | 193 | GNUNET_free (dir); |
194 | GNUNET_SCHEDULER_shutdown(); | 194 | GNUNET_SCHEDULER_shutdown (); |
195 | return; | 195 | return; |
196 | } | 196 | } |
197 | GNUNET_asprintf(&fn, | 197 | GNUNET_asprintf (&fn, |
198 | "%s/%.*s_%jd.dat", | 198 | "%s/%.*s_%jd.dat", |
199 | dir, | 199 | dir, |
200 | hname_len, | 200 | hname_len, |
201 | hname, | 201 | hname, |
202 | (intmax_t)pid); | 202 | (intmax_t) pid); |
203 | GNUNET_free(hname); | 203 | GNUNET_free (hname); |
204 | GNUNET_free(dir); | 204 | GNUNET_free (dir); |
205 | if (NULL == (bio = GNUNET_BIO_write_open(fn))) | 205 | if (NULL == (bio = GNUNET_BIO_write_open (fn))) |
206 | { | 206 | { |
207 | GNUNET_free(fn); | 207 | GNUNET_free (fn); |
208 | GNUNET_SCHEDULER_shutdown(); | 208 | GNUNET_SCHEDULER_shutdown (); |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | GNUNET_free(fn); | 211 | GNUNET_free (fn); |
212 | GNUNET_SCHEDULER_add_shutdown(&shutdown_task, | 212 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
213 | NULL); | 213 | NULL); |
214 | LOG_DEBUG("TESTBED-LOGGER startup complete\n"); | 214 | LOG_DEBUG ("TESTBED-LOGGER startup complete\n"); |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
@@ -225,11 +225,11 @@ GNUNET_SERVICE_MAIN | |||
225 | &client_connect_cb, | 225 | &client_connect_cb, |
226 | &client_disconnect_cb, | 226 | &client_disconnect_cb, |
227 | NULL, | 227 | NULL, |
228 | GNUNET_MQ_hd_var_size(log_msg, | 228 | GNUNET_MQ_hd_var_size (log_msg, |
229 | GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG, | 229 | GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG, |
230 | struct GNUNET_MessageHeader, | 230 | struct GNUNET_MessageHeader, |
231 | NULL), | 231 | NULL), |
232 | GNUNET_MQ_handler_end()); | 232 | GNUNET_MQ_handler_end ()); |
233 | 233 | ||
234 | 234 | ||
235 | /* end of gnunet-service-testbed-logger.c */ | 235 | /* end of gnunet-service-testbed-logger.c */ |