@ -52,7 +52,7 @@ class CallState {
Poll < ValueOrFailure < bool > > PollPullServerToClientMessageAvailable ( ) ;
Poll < ValueOrFailure < bool > > PollPullServerToClientMessageAvailable ( ) ;
void FinishPullServerToClientMessage ( ) ;
void FinishPullServerToClientMessage ( ) ;
Poll < Empty > PollServerTrailingMetadataAvailable ( ) ;
Poll < Empty > PollServerTrailingMetadataAvailable ( ) ;
void FinishPullServerTrailingMetadata ( ) ;
bool WasServerTrailingMetadataPulled ( ) const ;
Poll < bool > PollWasCancelled ( ) ;
Poll < bool > PollWasCancelled ( ) ;
// Debug
// Debug
std : : string DebugString ( ) const ;
std : : string DebugString ( ) const ;
@ -147,8 +147,6 @@ class CallState {
kReading ,
kReading ,
// Main call loop: processing one message
// Main call loop: processing one message
kProcessingServerToClientMessage ,
kProcessingServerToClientMessage ,
// Processing server trailing metadata
kProcessingServerTrailingMetadata ,
kTerminated ,
kTerminated ,
} ;
} ;
static const char * ServerToClientPullStateString (
static const char * ServerToClientPullStateString (
@ -172,8 +170,6 @@ class CallState {
return " Reading " ;
return " Reading " ;
case ServerToClientPullState : : kProcessingServerToClientMessage :
case ServerToClientPullState : : kProcessingServerToClientMessage :
return " ProcessingServerToClientMessage " ;
return " ProcessingServerToClientMessage " ;
case ServerToClientPullState : : kProcessingServerTrailingMetadata :
return " ProcessingServerTrailingMetadata " ;
case ServerToClientPullState : : kTerminated :
case ServerToClientPullState : : kTerminated :
return " Terminated " ;
return " Terminated " ;
}
}
@ -294,7 +290,6 @@ GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION inline void CallState::Start() {
case ServerToClientPullState : : kReading :
case ServerToClientPullState : : kReading :
case ServerToClientPullState : : kProcessingServerToClientMessage :
case ServerToClientPullState : : kProcessingServerToClientMessage :
LOG ( FATAL ) < < " Start called twice " ;
LOG ( FATAL ) < < " Start called twice " ;
case ServerToClientPullState : : kProcessingServerTrailingMetadata :
case ServerToClientPullState : : kTerminated :
case ServerToClientPullState : : kTerminated :
break ;
break ;
}
}
@ -644,7 +639,6 @@ CallState::PollPullServerInitialMetadataAvailable() {
case ServerToClientPullState : : kIdle :
case ServerToClientPullState : : kIdle :
case ServerToClientPullState : : kReading :
case ServerToClientPullState : : kReading :
case ServerToClientPullState : : kProcessingServerToClientMessage :
case ServerToClientPullState : : kProcessingServerToClientMessage :
case ServerToClientPullState : : kProcessingServerTrailingMetadata :
LOG ( FATAL ) < < " PollPullServerInitialMetadataAvailable called twice " ;
LOG ( FATAL ) < < " PollPullServerInitialMetadataAvailable called twice " ;
case ServerToClientPullState : : kTerminated :
case ServerToClientPullState : : kTerminated :
return false ;
return false ;
@ -703,7 +697,6 @@ CallState::FinishPullServerInitialMetadata() {
case ServerToClientPullState : : kIdle :
case ServerToClientPullState : : kIdle :
case ServerToClientPullState : : kReading :
case ServerToClientPullState : : kReading :
case ServerToClientPullState : : kProcessingServerToClientMessage :
case ServerToClientPullState : : kProcessingServerToClientMessage :
case ServerToClientPullState : : kProcessingServerTrailingMetadata :
LOG ( FATAL ) < < " Out of order FinishPullServerInitialMetadata " ;
LOG ( FATAL ) < < " Out of order FinishPullServerInitialMetadata " ;
case ServerToClientPullState : : kTerminated :
case ServerToClientPullState : : kTerminated :
return ;
return ;
@ -766,9 +759,6 @@ CallState::PollPullServerToClientMessageAvailable() {
case ServerToClientPullState : : kProcessingServerToClientMessage :
case ServerToClientPullState : : kProcessingServerToClientMessage :
LOG ( FATAL ) < < " PollPullServerToClientMessageAvailable called while "
LOG ( FATAL ) < < " PollPullServerToClientMessageAvailable called while "
" processing a message " ;
" processing a message " ;
case ServerToClientPullState : : kProcessingServerTrailingMetadata :
LOG ( FATAL ) < < " PollPullServerToClientMessageAvailable called while "
" processing trailing metadata " ;
case ServerToClientPullState : : kTerminated :
case ServerToClientPullState : : kTerminated :
return Failure { } ;
return Failure { } ;
}
}
@ -826,9 +816,6 @@ CallState::FinishPullServerToClientMessage() {
server_to_client_pull_state_ = ServerToClientPullState : : kIdle ;
server_to_client_pull_state_ = ServerToClientPullState : : kIdle ;
server_to_client_pull_waiter_ . Wake ( ) ;
server_to_client_pull_waiter_ . Wake ( ) ;
break ;
break ;
case ServerToClientPullState : : kProcessingServerTrailingMetadata :
LOG ( FATAL ) < < " FinishPullServerToClientMessage called while processing "
" trailing metadata " ;
case ServerToClientPullState : : kTerminated :
case ServerToClientPullState : : kTerminated :
break ;
break ;
}
}
@ -875,10 +862,7 @@ CallState::PollServerTrailingMetadataAvailable() {
case ServerToClientPushState : : kFinished :
case ServerToClientPushState : : kFinished :
if ( server_trailing_metadata_state_ ! =
if ( server_trailing_metadata_state_ ! =
ServerTrailingMetadataState : : kNotPushed ) {
ServerTrailingMetadataState : : kNotPushed ) {
server_to_client_pull_state_ =
break ; // Ready for processing
ServerToClientPullState : : kProcessingServerTrailingMetadata ;
server_to_client_pull_waiter_ . Wake ( ) ;
return Empty { } ;
}
}
ABSL_FALLTHROUGH_INTENDED ;
ABSL_FALLTHROUGH_INTENDED ;
case ServerToClientPushState : : kPushedServerInitialMetadata :
case ServerToClientPushState : : kPushedServerInitialMetadata :
@ -894,26 +878,14 @@ CallState::PollServerTrailingMetadataAvailable() {
case ServerToClientPullState : : kIdle :
case ServerToClientPullState : : kIdle :
if ( server_trailing_metadata_state_ ! =
if ( server_trailing_metadata_state_ ! =
ServerTrailingMetadataState : : kNotPushed ) {
ServerTrailingMetadataState : : kNotPushed ) {
server_to_client_pull_state_ =
break ; // Ready for processing
ServerToClientPullState : : kProcessingServerTrailingMetadata ;
server_to_client_pull_waiter_ . Wake ( ) ;
return Empty { } ;
}
}
return server_trailing_metadata_waiter_ . pending ( ) ;
return server_trailing_metadata_waiter_ . pending ( ) ;
case ServerToClientPullState : : kProcessingServerTrailingMetadata :
LOG ( FATAL ) < < " PollServerTrailingMetadataAvailable called twice " ;
case ServerToClientPullState : : kTerminated :
case ServerToClientPullState : : kTerminated :
return Empty { } ;
break ;
}
Crash ( " Unreachable " ) ;
}
}
server_to_client_pull_state_ = ServerToClientPullState : : kTerminated ;
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION inline void
server_to_client_pull_waiter_ . Wake ( ) ;
CallState : : FinishPullServerTrailingMetadata ( ) {
GRPC_TRACE_LOG ( call_state , INFO )
< < " [call_state] FinishPullServerTrailingMetadata: "
< < GRPC_DUMP_ARGS ( this , server_trailing_metadata_state_ ,
server_trailing_metadata_waiter_ . DebugString ( ) ) ;
switch ( server_trailing_metadata_state_ ) {
switch ( server_trailing_metadata_state_ ) {
case ServerTrailingMetadataState : : kNotPushed :
case ServerTrailingMetadataState : : kNotPushed :
LOG ( FATAL ) < < " FinishPullServerTrailingMetadata called before "
LOG ( FATAL ) < < " FinishPullServerTrailingMetadata called before "
@ -931,6 +903,21 @@ CallState::FinishPullServerTrailingMetadata() {
case ServerTrailingMetadataState : : kPulledCancel :
case ServerTrailingMetadataState : : kPulledCancel :
LOG ( FATAL ) < < " FinishPullServerTrailingMetadata called twice " ;
LOG ( FATAL ) < < " FinishPullServerTrailingMetadata called twice " ;
}
}
return Empty { } ;
}
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION inline bool
CallState : : WasServerTrailingMetadataPulled ( ) const {
switch ( server_trailing_metadata_state_ ) {
case ServerTrailingMetadataState : : kNotPushed :
case ServerTrailingMetadataState : : kPushed :
case ServerTrailingMetadataState : : kPushedCancel :
return false ;
case ServerTrailingMetadataState : : kPulled :
case ServerTrailingMetadataState : : kPulledCancel :
return true ;
}
GPR_UNREACHABLE_CODE ( Crash ( " unreachable " ) ) ;
}
}
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION inline Poll < bool >
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION inline Poll < bool >