mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	Merge pull request #3088 from Subv/clientsession_closing
Kernel/Sessions: Wake up any threads waiting on a ServerSession when its client is closed
This commit is contained in:
		
						commit
						93742ec510
					
				
					 2 changed files with 13 additions and 4 deletions
				
			
		|  | @ -26,9 +26,6 @@ ClientSession::~ClientSession() { | ||||||
|         if (hle_handler) |         if (hle_handler) | ||||||
|             hle_handler->ClientDisconnected(server); |             hle_handler->ClientDisconnected(server); | ||||||
| 
 | 
 | ||||||
|         // TODO(Subv): Force a wake up of all the ServerSession's waiting threads and set
 |  | ||||||
|         // their WaitSynchronization result to 0xC920181A.
 |  | ||||||
| 
 |  | ||||||
|         // Clean up the list of client threads with pending requests, they are unneeded now that the
 |         // Clean up the list of client threads with pending requests, they are unneeded now that the
 | ||||||
|         // client endpoint is closed.
 |         // client endpoint is closed.
 | ||||||
|         server->pending_requesting_threads.clear(); |         server->pending_requesting_threads.clear(); | ||||||
|  | @ -36,6 +33,13 @@ ClientSession::~ClientSession() { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     parent->client = nullptr; |     parent->client = nullptr; | ||||||
|  | 
 | ||||||
|  |     if (server) { | ||||||
|  |         // Notify any threads waiting on the ServerSession that the endpoint has been closed. Note
 | ||||||
|  |         // that this call has to happen after `Session::client` has been set to nullptr to let the
 | ||||||
|  |         // ServerSession know that the client endpoint has been closed.
 | ||||||
|  |         server->WakeupAllWaitingThreads(); | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ResultCode ClientSession::SendSyncRequest(SharedPtr<Thread> thread) { | ResultCode ClientSession::SendSyncRequest(SharedPtr<Thread> thread) { | ||||||
|  |  | ||||||
|  | @ -47,8 +47,13 @@ bool ServerSession::ShouldWait(Thread* thread) const { | ||||||
| 
 | 
 | ||||||
| void ServerSession::Acquire(Thread* thread) { | void ServerSession::Acquire(Thread* thread) { | ||||||
|     ASSERT_MSG(!ShouldWait(thread), "object unavailable!"); |     ASSERT_MSG(!ShouldWait(thread), "object unavailable!"); | ||||||
|  | 
 | ||||||
|  |     // If the client endpoint was closed, don't do anything. This ServerSession is now useless and
 | ||||||
|  |     // will linger until its last handle is closed by the running application.
 | ||||||
|  |     if (parent->client == nullptr) | ||||||
|  |         return; | ||||||
|  | 
 | ||||||
|     // We are now handling a request, pop it from the stack.
 |     // We are now handling a request, pop it from the stack.
 | ||||||
|     // TODO(Subv): What happens if the client endpoint is closed before any requests are made?
 |  | ||||||
|     ASSERT(!pending_requesting_threads.empty()); |     ASSERT(!pending_requesting_threads.empty()); | ||||||
|     currently_handling = pending_requesting_threads.back(); |     currently_handling = pending_requesting_threads.back(); | ||||||
|     pending_requesting_threads.pop_back(); |     pending_requesting_threads.pop_back(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue