Small code cleanups

This commit is contained in:
Maxime Coste 2016-08-09 21:45:06 +01:00
parent 3a24763d53
commit bedf2f703c
2 changed files with 3 additions and 4 deletions

View File

@ -216,7 +216,7 @@ void write(int fd, StringView data)
count -= written;
if (written == -1)
throw file_access_error("fd: " + to_string(fd), strerror(errno));
throw file_access_error(format("fd: {}", fd), strerror(errno));
}
}

View File

@ -548,9 +548,8 @@ void RemoteClient::write_next_key()
void send_command(StringView session, StringView command)
{
int sock = connect_to(session);
if (::write(sock, command.data(), (int)command.length()) < 0)
throw runtime_error(format("unable to write data to socket (fd: {}; errno: {})", sock, ::strerror(errno)));
close(sock);
auto close_sock = on_scope_end([sock]{ close(sock); });
write(sock, command);
}