95,8 → 95,8 |
#include <async.h> |
#include <fibril.h> |
#include <stdio.h> |
#include <libadt/hash_table.h> |
#include <libadt/list.h> |
#include <adt/hash_table.h> |
#include <adt/list.h> |
#include <ipc/ipc.h> |
#include <assert.h> |
#include <errno.h> |
174,7 → 174,7 |
} connection_t; |
|
/** Identifier of the incoming connection handled by the current fibril. */ |
__thread connection_t *FIBRIL_connection; |
fibril_local connection_t *FIBRIL_connection; |
|
static void default_client_connection(ipc_callid_t callid, ipc_call_t *call); |
static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call); |
190,11 → 190,9 |
*/ |
static async_client_conn_t interrupt_received = default_interrupt_received; |
|
|
static hash_table_t conn_hash_table; |
static LIST_INITIALIZE(timeout_list); |
|
|
#define CONN_HASH_TABLE_CHAINS 32 |
|
/** Compute hash into the connection hash table based on the source phone hash. |
500,9 → 498,10 |
|
/* Answer all remaining messages with EHANGUP */ |
while (!list_empty(&FIBRIL_connection->msg_queue)) { |
msg_t *msg |
= list_get_instance(FIBRIL_connection->msg_queue.next, msg_t, link); |
msg_t *msg; |
|
msg = list_get_instance(FIBRIL_connection->msg_queue.next, |
msg_t, link); |
list_remove(&msg->link); |
ipc_answer_0(msg->callid, EHANGUP); |
free(msg); |
563,7 → 562,7 |
} |
|
/* Add connection to the connection hash table */ |
ipcarg_t key = conn->in_phone_hash; |
unsigned long key = conn->in_phone_hash; |
|
futex_down(&async_futex); |
hash_table_insert(&conn_hash_table, &key, &conn->link); |
588,23 → 587,28 |
/* Unrouted call - do some default behaviour */ |
if ((callid & IPC_CALLID_NOTIFICATION)) { |
process_notification(callid, call); |
return; |
goto out; |
} |
|
switch (IPC_GET_METHOD(*call)) { |
case IPC_M_CONNECT_ME: |
case IPC_M_CONNECT_ME_TO: |
/* Open new connection with fibril etc. */ |
async_new_connection(IPC_GET_ARG5(*call), callid, call, |
client_connection); |
return; |
goto out; |
} |
|
/* Try to route the call through the connection hash table */ |
if (route_call(callid, call)) |
return; |
goto out; |
|
/* Unknown call from unknown phone - hang it up */ |
ipc_answer_0(callid, EHANGUP); |
return; |
|
out: |
; |
} |
|
/** Fire all timeouts that expired. */ |
662,8 → 666,8 |
|
suseconds_t timeout; |
if (!list_empty(&timeout_list)) { |
awaiter_t *waiter |
= list_get_instance(timeout_list.next, awaiter_t, link); |
awaiter_t *waiter = list_get_instance(timeout_list.next, |
awaiter_t, link); |
|
struct timeval tv; |
gettimeofday(&tv, NULL); |
680,8 → 684,8 |
futex_up(&async_futex); |
|
ipc_call_t call; |
ipc_callid_t callid |
= ipc_wait_cycle(&call, timeout, SYNCH_FLAGS_NONE); |
ipc_callid_t callid = ipc_wait_cycle(&call, timeout, |
SYNCH_FLAGS_NONE); |
|
if (!callid) { |
handle_expired_timeouts(); |
758,13 → 762,13 |
*/ |
static void reply_received(void *arg, int retval, ipc_call_t *data) |
{ |
futex_down(&async_futex); |
|
amsg_t *msg = (amsg_t *) arg; |
msg->retval = retval; |
|
futex_down(&async_futex); |
|
/* Copy data after futex_down, just in case the call was detached */ |
if (msg->dataptr) |
if ((msg->dataptr) && (data)) |
*msg->dataptr = *data; |
|
write_barrier(); |
810,6 → 814,7 |
msg->done = false; |
msg->dataptr = dataptr; |
|
msg->wdata.inlist = false; |
/* We may sleep in the next method, but it will use its own mechanism */ |
msg->wdata.active = true; |
|
849,6 → 854,7 |
msg->done = false; |
msg->dataptr = dataptr; |
|
msg->wdata.inlist = false; |
/* We may sleep in next method, but it will use its own mechanism */ |
msg->wdata.active = true; |
|