mirror of https://github.com/grpc/grpc-java.git
core,netty: block server shutdown until the socket is unbound
This commit is contained in:
parent
9739e5b8b6
commit
74e945ceb4
|
@ -29,8 +29,10 @@ import javax.annotation.concurrent.ThreadSafe;
|
|||
*/
|
||||
@ThreadSafe
|
||||
public abstract class Server {
|
||||
|
||||
/**
|
||||
* Bind and start the server.
|
||||
* Bind and start the server. After this call returns, clients may begin connecting to the
|
||||
* listening socket(s).
|
||||
*
|
||||
* @return {@code this} object
|
||||
* @throws IllegalStateException if already started
|
||||
|
@ -102,6 +104,8 @@ public abstract class Server {
|
|||
|
||||
/**
|
||||
* Initiates an orderly shutdown in which preexisting calls continue but new calls are rejected.
|
||||
* After this call returns, this server has released the listening socket(s) and may be reused by
|
||||
* another server.
|
||||
*
|
||||
* @return {@code this} object
|
||||
* @since 1.0.0
|
||||
|
@ -111,7 +115,8 @@ public abstract class Server {
|
|||
/**
|
||||
* Initiates a forceful shutdown in which preexisting and new calls are rejected. Although
|
||||
* forceful, the shutdown process is still not instantaneous; {@link #isTerminated()} will likely
|
||||
* return {@code false} immediately after this method returns.
|
||||
* return {@code false} immediately after this method returns. After this call returns, this
|
||||
* server has released the listening socket(s) and may be reused by another server.
|
||||
*
|
||||
* @return {@code this} object
|
||||
* @since 1.0.0
|
||||
|
|
|
@ -42,7 +42,9 @@ public interface InternalServer {
|
|||
/**
|
||||
* Initiates an orderly shutdown of the server. Existing transports continue, but new transports
|
||||
* will not be created (once {@link ServerListener#serverShutdown()} callback is called). This
|
||||
* method may only be called once.
|
||||
* method may only be called once. Blocks until the listening socket(s) have been closed. If
|
||||
* interrupted, this method will not wait for the close to complete, but it will happen
|
||||
* asynchronously.
|
||||
*/
|
||||
void shutdown();
|
||||
|
||||
|
|
|
@ -283,6 +283,12 @@ class NettyServer implements InternalServer, InternalWithLogId {
|
|||
eventLoopReferenceCounter.release();
|
||||
}
|
||||
});
|
||||
try {
|
||||
channel.closeFuture().sync();
|
||||
} catch (InterruptedException e) {
|
||||
log.log(Level.FINE, "Interrupted while shutting down", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue