-void flush_meta(int fd, short events, void *data)
-{
- connection_t *c = data;
- int result;
-
- ifdebug(META) logger(LOG_DEBUG, _("Flushing %d bytes to %s (%s)"),
- c->outbuflen, c->name, c->hostname);
-
- while(c->outbuflen) {
- result = send(c->socket, c->outbuf + c->outbufstart, c->outbuflen, 0);
- if(result <= 0) {
- if(!errno || errno == EPIPE) {
- ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection closed by %s (%s)"),
- c->name, c->hostname);
- } else if(errno == EINTR) {
- continue;
-#ifdef EWOULDBLOCK
- } else if(errno == EWOULDBLOCK) {
- ifdebug(CONNECTIONS) logger(LOG_DEBUG, _("Flushing %d bytes to %s (%s) would block"),
- c->outbuflen, c->name, c->hostname);
- return;
-#endif
- } else {
- logger(LOG_ERR, _("Flushing meta data to %s (%s) failed: %s"), c->name,
- c->hostname, strerror(errno));
- }
-
- terminate_connection(c, c->status.active);
- return;
+ if(!cipher_encrypt(&c->outcipher, buffer, length, buffer_prepare(&c->outbuf, length), &outlen, false) || outlen != length) {
+ logger(LOG_ERR, "Error while encrypting metadata to %s (%s)",
+ c->name, c->hostname);
+ return false;