io/uring/Queue: support IORING_CQE_F_MORE
This commit is contained in:
		
				
					committed by
					
						
						Max Kellermann
					
				
			
			
				
	
			
			
			
						parent
						
							268f737ac4
						
					
				
				
					commit
					b7655d38f7
				
			@@ -48,15 +48,20 @@ public:
 | 
				
			|||||||
		new_operation.cancellable = this;
 | 
							new_operation.cancellable = this;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void OnUringCompletion(int res) noexcept {
 | 
						void OnUringCompletion(int res, bool more) noexcept {
 | 
				
			||||||
		if (operation == nullptr)
 | 
							if (operation == nullptr)
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		assert(operation->cancellable == this);
 | 
							assert(operation->cancellable == this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (more) {
 | 
				
			||||||
 | 
								operation->OnUringCompletion(res);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
			operation->cancellable = nullptr;
 | 
								operation->cancellable = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			std::exchange(operation, nullptr)->OnUringCompletion(res);
 | 
								std::exchange(operation, nullptr)->OnUringCompletion(res);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace Uring
 | 
					} // namespace Uring
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,10 +57,13 @@ Queue::DispatchOneCompletion(struct io_uring_cqe &cqe) noexcept
 | 
				
			|||||||
	void *data = io_uring_cqe_get_data(&cqe);
 | 
						void *data = io_uring_cqe_get_data(&cqe);
 | 
				
			||||||
	if (data != nullptr) {
 | 
						if (data != nullptr) {
 | 
				
			||||||
		auto *c = (CancellableOperation *)data;
 | 
							auto *c = (CancellableOperation *)data;
 | 
				
			||||||
		c->OnUringCompletion(cqe.res);
 | 
							const bool more = cqe.flags & IORING_CQE_F_MORE;
 | 
				
			||||||
 | 
							c->OnUringCompletion(cqe.res, more);
 | 
				
			||||||
 | 
							if (!more) {
 | 
				
			||||||
			c->unlink();
 | 
								c->unlink();
 | 
				
			||||||
			delete c;
 | 
								delete c;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ring.SeenCompletion(cqe);
 | 
						ring.SeenCompletion(cqe);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user