elsewhere and unbreaks -fno-common.
Inspired by claudio
Problem reported by mortimer
-/* $OpenBSD: control.c,v 1.15 2019/12/18 09:18:27 florian Exp $ */
+/* $OpenBSD: control.c,v 1.16 2021/01/19 16:52:12 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;
+};
+
+TAILQ_HEAD(ctl_conns, ctl_conn) ctl_conns = TAILQ_HEAD_INITIALIZER(ctl_conns);
+
struct ctl_conn *control_connbyfd(int);
struct ctl_conn *control_connbypid(pid_t);
void control_close(int);
}
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.1 2019/01/23 13:11:00 florian Exp $ */
+/* $OpenBSD: control.h,v 1.2 2021/01/19 16:52:12 florian Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-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 fd);
void control_accept(int, short, void *);
void control_dispatch_imsg(int, short, void *);
int control_imsg_relay(struct imsg *);
-/* $OpenBSD: frontend.c,v 1.62 2021/01/19 16:50:50 florian Exp $ */
+/* $OpenBSD: frontend.c,v 1.63 2021/01/19 16:52:12 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
struct passwd *pw;
frontend_conf = config_new_empty();
- control_state.fd = -1;
log_init(debug, LOG_DAEMON);
log_setverbose(verbose);
frontend_startup();
break;
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_TAFD:
if ((ta_fd = imsg.fd) != -1)
-/* $OpenBSD: frontend.h,v 1.6 2019/11/27 17:09:12 florian Exp $ */
+/* $OpenBSD: frontend.h,v 1.7 2021/01/19 16:52:12 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-TAILQ_HEAD(ctl_conns, ctl_conn) ctl_conns;
-
struct trust_anchor {
TAILQ_ENTRY(trust_anchor) entry;
char *ta;