- goto respond;
- }
-
- if(req.type == REQ_RETRY) {
- logger(LOG_NOTICE, "Got '%s' command", "retry");
- retry();
- goto respond;
- }
-
- if(req.type == REQ_RELOAD) {
- logger(LOG_NOTICE, "Got '%s' command", "reload");
- res.res_errno = reload_configuration();
- 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 void handle_control_error(struct bufferevent *event, short what, void *data) {
- if(what & EVBUFFER_EOF)
- logger(LOG_DEBUG, "Control socket connection closed by peer");
- else
- logger(LOG_DEBUG, "Error while reading from control socket: %s", strerror(errno));
-
- close(event->ev_read.ev_fd);
- splay_delete(control_socket_tree, event);
-}