Changeset cd671c3 in mainline
- Timestamp:
- 2012-09-05T22:36:48Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1d5ef8
- Parents:
- 239acce
- Location:
- kernel/generic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/ipc/ipc.h
r239acce rcd671c3 116 116 link_t ta_link; 117 117 118 atomic_t refcnt; 119 118 120 /** Answerbox link. */ 119 121 link_t ab_link; … … 166 168 extern call_t *ipc_call_alloc(unsigned int); 167 169 extern void ipc_call_free(call_t *); 170 extern void ipc_call_hold(call_t *); 171 extern void ipc_call_release(call_t *); 168 172 169 173 extern int ipc_call(phone_t *, call_t *); -
kernel/generic/include/ipc/sysipc_ops.h
r239acce rcd671c3 55 55 * Context: caller 56 56 * Caller alive: guaranteed 57 * Races with: request_process(), answer_cleanup() 57 * Races with: request_process(), answer_cleanup(), 58 * _ipc_answer_free_call() 58 59 * Invoked on: all forgotten calls 59 60 */ -
kernel/generic/src/ipc/ipc.c
r239acce rcd671c3 80 80 } 81 81 82 void ipc_call_hold(call_t *call) 83 { 84 atomic_inc(&call->refcnt); 85 } 86 87 void ipc_call_release(call_t *call) 88 { 89 if (atomic_predec(&call->refcnt) == 0) { 90 if (call->buffer) 91 free(call->buffer); 92 slab_free(ipc_call_slab, call); 93 } 94 } 95 82 96 /** Allocate and initialize a call structure. 83 97 * … … 88 102 * 89 103 * @return If flags permit it, return NULL, or initialized kernel 90 * call structure .104 * call structure with one reference. 91 105 * 92 106 */ … … 94 108 { 95 109 call_t *call = slab_alloc(ipc_call_slab, flags); 96 if (call) 110 if (call) { 97 111 _ipc_call_init(call); 112 ipc_call_hold(call); 113 } 98 114 99 115 return call; … … 107 123 void ipc_call_free(call_t *call) 108 124 { 109 /* Check to see if we have data in the IPC_M_DATA_SEND buffer. */ 110 if (call->buffer) 111 free(call->buffer); 112 slab_free(ipc_call_slab, call); 125 ipc_call_release(call); 113 126 } 114 127 … … 605 618 list_remove(&call->ta_link); 606 619 620 /* 621 * The call may be freed by _ipc_answer_free_call() before we are done 622 * with it; to avoid working with a destroyed call_t structure, we 623 * must hold a reference to it. 624 */ 625 ipc_call_hold(call); 626 607 627 spinlock_unlock(&call->forget_lock); 608 628 spinlock_unlock(&TASK->active_calls_lock); … … 613 633 if (ops->request_forget) 614 634 ops->request_forget(call); 635 636 ipc_call_release(call); 615 637 616 638 goto restart;
Note:
See TracChangeset
for help on using the changeset viewer.