Rev 1088 | Rev 1141 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1088 | Rev 1090 | ||
|---|---|---|---|
| Line 60... | Line 60... | ||
| 60 | * the phones may disconnect during traversal of list of connected phones. |
60 | * the phones may disconnect during traversal of list of connected phones. |
| 61 | * The only possibility is try_lock with restart of list traversal. |
61 | * The only possibility is try_lock with restart of list traversal. |
| 62 | * |
62 | * |
| 63 | * Destroying is less frequent, this approach is taken. |
63 | * Destroying is less frequent, this approach is taken. |
| 64 | * |
64 | * |
| - | 65 | * Phone call |
|
| - | 66 | * |
|
| - | 67 | * *** Connect_me_to *** |
|
| - | 68 | * The caller sends IPC_M_CONNECT_ME_TO to an answerbox. The server |
|
| - | 69 | * receives 'phoneid' of the connecting phone as an ARG3. If it answers |
|
| - | 70 | * with RETVAL=0, the phonecall is accepted, otherwise it is refused. |
|
| - | 71 | * |
|
| - | 72 | * *** Connect_to_me *** |
|
| - | 73 | * The caller sends IPC_M_CONNECT_TO_ME, with special |
|
| - | 74 | * The server receives an automatically |
|
| - | 75 | * opened phoneid. If it accepts (RETVAL=0), it can use the phoneid |
|
| - | 76 | * immediately. |
|
| - | 77 | * Possible race condition can arise, when the client receives messages |
|
| - | 78 | * from new connection before getting response for connect_to_me message. |
|
| - | 79 | * Userspace should implement handshake protocol that would control it. |
|
| - | 80 | * |
|
| 65 | * Phone hangup |
81 | * Phone hangup |
| 66 | * |
82 | * |
| 67 | * *** The caller hangs up (sys_ipc_hangup) *** |
83 | * *** The caller hangs up (sys_ipc_hangup) *** |
| 68 | * - The phone is disconnected (no more messages can be sent over this phone), |
84 | * - The phone is disconnected (no more messages can be sent over this phone), |
| 69 | * all in-progress messages are correctly handled. The anwerbox receives |
85 | * all in-progress messages are correctly handled. The anwerbox receives |
| Line 98... | Line 114... | ||
| 98 | * 2) Disconnect all phones connected to answerbox. |
114 | * 2) Disconnect all phones connected to answerbox. |
| 99 | * |
115 | * |
| 100 | * 3) Answer all messages in 'calls' and 'dispatched_calls' queues with |
116 | * 3) Answer all messages in 'calls' and 'dispatched_calls' queues with |
| 101 | * appropriate error code (EHANGUP, EFORWARD). |
117 | * appropriate error code (EHANGUP, EFORWARD). |
| 102 | * |
118 | * |
| 103 | * 4) Wait for all async answers to arrive. |
119 | * 4) Wait for all async answers to arrive and dispose of them. |
| 104 | * |
120 | * |
| 105 | */ |
121 | */ |
| 106 | 122 | ||
| 107 | #include <synch/spinlock.h> |
123 | #include <synch/spinlock.h> |
| 108 | #include <ipc/ipc.h> |
124 | #include <ipc/ipc.h> |
| Line 140... | Line 156... | ||
| 140 | if (i >= IPC_MAX_PHONES) |
156 | if (i >= IPC_MAX_PHONES) |
| 141 | return -1; |
157 | return -1; |
| 142 | return i; |
158 | return i; |
| 143 | } |
159 | } |
| 144 | 160 | ||
| - | 161 | static void phone_deallocp(phone_t *phone) |
|
| - | 162 | { |
|
| - | 163 | ASSERT(phone->busy == IPC_BUSY_CONNECTING); |
|
| - | 164 | ASSERT(! phone->callee); |
|
| - | 165 | ||
| - | 166 | /* atomic operation */ |
|
| - | 167 | phone->busy = IPC_BUSY_FREE; |
|
| - | 168 | } |
|
| - | 169 | ||
| 145 | /** Disconnect phone a free the slot |
170 | /** Free slot from a disconnected phone |
| 146 | * |
171 | * |
| 147 | * All already sent messages will be correctly processed |
172 | * All already sent messages will be correctly processed |
| 148 | */ |
173 | */ |
| 149 | void phone_dealloc(int phoneid) |
174 | void phone_dealloc(int phoneid) |
| 150 | { |
175 | { |
| 151 | spinlock_lock(&TASK->lock); |
- | |
| 152 | - | ||
| 153 | ASSERT(TASK->phones[phoneid].busy == IPC_BUSY_CONNECTING); |
- | |
| 154 | ASSERT(! TASK->phones[phoneid].callee); |
176 | phone_deallocp(&TASK->phones[phoneid]); |
| 155 | - | ||
| 156 | TASK->phones[phoneid].busy = IPC_BUSY_FREE; |
- | |
| 157 | spinlock_unlock(&TASK->lock); |
- | |
| 158 | } |
177 | } |
| 159 | 178 | ||
| 160 | /** Connect phone to a given answerbox |
179 | /** Connect phone to a given answerbox |
| 161 | * |
180 | * |
| 162 | * @param phoneid The slot that will be connected |
181 | * @param phoneid The slot that will be connected |