mirror of
https://github.com/openbsd/src.git
synced 2024-12-22 16:42:56 -08:00
Replace imsgbuf_read_nofd() hack with the new imsgbuf API.
OK tb@
This commit is contained in:
parent
39e1fbec45
commit
98435822fc
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: control.c,v 1.128 2024/11/21 13:29:52 claudio Exp $ */
|
||||
/* $OpenBSD: control.c,v 1.129 2024/11/21 13:31:37 claudio Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
|
||||
@ -37,7 +37,6 @@ struct ctl_conn *control_connbyfd(int);
|
||||
struct ctl_conn *control_connbypid(pid_t);
|
||||
int control_close(struct ctl_conn *);
|
||||
void control_result(struct ctl_conn *, u_int);
|
||||
int imsgbuf_read_nofd(struct imsgbuf *);
|
||||
|
||||
int
|
||||
control_check(char *path)
|
||||
@ -261,7 +260,7 @@ control_dispatch_msg(struct pollfd *pfd, struct peer_head *peers)
|
||||
if (!(pfd->revents & POLLIN))
|
||||
return (0);
|
||||
|
||||
if (imsgbuf_read_nofd(&c->imsgbuf) != 1)
|
||||
if (imsgbuf_read(&c->imsgbuf) != 1)
|
||||
return control_close(c);
|
||||
|
||||
for (;;) {
|
||||
@ -593,27 +592,3 @@ control_result(struct ctl_conn *c, u_int code)
|
||||
imsg_compose(&c->imsgbuf, IMSG_CTL_RESULT, 0, c->imsgbuf.pid, -1,
|
||||
&code, sizeof(code));
|
||||
}
|
||||
|
||||
/* This should go into libutil, from smtpd/mproc.c */
|
||||
int
|
||||
imsgbuf_read_nofd(struct imsgbuf *imsgbuf)
|
||||
{
|
||||
ssize_t n;
|
||||
char *buf;
|
||||
size_t len;
|
||||
|
||||
buf = imsgbuf->r.buf + imsgbuf->r.wpos;
|
||||
len = sizeof(imsgbuf->r.buf) - imsgbuf->r.wpos;
|
||||
|
||||
while ((n = recv(imsgbuf->fd, buf, len, 0)) == -1) {
|
||||
if (errno == EAGAIN)
|
||||
return (1);
|
||||
if (errno != EINTR)
|
||||
return (-1);
|
||||
}
|
||||
if (n == 0)
|
||||
return (0);
|
||||
|
||||
imsgbuf->r.wpos += n;
|
||||
return (1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user