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"
6 #include "nostd/setproctitle.h"
8 static void acceptor_quit(struct mog_fd
**mfdp
)
10 struct mog_fd
*mfd
= *mfdp
;
13 struct mog_accept
*ac
= &mfd
->as
.accept
;
15 mog_thrpool_quit(&ac
->thrpool
, NULL
);
21 static bool svc_quit_i(void *svcptr
, void *ignored
)
23 struct mog_svc
*svc
= svcptr
;
25 svc
->persist_client
= 0;
26 mog_svc_dev_quit_prepare(svc
);
27 acceptor_quit(&svc
->mgmt_mfd
);
28 acceptor_quit(&svc
->http_mfd
);
29 acceptor_quit(&svc
->httpget_mfd
);
34 static bool svc_requeue_prepare(void *svcptr
, void *queue
)
36 struct mog_svc
*svc
= svcptr
;
40 mog_svc_dev_requeue_prepare(svc
);
45 _Noreturn
void cmogstored_exit(void)
47 /* call atexit() handlers and make valgrind happy */
48 setproctitle("cmogstored, shutting down");
49 mog_svc_each(svc_quit_i
, NULL
);
50 mog_svc_dev_shutdown();
51 mog_queue_stop(mog_notify_queue
);
52 mog_svc_dev_shutdown();
53 mog_svc_each(svc_requeue_prepare
, mog_notify_queue
);
54 mog_fdmap_requeue(mog_notify_queue
);
55 mog_queue_quit_loop(mog_notify_queue
);