Commit | Line | Data |
---|---|---|
3bd1e081 MD |
1 | /* |
2 | * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca> | |
3 | * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
4 | * | |
d14d33bf AM |
5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License, version 2 only, | |
7 | * as published by the Free Software Foundation. | |
3bd1e081 MD |
8 | * |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
d14d33bf AM |
14 | * You should have received a copy of the GNU General Public License along |
15 | * with this program; if not, write to the Free Software Foundation, Inc., | |
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
3bd1e081 MD |
17 | */ |
18 | ||
19 | #define _GNU_SOURCE | |
20 | #include <assert.h> | |
3bd1e081 MD |
21 | #include <poll.h> |
22 | #include <pthread.h> | |
23 | #include <stdlib.h> | |
24 | #include <string.h> | |
25 | #include <sys/mman.h> | |
26 | #include <sys/socket.h> | |
27 | #include <sys/types.h> | |
77c7c900 | 28 | #include <inttypes.h> |
3bd1e081 | 29 | #include <unistd.h> |
dbb5dfe6 | 30 | #include <sys/stat.h> |
3bd1e081 | 31 | |
990570ed | 32 | #include <common/common.h> |
10a8a223 | 33 | #include <common/kernel-ctl/kernel-ctl.h> |
10a8a223 | 34 | #include <common/sessiond-comm/sessiond-comm.h> |
00e2e675 | 35 | #include <common/sessiond-comm/relayd.h> |
dbb5dfe6 | 36 | #include <common/compat/fcntl.h> |
acdb9057 | 37 | #include <common/pipe.h> |
00e2e675 | 38 | #include <common/relayd/relayd.h> |
fe4477ee | 39 | #include <common/utils.h> |
07b86b52 | 40 | #include <common/consumer-stream.h> |
0857097f | 41 | |
10a8a223 | 42 | #include "kernel-consumer.h" |
3bd1e081 MD |
43 | |
44 | extern struct lttng_consumer_global_data consumer_data; | |
45 | extern int consumer_poll_timeout; | |
46 | extern volatile int consumer_quit; | |
47 | ||
3bd1e081 MD |
48 | /* |
49 | * Take a snapshot for a specific fd | |
50 | * | |
51 | * Returns 0 on success, < 0 on error | |
52 | */ | |
ffe60014 | 53 | int lttng_kconsumer_take_snapshot(struct lttng_consumer_stream *stream) |
3bd1e081 MD |
54 | { |
55 | int ret = 0; | |
56 | int infd = stream->wait_fd; | |
57 | ||
58 | ret = kernctl_snapshot(infd); | |
59 | if (ret != 0) { | |
87dc6a9c | 60 | errno = -ret; |
3bd1e081 MD |
61 | perror("Getting sub-buffer snapshot."); |
62 | } | |
63 | ||
64 | return ret; | |
65 | } | |
66 | ||
67 | /* | |
68 | * Get the produced position | |
69 | * | |
70 | * Returns 0 on success, < 0 on error | |
71 | */ | |
ffe60014 | 72 | int lttng_kconsumer_get_produced_snapshot(struct lttng_consumer_stream *stream, |
3bd1e081 MD |
73 | unsigned long *pos) |
74 | { | |
75 | int ret; | |
76 | int infd = stream->wait_fd; | |
77 | ||
78 | ret = kernctl_snapshot_get_produced(infd, pos); | |
79 | if (ret != 0) { | |
87dc6a9c | 80 | errno = -ret; |
3bd1e081 MD |
81 | perror("kernctl_snapshot_get_produced"); |
82 | } | |
83 | ||
84 | return ret; | |
85 | } | |
86 | ||
07b86b52 JD |
87 | /* |
88 | * Get the consumerd position | |
89 | * | |
90 | * Returns 0 on success, < 0 on error | |
91 | */ | |
92 | int lttng_kconsumer_get_consumed_snapshot(struct lttng_consumer_stream *stream, | |
93 | unsigned long *pos) | |
94 | { | |
95 | int ret; | |
96 | int infd = stream->wait_fd; | |
97 | ||
98 | ret = kernctl_snapshot_get_consumed(infd, pos); | |
99 | if (ret != 0) { | |
100 | errno = -ret; | |
101 | perror("kernctl_snapshot_get_consumed"); | |
102 | } | |
103 | ||
104 | return ret; | |
105 | } | |
106 | ||
107 | /* | |
108 | * Find a relayd and send the stream | |
109 | * | |
110 | * Returns 0 on success, < 0 on error | |
111 | */ | |
41ad7012 DG |
112 | static int send_relayd_stream(struct lttng_consumer_stream *stream, |
113 | char *path) | |
07b86b52 | 114 | { |
07b86b52 | 115 | int ret = 0; |
41ad7012 DG |
116 | const char *stream_path; |
117 | struct consumer_relayd_sock_pair *relayd; | |
118 | ||
119 | assert(stream); | |
120 | assert(stream->net_seq_idx != -1ULL); | |
07b86b52 JD |
121 | |
122 | if (path != NULL) { | |
123 | stream_path = path; | |
124 | } else { | |
125 | stream_path = stream->chan->pathname; | |
126 | } | |
41ad7012 | 127 | |
07b86b52 JD |
128 | /* The stream is not metadata. Get relayd reference if exists. */ |
129 | rcu_read_lock(); | |
130 | relayd = consumer_find_relayd(stream->net_seq_idx); | |
131 | if (relayd != NULL) { | |
132 | /* Add stream on the relayd */ | |
133 | pthread_mutex_lock(&relayd->ctrl_sock_mutex); | |
41ad7012 DG |
134 | ret = relayd_add_stream(&relayd->control_sock, stream->name, |
135 | stream_path, &stream->relayd_stream_id, | |
136 | stream->chan->tracefile_size, stream->chan->tracefile_count); | |
07b86b52 JD |
137 | pthread_mutex_unlock(&relayd->ctrl_sock_mutex); |
138 | if (ret < 0) { | |
139 | goto end; | |
140 | } | |
141 | uatomic_inc(&relayd->refcount); | |
41ad7012 DG |
142 | } else { |
143 | ERR("Stream %" PRIu64 " relayd ID %" PRIu64 " unknown. Can't send it.", | |
144 | stream->key, stream->net_seq_idx); | |
07b86b52 JD |
145 | ret = -1; |
146 | goto end; | |
147 | } | |
148 | ||
41ad7012 DG |
149 | DBG("Stream %s with key %" PRIu64 " sent to relayd id %" PRIu64, |
150 | stream->name, stream->key, stream->net_seq_idx); | |
151 | ||
07b86b52 JD |
152 | end: |
153 | rcu_read_unlock(); | |
154 | return ret; | |
155 | } | |
156 | ||
157 | /* | |
158 | * Find a relayd and close the stream | |
159 | */ | |
41ad7012 | 160 | static void close_relayd_stream(struct lttng_consumer_stream *stream) |
07b86b52 JD |
161 | { |
162 | struct consumer_relayd_sock_pair *relayd; | |
163 | ||
164 | /* The stream is not metadata. Get relayd reference if exists. */ | |
165 | rcu_read_lock(); | |
166 | relayd = consumer_find_relayd(stream->net_seq_idx); | |
41ad7012 | 167 | if (relayd) { |
07b86b52 JD |
168 | consumer_stream_relayd_close(stream, relayd); |
169 | } | |
170 | rcu_read_unlock(); | |
171 | } | |
172 | ||
173 | /* | |
174 | * Take a snapshot of all the stream of a channel | |
175 | * | |
176 | * Returns 0 on success, < 0 on error | |
177 | */ | |
178 | int lttng_kconsumer_snapshot_channel(uint64_t key, char *path, | |
179 | uint64_t relayd_id, struct lttng_consumer_local_data *ctx) | |
180 | { | |
181 | int ret; | |
182 | unsigned long consumed_pos, produced_pos; | |
183 | struct lttng_consumer_channel *channel; | |
184 | struct lttng_consumer_stream *stream; | |
185 | ||
186 | DBG("Kernel consumer snapshot channel %lu", key); | |
187 | ||
188 | rcu_read_lock(); | |
189 | ||
190 | channel = consumer_find_channel(key); | |
191 | if (!channel) { | |
192 | ERR("No channel found for key %lu", key); | |
193 | ret = -1; | |
194 | goto end; | |
195 | } | |
196 | ||
197 | /* Splice is not supported yet for channel snapshot. */ | |
198 | if (channel->output != CONSUMER_CHANNEL_MMAP) { | |
199 | ERR("Unsupported output %d", channel->output); | |
200 | ret = -1; | |
201 | goto end; | |
202 | } | |
203 | ||
204 | cds_list_for_each_entry(stream, &channel->stream_no_monitor_list.head, | |
205 | no_monitor_node) { | |
206 | /* | |
207 | * Lock stream because we are about to change its state. | |
208 | */ | |
209 | pthread_mutex_lock(&stream->lock); | |
210 | ||
29decac3 DG |
211 | /* |
212 | * Assign the received relayd ID so we can use it for streaming. The streams | |
213 | * are not visible to anyone so this is OK to change it. | |
214 | */ | |
07b86b52 JD |
215 | stream->net_seq_idx = relayd_id; |
216 | channel->relayd_id = relayd_id; | |
217 | if (relayd_id != (uint64_t) -1ULL) { | |
218 | ret = send_relayd_stream(stream, path); | |
219 | if (ret < 0) { | |
220 | ERR("sending stream to relayd"); | |
221 | goto end_unlock; | |
222 | } | |
07b86b52 JD |
223 | } else { |
224 | ret = utils_create_stream_file(path, stream->name, | |
225 | stream->chan->tracefile_size, stream->tracefile_count_current, | |
226 | stream->uid, stream->gid); | |
227 | if (ret < 0) { | |
228 | ERR("utils_create_stream_file"); | |
229 | goto end_unlock; | |
230 | } | |
231 | ||
232 | stream->out_fd = ret; | |
233 | stream->tracefile_size_current = 0; | |
234 | ||
235 | DBG("Kernel consumer snapshot stream %s/%s (%lu)", path, | |
236 | stream->name, stream->key); | |
237 | } | |
238 | ||
239 | ret = kernctl_buffer_flush(stream->wait_fd); | |
240 | if (ret < 0) { | |
241 | ERR("Failed to flush kernel metadata stream"); | |
242 | goto end_unlock; | |
243 | } | |
244 | ||
245 | ret = lttng_kconsumer_take_snapshot(stream); | |
246 | if (ret < 0) { | |
247 | ERR("Taking kernel snapshot"); | |
248 | goto end_unlock; | |
249 | } | |
250 | ||
251 | ret = lttng_kconsumer_get_produced_snapshot(stream, &produced_pos); | |
252 | if (ret < 0) { | |
253 | ERR("Produced kernel snapshot position"); | |
254 | goto end_unlock; | |
255 | } | |
256 | ||
257 | ret = lttng_kconsumer_get_consumed_snapshot(stream, &consumed_pos); | |
258 | if (ret < 0) { | |
259 | ERR("Consumerd kernel snapshot position"); | |
260 | goto end_unlock; | |
261 | } | |
262 | ||
263 | if (stream->max_sb_size == 0) { | |
264 | ret = kernctl_get_max_subbuf_size(stream->wait_fd, | |
265 | &stream->max_sb_size); | |
266 | if (ret < 0) { | |
267 | ERR("Getting kernel max_sb_size"); | |
268 | goto end_unlock; | |
269 | } | |
270 | } | |
271 | ||
272 | while (consumed_pos < produced_pos) { | |
273 | ssize_t read_len; | |
274 | unsigned long len, padded_len; | |
275 | ||
276 | DBG("Kernel consumer taking snapshot at pos %lu", consumed_pos); | |
277 | ||
278 | ret = kernctl_get_subbuf(stream->wait_fd, &consumed_pos); | |
279 | if (ret < 0) { | |
280 | if (errno != EAGAIN) { | |
281 | PERROR("kernctl_get_subbuf snapshot"); | |
282 | goto end_unlock; | |
283 | } | |
284 | DBG("Kernel consumer get subbuf failed. Skipping it."); | |
285 | consumed_pos += stream->max_sb_size; | |
286 | continue; | |
287 | } | |
288 | ||
289 | ret = kernctl_get_subbuf_size(stream->wait_fd, &len); | |
290 | if (ret < 0) { | |
291 | ERR("Snapshot kernctl_get_subbuf_size"); | |
29decac3 | 292 | goto error_put_subbuf; |
07b86b52 JD |
293 | } |
294 | ||
295 | ret = kernctl_get_padded_subbuf_size(stream->wait_fd, &padded_len); | |
296 | if (ret < 0) { | |
297 | ERR("Snapshot kernctl_get_padded_subbuf_size"); | |
29decac3 | 298 | goto error_put_subbuf; |
07b86b52 JD |
299 | } |
300 | ||
301 | read_len = lttng_consumer_on_read_subbuffer_mmap(ctx, stream, len, | |
302 | padded_len - len); | |
303 | /* | |
29decac3 DG |
304 | * We write the padded len in local tracefiles but the data len |
305 | * when using a relay. Display the error but continue processing | |
306 | * to try to release the subbuffer. | |
07b86b52 JD |
307 | */ |
308 | if (relayd_id != (uint64_t) -1ULL) { | |
309 | if (read_len != len) { | |
310 | ERR("Error sending to the relay (ret: %zd != len: %lu)", | |
311 | read_len, len); | |
312 | } | |
313 | } else { | |
314 | if (read_len != padded_len) { | |
315 | ERR("Error writing to tracefile (ret: %zd != len: %lu)", | |
316 | read_len, padded_len); | |
317 | } | |
318 | } | |
319 | ||
320 | ret = kernctl_put_subbuf(stream->wait_fd); | |
321 | if (ret < 0) { | |
322 | ERR("Snapshot kernctl_put_subbuf"); | |
323 | goto end_unlock; | |
324 | } | |
325 | consumed_pos += stream->max_sb_size; | |
326 | } | |
327 | ||
328 | if (relayd_id == (uint64_t) -1ULL) { | |
329 | ret = close(stream->out_fd); | |
330 | if (ret < 0) { | |
331 | PERROR("Kernel consumer snapshot close out_fd"); | |
332 | goto end_unlock; | |
333 | } | |
334 | stream->out_fd = -1; | |
335 | } else { | |
336 | close_relayd_stream(stream); | |
337 | stream->net_seq_idx = (uint64_t) -1ULL; | |
338 | } | |
339 | pthread_mutex_unlock(&stream->lock); | |
340 | } | |
341 | ||
342 | /* All good! */ | |
343 | ret = 0; | |
344 | goto end; | |
345 | ||
29decac3 DG |
346 | error_put_subbuf: |
347 | ret = kernctl_put_subbuf(stream->wait_fd); | |
348 | if (ret < 0) { | |
349 | ERR("Snapshot kernctl_put_subbuf error path"); | |
350 | } | |
07b86b52 JD |
351 | end_unlock: |
352 | pthread_mutex_unlock(&stream->lock); | |
353 | end: | |
354 | rcu_read_unlock(); | |
355 | return ret; | |
356 | } | |
357 | ||
358 | /* | |
359 | * Read the whole metadata available for a snapshot. | |
360 | * | |
361 | * Returns 0 on success, < 0 on error | |
362 | */ | |
363 | int lttng_kconsumer_snapshot_metadata(uint64_t key, char *path, | |
e2039c7a | 364 | uint64_t relayd_id, struct lttng_consumer_local_data *ctx) |
07b86b52 | 365 | { |
d771f832 DG |
366 | int ret, use_relayd = 0; |
367 | ssize_t ret_read; | |
07b86b52 JD |
368 | struct lttng_consumer_channel *metadata_channel; |
369 | struct lttng_consumer_stream *metadata_stream; | |
d771f832 DG |
370 | |
371 | assert(ctx); | |
07b86b52 JD |
372 | |
373 | DBG("Kernel consumer snapshot metadata with key %" PRIu64 " at path %s", | |
374 | key, path); | |
375 | ||
376 | rcu_read_lock(); | |
377 | ||
378 | metadata_channel = consumer_find_channel(key); | |
379 | if (!metadata_channel) { | |
d771f832 | 380 | ERR("Kernel snapshot metadata not found for key %" PRIu64, key); |
07b86b52 | 381 | ret = -1; |
d771f832 | 382 | goto error; |
07b86b52 JD |
383 | } |
384 | ||
385 | metadata_stream = metadata_channel->metadata_stream; | |
386 | assert(metadata_stream); | |
387 | ||
d771f832 | 388 | /* Flag once that we have a valid relayd for the stream. */ |
e2039c7a | 389 | if (relayd_id != (uint64_t) -1ULL) { |
d771f832 DG |
390 | use_relayd = 1; |
391 | } | |
392 | ||
393 | if (use_relayd) { | |
e2039c7a JD |
394 | ret = send_relayd_stream(metadata_stream, path); |
395 | if (ret < 0) { | |
d771f832 | 396 | goto error; |
e2039c7a | 397 | } |
e2039c7a JD |
398 | } else { |
399 | ret = utils_create_stream_file(path, metadata_stream->name, | |
400 | metadata_stream->chan->tracefile_size, | |
401 | metadata_stream->tracefile_count_current, | |
402 | metadata_stream->uid, metadata_stream->gid); | |
403 | if (ret < 0) { | |
d771f832 | 404 | goto error; |
e2039c7a JD |
405 | } |
406 | metadata_stream->out_fd = ret; | |
07b86b52 | 407 | } |
07b86b52 | 408 | |
d771f832 DG |
409 | do { |
410 | ret_read = lttng_kconsumer_read_subbuffer(metadata_stream, ctx); | |
411 | if (ret_read < 0) { | |
412 | if (ret_read != -EPERM) { | |
413 | ERR("Kernel snapshot reading metadata subbuffer (ret: %ld)", | |
414 | ret_read); | |
415 | goto error; | |
07b86b52 | 416 | } |
d771f832 | 417 | /* ret_read is negative at this point so we will exit the loop. */ |
07b86b52 JD |
418 | continue; |
419 | } | |
d771f832 | 420 | } while (ret_read >= 0); |
07b86b52 | 421 | |
d771f832 DG |
422 | if (use_relayd) { |
423 | close_relayd_stream(metadata_stream); | |
424 | metadata_stream->net_seq_idx = (uint64_t) -1ULL; | |
425 | } else { | |
e2039c7a JD |
426 | ret = close(metadata_stream->out_fd); |
427 | if (ret < 0) { | |
d771f832 DG |
428 | PERROR("Kernel consumer snapshot metadata close out_fd"); |
429 | /* | |
430 | * Don't go on error here since the snapshot was successful at this | |
431 | * point but somehow the close failed. | |
432 | */ | |
e2039c7a JD |
433 | } |
434 | metadata_stream->out_fd = -1; | |
e2039c7a JD |
435 | } |
436 | ||
07b86b52 | 437 | ret = 0; |
d771f832 DG |
438 | |
439 | error: | |
07b86b52 JD |
440 | rcu_read_unlock(); |
441 | return ret; | |
442 | } | |
443 | ||
1803a064 MD |
444 | /* |
445 | * Receive command from session daemon and process it. | |
446 | * | |
447 | * Return 1 on success else a negative value or 0. | |
448 | */ | |
3bd1e081 MD |
449 | int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, |
450 | int sock, struct pollfd *consumer_sockpoll) | |
451 | { | |
452 | ssize_t ret; | |
f50f23d9 | 453 | enum lttng_error_code ret_code = LTTNG_OK; |
3bd1e081 MD |
454 | struct lttcomm_consumer_msg msg; |
455 | ||
456 | ret = lttcomm_recv_unix_sock(sock, &msg, sizeof(msg)); | |
457 | if (ret != sizeof(msg)) { | |
f73fabfd | 458 | lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_CMD); |
1803a064 MD |
459 | if (ret > 0) { |
460 | ret = -1; | |
461 | } | |
3bd1e081 MD |
462 | return ret; |
463 | } | |
464 | if (msg.cmd_type == LTTNG_CONSUMER_STOP) { | |
f50f23d9 DG |
465 | /* |
466 | * Notify the session daemon that the command is completed. | |
467 | * | |
468 | * On transport layer error, the function call will print an error | |
469 | * message so handling the returned code is a bit useless since we | |
470 | * return an error code anyway. | |
471 | */ | |
472 | (void) consumer_send_status_msg(sock, ret_code); | |
3bd1e081 MD |
473 | return -ENOENT; |
474 | } | |
475 | ||
b0b335c8 MD |
476 | /* relayd needs RCU read-side protection */ |
477 | rcu_read_lock(); | |
478 | ||
3bd1e081 | 479 | switch (msg.cmd_type) { |
00e2e675 DG |
480 | case LTTNG_CONSUMER_ADD_RELAYD_SOCKET: |
481 | { | |
f50f23d9 | 482 | /* Session daemon status message are handled in the following call. */ |
7735ef9e DG |
483 | ret = consumer_add_relayd_socket(msg.u.relayd_sock.net_index, |
484 | msg.u.relayd_sock.type, ctx, sock, consumer_sockpoll, | |
46e6455f | 485 | &msg.u.relayd_sock.sock, msg.u.relayd_sock.session_id); |
00e2e675 DG |
486 | goto end_nosignal; |
487 | } | |
3bd1e081 MD |
488 | case LTTNG_CONSUMER_ADD_CHANNEL: |
489 | { | |
490 | struct lttng_consumer_channel *new_channel; | |
e43c41c5 | 491 | int ret_recv; |
3bd1e081 | 492 | |
f50f23d9 DG |
493 | /* First send a status message before receiving the fds. */ |
494 | ret = consumer_send_status_msg(sock, ret_code); | |
495 | if (ret < 0) { | |
496 | /* Somehow, the session daemon is not responding anymore. */ | |
1803a064 | 497 | goto error_fatal; |
f50f23d9 | 498 | } |
d88aee68 | 499 | DBG("consumer_add_channel %" PRIu64, msg.u.channel.channel_key); |
3bd1e081 | 500 | new_channel = consumer_allocate_channel(msg.u.channel.channel_key, |
ffe60014 DG |
501 | msg.u.channel.session_id, msg.u.channel.pathname, |
502 | msg.u.channel.name, msg.u.channel.uid, msg.u.channel.gid, | |
1624d5b7 JD |
503 | msg.u.channel.relayd_id, msg.u.channel.output, |
504 | msg.u.channel.tracefile_size, | |
1950109e | 505 | msg.u.channel.tracefile_count, 0, |
2bba9e53 | 506 | msg.u.channel.monitor); |
3bd1e081 | 507 | if (new_channel == NULL) { |
f73fabfd | 508 | lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); |
3bd1e081 MD |
509 | goto end_nosignal; |
510 | } | |
ffe60014 | 511 | new_channel->nb_init_stream_left = msg.u.channel.nb_init_streams; |
95a1109b JD |
512 | switch (msg.u.channel.output) { |
513 | case LTTNG_EVENT_SPLICE: | |
514 | new_channel->output = CONSUMER_CHANNEL_SPLICE; | |
515 | break; | |
516 | case LTTNG_EVENT_MMAP: | |
517 | new_channel->output = CONSUMER_CHANNEL_MMAP; | |
518 | break; | |
519 | default: | |
520 | ERR("Channel output unknown %d", msg.u.channel.output); | |
521 | goto end_nosignal; | |
522 | } | |
ffe60014 DG |
523 | |
524 | /* Translate and save channel type. */ | |
525 | switch (msg.u.channel.type) { | |
526 | case CONSUMER_CHANNEL_TYPE_DATA: | |
527 | case CONSUMER_CHANNEL_TYPE_METADATA: | |
528 | new_channel->type = msg.u.channel.type; | |
529 | break; | |
530 | default: | |
531 | assert(0); | |
532 | goto end_nosignal; | |
533 | }; | |
534 | ||
3bd1e081 | 535 | if (ctx->on_recv_channel != NULL) { |
e43c41c5 JD |
536 | ret_recv = ctx->on_recv_channel(new_channel); |
537 | if (ret_recv == 0) { | |
538 | ret = consumer_add_channel(new_channel, ctx); | |
539 | } else if (ret_recv < 0) { | |
3bd1e081 MD |
540 | goto end_nosignal; |
541 | } | |
542 | } else { | |
e43c41c5 | 543 | ret = consumer_add_channel(new_channel, ctx); |
3bd1e081 | 544 | } |
e43c41c5 JD |
545 | |
546 | /* If we received an error in add_channel, we need to report it. */ | |
821fffb2 | 547 | if (ret < 0) { |
1803a064 MD |
548 | ret = consumer_send_status_msg(sock, ret); |
549 | if (ret < 0) { | |
550 | goto error_fatal; | |
551 | } | |
e43c41c5 JD |
552 | goto end_nosignal; |
553 | } | |
554 | ||
3bd1e081 MD |
555 | goto end_nosignal; |
556 | } | |
557 | case LTTNG_CONSUMER_ADD_STREAM: | |
558 | { | |
dae10966 DG |
559 | int fd; |
560 | struct lttng_pipe *stream_pipe; | |
00e2e675 | 561 | struct lttng_consumer_stream *new_stream; |
ffe60014 | 562 | struct lttng_consumer_channel *channel; |
c80048c6 | 563 | int alloc_ret = 0; |
3bd1e081 | 564 | |
ffe60014 DG |
565 | /* |
566 | * Get stream's channel reference. Needed when adding the stream to the | |
567 | * global hash table. | |
568 | */ | |
569 | channel = consumer_find_channel(msg.u.stream.channel_key); | |
570 | if (!channel) { | |
571 | /* | |
572 | * We could not find the channel. Can happen if cpu hotplug | |
573 | * happens while tearing down. | |
574 | */ | |
d88aee68 | 575 | ERR("Unable to find channel key %" PRIu64, msg.u.stream.channel_key); |
ffe60014 DG |
576 | ret_code = LTTNG_ERR_KERN_CHAN_NOT_FOUND; |
577 | } | |
578 | ||
f50f23d9 DG |
579 | /* First send a status message before receiving the fds. */ |
580 | ret = consumer_send_status_msg(sock, ret_code); | |
1803a064 | 581 | if (ret < 0) { |
d771f832 | 582 | /* Somehow, the session daemon is not responding anymore. */ |
1803a064 MD |
583 | goto error_fatal; |
584 | } | |
585 | if (ret_code != LTTNG_OK) { | |
d771f832 | 586 | /* Channel was not found. */ |
f50f23d9 DG |
587 | goto end_nosignal; |
588 | } | |
589 | ||
d771f832 | 590 | /* Blocking call */ |
3bd1e081 | 591 | if (lttng_consumer_poll_socket(consumer_sockpoll) < 0) { |
3f8e211f | 592 | rcu_read_unlock(); |
3bd1e081 MD |
593 | return -EINTR; |
594 | } | |
00e2e675 DG |
595 | |
596 | /* Get stream file descriptor from socket */ | |
f2fc6720 MD |
597 | ret = lttcomm_recv_fds_unix_sock(sock, &fd, 1); |
598 | if (ret != sizeof(fd)) { | |
f73fabfd | 599 | lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_FD); |
3f8e211f | 600 | rcu_read_unlock(); |
3bd1e081 MD |
601 | return ret; |
602 | } | |
3bd1e081 | 603 | |
f50f23d9 DG |
604 | /* |
605 | * Send status code to session daemon only if the recv works. If the | |
606 | * above recv() failed, the session daemon is notified through the | |
607 | * error socket and the teardown is eventually done. | |
608 | */ | |
609 | ret = consumer_send_status_msg(sock, ret_code); | |
610 | if (ret < 0) { | |
611 | /* Somehow, the session daemon is not responding anymore. */ | |
612 | goto end_nosignal; | |
613 | } | |
614 | ||
ffe60014 DG |
615 | new_stream = consumer_allocate_stream(channel->key, |
616 | fd, | |
617 | LTTNG_CONSUMER_ACTIVE_STREAM, | |
618 | channel->name, | |
619 | channel->uid, | |
620 | channel->gid, | |
621 | channel->relayd_id, | |
622 | channel->session_id, | |
623 | msg.u.stream.cpu, | |
624 | &alloc_ret, | |
625 | channel->type); | |
3bd1e081 | 626 | if (new_stream == NULL) { |
c80048c6 MD |
627 | switch (alloc_ret) { |
628 | case -ENOMEM: | |
629 | case -EINVAL: | |
630 | default: | |
631 | lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); | |
632 | break; | |
c80048c6 | 633 | } |
3f8e211f | 634 | goto end_nosignal; |
3bd1e081 | 635 | } |
d771f832 | 636 | |
ffe60014 DG |
637 | new_stream->chan = channel; |
638 | new_stream->wait_fd = fd; | |
07b86b52 JD |
639 | switch (channel->output) { |
640 | case CONSUMER_CHANNEL_SPLICE: | |
641 | new_stream->output = LTTNG_EVENT_SPLICE; | |
642 | break; | |
643 | case CONSUMER_CHANNEL_MMAP: | |
644 | new_stream->output = LTTNG_EVENT_MMAP; | |
645 | break; | |
646 | default: | |
647 | ERR("Stream output unknown %d", channel->output); | |
648 | goto end_nosignal; | |
649 | } | |
00e2e675 | 650 | |
a0c83db9 DG |
651 | /* |
652 | * We've just assigned the channel to the stream so increment the | |
07b86b52 JD |
653 | * refcount right now. We don't need to increment the refcount for |
654 | * streams in no monitor because we handle manually the cleanup of | |
655 | * those. It is very important to make sure there is NO prior | |
656 | * consumer_del_stream() calls or else the refcount will be unbalanced. | |
a0c83db9 | 657 | */ |
07b86b52 JD |
658 | if (channel->monitor) { |
659 | uatomic_inc(&new_stream->chan->refcount); | |
660 | } | |
9d9353f9 | 661 | |
fb3a43a9 DG |
662 | /* |
663 | * The buffer flush is done on the session daemon side for the kernel | |
664 | * so no need for the stream "hangup_flush_done" variable to be | |
665 | * tracked. This is important for a kernel stream since we don't rely | |
666 | * on the flush state of the stream to read data. It's not the case for | |
667 | * user space tracing. | |
668 | */ | |
669 | new_stream->hangup_flush_done = 0; | |
670 | ||
633d0084 DG |
671 | if (ctx->on_recv_stream) { |
672 | ret = ctx->on_recv_stream(new_stream); | |
673 | if (ret < 0) { | |
d771f832 | 674 | consumer_stream_free(new_stream); |
633d0084 | 675 | goto end_nosignal; |
fb3a43a9 | 676 | } |
633d0084 | 677 | } |
fb3a43a9 | 678 | |
07b86b52 JD |
679 | if (new_stream->metadata_flag) { |
680 | channel->metadata_stream = new_stream; | |
681 | } | |
682 | ||
2bba9e53 DG |
683 | /* Do not monitor this stream. */ |
684 | if (!channel->monitor) { | |
5eecee74 | 685 | DBG("Kernel consumer add stream %s in no monitor mode with " |
6dc3064a | 686 | "relayd id %" PRIu64, new_stream->name, |
5eecee74 | 687 | new_stream->net_seq_idx); |
07b86b52 JD |
688 | cds_list_add(&new_stream->no_monitor_node, |
689 | &channel->stream_no_monitor_list.head); | |
6dc3064a DG |
690 | break; |
691 | } | |
692 | ||
e2039c7a JD |
693 | ret = send_relayd_stream(new_stream, NULL); |
694 | if (ret < 0) { | |
d771f832 | 695 | consumer_stream_free(new_stream); |
e2039c7a JD |
696 | goto end_nosignal; |
697 | } | |
698 | ||
50f8ae69 | 699 | /* Get the right pipe where the stream will be sent. */ |
633d0084 | 700 | if (new_stream->metadata_flag) { |
dae10966 | 701 | stream_pipe = ctx->consumer_metadata_pipe; |
3bd1e081 | 702 | } else { |
dae10966 | 703 | stream_pipe = ctx->consumer_data_pipe; |
50f8ae69 DG |
704 | } |
705 | ||
dae10966 | 706 | ret = lttng_pipe_write(stream_pipe, &new_stream, sizeof(new_stream)); |
50f8ae69 | 707 | if (ret < 0) { |
dae10966 | 708 | ERR("Consumer write %s stream to pipe %d", |
50f8ae69 | 709 | new_stream->metadata_flag ? "metadata" : "data", |
dae10966 | 710 | lttng_pipe_get_writefd(stream_pipe)); |
d771f832 | 711 | consumer_stream_free(new_stream); |
50f8ae69 | 712 | goto end_nosignal; |
3bd1e081 | 713 | } |
00e2e675 | 714 | |
50f8ae69 | 715 | DBG("Kernel consumer ADD_STREAM %s (fd: %d) with relayd id %" PRIu64, |
ffe60014 | 716 | new_stream->name, fd, new_stream->relayd_stream_id); |
3bd1e081 MD |
717 | break; |
718 | } | |
719 | case LTTNG_CONSUMER_UPDATE_STREAM: | |
720 | { | |
3f8e211f DG |
721 | rcu_read_unlock(); |
722 | return -ENOSYS; | |
723 | } | |
724 | case LTTNG_CONSUMER_DESTROY_RELAYD: | |
725 | { | |
a6ba4fe1 | 726 | uint64_t index = msg.u.destroy_relayd.net_seq_idx; |
3f8e211f DG |
727 | struct consumer_relayd_sock_pair *relayd; |
728 | ||
a6ba4fe1 | 729 | DBG("Kernel consumer destroying relayd %" PRIu64, index); |
3f8e211f DG |
730 | |
731 | /* Get relayd reference if exists. */ | |
a6ba4fe1 | 732 | relayd = consumer_find_relayd(index); |
3f8e211f | 733 | if (relayd == NULL) { |
3448e266 | 734 | DBG("Unable to find relayd %" PRIu64, index); |
f50f23d9 | 735 | ret_code = LTTNG_ERR_NO_CONSUMER; |
3bd1e081 | 736 | } |
3f8e211f | 737 | |
a6ba4fe1 DG |
738 | /* |
739 | * Each relayd socket pair has a refcount of stream attached to it | |
740 | * which tells if the relayd is still active or not depending on the | |
741 | * refcount value. | |
742 | * | |
743 | * This will set the destroy flag of the relayd object and destroy it | |
744 | * if the refcount reaches zero when called. | |
745 | * | |
746 | * The destroy can happen either here or when a stream fd hangs up. | |
747 | */ | |
f50f23d9 DG |
748 | if (relayd) { |
749 | consumer_flag_relayd_for_destroy(relayd); | |
750 | } | |
751 | ||
752 | ret = consumer_send_status_msg(sock, ret_code); | |
753 | if (ret < 0) { | |
754 | /* Somehow, the session daemon is not responding anymore. */ | |
1803a064 | 755 | goto error_fatal; |
f50f23d9 | 756 | } |
3f8e211f | 757 | |
3f8e211f | 758 | goto end_nosignal; |
3bd1e081 | 759 | } |
6d805429 | 760 | case LTTNG_CONSUMER_DATA_PENDING: |
53632229 | 761 | { |
c8f59ee5 | 762 | int32_t ret; |
6d805429 | 763 | uint64_t id = msg.u.data_pending.session_id; |
c8f59ee5 | 764 | |
6d805429 | 765 | DBG("Kernel consumer data pending command for id %" PRIu64, id); |
c8f59ee5 | 766 | |
6d805429 | 767 | ret = consumer_data_pending(id); |
c8f59ee5 DG |
768 | |
769 | /* Send back returned value to session daemon */ | |
770 | ret = lttcomm_send_unix_sock(sock, &ret, sizeof(ret)); | |
771 | if (ret < 0) { | |
6d805429 | 772 | PERROR("send data pending ret code"); |
1803a064 | 773 | goto error_fatal; |
c8f59ee5 | 774 | } |
f50f23d9 DG |
775 | |
776 | /* | |
777 | * No need to send back a status message since the data pending | |
778 | * returned value is the response. | |
779 | */ | |
c8f59ee5 | 780 | break; |
53632229 | 781 | } |
6dc3064a DG |
782 | case LTTNG_CONSUMER_SNAPSHOT_CHANNEL: |
783 | { | |
07b86b52 JD |
784 | if (msg.u.snapshot_channel.metadata == 1) { |
785 | ret = lttng_kconsumer_snapshot_metadata(msg.u.snapshot_channel.key, | |
e2039c7a JD |
786 | msg.u.snapshot_channel.pathname, |
787 | msg.u.snapshot_channel.relayd_id, ctx); | |
07b86b52 JD |
788 | if (ret < 0) { |
789 | ERR("Snapshot metadata failed"); | |
790 | ret_code = LTTNG_ERR_KERN_META_FAIL; | |
791 | } | |
792 | } else { | |
793 | ret = lttng_kconsumer_snapshot_channel(msg.u.snapshot_channel.key, | |
794 | msg.u.snapshot_channel.pathname, | |
795 | msg.u.snapshot_channel.relayd_id, ctx); | |
796 | if (ret < 0) { | |
797 | ERR("Snapshot channel failed"); | |
798 | ret_code = LTTNG_ERR_KERN_CHAN_FAIL; | |
799 | } | |
800 | } | |
801 | ||
6dc3064a DG |
802 | ret = consumer_send_status_msg(sock, ret_code); |
803 | if (ret < 0) { | |
804 | /* Somehow, the session daemon is not responding anymore. */ | |
805 | goto end_nosignal; | |
806 | } | |
807 | break; | |
808 | } | |
07b86b52 JD |
809 | case LTTNG_CONSUMER_DESTROY_CHANNEL: |
810 | { | |
811 | uint64_t key = msg.u.destroy_channel.key; | |
812 | struct lttng_consumer_channel *channel; | |
813 | ||
814 | channel = consumer_find_channel(key); | |
815 | if (!channel) { | |
816 | ERR("Kernel consumer destroy channel %" PRIu64 " not found", key); | |
817 | ret_code = LTTNG_ERR_KERN_CHAN_NOT_FOUND; | |
818 | } | |
819 | ||
820 | ret = consumer_send_status_msg(sock, ret_code); | |
821 | if (ret < 0) { | |
822 | /* Somehow, the session daemon is not responding anymore. */ | |
823 | goto end_nosignal; | |
824 | } | |
825 | ||
826 | /* | |
827 | * This command should ONLY be issued for channel with streams set in | |
828 | * no monitor mode. | |
829 | */ | |
830 | assert(!channel->monitor); | |
831 | ||
832 | /* | |
833 | * The refcount should ALWAYS be 0 in the case of a channel in no | |
834 | * monitor mode. | |
835 | */ | |
836 | assert(!uatomic_sub_return(&channel->refcount, 1)); | |
837 | ||
838 | consumer_del_channel(channel); | |
839 | ||
840 | goto end_nosignal; | |
841 | } | |
3bd1e081 | 842 | default: |
3f8e211f | 843 | goto end_nosignal; |
3bd1e081 | 844 | } |
3f8e211f | 845 | |
3bd1e081 | 846 | end_nosignal: |
b0b335c8 | 847 | rcu_read_unlock(); |
4cbc1a04 DG |
848 | |
849 | /* | |
850 | * Return 1 to indicate success since the 0 value can be a socket | |
851 | * shutdown during the recv() or send() call. | |
852 | */ | |
853 | return 1; | |
1803a064 MD |
854 | |
855 | error_fatal: | |
856 | rcu_read_unlock(); | |
857 | /* This will issue a consumer stop. */ | |
858 | return -1; | |
3bd1e081 | 859 | } |
d41f73b7 MD |
860 | |
861 | /* | |
862 | * Consume data on a file descriptor and write it on a trace file. | |
863 | */ | |
4078b776 | 864 | ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream, |
d41f73b7 MD |
865 | struct lttng_consumer_local_data *ctx) |
866 | { | |
1d4dfdef | 867 | unsigned long len, subbuf_size, padding; |
d41f73b7 | 868 | int err; |
4078b776 | 869 | ssize_t ret = 0; |
d41f73b7 MD |
870 | int infd = stream->wait_fd; |
871 | ||
872 | DBG("In read_subbuffer (infd : %d)", infd); | |
873 | /* Get the next subbuffer */ | |
874 | err = kernctl_get_next_subbuf(infd); | |
875 | if (err != 0) { | |
1d4dfdef | 876 | ret = err; |
d41f73b7 MD |
877 | /* |
878 | * This is a debug message even for single-threaded consumer, | |
879 | * because poll() have more relaxed criterions than get subbuf, | |
880 | * so get_subbuf may fail for short race windows where poll() | |
881 | * would issue wakeups. | |
882 | */ | |
883 | DBG("Reserving sub buffer failed (everything is normal, " | |
884 | "it is due to concurrency)"); | |
885 | goto end; | |
886 | } | |
887 | ||
1d4dfdef DG |
888 | /* Get the full subbuffer size including padding */ |
889 | err = kernctl_get_padded_subbuf_size(infd, &len); | |
890 | if (err != 0) { | |
891 | errno = -err; | |
892 | perror("Getting sub-buffer len failed."); | |
893 | ret = err; | |
894 | goto end; | |
895 | } | |
896 | ||
ffe60014 | 897 | switch (stream->chan->output) { |
07b86b52 | 898 | case CONSUMER_CHANNEL_SPLICE: |
1d4dfdef DG |
899 | /* |
900 | * XXX: The lttng-modules splice "actor" does not handle copying | |
901 | * partial pages hence only using the subbuffer size without the | |
902 | * padding makes the splice fail. | |
903 | */ | |
904 | subbuf_size = len; | |
905 | padding = 0; | |
906 | ||
907 | /* splice the subbuffer to the tracefile */ | |
91dfef6e DG |
908 | ret = lttng_consumer_on_read_subbuffer_splice(ctx, stream, subbuf_size, |
909 | padding); | |
910 | /* | |
911 | * XXX: Splice does not support network streaming so the return value | |
912 | * is simply checked against subbuf_size and not like the mmap() op. | |
913 | */ | |
1d4dfdef DG |
914 | if (ret != subbuf_size) { |
915 | /* | |
916 | * display the error but continue processing to try | |
917 | * to release the subbuffer | |
918 | */ | |
919 | ERR("Error splicing to tracefile (ret: %zd != len: %lu)", | |
920 | ret, subbuf_size); | |
921 | } | |
922 | break; | |
07b86b52 | 923 | case CONSUMER_CHANNEL_MMAP: |
1d4dfdef DG |
924 | /* Get subbuffer size without padding */ |
925 | err = kernctl_get_subbuf_size(infd, &subbuf_size); | |
926 | if (err != 0) { | |
927 | errno = -err; | |
928 | perror("Getting sub-buffer len failed."); | |
929 | ret = err; | |
930 | goto end; | |
931 | } | |
47e81c02 | 932 | |
1d4dfdef DG |
933 | /* Make sure the tracer is not gone mad on us! */ |
934 | assert(len >= subbuf_size); | |
935 | ||
936 | padding = len - subbuf_size; | |
937 | ||
938 | /* write the subbuffer to the tracefile */ | |
91dfef6e DG |
939 | ret = lttng_consumer_on_read_subbuffer_mmap(ctx, stream, subbuf_size, |
940 | padding); | |
941 | /* | |
942 | * The mmap operation should write subbuf_size amount of data when | |
943 | * network streaming or the full padding (len) size when we are _not_ | |
944 | * streaming. | |
945 | */ | |
d88aee68 DG |
946 | if ((ret != subbuf_size && stream->net_seq_idx != (uint64_t) -1ULL) || |
947 | (ret != len && stream->net_seq_idx == (uint64_t) -1ULL)) { | |
1d4dfdef | 948 | /* |
91dfef6e DG |
949 | * Display the error but continue processing to try to release the |
950 | * subbuffer | |
1d4dfdef | 951 | */ |
91dfef6e DG |
952 | ERR("Error writing to tracefile " |
953 | "(ret: %zd != len: %lu != subbuf_size: %lu)", | |
954 | ret, len, subbuf_size); | |
1d4dfdef DG |
955 | } |
956 | break; | |
957 | default: | |
958 | ERR("Unknown output method"); | |
959 | ret = -1; | |
d41f73b7 MD |
960 | } |
961 | ||
962 | err = kernctl_put_next_subbuf(infd); | |
963 | if (err != 0) { | |
21073eaa | 964 | errno = -err; |
d41f73b7 MD |
965 | if (errno == EFAULT) { |
966 | perror("Error in unreserving sub buffer\n"); | |
967 | } else if (errno == EIO) { | |
968 | /* Should never happen with newer LTTng versions */ | |
969 | perror("Reader has been pushed by the writer, last sub-buffer corrupted."); | |
970 | } | |
21073eaa DG |
971 | |
972 | ret = -err; | |
d41f73b7 MD |
973 | goto end; |
974 | } | |
975 | ||
976 | end: | |
977 | return ret; | |
978 | } | |
979 | ||
980 | int lttng_kconsumer_on_recv_stream(struct lttng_consumer_stream *stream) | |
981 | { | |
982 | int ret; | |
ffe60014 DG |
983 | |
984 | assert(stream); | |
985 | ||
2bba9e53 DG |
986 | /* |
987 | * Don't create anything if this is set for streaming or should not be | |
988 | * monitored. | |
989 | */ | |
990 | if (stream->net_seq_idx == (uint64_t) -1ULL && stream->chan->monitor) { | |
fe4477ee JD |
991 | ret = utils_create_stream_file(stream->chan->pathname, stream->name, |
992 | stream->chan->tracefile_size, stream->tracefile_count_current, | |
993 | stream->uid, stream->gid); | |
994 | if (ret < 0) { | |
995 | goto error; | |
996 | } | |
997 | stream->out_fd = ret; | |
998 | stream->tracefile_size_current = 0; | |
ffe60014 | 999 | } |
d41f73b7 | 1000 | |
d41f73b7 MD |
1001 | if (stream->output == LTTNG_EVENT_MMAP) { |
1002 | /* get the len of the mmap region */ | |
1003 | unsigned long mmap_len; | |
1004 | ||
1005 | ret = kernctl_get_mmap_len(stream->wait_fd, &mmap_len); | |
1006 | if (ret != 0) { | |
87dc6a9c | 1007 | errno = -ret; |
ffe60014 | 1008 | PERROR("kernctl_get_mmap_len"); |
d41f73b7 MD |
1009 | goto error_close_fd; |
1010 | } | |
1011 | stream->mmap_len = (size_t) mmap_len; | |
1012 | ||
ffe60014 DG |
1013 | stream->mmap_base = mmap(NULL, stream->mmap_len, PROT_READ, |
1014 | MAP_PRIVATE, stream->wait_fd, 0); | |
d41f73b7 | 1015 | if (stream->mmap_base == MAP_FAILED) { |
ffe60014 | 1016 | PERROR("Error mmaping"); |
d41f73b7 MD |
1017 | ret = -1; |
1018 | goto error_close_fd; | |
1019 | } | |
1020 | } | |
1021 | ||
1022 | /* we return 0 to let the library handle the FD internally */ | |
1023 | return 0; | |
1024 | ||
1025 | error_close_fd: | |
1026 | { | |
1027 | int err; | |
1028 | ||
1029 | err = close(stream->out_fd); | |
1030 | assert(!err); | |
1031 | } | |
1032 | error: | |
1033 | return ret; | |
1034 | } | |
1035 | ||
ca22feea DG |
1036 | /* |
1037 | * Check if data is still being extracted from the buffers for a specific | |
4e9a4686 DG |
1038 | * stream. Consumer data lock MUST be acquired before calling this function |
1039 | * and the stream lock. | |
ca22feea | 1040 | * |
6d805429 | 1041 | * Return 1 if the traced data are still getting read else 0 meaning that the |
ca22feea DG |
1042 | * data is available for trace viewer reading. |
1043 | */ | |
6d805429 | 1044 | int lttng_kconsumer_data_pending(struct lttng_consumer_stream *stream) |
ca22feea DG |
1045 | { |
1046 | int ret; | |
1047 | ||
1048 | assert(stream); | |
1049 | ||
ca22feea DG |
1050 | ret = kernctl_get_next_subbuf(stream->wait_fd); |
1051 | if (ret == 0) { | |
1052 | /* There is still data so let's put back this subbuffer. */ | |
1053 | ret = kernctl_put_subbuf(stream->wait_fd); | |
1054 | assert(ret == 0); | |
6d805429 | 1055 | ret = 1; /* Data is pending */ |
4e9a4686 | 1056 | goto end; |
ca22feea DG |
1057 | } |
1058 | ||
6d805429 DG |
1059 | /* Data is NOT pending and ready to be read. */ |
1060 | ret = 0; | |
ca22feea | 1061 | |
6efae65e DG |
1062 | end: |
1063 | return ret; | |
ca22feea | 1064 | } |