- res_data = evbuffer_new();
- if (res_data == NULL) {
- res.res_errno = ENOMEM;
- goto respond;
- }
-
- if(req.type == REQ_STOP) {
- logger(LOG_NOTICE, _("Got stop command"));
- event_loopexit(NULL);
- goto respond;
- }
-
- logger(LOG_DEBUG, _("Malformed control command received"));
- res.res_errno = EINVAL;
-
-respond:
- res.length = (sizeof res)
- + ((res_data == NULL) ? 0 : EVBUFFER_LENGTH(res_data));
- evbuffer_drain(event->input, req.length);
- if(bufferevent_write(event, &res, sizeof res) == -1)
- goto failure;
- if(res_data != NULL) {
- if(bufferevent_write_buffer(event, res_data) == -1)
- goto failure;
- evbuffer_free(res_data);
- }
- return;
-
-failure:
- logger(LOG_INFO, _("Closing control socket on error"));
- evbuffer_free(res_data);
- close(event->ev_read.ev_fd);
- splay_delete(control_socket_tree, event);
+static bool control_return(connection_t *c, int type, int error) {
+ return send_request(c, "%d %d %d", CONTROL, type, error);