diff options
author | Zeling Feng <zeling@google.com> | 2021-02-25 14:58:37 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-02-25 15:01:14 -0800 |
commit | 67761345c8f2d01f41eb8bbeb0dc8f5d94b4e576 (patch) | |
tree | 445e2c35ac05ca8e493515f1e57bb975743acdfa /test/packetimpact/dut | |
parent | 38c42bbf4ad2200f0ec72e51d1cfbbd83d782a63 (diff) |
Move SetNonblocking into posix_server
- open flags can be different on different OSs, by putting SetNonblocking into
the posix_server rather than the testbench, we can always get the right value
for O_NONBLOCK
- merged the tcp_queue_{send,receive}_in_syn_sent into a single file
PiperOrigin-RevId: 359620630
Diffstat (limited to 'test/packetimpact/dut')
-rw-r--r-- | test/packetimpact/dut/posix_server.cc | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/test/packetimpact/dut/posix_server.cc b/test/packetimpact/dut/posix_server.cc index eba21df12..0d93b806e 100644 --- a/test/packetimpact/dut/posix_server.cc +++ b/test/packetimpact/dut/posix_server.cc @@ -180,16 +180,6 @@ class PosixImpl final : public posix_server::Posix::Service { return ::grpc::Status::OK; } - ::grpc::Status Fcntl(grpc::ServerContext *context, - const ::posix_server::FcntlRequest *request, - ::posix_server::FcntlResponse *response) override { - response->set_ret(::fcntl(request->fd(), request->cmd(), request->arg())); - if (response->ret() < 0) { - response->set_errno_(errno); - } - return ::grpc::Status::OK; - } - ::grpc::Status GetSockName( grpc::ServerContext *context, const ::posix_server::GetSockNameRequest *request, @@ -330,6 +320,31 @@ class PosixImpl final : public posix_server::Posix::Service { return ::grpc::Status::OK; } + ::grpc::Status SetNonblocking( + grpc::ServerContext *context, + const ::posix_server::SetNonblockingRequest *request, + ::posix_server::SetNonblockingResponse *response) override { + int flags = fcntl(request->fd(), F_GETFL); + if (flags == -1) { + response->set_ret(-1); + response->set_errno_(errno); + response->set_cmd("F_GETFL"); + return ::grpc::Status::OK; + } + if (request->nonblocking()) { + flags |= O_NONBLOCK; + } else { + flags &= ~O_NONBLOCK; + } + int ret = fcntl(request->fd(), F_SETFL, flags); + response->set_ret(ret); + if (ret == -1) { + response->set_errno_(errno); + response->set_cmd("F_SETFL"); + } + return ::grpc::Status::OK; + } + ::grpc::Status SetSockOpt( grpc::ServerContext *context, const ::posix_server::SetSockOptRequest *request, |