diff options
| author | Roy Marples <roy@marples.name> | 2021-03-10 13:09:39 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2021-03-10 13:09:39 +0000 |
| commit | 88d1590824689f47fc3e3ceff0bdaa7dad6a34f5 (patch) | |
| tree | 4d4bdf110e017b834583ac8f992e89ed15ac3f11 | |
| parent | 391e962e58eedaec26449f8617bbbf1e993deeef (diff) | |
| download | dhcpcd-88d1590824689f47fc3e3ceff0bdaa7dad6a34f5.tar.xz | |
| -rw-r--r-- | src/control.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/control.c b/src/control.c index 13602914..e77dd176 100644 --- a/src/control.c +++ b/src/control.c @@ -100,11 +100,15 @@ control_handle_read(struct fd_list *fd) ssize_t bytes; bytes = read(fd->fd, buffer, sizeof(buffer) - 1); - - if (bytes == -1 || bytes == 0) { - /* Control was closed or there was an error. - * Remove it from our list. */ +#ifdef PRIVSEP + if (bytes == 0 && IN_PRIVSEP(fd->ctx)) { + if (ps_ctl_sendeof(fd) == -1) + logerr(__func__); + } +#endif + if (bytes == -1) logerr(__func__); + if (bytes == -1 || bytes == 0) { control_free(fd); return; } @@ -171,20 +175,17 @@ control_handle_write(struct fd_list *fd) if (TAILQ_FIRST(&fd->queue) != NULL) return; - /* Remove ELE_WRITE */ - if (fd->flags & FD_LISTEN) { - if (eloop_event_add(fd->ctx->eloop, fd->fd, ELE_READ, - control_handle_data, fd) == -1) - logerr("%s: eloop_event_add", __func__); - } else - eloop_event_delete(fd->ctx->eloop, fd->fd); #ifdef PRIVSEP if (IN_PRIVSEP_SE(fd->ctx) && !(fd->flags & FD_LISTEN)) { if (ps_ctl_sendeof(fd) == -1) logerr(__func__); - control_free(fd); } #endif + + /* Done sending data, stop watching write to fd */ + if (eloop_event_add(fd->ctx->eloop, fd->fd, ELE_READ, + control_handle_data, fd) == -1) + logerr("%s: eloop_event_add", __func__); } |
