2 * Copyright (C) 2012-2020 all contributors <cmogstored-public@yhbt.net>
3 * License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
5 #include "cmogstored.h"
8 * access to this should only be called in the main thread, this
9 * is currently not thread safe as there's no need for it.
11 static LIST_HEAD(queue_head
, mog_queue
) all_queues
;
13 struct mog_queue
*mog_queue_init(int queue_fd
)
19 * Do not bother with epoll_create1(EPOLL_CLOEXEC),
20 * there's no kqueue version of it. We only create epoll/kqueue
21 * descriptors before we'd ever fork anything
23 CHECK(int, 0, mog_set_cloexec(queue_fd
, true));
25 mfd
= mog_fd_init(queue_fd
, MOG_FD_TYPE_QUEUE
);
27 q
->queue_fd
= queue_fd
;
28 memset(&q
->thrpool
, 0, sizeof(struct mog_thrpool
));
29 LIST_INSERT_HEAD(&all_queues
, q
, qbuddies
);
34 void mog_queue_stop(struct mog_queue
*keep
)
36 struct mog_queue
*queue
, *tmp
;
39 LIST_FOREACH_SAFE(queue
, &all_queues
, qbuddies
, tmp
) {
40 /* keep is usually mog_notify_queue */
43 LIST_REMOVE(queue
, qbuddies
);
44 mog_thrpool_quit(&queue
->thrpool
, queue
);
45 mfd
= mog_fd_of(queue
);
50 void mog_queue_drop(struct mog_fd
*mfd
)
52 switch (mfd
->fd_type
) {
53 case MOG_FD_TYPE_HTTP
:
54 case MOG_FD_TYPE_HTTPGET
:
57 case MOG_FD_TYPE_MGMT
:
62 "dropping fd_type=%d, functionality may be compromised",