diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/iomgr/fd_posix.c | 8 | ||||
-rw-r--r-- | src/core/iomgr/fd_posix.h | 3 | ||||
-rw-r--r-- | src/core/iomgr/tcp_posix.c | 6 | ||||
-rw-r--r-- | src/core/iomgr/tcp_posix.h | 6 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/interfaces/face/face.py | 8 |
5 files changed, 27 insertions, 4 deletions
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index b4bd6bf226..079cb06d48 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -221,6 +221,14 @@ static void close_fd_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd) { grpc_exec_ctx_enqueue(exec_ctx, fd->on_done_closure, 1); } +int grpc_fd_wrapped_fd(grpc_fd *fd) { + if (fd->released || fd->closed) { + return -1; + } else { + return fd->fd; + } +} + void grpc_fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure *on_done, int *release_fd, const char *reason) { fd->on_done_closure = on_done; diff --git a/src/core/iomgr/fd_posix.h b/src/core/iomgr/fd_posix.h index d088749408..8062dd01db 100644 --- a/src/core/iomgr/fd_posix.h +++ b/src/core/iomgr/fd_posix.h @@ -105,6 +105,9 @@ struct grpc_fd { This takes ownership of closing fd. */ grpc_fd *grpc_fd_create(int fd, const char *name); +/* Return the wrapped fd, or -1 if it has been released or closed. */ +int grpc_fd_wrapped_fd(grpc_fd *fd); + /* Releases fd to be asynchronously destroyed. on_done is called when the underlying file descriptor is definitely close()d. If on_done is NULL, no callback will be made. diff --git a/src/core/iomgr/tcp_posix.c b/src/core/iomgr/tcp_posix.c index f3be41aa57..65783a7afa 100644 --- a/src/core/iomgr/tcp_posix.c +++ b/src/core/iomgr/tcp_posix.c @@ -473,6 +473,12 @@ grpc_endpoint *grpc_tcp_create(grpc_fd *em_fd, size_t slice_size, return &tcp->base; } +int grpc_tcp_fd(grpc_endpoint *ep) { + grpc_tcp *tcp = (grpc_tcp *)ep; + GPR_ASSERT(ep->vtable == &vtable); + return grpc_fd_wrapped_fd(tcp->em_fd); +} + void grpc_tcp_destroy_and_release_fd(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, int *fd, grpc_closure *done) { grpc_tcp *tcp = (grpc_tcp *)ep; diff --git a/src/core/iomgr/tcp_posix.h b/src/core/iomgr/tcp_posix.h index b554983ae1..495ed009c8 100644 --- a/src/core/iomgr/tcp_posix.h +++ b/src/core/iomgr/tcp_posix.h @@ -56,6 +56,12 @@ extern int grpc_tcp_trace; grpc_endpoint *grpc_tcp_create(grpc_fd *fd, size_t read_slice_size, const char *peer_string); +/* Return the tcp endpoint's fd, or -1 if this is not available. Does not + release the fd. + Requires: ep must be a tcp endpoint. + */ +int grpc_tcp_fd(grpc_endpoint *ep); + /* Destroy the tcp endpoint without closing its fd. *fd will be set and done * will be called when the endpoint is destroyed. * Requires: ep must be a tcp endpoint and fd must not be NULL. */ diff --git a/src/python/grpcio/grpc/framework/interfaces/face/face.py b/src/python/grpcio/grpc/framework/interfaces/face/face.py index 3b402356d2..59da83dc9c 100644 --- a/src/python/grpcio/grpc/framework/interfaces/face/face.py +++ b/src/python/grpcio/grpc/framework/interfaces/face/face.py @@ -378,7 +378,7 @@ class UnaryUnaryMultiCallable(object): metadata: A metadata value to be passed to the service-side of the RPC. with_call: Whether or not to include return a Call for the RPC in addition - to the reponse. + to the response. protocol_options: A value specified by the provider of a Face interface implementation affording custom state and behavior. @@ -496,7 +496,7 @@ class StreamUnaryMultiCallable(object): metadata: A metadata value to be passed to the service-side of the RPC. with_call: Whether or not to include return a Call for the RPC in addition - to the reponse. + to the response. protocol_options: A value specified by the provider of a Face interface implementation affording custom state and behavior. @@ -699,7 +699,7 @@ class GenericStub(object): timeout: A duration of time in seconds to allow for the RPC. metadata: A metadata value to be passed to the service-side of the RPC. with_call: Whether or not to include return a Call for the RPC in addition - to the reponse. + to the response. protocol_options: A value specified by the provider of a Face interface implementation affording custom state and behavior. @@ -774,7 +774,7 @@ class GenericStub(object): timeout: A duration of time in seconds to allow for the RPC. metadata: A metadata value to be passed to the service-side of the RPC. with_call: Whether or not to include return a Call for the RPC in addition - to the reponse. + to the response. protocol_options: A value specified by the provider of a Face interface implementation affording custom state and behavior. |