mirror of
https://github.com/nestriness/cdc-file-transfer.git
synced 2026-05-01 17:03:07 +03:00
[common] Add support for ClientSocket on Linux (#97)
Uses the abstractions written for ServerSocket in ClientSocket, so that it builds on Linux. Also adds a method to poll for connections and uses that in cdc_rsync. Similar code will be used in cdc_fuse_fs to wait for a connection in a future CL.
This commit is contained in:
@@ -300,24 +300,9 @@ absl::Status CdcRsyncClient::StartServer(const ServerArch& arch) {
|
||||
"Failed to start cdc_rsync_server process");
|
||||
}
|
||||
|
||||
// Poll the connection to the socket with port |local_port| until the port
|
||||
// forwarding connection is set up.
|
||||
timeout_timer.Reset();
|
||||
for (;;) {
|
||||
assert(local_port != 0);
|
||||
status = socket_.Connect(local_port);
|
||||
if (status.ok()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (timeout_timer.ElapsedSeconds() > options_.connection_timeout_sec) {
|
||||
return SetTag(
|
||||
absl::DeadlineExceededError("Timeout while connecting to server"),
|
||||
Tag::kConnectionTimeout);
|
||||
}
|
||||
|
||||
Util::Sleep(10);
|
||||
}
|
||||
// Wait for port forwarding to be up.
|
||||
RETURN_IF_ERROR(ClientSocket::WaitForConnection(
|
||||
local_port, absl::Seconds(options_.connection_timeout_sec)));
|
||||
|
||||
server_process_ = std::move(srv_process);
|
||||
port_forwarding_process_ = std::move(fwd_process);
|
||||
|
||||
Reference in New Issue
Block a user