Ignore:
Timestamp:
2018-03-15T17:40:20Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
530f2de, e9e4068
Parents:
30f1a25 (diff), a36f442 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jakub Jermar <jakub@…> (2018-03-15 17:25:56)
git-committer:
Jakub Jermar <jakub@…> (2018-03-15 17:40:20)
Message:

Merge branch 'noreclaimers'

This commit removes the left-over from the original IPC phone life-cycle
management in which phones were freed lazily during an attempt to
allocate a new phone when the allocator found a hung-up phone with zero
active calls. This mechanism is the reason why kernel objects had to
have the reclaim method. This commit changes the behavior in that phones
are deallocated with their last reference. At the same time it makes
sure that each active call has its own reference on the phone.

This change also makes sure that each connected phone has a capability
via which it can be hung up by the user or cleaned up in ipc_cleanup().
A special mode for phone_alloc() was introduced that allows calls such
as IPC_M_CONNECT_ME_TO and IPC_M_CONNECT_TO_ME to allocate an
unpublished capability and publish it only when the phone is
successfully connected. This fixes a nasty race condition when the user
destroys the capability before the phone is connected and then this
phone becomes essentially invisible for ipc_cleanup().

Last but not least, ipc_cleanup() was slightly streamlined in that it
now knows for how many calls it has to wait from the answerbox's active
call count.

File:
1 edited

Legend:

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

    r30f1a25 r67f11a0  
    4343{
    4444        cap_handle_t phone_handle;
    45         errno_t rc = phone_alloc(TASK, &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;
    4648        IPC_SET_ARG5(call->data, (rc == EOK) ? phone_handle : -1);
    4749        return 0;
     
    5153{
    5254        cap_handle_t phone_handle = (cap_handle_t) IPC_GET_ARG5(*olddata);
     55        kobject_t *phone_obj = (kobject_t *) answer->priv;
    5356
    54         if (phone_handle >= 0)
    55                 phone_dealloc(phone_handle);
     57        if (phone_handle >= 0) {
     58                kobject_put(phone_obj);
     59                cap_free(TASK, phone_handle);
     60        }
    5661
    5762        return EOK;
     
    6166{
    6267        cap_handle_t phone_handle = (cap_handle_t) IPC_GET_ARG5(*olddata);
     68        kobject_t *phone_obj = (kobject_t *) answer->priv;
    6369
    6470        if (IPC_GET_RETVAL(answer->data) != EOK) {
     
    6672                answer_cleanup(answer, olddata);
    6773        } else if (phone_handle >= 0) {
    68                 /* The connection was accepted */
    69                 if (phone_connect(phone_handle, &answer->sender->answerbox)) {
     74                /*
     75                 * The connection was accepted
     76                 */
     77
     78                /*
     79                 * We need to create another reference as the one we have now
     80                 * will be consumed by ipc_phone_connect().
     81                 */
     82                kobject_add_ref(phone_obj);
     83
     84                if (ipc_phone_connect(phone_obj->phone,
     85                    &answer->sender->answerbox)) {
     86                        /* Pass the reference to the capability */
     87                        cap_publish(TASK, phone_handle, phone_obj);
    7088                        /* Set 'phone hash' as ARG5 of response */
    71                         kobject_t *phone_obj = kobject_get(TASK, phone_handle,
    72                             KOBJECT_TYPE_PHONE);
    7389                        IPC_SET_ARG5(answer->data,
    7490                            (sysarg_t) phone_obj->phone);
    75                         kobject_put(phone_obj);
    7691                } else {
    7792                        /* The answerbox is shutting down. */
Note: See TracChangeset for help on using the changeset viewer.