class HandleTable

Defined at line 37 of file ../../zircon/kernel/object/include/object/handle_table.h

A HandleTable is the data structure which stores the Handles

associated with one or more ProcessDispatchers.

Methods that require a ProcessDispatcher

&

|caller| will use to supplied

ProcessDispatcher as the target of ZX_POL_BAD_HANDLE job policy.

Public Methods

void HandleTable (const HandleTable & )

Defined at line 42 of file ../../zircon/kernel/object/include/object/handle_table.h

void HandleTable ()

Defined at line 42 of file ../../zircon/kernel/object/handle_table.cc

void HandleTable (HandleTable && )

Defined at line 43 of file ../../zircon/kernel/object/include/object/handle_table.h

HandleTable & operator= (const HandleTable & )

Defined at line 45 of file ../../zircon/kernel/object/include/object/handle_table.h

HandleTable & operator= (HandleTable && )

Defined at line 46 of file ../../zircon/kernel/object/include/object/handle_table.h

void ~HandleTable ()

Defined at line 53 of file ../../zircon/kernel/object/handle_table.cc

Handle * GetHandleLocked (ProcessDispatcher & caller, zx_handle_t handle_value)

Maps a handle value into a Handle as long we can verify that

it belongs to this handle table.

Defined at line 55 of file ../../zircon/kernel/object/include/object/handle_table.h

zx_koid_t get_koid ()

Defined at line 60 of file ../../zircon/kernel/object/include/object/handle_table.h

template <typename T>
zx_status_t GetDispatcher (ProcessDispatcher & caller, zx_handle_t handle_value, fbl::RefPtr<T> * dispatcher)

Get the dispatcher corresponding to this handle value.

Defined at line 81 of file ../../zircon/kernel/object/include/object/handle_table.h

zx_handle_t MapHandleToValue (const Handle * handle)

Maps a |handle| to an integer which can be given to usermode as a

handle value. Uses Handle->base_value() plus additional mixing.

Defined at line 82 of file ../../zircon/kernel/object/handle_table.cc

zx_handle_t MapHandleToValue (const HandleOwner & handle)

Defined at line 86 of file ../../zircon/kernel/object/handle_table.cc

template <typename T>
zx_status_t GetDispatcherAndRights (ProcessDispatcher & caller, zx_handle_t handle_value, fbl::RefPtr<T> * dispatcher, zx_rights_t * out_rights)

Get the dispatcher and the rights corresponding to this handle value.

Defined at line 88 of file ../../zircon/kernel/object/include/object/handle_table.h

template <typename T>
zx_status_t GetDispatcherWithRightsNoPolicyCheck (zx_handle_t handle_value, zx_rights_t desired_rights, fbl::RefPtr<T> * dispatcher, zx_rights_t * out_rights)

Defined at line 101 of file ../../zircon/kernel/object/include/object/handle_table.h

uint32_t HandleCount ()

Returns the number of outstanding handles in this handle table.

Defined at line 107 of file ../../zircon/kernel/object/handle_table.cc

template <typename T>
zx_status_t GetDispatcherWithRights (ProcessDispatcher & caller, zx_handle_t handle_value, zx_rights_t desired_rights, fbl::RefPtr<T> * dispatcher, zx_rights_t * out_rights)

Defined at line 110 of file ../../zircon/kernel/object/include/object/handle_table.h

void AddHandle (HandleOwner handle)

Adds |handle| to this handle table.

Defined at line 112 of file ../../zircon/kernel/object/handle_table.cc

void AddHandleLocked (HandleOwner handle)

Defined at line 118 of file ../../zircon/kernel/object/handle_table.cc

template <typename T>
zx_status_t GetDispatcherWithRights (ProcessDispatcher & caller, zx_handle_t handle_value, zx_rights_t desired_rights, fbl::RefPtr<T> * dispatcher)

Get the dispatcher corresponding to this handle value, after

checking that this handle has the desired rights.

Defined at line 120 of file ../../zircon/kernel/object/include/object/handle_table.h

HandleOwner RemoveHandleLocked (Handle * handle)

Set of overloads that remove the |handle| or |handle_value| from this

handle table and returns ownership to the handle.

Defined at line 124 of file ../../zircon/kernel/object/handle_table.cc

template <typename T>
zx_status_t ForEachHandle (T func)

Calls the provided

|zx_status_t func(zx_handle_t, zx_rights_t, fbl::RefPtr

<Dispatcher

>)|

on every handle owned by the handle table. Stops if |func| returns an error,

returning the error value.

Defined at line 132 of file ../../zircon/kernel/object/include/object/handle_table.h

template <typename T>
zx_status_t ForEachHandleLocked (T func)

Similar to |ForEachHandle|, but requires the caller to be holding the |lock_|

Defined at line 139 of file ../../zircon/kernel/object/include/object/handle_table.h

HandleOwner RemoveHandleLocked (ProcessDispatcher & caller, zx_handle_t handle_value)

Defined at line 143 of file ../../zircon/kernel/object/handle_table.cc

HandleOwner RemoveHandle (ProcessDispatcher & caller, zx_handle_t handle_value)

Defined at line 137 of file ../../zircon/kernel/object/handle_table.cc

zx_status_t RemoveHandles (ProcessDispatcher & caller, ktl::span<const zx_handle_t> handles)

Remove all of an array of |handles| from the handle table. Returns ZX_OK if all of the

handles were removed, and returns ZX_ERR_BAD_HANDLE if any were not.

Defined at line 150 of file ../../zircon/kernel/object/handle_table.cc

zx_koid_t GetKoidForHandle (ProcessDispatcher & caller, zx_handle_t handle_value)

Defined at line 166 of file ../../zircon/kernel/object/handle_table.cc

template <typename Func>
zx_status_t ForEachHandleBatched (Func && func)

Iterates over every handle owned by this handle table and calls |func| on each one.

Returns the error returned by |func| or ZX_OK if iteration completed without error. Upon

error, iteration stops.

|func| should match: |zx_status_t func(zx_handle_t, zx_rights_t, const Dispatcher*)|

This method differs from ForEachHandle in that it does not hold the handle table lock for the

duration. Instead, it iterates over handles in batches in order to minimize the length of time

the handle table lock is held.

While the method acquires the handle table lock it does not hold the lock while calling |func|.

In other words, the iteration over the handle table is not atomic. This means that the set of

handles |func| "sees" may be different from the set held by the handle table at the start or

end of the call.

Handles being added or removed concurrent with |ForEachHandleBatched| may or may not be

observed by |func|.

A Handle observed by |func| may or may not be owned by the handle table at the moment |func| is

invoked, however, it is guaranteed it was held at some point between the invocation of this

method and |func|.

Defined at line 310 of file ../../zircon/kernel/object/include/object/handle_table.h

zx_status_t GetHandleInfo (fbl::Array<zx_info_handle_extended_t> * handles)

Defined at line 188 of file ../../zircon/kernel/object/handle_table.cc

void Clean ()

Called when all the containing ProcessDispatchers have transitioned to the Dead state.

Defined at line 59 of file ../../zircon/kernel/object/handle_table.cc

Lock<BrwLockPi> * get_lock ()

accessors

Defined at line 181 of file ../../zircon/kernel/object/include/object/handle_table.h