2 * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; only version 2
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #include <lttng/ust-ctl.h>
23 #include <lttng/ust-abi.h>
24 #include <lttng/ust-events.h>
27 #include <usterr-signal-safe.h>
30 #include "../libringbuffer/backend.h"
31 #include "../libringbuffer/frontend.h"
33 volatile enum ust_loglevel ust_loglevel
;
36 void init_object(struct lttng_ust_object_data
*data
)
41 data
->memory_map_size
= 0;
44 int ustctl_release_handle(int sock
, int handle
)
46 struct ustcomm_ust_msg lum
;
47 struct ustcomm_ust_reply lur
;
51 memset(&lum
, 0, sizeof(lum
));
53 lum
.cmd
= LTTNG_UST_RELEASE
;
54 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
62 * If sock is negative, it means we don't have to notify the other side
63 * (e.g. application has already vanished).
65 int ustctl_release_object(int sock
, struct lttng_ust_object_data
*data
)
69 if (data
->shm_fd
>= 0) {
70 ret
= close(data
->shm_fd
);
75 if (data
->wait_fd
>= 0) {
76 ret
= close(data
->wait_fd
);
81 return ustctl_release_handle(sock
, data
->handle
);
85 * Send registration done packet to the application.
87 int ustctl_register_done(int sock
)
89 struct ustcomm_ust_msg lum
;
90 struct ustcomm_ust_reply lur
;
93 DBG("Sending register done command to %d", sock
);
94 memset(&lum
, 0, sizeof(lum
));
95 lum
.handle
= LTTNG_UST_ROOT_HANDLE
;
96 lum
.cmd
= LTTNG_UST_REGISTER_DONE
;
97 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
100 if (lur
.ret_code
!= USTCOMM_OK
) {
101 DBG("Return code: %s", ustcomm_get_readable_code(lur
.ret_code
));
111 * returns session handle.
113 int ustctl_create_session(int sock
)
115 struct ustcomm_ust_msg lum
;
116 struct ustcomm_ust_reply lur
;
117 int ret
, session_handle
;
120 memset(&lum
, 0, sizeof(lum
));
121 lum
.handle
= LTTNG_UST_ROOT_HANDLE
;
122 lum
.cmd
= LTTNG_UST_SESSION
;
123 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
126 session_handle
= lur
.ret_val
;
127 DBG("received session handle %u", session_handle
);
128 return session_handle
;
131 /* open the metadata global channel */
132 int ustctl_open_metadata(int sock
, int session_handle
,
133 struct lttng_ust_channel_attr
*chops
,
134 struct lttng_ust_object_data
**_metadata_data
)
136 struct ustcomm_ust_msg lum
;
137 struct ustcomm_ust_reply lur
;
138 struct lttng_ust_object_data
*metadata_data
;
141 metadata_data
= malloc(sizeof(*metadata_data
));
144 init_object(metadata_data
);
145 /* Create metadata channel */
146 memset(&lum
, 0, sizeof(lum
));
147 lum
.handle
= session_handle
;
148 lum
.cmd
= LTTNG_UST_METADATA
;
149 lum
.u
.channel
.overwrite
= chops
->overwrite
;
150 lum
.u
.channel
.subbuf_size
= chops
->subbuf_size
;
151 lum
.u
.channel
.num_subbuf
= chops
->num_subbuf
;
152 lum
.u
.channel
.switch_timer_interval
= chops
->switch_timer_interval
;
153 lum
.u
.channel
.read_timer_interval
= chops
->read_timer_interval
;
154 lum
.u
.channel
.output
= chops
->output
;
155 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
160 if (lur
.ret_code
!= USTCOMM_OK
) {
164 metadata_data
->handle
= lur
.ret_val
;
165 DBG("received metadata handle %u", metadata_data
->handle
);
166 metadata_data
->memory_map_size
= lur
.u
.channel
.memory_map_size
;
168 ret
= ustcomm_recv_fd(sock
);
172 metadata_data
->shm_fd
= ret
;
174 * We need to get the second FD even if the first fails, because
175 * libust expects us to read the two FDs.
178 ret
= ustcomm_recv_fd(sock
);
182 metadata_data
->wait_fd
= ret
;
185 *_metadata_data
= metadata_data
;
189 (void) ustctl_release_object(sock
, metadata_data
);
194 int ustctl_create_channel(int sock
, int session_handle
,
195 struct lttng_ust_channel_attr
*chops
,
196 struct lttng_ust_object_data
**_channel_data
)
198 struct ustcomm_ust_msg lum
;
199 struct ustcomm_ust_reply lur
;
200 struct lttng_ust_object_data
*channel_data
;
203 channel_data
= malloc(sizeof(*channel_data
));
206 init_object(channel_data
);
207 /* Create metadata channel */
208 memset(&lum
, 0, sizeof(lum
));
209 lum
.handle
= session_handle
;
210 lum
.cmd
= LTTNG_UST_CHANNEL
;
211 lum
.u
.channel
.overwrite
= chops
->overwrite
;
212 lum
.u
.channel
.subbuf_size
= chops
->subbuf_size
;
213 lum
.u
.channel
.num_subbuf
= chops
->num_subbuf
;
214 lum
.u
.channel
.switch_timer_interval
= chops
->switch_timer_interval
;
215 lum
.u
.channel
.read_timer_interval
= chops
->read_timer_interval
;
216 lum
.u
.channel
.output
= chops
->output
;
217 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
222 if (lur
.ret_code
!= USTCOMM_OK
) {
226 channel_data
->handle
= lur
.ret_val
;
227 DBG("received channel handle %u", channel_data
->handle
);
228 channel_data
->memory_map_size
= lur
.u
.channel
.memory_map_size
;
230 ret
= ustcomm_recv_fd(sock
);
234 channel_data
->shm_fd
= ret
;
236 * We need to get the second FD even if the first fails, because
237 * libust expects us to read the two FDs.
240 ret
= ustcomm_recv_fd(sock
);
244 channel_data
->wait_fd
= ret
;
247 *_channel_data
= channel_data
;
251 (void) ustctl_release_object(sock
, channel_data
);
257 * Return -ENOENT if no more stream is available for creation.
258 * Return 0 on success.
259 * Return negative error value on error.
261 int ustctl_create_stream(int sock
, struct lttng_ust_object_data
*channel_data
,
262 struct lttng_ust_object_data
**_stream_data
)
264 struct ustcomm_ust_msg lum
;
265 struct ustcomm_ust_reply lur
;
266 struct lttng_ust_object_data
*stream_data
;
267 int ret
, fd
, err
= 0;
269 stream_data
= malloc(sizeof(*stream_data
));
272 init_object(stream_data
);
273 memset(&lum
, 0, sizeof(lum
));
274 lum
.handle
= channel_data
->handle
;
275 lum
.cmd
= LTTNG_UST_STREAM
;
276 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
281 if (lur
.ret_code
!= USTCOMM_OK
) {
286 stream_data
->handle
= lur
.ret_val
;
287 DBG("received stream handle %u", stream_data
->handle
);
288 stream_data
->memory_map_size
= lur
.u
.stream
.memory_map_size
;
290 fd
= ustcomm_recv_fd(sock
);
294 stream_data
->shm_fd
= fd
;
296 * We need to get the second FD even if the first fails, because
297 * libust expects us to read the two FDs.
300 fd
= ustcomm_recv_fd(sock
);
304 stream_data
->wait_fd
= fd
;
307 *_stream_data
= stream_data
;
311 (void) ustctl_release_object(sock
, stream_data
);
316 int ustctl_create_event(int sock
, struct lttng_ust_event
*ev
,
317 struct lttng_ust_object_data
*channel_data
,
318 struct lttng_ust_object_data
**_event_data
)
320 struct ustcomm_ust_msg lum
;
321 struct ustcomm_ust_reply lur
;
322 struct lttng_ust_object_data
*event_data
;
325 event_data
= malloc(sizeof(*event_data
));
328 init_object(event_data
);
329 memset(&lum
, 0, sizeof(lum
));
330 lum
.handle
= channel_data
->handle
;
331 lum
.cmd
= LTTNG_UST_EVENT
;
332 strncpy(lum
.u
.event
.name
, ev
->name
,
333 LTTNG_UST_SYM_NAME_LEN
);
334 lum
.u
.event
.instrumentation
= ev
->instrumentation
;
335 lum
.u
.event
.loglevel_type
= ev
->loglevel_type
;
336 lum
.u
.event
.loglevel
= ev
->loglevel
;
337 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
342 event_data
->handle
= lur
.ret_val
;
343 DBG("received event handle %u", event_data
->handle
);
344 *_event_data
= event_data
;
348 int ustctl_add_context(int sock
, struct lttng_ust_context
*ctx
,
349 struct lttng_ust_object_data
*obj_data
,
350 struct lttng_ust_object_data
**_context_data
)
352 struct ustcomm_ust_msg lum
;
353 struct ustcomm_ust_reply lur
;
354 struct lttng_ust_object_data
*context_data
;
357 context_data
= malloc(sizeof(*context_data
));
360 init_object(context_data
);
361 memset(&lum
, 0, sizeof(lum
));
362 lum
.handle
= obj_data
->handle
;
363 lum
.cmd
= LTTNG_UST_CONTEXT
;
364 lum
.u
.context
.ctx
= ctx
->ctx
;
365 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
370 context_data
->handle
= lur
.ret_val
;
371 DBG("received context handle %u", context_data
->handle
);
372 *_context_data
= context_data
;
376 /* Enable event, channel and session ioctl */
377 int ustctl_enable(int sock
, struct lttng_ust_object_data
*object
)
379 struct ustcomm_ust_msg lum
;
380 struct ustcomm_ust_reply lur
;
383 memset(&lum
, 0, sizeof(lum
));
384 lum
.handle
= object
->handle
;
385 lum
.cmd
= LTTNG_UST_ENABLE
;
386 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
389 DBG("enabled handle %u", object
->handle
);
393 /* Disable event, channel and session ioctl */
394 int ustctl_disable(int sock
, struct lttng_ust_object_data
*object
)
396 struct ustcomm_ust_msg lum
;
397 struct ustcomm_ust_reply lur
;
400 memset(&lum
, 0, sizeof(lum
));
401 lum
.handle
= object
->handle
;
402 lum
.cmd
= LTTNG_UST_DISABLE
;
403 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
406 DBG("disable handle %u", object
->handle
);
410 int ustctl_start_session(int sock
, int handle
)
412 struct lttng_ust_object_data obj
;
415 return ustctl_enable(sock
, &obj
);
418 int ustctl_stop_session(int sock
, int handle
)
420 struct lttng_ust_object_data obj
;
423 return ustctl_disable(sock
, &obj
);
426 int ustctl_tracepoint_list(int sock
)
428 struct ustcomm_ust_msg lum
;
429 struct ustcomm_ust_reply lur
;
430 int ret
, tp_list_handle
;
432 memset(&lum
, 0, sizeof(lum
));
433 lum
.handle
= LTTNG_UST_ROOT_HANDLE
;
434 lum
.cmd
= LTTNG_UST_TRACEPOINT_LIST
;
435 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
438 tp_list_handle
= lur
.ret_val
;
439 DBG("received tracepoint list handle %u", tp_list_handle
);
440 return tp_list_handle
;
443 int ustctl_tracepoint_list_get(int sock
, int tp_list_handle
,
444 struct lttng_ust_tracepoint_iter
*iter
)
446 struct ustcomm_ust_msg lum
;
447 struct ustcomm_ust_reply lur
;
450 memset(&lum
, 0, sizeof(lum
));
451 lum
.handle
= tp_list_handle
;
452 lum
.cmd
= LTTNG_UST_TRACEPOINT_LIST_GET
;
453 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
456 DBG("received tracepoint list entry name %s loglevel %d",
457 lur
.u
.tracepoint
.name
,
458 lur
.u
.tracepoint
.loglevel
);
459 memcpy(iter
, &lur
.u
.tracepoint
, sizeof(*iter
));
463 int ustctl_tracer_version(int sock
, struct lttng_ust_tracer_version
*v
)
465 struct ustcomm_ust_msg lum
;
466 struct ustcomm_ust_reply lur
;
469 memset(&lum
, 0, sizeof(lum
));
470 lum
.handle
= LTTNG_UST_ROOT_HANDLE
;
471 lum
.cmd
= LTTNG_UST_TRACER_VERSION
;
472 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
475 memcpy(v
, &lur
.u
.version
, sizeof(*v
));
476 DBG("received tracer version");
480 int ustctl_wait_quiescent(int sock
)
482 struct ustcomm_ust_msg lum
;
483 struct ustcomm_ust_reply lur
;
486 memset(&lum
, 0, sizeof(lum
));
487 lum
.handle
= LTTNG_UST_ROOT_HANDLE
;
488 lum
.cmd
= LTTNG_UST_WAIT_QUIESCENT
;
489 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
492 DBG("waited for quiescent state");
496 int ustctl_calibrate(int sock
, struct lttng_ust_calibrate
*calibrate
)
501 int ustctl_sock_flush_buffer(int sock
, struct lttng_ust_object_data
*object
)
503 struct ustcomm_ust_msg lum
;
504 struct ustcomm_ust_reply lur
;
507 memset(&lum
, 0, sizeof(lum
));
508 lum
.handle
= object
->handle
;
509 lum
.cmd
= LTTNG_UST_FLUSH_BUFFER
;
510 ret
= ustcomm_send_app_cmd(sock
, &lum
, &lur
);
513 DBG("flushed buffer handle %u", object
->handle
);
517 /* Buffer operations */
519 /* Map channel shm into process memory */
520 struct lttng_ust_shm_handle
*ustctl_map_channel(struct lttng_ust_object_data
*chan_data
)
522 struct lttng_ust_shm_handle
*handle
;
523 struct channel
*chan
;
525 struct lttng_ust_lib_ring_buffer_config
*config
;
528 handle
= channel_handle_create(chan_data
->shm_fd
,
530 chan_data
->memory_map_size
);
532 ERR("create handle error");
536 * Set to -1, and then close the shm fd, and set the handle shm
537 * fd to -1 too. We don't need the shm fds after they have been
539 * The wait_fd is set to -1 in chan_data because it is now owned
542 chan_data
->shm_fd
= -1;
543 chan_data
->wait_fd
= -1;
545 /* chan is object 0. This is hardcoded. */
546 if (handle
->table
->objects
[0].shm_fd
>= 0) {
547 ret
= close(handle
->table
->objects
[0].shm_fd
);
549 perror("Error closing shm_fd");
551 handle
->table
->objects
[0].shm_fd
= -1;
555 * TODO: add consistency checks to be resilient if the
556 * application try to feed us with incoherent channel structure
559 chan
= shmp(handle
, handle
->chan
);
560 /* chan is object 0. This is hardcoded. */
561 chan_size
= handle
->table
->objects
[0].allocated_len
;
562 handle
->shadow_chan
= malloc(chan_size
);
563 if (!handle
->shadow_chan
) {
564 channel_destroy(chan
, handle
, 1);
567 memcpy(handle
->shadow_chan
, chan
, chan_size
);
569 * The callback pointers in the producer are invalid in the
570 * consumer. We need to look them up here.
572 config
= &handle
->shadow_chan
->backend
.config
;
573 switch (config
->client_type
) {
574 case LTTNG_CLIENT_METADATA
:
575 memcpy(&config
->cb
, lttng_client_callbacks_metadata
,
578 case LTTNG_CLIENT_DISCARD
:
579 memcpy(&config
->cb
, lttng_client_callbacks_discard
,
582 case LTTNG_CLIENT_OVERWRITE
:
583 memcpy(&config
->cb
, lttng_client_callbacks_overwrite
,
587 ERR("Unknown client type %d", config
->client_type
);
588 channel_destroy(chan
, handle
, 1);
591 /* Replace the object table pointer. */
592 ret
= munmap(handle
->table
->objects
[0].memory_map
,
593 handle
->table
->objects
[0].memory_map_size
);
598 handle
->table
->objects
[0].memory_map
= (char *) handle
->shadow_chan
;
599 handle
->table
->objects
[0].is_shadow
= 1;
603 /* Add stream to channel shm and map its shm into process memory */
604 int ustctl_add_stream(struct lttng_ust_shm_handle
*handle
,
605 struct lttng_ust_object_data
*stream_data
)
609 if (!stream_data
->handle
)
612 ret
= channel_handle_add_stream(handle
,
614 stream_data
->wait_fd
,
615 stream_data
->memory_map_size
);
617 ERR("add stream error\n");
621 * Set to -1 because the lttng_ust_shm_handle destruction will take care
622 * of closing shm_fd and wait_fd.
624 stream_data
->shm_fd
= -1;
625 stream_data
->wait_fd
= -1;
629 void ustctl_unmap_channel(struct lttng_ust_shm_handle
*handle
)
631 struct channel
*chan
;
633 chan
= shmp(handle
, handle
->chan
);
634 channel_destroy(chan
, handle
, 1);
638 * ustctl closes the shm_fd fds after mapping it.
640 struct lttng_ust_lib_ring_buffer
*ustctl_open_stream_read(struct lttng_ust_shm_handle
*handle
,
643 struct channel
*chan
= handle
->shadow_chan
;
644 int *shm_fd
, *wait_fd
;
645 uint64_t *memory_map_size
;
646 struct lttng_ust_lib_ring_buffer
*buf
;
649 buf
= channel_get_ring_buffer(&chan
->backend
.config
,
650 chan
, cpu
, handle
, &shm_fd
, &wait_fd
, &memory_map_size
);
653 ret
= lib_ring_buffer_open_read(buf
, handle
, 1);
657 * We can close shm_fd early, right after is has been mapped.
660 ret
= close(*shm_fd
);
662 perror("Error closing shm_fd");
669 void ustctl_close_stream_read(struct lttng_ust_shm_handle
*handle
,
670 struct lttng_ust_lib_ring_buffer
*buf
)
672 lib_ring_buffer_release_read(buf
, handle
, 1);
675 /* For mmap mode, readable without "get" operation */
677 void *ustctl_get_mmap_base(struct lttng_ust_shm_handle
*handle
,
678 struct lttng_ust_lib_ring_buffer
*buf
)
680 return shmp(handle
, buf
->backend
.memory_map
);
683 /* returns the length to mmap. */
684 int ustctl_get_mmap_len(struct lttng_ust_shm_handle
*handle
,
685 struct lttng_ust_lib_ring_buffer
*buf
,
688 unsigned long mmap_buf_len
;
689 struct channel
*chan
= handle
->shadow_chan
;
691 if (chan
->backend
.config
.output
!= RING_BUFFER_MMAP
)
693 mmap_buf_len
= chan
->backend
.buf_size
;
694 if (chan
->backend
.extra_reader_sb
)
695 mmap_buf_len
+= chan
->backend
.subbuf_size
;
696 if (mmap_buf_len
> INT_MAX
)
702 /* returns the maximum size for sub-buffers. */
703 int ustctl_get_max_subbuf_size(struct lttng_ust_shm_handle
*handle
,
704 struct lttng_ust_lib_ring_buffer
*buf
,
707 struct channel
*chan
= handle
->shadow_chan
;
709 *len
= chan
->backend
.subbuf_size
;
714 * For mmap mode, operate on the current packet (between get/put or
715 * get_next/put_next).
718 /* returns the offset of the subbuffer belonging to the mmap reader. */
719 int ustctl_get_mmap_read_offset(struct lttng_ust_shm_handle
*handle
,
720 struct lttng_ust_lib_ring_buffer
*buf
, unsigned long *off
)
722 struct channel
*chan
= handle
->shadow_chan
;
723 unsigned long sb_bindex
;
725 if (chan
->backend
.config
.output
!= RING_BUFFER_MMAP
)
727 sb_bindex
= subbuffer_id_get_index(&chan
->backend
.config
,
728 buf
->backend
.buf_rsb
.id
);
729 *off
= shmp(handle
, shmp_index(handle
, buf
->backend
.array
, sb_bindex
)->shmp
)->mmap_offset
;
733 /* returns the size of the current sub-buffer, without padding (for mmap). */
734 int ustctl_get_subbuf_size(struct lttng_ust_shm_handle
*handle
,
735 struct lttng_ust_lib_ring_buffer
*buf
, unsigned long *len
)
737 struct channel
*chan
= handle
->shadow_chan
;
739 *len
= lib_ring_buffer_get_read_data_size(&chan
->backend
.config
, buf
,
744 /* returns the size of the current sub-buffer, without padding (for mmap). */
745 int ustctl_get_padded_subbuf_size(struct lttng_ust_shm_handle
*handle
,
746 struct lttng_ust_lib_ring_buffer
*buf
, unsigned long *len
)
748 struct channel
*chan
= handle
->shadow_chan
;
750 *len
= lib_ring_buffer_get_read_data_size(&chan
->backend
.config
, buf
,
752 *len
= PAGE_ALIGN(*len
);
756 /* Get exclusive read access to the next sub-buffer that can be read. */
757 int ustctl_get_next_subbuf(struct lttng_ust_shm_handle
*handle
,
758 struct lttng_ust_lib_ring_buffer
*buf
)
760 return lib_ring_buffer_get_next_subbuf(buf
, handle
);
764 /* Release exclusive sub-buffer access, move consumer forward. */
765 int ustctl_put_next_subbuf(struct lttng_ust_shm_handle
*handle
,
766 struct lttng_ust_lib_ring_buffer
*buf
)
768 lib_ring_buffer_put_next_subbuf(buf
, handle
);
774 /* Get a snapshot of the current ring buffer producer and consumer positions */
775 int ustctl_snapshot(struct lttng_ust_shm_handle
*handle
,
776 struct lttng_ust_lib_ring_buffer
*buf
)
778 return lib_ring_buffer_snapshot(buf
, &buf
->cons_snapshot
,
779 &buf
->prod_snapshot
, handle
);
782 /* Get the consumer position (iteration start) */
783 int ustctl_snapshot_get_consumed(struct lttng_ust_shm_handle
*handle
,
784 struct lttng_ust_lib_ring_buffer
*buf
, unsigned long *pos
)
786 *pos
= buf
->cons_snapshot
;
790 /* Get the producer position (iteration end) */
791 int ustctl_snapshot_get_produced(struct lttng_ust_shm_handle
*handle
,
792 struct lttng_ust_lib_ring_buffer
*buf
, unsigned long *pos
)
794 *pos
= buf
->prod_snapshot
;
798 /* Get exclusive read access to the specified sub-buffer position */
799 int ustctl_get_subbuf(struct lttng_ust_shm_handle
*handle
,
800 struct lttng_ust_lib_ring_buffer
*buf
, unsigned long *pos
)
802 return lib_ring_buffer_get_subbuf(buf
, *pos
, handle
);
805 /* Release exclusive sub-buffer access */
806 int ustctl_put_subbuf(struct lttng_ust_shm_handle
*handle
,
807 struct lttng_ust_lib_ring_buffer
*buf
)
809 lib_ring_buffer_put_subbuf(buf
, handle
);
813 void ustctl_flush_buffer(struct lttng_ust_shm_handle
*handle
,
814 struct lttng_ust_lib_ring_buffer
*buf
,
817 lib_ring_buffer_switch_slow(buf
,
818 producer_active
? SWITCH_ACTIVE
: SWITCH_FLUSH
,