[kernel] Add the handle_close syscallnnAdd a generic handle_close syscall and use it in j6::channel when failing to open
This commit is contained in:
@@ -44,6 +44,11 @@ interface syscalls [syscall] {
|
|||||||
param mask uint32 # The capability bitmask
|
param mask uint32 # The capability bitmask
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Close the handle to an object
|
||||||
|
function handle_close {
|
||||||
|
param hnd ref object [handle] # The handle to close
|
||||||
|
}
|
||||||
|
|
||||||
# Block waiting on a futex
|
# Block waiting on a futex
|
||||||
function futex_wait [static] {
|
function futex_wait [static] {
|
||||||
param address uint32* # Address of the futex value
|
param address uint32* # Address of the futex value
|
||||||
|
|||||||
@@ -32,4 +32,13 @@ handle_clone(j6_handle_t orig, j6_handle_t *clone, uint32_t mask)
|
|||||||
return j6_status_ok;
|
return j6_status_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
j6_status_t
|
||||||
|
handle_close(j6_handle_t hnd)
|
||||||
|
{
|
||||||
|
process &p = process::current();
|
||||||
|
p.remove_handle(hnd);
|
||||||
|
return j6_status_ok;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace syscalls
|
} // namespace syscalls
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ channel::create(size_t tx_size, size_t rx_size)
|
|||||||
uintptr_t rx_addr = create_channel_vma(rx_vma, rx_size);
|
uintptr_t rx_addr = create_channel_vma(rx_vma, rx_size);
|
||||||
if (!rx_addr) {
|
if (!rx_addr) {
|
||||||
j6_vma_unmap(tx_vma, 0);
|
j6_vma_unmap(tx_vma, 0);
|
||||||
// TODO: Close TX handle
|
j6_handle_close(tx_vma);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ channel::open(const channel_def &def)
|
|||||||
result = j6_vma_map(def.rx, 0, &rx_addr, 0);
|
result = j6_vma_map(def.rx, 0, &rx_addr, 0);
|
||||||
if (result != j6_status_ok) {
|
if (result != j6_status_ok) {
|
||||||
j6_vma_unmap(def.tx, 0);
|
j6_vma_unmap(def.tx, 0);
|
||||||
// TODO: Close TX handle
|
j6_handle_close(def.tx);
|
||||||
syslog(j6::logs::ipc, j6::log_level::error, "Failed to map channel VMA. Error: %lx", result);
|
syslog(j6::logs::ipc, j6::log_level::error, "Failed to map channel VMA. Error: %lx", result);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user