Changeset 7975433 in mainline


Ignore:
Timestamp:
2012-08-16T21:25:56Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8f6858d0
Parents:
2405bb5
Message:

Cleanup of forgotten calls on answer.

Location:
kernel/generic/src/ipc
Files:
2 edited

Legend:

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

    r2405bb5 r7975433  
    190190                /* This is a forgotten call and call->sender is not valid. */
    191191                spinlock_unlock(&call->forget_lock);
    192                 /* TODO: free the call and its resources */
     192                ipc_call_free(call);
    193193                return;
    194194        } else {
  • kernel/generic/src/ipc/sysipc.c

    r2405bb5 r7975433  
    174174}
    175175
    176 static int a_preprocess_m_connection_clone(call_t *answer, ipc_data_t *olddata)
     176static void cleanup_m_connection_clone(call_t *answer, ipc_data_t *olddata)
    177177{
    178178        int phoneid = (int) IPC_GET_ARG1(*olddata);
    179179        phone_t *phone = &TASK->phones[phoneid];
    180180
     181        /*
     182         * In this case, the connection was established at the request time and
     183         * therefore we need to slam the phone.  We don't merely hangup as that
     184         * would result in sending IPC_M_HUNGUP to the third party on the other
     185         * side of the cloned phone.
     186         */
     187        mutex_lock(&phone->lock);
     188        if (phone->state == IPC_PHONE_CONNECTED) {
     189                irq_spinlock_lock(&phone->callee->lock, true);
     190                list_remove(&phone->link);
     191                phone->state = IPC_PHONE_SLAMMED;
     192                irq_spinlock_unlock(&phone->callee->lock, true);
     193        }
     194        mutex_unlock(&phone->lock);
     195}
     196
     197static int a_preprocess_m_connection_clone(call_t *answer, ipc_data_t *olddata)
     198{
    181199        if (IPC_GET_RETVAL(answer->data) != EOK) {
    182200                /*
    183                  * The recipient of the cloned phone rejected the offer.  In
    184                  * this case, the connection was established at the request
    185                  * time and therefore we need to slam the phone.  We don't
    186                  * merely hangup as that would result in sending IPC_M_HUNGUP
    187                  * to the third party on the other side of the cloned phone.
     201                 * The recipient of the cloned phone rejected the offer.
    188202                 */
    189                 mutex_lock(&phone->lock);
    190                 if (phone->state == IPC_PHONE_CONNECTED) {
    191                         irq_spinlock_lock(&phone->callee->lock, true);
    192                         list_remove(&phone->link);
    193                         phone->state = IPC_PHONE_SLAMMED;
    194                         irq_spinlock_unlock(&phone->callee->lock, true);
    195                 }
    196                 mutex_unlock(&phone->lock);
     203                cleanup_m_connection_clone(answer, olddata);
    197204        }
    198205
     
    206213        if (IPC_GET_RETVAL(answer->data) != EOK) {
    207214                /*
    208                  * The other party on the cloned phoned rejected our request
     215                 * The other party on the cloned phone rejected our request
    209216                 * for connection on the protocol level.  We need to break the
    210217                 * connection without sending IPC_M_HUNGUP back.
     
    223230}
    224231
     232static void cleanup_m_connect_to_me(call_t *answer, ipc_data_t *olddata)
     233{
     234        int phoneid = (int) IPC_GET_ARG5(*olddata);
     235       
     236        phone_dealloc(phoneid);
     237}
     238
    225239static int a_preprocess_m_connect_to_me(call_t *answer, ipc_data_t *olddata)
    226240{
     
    229243        if (IPC_GET_RETVAL(answer->data) != EOK) {
    230244                /* The connection was not accepted */
    231                 phone_dealloc(phoneid);
     245                cleanup_m_connect_to_me(answer, olddata);
    232246        } else {
    233247                /* The connection was accepted */
     
    240254}
    241255
     256static void cleanup_m_connect_me_to(call_t *answer, ipc_data_t *olddata)
     257{
     258        phone_dealloc(answer->priv);
     259}
     260
    242261static int a_preprocess_m_connect_me_to(call_t *answer, ipc_data_t *olddata)
    243262{
    244263        phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata);
    245264
    246         /* If the users accepted call, connect */
     265        /* If the user accepted call, connect */
    247266        if (IPC_GET_RETVAL(answer->data) == EOK)
    248267                ipc_phone_connect(phone, &TASK->answerbox);
     
    406425}
    407426
     427/** Cleanup additional resources associated with the answer. */
     428static void cleanup_forgotten(call_t *answer, ipc_data_t *olddata)
     429{
     430        if (!olddata)
     431                return;
     432
     433        switch (IPC_GET_IMETHOD(*olddata)) {
     434        case IPC_M_CONNECTION_CLONE:
     435                cleanup_m_connection_clone(answer, olddata);
     436                break;
     437        case IPC_M_CONNECT_TO_ME:
     438                cleanup_m_connect_to_me(answer, olddata);
     439                break;
     440        case IPC_M_CONNECT_ME_TO:
     441                cleanup_m_connect_me_to(answer, olddata);
     442                break;
     443        default:
     444                break;
     445        }
     446}
     447
    408448/** Interpret process answer as control information.
    409449 *
     
    426466                 */
    427467                spinlock_unlock(&answer->forget_lock);
    428                 /* TODO: free the call and its resources */
     468                cleanup_forgotten(answer, olddata);
    429469                return rc;
    430470        } else {
Note: See TracChangeset for help on using the changeset viewer.