[Yunq] Delete client capability in destructor.
Add a method to the server class to create an unowned capability. This makes it simpler to create a capability for passing to other processes. Duplicate the init yellowstone cap when using it temporarily.
This commit is contained in:
parent
96a2f74e14
commit
ad7794c694
24 changed files with 98 additions and 9 deletions
|
|
@ -3,10 +3,18 @@
|
|||
|
||||
#include <glacier/buffer/byte_buffer.h>
|
||||
#include <glacier/buffer/cap_buffer.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <zcall.h>
|
||||
|
||||
|
||||
|
||||
VFSClient::~VFSClient() {
|
||||
if (endpoint_ != 0) {
|
||||
check(ZCapRelease(endpoint_));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
glcr::ErrorCode VFSClient::OpenFile(const OpenFileRequest& request, OpenFileResponse& response) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class VFSClient {
|
|||
VFSClient(z_cap_t VFS_cap) : endpoint_(VFS_cap) {}
|
||||
VFSClient(const VFSClient&) = delete;
|
||||
VFSClient(VFSClient&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
||||
~VFSClient();
|
||||
|
||||
z_cap_t Capability() { return endpoint_; }
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ VFSServerBase::~VFSServerBase() {
|
|||
}
|
||||
}
|
||||
|
||||
glcr::ErrorOr<z_cap_t> VFSServerBase::CreateClientCap() {
|
||||
uint64_t client_cap;
|
||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
||||
return client_cap;
|
||||
}
|
||||
|
||||
glcr::ErrorOr<VFSClient> VFSServerBase::CreateClient() {
|
||||
uint64_t client_cap;
|
||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class VFSServerBase {
|
|||
VFSServerBase(VFSServerBase&&) = delete;
|
||||
virtual ~VFSServerBase();
|
||||
|
||||
glcr::ErrorOr<z_cap_t> CreateClientCap();
|
||||
glcr::ErrorOr<VFSClient> CreateClient();
|
||||
|
||||
[[nodiscard]] Thread RunServer();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue