Ignore:
Timestamp:
2018-10-29T17:15:02Z (5 years ago)
Author:
Jakub Jermar <jakub@…>
Children:
eec201d
Parents:
184f2f8a
git-author:
Jakub Jermar <jakub@…> (2018-10-28 12:42:35)
git-committer:
Jakub Jermar <jakub@…> (2018-10-29 17:15:02)
Message:

Use user-defined labels instead of phone hashes

This commit changes the way how the async framework maps incomming calls
to connections. Instead of abusing the kernel addresses of attached
phones as identifiers, the IPC_M_CONNECT_TO_ME and IPC_M_CONNECT_ME_TO
messages allow the server to specify an arbitrary label which is
remembered in the connected phone and consequently imprinted on each
call which is routed through this phone.

The async framework uses the address of the connection structure as the
label. This removes the need for a connection hash table because each
incoming call already remembers the connection in its label.

To disambiguate this new label and the other user-defined label used for
answers, the call structure now has the request_label member for the
former and answer_label member for the latter.

This commit also moves the kernel definition of ipc_data_t to abi/ and
removes the uspace redefinition thereof. Finally, when forwarding the
IPC_M_CONNECT_TO_ME call, the phone capability and the kernel object
allocated in request_process are now correctly disposed of.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ops/concttome.c

    r184f2f8a rf5837524  
    4242static int request_process(call_t *call, answerbox_t *box)
    4343{
    44         cap_phone_handle_t phone_handle;
    45         kobject_t *phone_obj;
    46         errno_t rc = phone_alloc(TASK, false, &phone_handle, &phone_obj);
    47         call->priv = (sysarg_t) phone_obj;
    48         IPC_SET_ARG5(call->data,
    49             (rc == EOK) ? CAP_HANDLE_RAW(phone_handle) : CAP_NIL);
     44        cap_phone_handle_t phandle = CAP_NIL;
     45        kobject_t *pobj = NULL;
     46        errno_t rc = phone_alloc(TASK, false, &phandle, &pobj);
     47        if (rc == EOK) {
     48                /*
     49                 * Set the sender-assigned label to the new phone.
     50                 */
     51                pobj->phone->label = IPC_GET_ARG5(call->data);
     52        }
     53        call->priv = (sysarg_t) pobj;
     54        IPC_SET_ARG5(call->data, CAP_HANDLE_RAW(phandle));
    5055        return 0;
    5156}
     
    5358static errno_t answer_cleanup(call_t *answer, ipc_data_t *olddata)
    5459{
    55         cap_phone_handle_t phone_handle = (cap_handle_t) IPC_GET_ARG5(*olddata);
    56         kobject_t *phone_obj = (kobject_t *) answer->priv;
     60        cap_phone_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(*olddata);
     61        kobject_t *pobj = (kobject_t *) answer->priv;
    5762
    58         if (CAP_HANDLE_VALID(phone_handle)) {
    59                 kobject_put(phone_obj);
    60                 cap_free(TASK, phone_handle);
     63        if (CAP_HANDLE_VALID(phandle)) {
     64                kobject_put(pobj);
     65                cap_free(TASK, phandle);
    6166        }
    6267
     
    6671static errno_t answer_preprocess(call_t *answer, ipc_data_t *olddata)
    6772{
    68         cap_phone_handle_t phone_handle = (cap_handle_t) IPC_GET_ARG5(*olddata);
    69         kobject_t *phone_obj = (kobject_t *) answer->priv;
     73        cap_phone_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(*olddata);
     74        kobject_t *pobj = (kobject_t *) answer->priv;
    7075
    7176        if (IPC_GET_RETVAL(answer->data) != EOK) {
    7277                /* The connection was not accepted */
    7378                answer_cleanup(answer, olddata);
    74         } else if (CAP_HANDLE_VALID(phone_handle)) {
     79        } else if (CAP_HANDLE_VALID(phandle)) {
    7580                /*
    7681                 * The connection was accepted
     
    8186                 * will be consumed by ipc_phone_connect().
    8287                 */
    83                 kobject_add_ref(phone_obj);
     88                kobject_add_ref(pobj);
    8489
    85                 if (ipc_phone_connect(phone_obj->phone,
     90                if (ipc_phone_connect(pobj->phone,
    8691                    &answer->sender->answerbox)) {
    8792                        /* Pass the reference to the capability */
    88                         cap_publish(TASK, phone_handle, phone_obj);
    89                         /* Set 'phone hash' as ARG5 of response */
    90                         IPC_SET_ARG5(answer->data,
    91                             (sysarg_t) phone_obj->phone);
     93                        cap_publish(TASK, phandle, pobj);
    9294                } else {
    9395                        /* The answerbox is shutting down. */
Note: See TracChangeset for help on using the changeset viewer.