bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen service_process_notify_callback_t *write_callback;
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen service_process_notify_callback_t *write_callback)
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen notify = i_new(struct service_process_notify, 1);
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen notify->process_queue = aqueue_init(¬ify->processes.arr);
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainenstatic void service_process_notify_reset(struct service_process_notify *notify)
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen struct service_process *const *processes, *process;
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen processes = array_idx_modifiable(¬ify->processes, 0);
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen for (i = 0; i < count; i++) {
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen process = processes[aqueue_idx(notify->process_queue, i)];
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainenstatic void notify_flush(struct service_process_notify *notify)
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen struct service_process *const *processes, *process;
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen while (aqueue_count(notify->process_queue) > 0) {
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen processes = array_idx_modifiable(¬ify->processes, 0);
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen process = processes[aqueue_idx(notify->process_queue, 0)];
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen if (notify->write_callback(notify->fd, process) < 0) {
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainenvoid service_process_notify_deinit(struct service_process_notify **_notify)
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen struct service_process_notify *notify = *_notify;
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainenvoid service_process_notify_add(struct service_process_notify *notify,
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen if (notify->write_callback(notify->fd, process) < 0) {
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen notify->io_write = io_add(notify->fd, IO_WRITE,