Rev 1614 | Rev 1653 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1614 | Rev 1648 | ||
|---|---|---|---|
| Line 129... | Line 129... | ||
| 129 | ipcarg_t in_phone_hash; /**< Incoming phone hash. */ |
129 | ipcarg_t in_phone_hash; /**< Incoming phone hash. */ |
| 130 | link_t msg_queue; /**< Messages that should be delivered to this thread */ |
130 | link_t msg_queue; /**< Messages that should be delivered to this thread */ |
| 131 | /* Structures for connection opening packet */ |
131 | /* Structures for connection opening packet */ |
| 132 | ipc_callid_t callid; |
132 | ipc_callid_t callid; |
| 133 | ipc_call_t call; |
133 | ipc_call_t call; |
| - | 134 | ipc_callid_t close_callid; /* Identification of closing packet */ |
|
| 134 | void (*cthread)(ipc_callid_t,ipc_call_t *); |
135 | void (*cthread)(ipc_callid_t,ipc_call_t *); |
| 135 | } connection_t; |
136 | } connection_t; |
| 136 | 137 | ||
| 137 | /** Identifier of incoming connection handled by current thread */ |
138 | /** Identifier of incoming connection handled by current thread */ |
| 138 | __thread connection_t *PS_connection; |
139 | __thread connection_t *PS_connection; |
| Line 264... | Line 265... | ||
| 264 | 265 | ||
| 265 | msg = malloc(sizeof(*msg)); |
266 | msg = malloc(sizeof(*msg)); |
| 266 | msg->callid = callid; |
267 | msg->callid = callid; |
| 267 | msg->call = *call; |
268 | msg->call = *call; |
| 268 | list_append(&msg->link, &conn->msg_queue); |
269 | list_append(&msg->link, &conn->msg_queue); |
| - | 270 | ||
| - | 271 | if (IPC_GET_METHOD(*call) == IPC_M_PHONE_HUNGUP) |
|
| - | 272 | conn->close_callid = callid; |
|
| 269 | 273 | ||
| 270 | /* If the call is waiting for event, run it */ |
274 | /* If the call is waiting for event, run it */ |
| 271 | if (!conn->wdata.active) { |
275 | if (!conn->wdata.active) { |
| 272 | /* If in timeout list, remove it */ |
276 | /* If in timeout list, remove it */ |
| 273 | if (conn->wdata.inlist) { |
277 | if (conn->wdata.inlist) { |
| Line 356... | Line 360... | ||
| 356 | */ |
360 | */ |
| 357 | static int connection_thread(void *arg) |
361 | static int connection_thread(void *arg) |
| 358 | { |
362 | { |
| 359 | unsigned long key; |
363 | unsigned long key; |
| 360 | msg_t *msg; |
364 | msg_t *msg; |
| - | 365 | int close_answered = 0; |
|
| 361 | 366 | ||
| 362 | /* Setup thread local connection pointer */ |
367 | /* Setup thread local connection pointer */ |
| 363 | PS_connection = (connection_t *)arg; |
368 | PS_connection = (connection_t *)arg; |
| 364 | PS_connection->cthread(PS_connection->callid, &PS_connection->call); |
369 | PS_connection->cthread(PS_connection->callid, &PS_connection->call); |
| 365 | /* Remove myself from connection hash table */ |
370 | /* Remove myself from connection hash table */ |
| Line 369... | Line 374... | ||
| 369 | futex_up(&async_futex); |
374 | futex_up(&async_futex); |
| 370 | /* Answer all remaining messages with ehangup */ |
375 | /* Answer all remaining messages with ehangup */ |
| 371 | while (!list_empty(&PS_connection->msg_queue)) { |
376 | while (!list_empty(&PS_connection->msg_queue)) { |
| 372 | msg = list_get_instance(PS_connection->msg_queue.next, msg_t, link); |
377 | msg = list_get_instance(PS_connection->msg_queue.next, msg_t, link); |
| 373 | list_remove(&msg->link); |
378 | list_remove(&msg->link); |
| - | 379 | if (msg->callid == PS_connection->close_callid) |
|
| - | 380 | close_answered = 1; |
|
| 374 | ipc_answer_fast(msg->callid, EHANGUP, 0, 0); |
381 | ipc_answer_fast(msg->callid, EHANGUP, 0, 0); |
| 375 | free(msg); |
382 | free(msg); |
| 376 | } |
383 | } |
| - | 384 | if (PS_connection->close_callid) |
|
| - | 385 | ipc_answer_fast(PS_connection->close_callid, 0, 0, 0); |
|
| 377 | } |
386 | } |
| 378 | 387 | ||
| 379 | /** Create new thread for a new connection |
388 | /** Create new thread for a new connection |
| 380 | * |
389 | * |
| 381 | * Creates new thread for connection, fills in connection |
390 | * Creates new thread for connection, fills in connection |
| Line 404... | Line 413... | ||
| 404 | return NULL; |
413 | return NULL; |
| 405 | } |
414 | } |
| 406 | conn->in_phone_hash = in_phone_hash; |
415 | conn->in_phone_hash = in_phone_hash; |
| 407 | list_initialize(&conn->msg_queue); |
416 | list_initialize(&conn->msg_queue); |
| 408 | conn->callid = callid; |
417 | conn->callid = callid; |
| - | 418 | conn->close_callid = 0; |
|
| 409 | if (call) |
419 | if (call) |
| 410 | conn->call = *call; |
420 | conn->call = *call; |
| 411 | conn->wdata.active = 1; /* We will activate it asap */ |
421 | conn->wdata.active = 1; /* We will activate it asap */ |
| 412 | conn->cthread = cthread; |
422 | conn->cthread = cthread; |
| 413 | 423 | ||