- query_t q;
- query_init(&q);
-
- for (;;) {
- int nb = buffer_read(&q.data, fd, -1);
- const char *eoq;
-
- if (nb < 0) {
- if (errno == EAGAIN || errno == EINTR)
- continue;
- UNIXERR("read");
- break;
- }
- if (nb == 0) {
- if (q.data.len)
- syslog(LOG_ERR, "unexpected end of data");
- break;
- }
-
- eoq = strstr(q.data.data + MAX(0, q.data.len - 3), "\r\n\r\n");
- if (!eoq)
- continue;
-
- if (postfix_parsejob(&q) < 0)
- break;
-
- buffer_consume(&q.data, eoq + strlen("\r\n\r\n") - q.data.data);
- if (xwrite(fd, "DUNNO\r\n", strlen("DUNNO\r\n"))) {
- UNIXERR("write");
- break;
- }
- }
-
- query_wipe(&q);
- close(fd);
- return NULL;
+ va_list args;
+ va_start(args, fmt);
+ buffer_addvf(&pcy->obuf, fmt, args);
+ va_end(args);
+ buffer_addstr(&pcy->obuf, "\n\n");
+ buffer_consume(&pcy->ibuf, ((query_t*)(pcy->data))->eoq - pcy->ibuf.data);
+ epoll_modify(pcy->fd, EPOLLIN | EPOLLOUT, pcy);