Changeset b1e6269 in mainline


Ignore:
Timestamp:
2012-08-24T22:27:44Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
20282ef3
Parents:
13dbaa8c
Message:

Add two new sysipc_ops_t members:

  • request_forget()
  • answer_cleanup()

Call these members to perform cleanup at appropriate times.

Location:
kernel/generic
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ipc/sysipc_ops.h

    r13dbaa8c rb1e6269  
    4040typedef struct {
    4141        int (* request_preprocess)(call_t *, phone_t *);
     42        void (* request_forget)(call_t *);
    4243        int (* request_process)(call_t *, answerbox_t *);
     44        void (* answer_cleanup)(call_t *, ipc_data_t *);
    4345        int (* answer_preprocess)(call_t *, ipc_data_t *);
    4446        int (* answer_process)(call_t *);
     
    4850
    4951extern int null_request_preprocess(call_t *, phone_t *);
     52extern void null_request_forget(call_t *);
    5053extern int null_request_process(call_t *, answerbox_t *);
     54extern void null_answer_cleanup(call_t *, ipc_data_t *);
    5155extern int null_answer_preprocess(call_t *, ipc_data_t *);
    5256extern int null_answer_process(call_t *);
  • kernel/generic/src/ipc/ipc.c

    r13dbaa8c rb1e6269  
    4545#include <ipc/kbox.h>
    4646#include <ipc/event.h>
     47#include <ipc/sysipc_ops.h>
    4748#include <errno.h>
    4849#include <mm/slab.h>
     
    613614        spinlock_unlock(&call->forget_lock);
    614615        spinlock_unlock(&TASK->active_calls_lock);
     616
     617        sysipc_ops_t *ops = sysipc_ops_get(call->request_method);
     618        if (ops->request_forget)
     619                ops->request_forget(call);
     620
    615621        goto restart;
    616622}
  • kernel/generic/src/ipc/ops/clnestab.c

    r13dbaa8c rb1e6269  
    4545}
    4646
     47static void answer_cleanup(call_t *answer, ipc_data_t *olddata)
     48{
     49        phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata);
     50
     51        mutex_lock(&phone->lock);
     52        if (phone->state == IPC_PHONE_CONNECTED) {
     53                irq_spinlock_lock(&phone->callee->lock, true);
     54                list_remove(&phone->link);
     55                phone->state = IPC_PHONE_SLAMMED;
     56                irq_spinlock_unlock(&phone->callee->lock, true);
     57        }
     58        mutex_unlock(&phone->lock);
     59}
     60
    4761static int answer_preprocess(call_t *answer, ipc_data_t *olddata)
    4862{
    49         phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata);
    5063
    5164        if (IPC_GET_RETVAL(answer->data) != EOK) {
     
    5568                 * connection without sending IPC_M_HUNGUP back.
    5669                 */
    57                 mutex_lock(&phone->lock);
    58                 if (phone->state == IPC_PHONE_CONNECTED) {
    59                         irq_spinlock_lock(&phone->callee->lock, true);
    60                         list_remove(&phone->link);
    61                         phone->state = IPC_PHONE_SLAMMED;
    62                         irq_spinlock_unlock(&phone->callee->lock, true);
    63                 }
    64                 mutex_unlock(&phone->lock);
     70                answer_cleanup(answer, olddata);
    6571        }
    6672       
     
    7076sysipc_ops_t ipc_m_clone_establish_ops = {
    7177        .request_preprocess = request_preprocess,
     78        .request_forget = null_request_forget,
    7279        .request_process = null_request_process,
     80        .answer_cleanup = answer_cleanup,
    7381        .answer_preprocess = answer_preprocess,
    7482        .answer_process = null_answer_process,
  • kernel/generic/src/ipc/ops/conctmeto.c

    r13dbaa8c rb1e6269  
    5454}
    5555
     56static void request_forget(call_t *call)
     57{
     58        phone_dealloc(call->priv);
     59}
     60
    5661static int answer_preprocess(call_t *answer, ipc_data_t *olddata)
    5762{
     
    7782sysipc_ops_t ipc_m_connect_me_to_ops = {
    7883        .request_preprocess = request_preprocess,
     84        .request_forget = request_forget,
    7985        .request_process = null_request_process,
     86        .answer_cleanup = null_answer_cleanup,
    8087        .answer_preprocess = answer_preprocess,
    8188        .answer_process = answer_process,
  • kernel/generic/src/ipc/ops/concttome.c

    r13dbaa8c rb1e6269  
    5555}
    5656
     57static void answer_cleanup(call_t *answer, ipc_data_t *olddata)
     58{
     59        int phoneid = (int) IPC_GET_ARG5(*olddata);
     60
     61        phone_dealloc(phoneid);
     62}
     63
    5764static int answer_preprocess(call_t *answer, ipc_data_t *olddata)
    5865{
     
    6168        if (IPC_GET_RETVAL(answer->data) != EOK) {
    6269                /* The connection was not accepted */
    63                 int phoneid = (int) IPC_GET_ARG5(*olddata);
    64        
    65                 phone_dealloc(phoneid);
     70                answer_cleanup(answer, olddata);
    6671        } else {
    6772                /* The connection was accepted */
     
    7782sysipc_ops_t ipc_m_connect_to_me_ops = {
    7883        .request_preprocess = null_request_preprocess,
     84        .request_forget = null_request_forget,
    7985        .request_process = request_process,
     86        .answer_cleanup = answer_cleanup,
    8087        .answer_preprocess = answer_preprocess,
    8188        .answer_process = null_answer_process,
  • kernel/generic/src/ipc/ops/connclone.c

    r13dbaa8c rb1e6269  
    9797}
    9898
     99static void answer_cleanup(call_t *answer, ipc_data_t *olddata)
     100{
     101        int phoneid = (int) IPC_GET_ARG1(*olddata);
     102        phone_t *phone = &TASK->phones[phoneid];
     103
     104        /*
     105         * In this case, the connection was established at the request
     106         * time and therefore we need to slam the phone.  We don't
     107         * merely hangup as that would result in sending IPC_M_HUNGUP
     108         * to the third party on the other side of the cloned phone.
     109         */
     110        mutex_lock(&phone->lock);
     111        if (phone->state == IPC_PHONE_CONNECTED) {
     112                irq_spinlock_lock(&phone->callee->lock, true);
     113                list_remove(&phone->link);
     114                phone->state = IPC_PHONE_SLAMMED;
     115                irq_spinlock_unlock(&phone->callee->lock, true);
     116        }
     117        mutex_unlock(&phone->lock);
     118}
     119
    99120static int answer_preprocess(call_t *answer, ipc_data_t *olddata)
    100121{
     
    103124                 * The recipient of the cloned phone rejected the offer.
    104125                 */
    105                 int phoneid = (int) IPC_GET_ARG1(*olddata);
    106                 phone_t *phone = &TASK->phones[phoneid];
    107 
    108                 /*
    109                  * In this case, the connection was established at the request
    110                  * time and therefore we need to slam the phone.  We don't
    111                  * merely hangup as that would result in sending IPC_M_HUNGUP
    112                  * to the third party on the other side of the cloned phone.
    113                  */
    114                 mutex_lock(&phone->lock);
    115                 if (phone->state == IPC_PHONE_CONNECTED) {
    116                         irq_spinlock_lock(&phone->callee->lock, true);
    117                         list_remove(&phone->link);
    118                         phone->state = IPC_PHONE_SLAMMED;
    119                         irq_spinlock_unlock(&phone->callee->lock, true);
    120                 }
    121                 mutex_unlock(&phone->lock);
     126                answer_cleanup(answer, olddata);
    122127        }
    123128
     
    127132sysipc_ops_t ipc_m_connection_clone_ops = {
    128133        .request_preprocess = request_preprocess,
     134        .request_forget = null_request_forget,
    129135        .request_process = null_request_process,
     136        .answer_cleanup = answer_cleanup,
    130137        .answer_preprocess = answer_preprocess,
    131138        .answer_process = null_answer_process,
  • kernel/generic/src/ipc/ops/dataread.c

    r13dbaa8c rb1e6269  
    108108sysipc_ops_t ipc_m_data_read_ops = {
    109109        .request_preprocess = request_preprocess,
     110        .request_forget = null_request_forget,
    110111        .request_process = null_request_process,
     112        .answer_cleanup = null_answer_cleanup,
    111113        .answer_preprocess = answer_preprocess,
    112114        .answer_process = answer_process,
  • kernel/generic/src/ipc/ops/datawrite.c

    r13dbaa8c rb1e6269  
    8484                }
    8585        }
    86         free(answer->buffer);
    87         answer->buffer = NULL;
    8886
    8987        return EOK;
     
    9391sysipc_ops_t ipc_m_data_write_ops = {
    9492        .request_preprocess = request_preprocess,
     93        .request_forget = null_request_forget,
    9594        .request_process = null_request_process,
     95        .answer_cleanup = null_answer_cleanup,
    9696        .answer_preprocess = answer_preprocess,
    9797        .answer_process = null_answer_process,
  • kernel/generic/src/ipc/ops/debug.c

    r13dbaa8c rb1e6269  
    6565        .request_preprocess = null_request_preprocess,
    6666#endif
     67        .request_forget = null_request_forget,
    6768        .request_process = request_process,
     69        .answer_cleanup = null_answer_cleanup,
    6870        .answer_preprocess = null_answer_preprocess,
    6971        .answer_process = answer_process,
  • kernel/generic/src/ipc/ops/sharein.c

    r13dbaa8c rb1e6269  
    6161sysipc_ops_t ipc_m_share_in_ops = {
    6262        .request_preprocess = null_request_preprocess,
     63        .request_forget = null_request_forget,
    6364        .request_process = null_request_process,
     65        .answer_cleanup = null_answer_cleanup,
    6466        .answer_preprocess = answer_preprocess,
    6567        .answer_process = null_answer_process,
  • kernel/generic/src/ipc/ops/shareout.c

    r13dbaa8c rb1e6269  
    8282sysipc_ops_t ipc_m_share_out_ops = {
    8383        .request_preprocess = request_preprocess,
     84        .request_forget = null_request_forget,
    8485        .request_process = null_request_process,
     86        .answer_cleanup = null_answer_cleanup,
    8587        .answer_preprocess = answer_preprocess,
    8688        .answer_process = null_answer_process,
  • kernel/generic/src/ipc/ops/stchngath.c

    r13dbaa8c rb1e6269  
    118118sysipc_ops_t ipc_m_state_change_authorize_ops = {
    119119        .request_preprocess = request_preprocess,
     120        .request_forget = null_request_forget,
    120121        .request_process = null_request_process,
     122        .answer_cleanup = null_answer_cleanup,
    121123        .answer_preprocess = answer_preprocess,
    122124        .answer_process = null_answer_process,
  • kernel/generic/src/ipc/sysipc.c

    r13dbaa8c rb1e6269  
    160160{
    161161        int rc = EOK;
     162        sysipc_ops_t *ops;
    162163
    163164        spinlock_lock(&answer->forget_lock);
     
    167168                 */
    168169                spinlock_unlock(&answer->forget_lock);
    169                 /* TODO: cleanup? */
     170
     171                ops = sysipc_ops_get(answer->request_method);
     172                if (ops->answer_cleanup)
     173                        ops->answer_cleanup(answer, olddata);
     174
    170175                return rc;
    171176        } else {
     
    198203       
    199204
    200         sysipc_ops_t *ops = sysipc_ops_get(answer->request_method);
     205        ops = sysipc_ops_get(answer->request_method);
    201206        if (ops->answer_preprocess)
    202207                rc = ops->answer_preprocess(answer, olddata);
  • kernel/generic/src/ipc/sysipc_ops.c

    r13dbaa8c rb1e6269  
    6464static sysipc_ops_t null_ops = {
    6565        .request_preprocess = null_request_preprocess,
     66        .request_forget = null_request_forget,
    6667        .request_process = null_request_process,
     68        .answer_cleanup = null_answer_cleanup,
    6769        .answer_preprocess = null_answer_preprocess,
    6870        .answer_process = null_answer_process,
     
    7476}
    7577
     78void null_request_forget(call_t *call)
     79{
     80}
     81
    7682int null_request_process(call_t *call, answerbox_t *box)
    7783{
    7884        return EOK;
     85}
     86
     87void null_answer_cleanup(call_t *call, ipc_data_t *data)
     88{
    7989}
    8090
Note: See TracChangeset for help on using the changeset viewer.