elsewhere and unbreaks -fno-common.
Inspired by claudio
Problem reported by mortimer
-/* $OpenBSD: control.c,v 1.6 2019/03/11 22:53:29 pamela Exp $ */
+/* $OpenBSD: control.c,v 1.7 2021/01/19 16:49:10 florian Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
#define CONTROL_BACKLOG 5
+struct {
+ struct event ev;
+ struct event evt;
+ int fd;
+} control_state = {.fd = -1};
+
+struct ctl_conn {
+ TAILQ_ENTRY(ctl_conn) entry;
+ struct imsgev iev;
+};
+
struct ctl_conn *control_connbyfd(int);
struct ctl_conn *control_connbypid(pid_t);
void control_close(int);
+TAILQ_HEAD(ctl_conns, ctl_conn) ctl_conns = TAILQ_HEAD_INITIALIZER(ctl_conns);
+
int
control_init(char *path)
{
}
int
-control_listen(void)
+control_listen(int fd)
{
+ if (control_state.fd != -1)
+ fatalx("%s: received unexpected controlsock", __func__);
+ control_state.fd = fd;
if (listen(control_state.fd, CONTROL_BACKLOG) == -1) {
log_warn("%s: listen", __func__);
return (-1);
-/* $OpenBSD: control.h,v 1.3 2018/08/04 09:36:49 florian Exp $ */
+/* $OpenBSD: control.h,v 1.4 2021/01/19 16:49:10 florian Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
*/
#ifndef SMALL
-struct {
- struct event ev;
- struct event evt;
- int fd;
-} control_state;
-
-struct ctl_conn {
- TAILQ_ENTRY(ctl_conn) entry;
- struct imsgev iev;
-};
-
int control_init(char *);
-int control_listen(void);
+int control_listen(int);
void control_accept(int, short, void *);
void control_dispatch_imsg(int, short, void *);
int control_imsg_relay(struct imsg *);
-/* $OpenBSD: frontend.c,v 1.47 2021/01/19 16:48:20 florian Exp $ */
+/* $OpenBSD: frontend.c,v 1.48 2021/01/19 16:49:10 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
log_init(debug, LOG_DAEMON);
log_setverbose(verbose);
-#ifndef SMALL
- control_state.fd = -1;
-#endif /* SMALL */
-
if ((pw = getpwnam(SLAACD_USER)) == NULL)
fatal("getpwnam");
break;
#ifndef SMALL
case IMSG_CONTROLFD:
- if (control_state.fd != -1)
- fatalx("%s: received unexpected controlsock",
- __func__);
if ((fd = imsg.fd) == -1)
fatalx("%s: expected to receive imsg "
"control fd but didn't receive any",
__func__);
- control_state.fd = fd;
/* Listen on control socket. */
- TAILQ_INIT(&ctl_conns);
- control_listen();
+ control_listen(fd);
break;
case IMSG_CTL_END:
control_imsg_relay(&imsg);
-/* $OpenBSD: frontend.h,v 1.3 2017/12/10 10:07:54 florian Exp $ */
+/* $OpenBSD: frontend.h,v 1.4 2021/01/19 16:49:10 florian Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifndef SMALL
-TAILQ_HEAD(ctl_conns, ctl_conn) ctl_conns;
-#endif /* SMALL */
-
void frontend(int, int);
void frontend_dispatch_main(int, short, void *);
void frontend_dispatch_engine(int, short, void *);