Small code cleanups
This commit is contained in:
parent
3a24763d53
commit
bedf2f703c
|
@ -216,7 +216,7 @@ void write(int fd, StringView data)
|
||||||
count -= written;
|
count -= written;
|
||||||
|
|
||||||
if (written == -1)
|
if (written == -1)
|
||||||
throw file_access_error("fd: " + to_string(fd), strerror(errno));
|
throw file_access_error(format("fd: {}", fd), strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -548,9 +548,8 @@ void RemoteClient::write_next_key()
|
||||||
void send_command(StringView session, StringView command)
|
void send_command(StringView session, StringView command)
|
||||||
{
|
{
|
||||||
int sock = connect_to(session);
|
int sock = connect_to(session);
|
||||||
if (::write(sock, command.data(), (int)command.length()) < 0)
|
auto close_sock = on_scope_end([sock]{ close(sock); });
|
||||||
throw runtime_error(format("unable to write data to socket (fd: {}; errno: {})", sock, ::strerror(errno)));
|
write(sock, command);
|
||||||
close(sock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user