Lines Matching refs:fd

74 control_queue_free(struct fd_list *fd)  in control_queue_free()  argument
78 while ((fdp = TAILQ_FIRST(&fd->queue))) { in control_queue_free()
79 TAILQ_REMOVE(&fd->queue, fdp, next); in control_queue_free()
81 control_queue_purge(fd->ctx, fdp->data); in control_queue_free()
84 while ((fdp = TAILQ_FIRST(&fd->free_queue))) { in control_queue_free()
85 TAILQ_REMOVE(&fd->free_queue, fdp, next); in control_queue_free()
91 control_delete(struct fd_list *fd) in control_delete() argument
94 TAILQ_REMOVE(&fd->ctx->control_fds, fd, next); in control_delete()
95 eloop_event_delete(fd->ctx->eloop, fd->fd, 0); in control_delete()
96 close(fd->fd); in control_delete()
97 control_queue_free(fd); in control_delete()
98 free(fd); in control_delete()
104 struct fd_list *fd = arg; in control_handle_data() local
110 bytes = read(fd->fd, buffer, sizeof(buffer) - 1); in control_handle_data()
114 control_delete(fd); in control_handle_data()
141 if (dhcpcd_handleargs(fd->ctx, fd, argc, argvp) == -1) { in control_handle_data()
142 logger(fd->ctx, LOG_ERR, in control_handle_data()
145 control_delete(fd); in control_handle_data()
158 int fd, flags; in control_handle1() local
161 if ((fd = accept(lfd, (struct sockaddr *)&run, &len)) == -1) in control_handle1()
163 if ((flags = fcntl(fd, F_GETFD, 0)) == -1 || in control_handle1()
164 fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) in control_handle1()
166 close(fd); in control_handle1()
169 if ((flags = fcntl(fd, F_GETFL, 0)) == -1 || in control_handle1()
170 fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) in control_handle1()
172 close(fd); in control_handle1()
178 l->fd = fd; in control_handle1()
183 eloop_event_add(ctx->eloop, l->fd, in control_handle1()
186 close(fd); in control_handle1()
208 int fd; in make_sock() local
211 if ((fd = socket(AF_UNIX, in make_sock()
217 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) in make_sock()
219 if ((flags = fcntl(fd, F_GETFD, 0)) == -1 || in make_sock()
220 fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) in make_sock()
222 close(fd); in make_sock()
225 if ((flags = fcntl(fd, F_GETFL, 0)) == -1 || in make_sock()
226 fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) in make_sock()
228 close(fd); in make_sock()
240 return fd; in make_sock()
250 int fd; in control_start1() local
253 if ((fd = make_sock(&sa, ifname, (fmode & S_UNPRIV) == S_UNPRIV)) == -1) in control_start1()
257 if (bind(fd, (struct sockaddr *)&sa, len) == -1 || in control_start1()
261 listen(fd, sizeof(ctx->control_fds)) == -1) in control_start1()
263 close(fd); in control_start1()
271 return fd; in control_start1()
277 int fd; in control_start() local
279 if ((fd = control_start1(ctx, ifname, S_PRIV)) == -1) in control_start()
282 ctx->control_fd = fd; in control_start()
283 eloop_event_add(ctx->eloop, fd, control_handle, ctx, NULL, NULL); in control_start()
285 if (ifname == NULL && (fd = control_start1(ctx, NULL, S_UNPRIV)) != -1){ in control_start()
288 ctx->control_unpriv_fd = fd; in control_start()
289 eloop_event_add(ctx->eloop, fd, control_handle_unpriv, in control_start()
323 eloop_event_delete(ctx->eloop, l->fd, 0); in control_stop()
324 close(l->fd); in control_stop()
376 struct fd_list *fd; in control_writeone() local
380 fd = arg; in control_writeone()
381 data = TAILQ_FIRST(&fd->queue); in control_writeone()
386 if (writev(fd->fd, iov, 2) == -1) { in control_writeone()
387 logger(fd->ctx, LOG_ERR, in control_writeone()
388 "%s: writev fd %d: %m", __func__, fd->fd); in control_writeone()
390 control_delete(fd); in control_writeone()
394 TAILQ_REMOVE(&fd->queue, data, next); in control_writeone()
396 control_queue_purge(fd->ctx, data->data); in control_writeone()
399 TAILQ_INSERT_TAIL(&fd->free_queue, data, next); in control_writeone()
401 if (TAILQ_FIRST(&fd->queue) == NULL) in control_writeone()
402 eloop_event_delete(fd->ctx->eloop, fd->fd, 1); in control_writeone()
406 control_queue(struct fd_list *fd, char *data, size_t data_len, uint8_t fit) in control_queue() argument
411 d = TAILQ_FIRST(&fd->free_queue); in control_queue()
413 TAILQ_REMOVE(&fd->free_queue, d, next); in control_queue()
416 TAILQ_FOREACH(d, &fd->queue, next) { in control_queue()
429 TAILQ_INSERT_TAIL(&fd->queue, d, next); in control_queue()
430 eloop_event_add(fd->ctx->eloop, fd->fd, in control_queue()
431 NULL, NULL, control_writeone, fd); in control_queue()