forked from mirrors/gecko-dev
		
	Bug 1788173 - Force IPC channel error on timeout waiting for client connection r=ipc-reviewers,jld
Differential Revision: https://phabricator.services.mozilla.com/D173585
This commit is contained in:
		
							parent
							
								
									4c61d223e2
								
							
						
					
					
						commit
						4ca7ebefd5
					
				
					 2 changed files with 24 additions and 0 deletions
				
			
		|  | @ -115,6 +115,11 @@ void Channel::ChannelImpl::Close() { | ||||||
| void Channel::ChannelImpl::CloseLocked() { | void Channel::ChannelImpl::CloseLocked() { | ||||||
|   chan_cap_.NoteExclusiveAccess(); |   chan_cap_.NoteExclusiveAccess(); | ||||||
| 
 | 
 | ||||||
|  |   if (connect_timeout_) { | ||||||
|  |     connect_timeout_->Cancel(); | ||||||
|  |     connect_timeout_ = nullptr; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   // If we still have pending I/O, cancel it. The references inside
 |   // If we still have pending I/O, cancel it. The references inside
 | ||||||
|   // `input_state_` and `output_state_` will keep the buffers alive until they
 |   // `input_state_` and `output_state_` will keep the buffers alive until they
 | ||||||
|   // complete.
 |   // complete.
 | ||||||
|  | @ -316,9 +321,23 @@ bool Channel::ChannelImpl::ProcessConnection() { | ||||||
|   switch (err) { |   switch (err) { | ||||||
|     case ERROR_IO_PENDING: |     case ERROR_IO_PENDING: | ||||||
|       input_state_.is_pending = this; |       input_state_.is_pending = this; | ||||||
|  |       NS_NewTimerWithCallback( | ||||||
|  |           getter_AddRefs(connect_timeout_), | ||||||
|  |           [self = RefPtr{this}](nsITimer* timer) { | ||||||
|  |             CHROMIUM_LOG(ERROR) << "ConnectNamedPipe timed out!"; | ||||||
|  |             self->IOThread().AssertOnCurrentThread(); | ||||||
|  |             self->Close(); | ||||||
|  |             self->listener_->OnChannelError(); | ||||||
|  |           }, | ||||||
|  |           10000, nsITimer::TYPE_ONE_SHOT, "ChannelImpl::ProcessConnection", | ||||||
|  |           IOThread().GetEventTarget()); | ||||||
|       break; |       break; | ||||||
|     case ERROR_PIPE_CONNECTED: |     case ERROR_PIPE_CONNECTED: | ||||||
|       waiting_connect_ = false; |       waiting_connect_ = false; | ||||||
|  |       if (connect_timeout_) { | ||||||
|  |         connect_timeout_->Cancel(); | ||||||
|  |         connect_timeout_ = nullptr; | ||||||
|  |       } | ||||||
|       break; |       break; | ||||||
|     case ERROR_NO_DATA: |     case ERROR_NO_DATA: | ||||||
|       // The pipe is being closed.
 |       // The pipe is being closed.
 | ||||||
|  |  | ||||||
|  | @ -155,6 +155,11 @@ class Channel::ChannelImpl : public MessageLoopForIO::IOHandler { | ||||||
|   // buffers of this message.
 |   // buffers of this message.
 | ||||||
|   mozilla::UniquePtr<Message> incoming_message_ MOZ_GUARDED_BY(IOThread()); |   mozilla::UniquePtr<Message> incoming_message_ MOZ_GUARDED_BY(IOThread()); | ||||||
| 
 | 
 | ||||||
|  |   // Timer started when a MODE_SERVER channel begins waiting for a connection,
 | ||||||
|  |   // and cancelled when the connection completes. Will produce an error if no
 | ||||||
|  |   // connection occurs before the timeout.
 | ||||||
|  |   nsCOMPtr<nsITimer> connect_timeout_ MOZ_GUARDED_BY(IOThread()); | ||||||
|  | 
 | ||||||
|   // Will be set to `true` until `Connect()` has been called, and, if in
 |   // Will be set to `true` until `Connect()` has been called, and, if in
 | ||||||
|   // server-mode, the client has connected. The `input_state_` is used to wait
 |   // server-mode, the client has connected. The `input_state_` is used to wait
 | ||||||
|   // for the client to connect in overlapped mode.
 |   // for the client to connect in overlapped mode.
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Alexandre Lissy
						Alexandre Lissy