elsewhere and unbreaks -fno-common.
Inspired by claudio
Problem reported by mortimer
-/* $OpenBSD: control.c,v 1.5 2019/03/02 03:40:45 pamela Exp $ */
+/* $OpenBSD: control.c,v 1.6 2021/01/19 16:54:00 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 = -1;
if (listen(control_state.fd, CONTROL_BACKLOG) == -1) {
log_warn("%s: listen", __func__);
return (-1);
-/* $OpenBSD: control.h,v 1.2 2018/08/04 09:37:17 florian Exp $ */
+/* $OpenBSD: control.h,v 1.3 2021/01/19 16:54:00 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.37 2021/01/19 16:53:27 florian Exp $ */
+/* $OpenBSD: frontend.c,v 1.38 2021/01/19 16:54:00 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
uint8_t *sndcmsgbuf = NULL;
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;
default:
log_debug("%s: error handling imsg %d", __func__,
-/* $OpenBSD: frontend.h,v 1.3 2018/07/13 08:32:10 florian Exp $ */
+/* $OpenBSD: frontend.h,v 1.4 2021/01/19 16:54:00 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;
-
void frontend(int, int);
void frontend_dispatch_main(int, short, void *);
void frontend_dispatch_engine(int, short, void *);