Rev 4528 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4528 | Rev 4542 | ||
|---|---|---|---|
| Line 176... | Line 176... | ||
| 176 | /** Identifier of the incoming connection handled by the current fibril. */ |
176 | /** Identifier of the incoming connection handled by the current fibril. */ |
| 177 | fibril_local connection_t *FIBRIL_connection; |
177 | fibril_local connection_t *FIBRIL_connection; |
| 178 | 178 | ||
| 179 | static void default_client_connection(ipc_callid_t callid, ipc_call_t *call); |
179 | static void default_client_connection(ipc_callid_t callid, ipc_call_t *call); |
| 180 | static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call); |
180 | static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call); |
| 181 | static void default_pending(void); |
- | |
| 182 | 181 | ||
| 183 | /** |
182 | /** |
| 184 | * Pointer to a fibril function that will be used to handle connections. |
183 | * Pointer to a fibril function that will be used to handle connections. |
| 185 | */ |
184 | */ |
| 186 | static async_client_conn_t client_connection = default_client_connection; |
185 | static async_client_conn_t client_connection = default_client_connection; |
| Line 189... | Line 188... | ||
| 189 | * Pointer to a fibril function that will be used to handle interrupt |
188 | * Pointer to a fibril function that will be used to handle interrupt |
| 190 | * notifications. |
189 | * notifications. |
| 191 | */ |
190 | */ |
| 192 | static async_client_conn_t interrupt_received = default_interrupt_received; |
191 | static async_client_conn_t interrupt_received = default_interrupt_received; |
| 193 | 192 | ||
| 194 | /** |
- | |
| 195 | * Pointer to a fibril function that will be used to handle pending |
- | |
| 196 | * operations. |
- | |
| 197 | */ |
- | |
| 198 | static async_pending_t pending = default_pending; |
- | |
| 199 | - | ||
| 200 | static hash_table_t conn_hash_table; |
193 | static hash_table_t conn_hash_table; |
| 201 | static LIST_INITIALIZE(timeout_list); |
194 | static LIST_INITIALIZE(timeout_list); |
| 202 | 195 | ||
| 203 | #define CONN_HASH_TABLE_CHAINS 32 |
196 | #define CONN_HASH_TABLE_CHAINS 32 |
| 204 | 197 | ||
| Line 379... | Line 372... | ||
| 379 | 372 | ||
| 380 | futex_up(&async_futex); |
373 | futex_up(&async_futex); |
| 381 | return true; |
374 | return true; |
| 382 | } |
375 | } |
| 383 | 376 | ||
| 384 | /** Pending fibril. |
- | |
| 385 | * |
- | |
| 386 | * After each call the pending operations are executed in a separate |
- | |
| 387 | * fibril. The function pending() is c. |
- | |
| 388 | * |
- | |
| 389 | * @param arg Unused. |
- | |
| 390 | * |
- | |
| 391 | * @return Always zero. |
- | |
| 392 | * |
- | |
| 393 | */ |
- | |
| 394 | static int pending_fibril(void *arg) |
- | |
| 395 | { |
- | |
| 396 | pending(); |
- | |
| 397 | - | ||
| 398 | return 0; |
- | |
| 399 | } |
- | |
| 400 | - | ||
| 401 | /** Process pending actions. |
- | |
| 402 | * |
- | |
| 403 | * A new fibril is created which would process the pending operations. |
- | |
| 404 | * |
- | |
| 405 | * @return False if an error occured. |
- | |
| 406 | * True if the execution was passed to the pending fibril. |
- | |
| 407 | * |
- | |
| 408 | */ |
- | |
| 409 | static bool process_pending(void) |
- | |
| 410 | { |
- | |
| 411 | futex_down(&async_futex); |
- | |
| 412 | - | ||
| 413 | fid_t fid = fibril_create(pending_fibril, NULL); |
- | |
| 414 | fibril_add_ready(fid); |
- | |
| 415 | - | ||
| 416 | futex_up(&async_futex); |
- | |
| 417 | return true; |
- | |
| 418 | } |
- | |
| 419 | - | ||
| 420 | /** Return new incoming message for the current (fibril-local) connection. |
377 | /** Return new incoming message for the current (fibril-local) connection. |
| 421 | * |
378 | * |
| 422 | * @param call Storage where the incoming call data will be stored. |
379 | * @param call Storage where the incoming call data will be stored. |
| 423 | * @param usecs Timeout in microseconds. Zero denotes no timeout. |
380 | * @param usecs Timeout in microseconds. Zero denotes no timeout. |
| 424 | * |
381 | * |
| Line 511... | Line 468... | ||
| 511 | */ |
468 | */ |
| 512 | static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call) |
469 | static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call) |
| 513 | { |
470 | { |
| 514 | } |
471 | } |
| 515 | 472 | ||
| 516 | /** Default fibril function that gets called to handle pending operations. |
- | |
| 517 | * |
- | |
| 518 | * This function is defined as a weak symbol - to be redefined in user code. |
- | |
| 519 | * |
- | |
| 520 | */ |
- | |
| 521 | static void default_pending(void) |
- | |
| 522 | { |
- | |
| 523 | } |
- | |
| 524 | - | ||
| 525 | /** Wrapper for client connection fibril. |
473 | /** Wrapper for client connection fibril. |
| 526 | * |
474 | * |
| 527 | * When a new connection arrives, a fibril with this implementing function is |
475 | * When a new connection arrives, a fibril with this implementing function is |
| 528 | * created. It calls client_connection() and does the final cleanup. |
476 | * created. It calls client_connection() and does the final cleanup. |
| 529 | * |
477 | * |
| Line 658... | Line 606... | ||
| 658 | /* Unknown call from unknown phone - hang it up */ |
606 | /* Unknown call from unknown phone - hang it up */ |
| 659 | ipc_answer_0(callid, EHANGUP); |
607 | ipc_answer_0(callid, EHANGUP); |
| 660 | return; |
608 | return; |
| 661 | 609 | ||
| 662 | out: |
610 | out: |
| 663 | process_pending(); |
611 | ; |
| 664 | } |
612 | } |
| 665 | 613 | ||
| 666 | /** Fire all timeouts that expired. */ |
614 | /** Fire all timeouts that expired. */ |
| 667 | static void handle_expired_timeouts(void) |
615 | static void handle_expired_timeouts(void) |
| 668 | { |
616 | { |
| Line 1047... | Line 995... | ||
| 1047 | void async_set_interrupt_received(async_client_conn_t intr) |
995 | void async_set_interrupt_received(async_client_conn_t intr) |
| 1048 | { |
996 | { |
| 1049 | interrupt_received = intr; |
997 | interrupt_received = intr; |
| 1050 | } |
998 | } |
| 1051 | 999 | ||
| 1052 | /** Setter for pending function pointer. |
- | |
| 1053 | * |
- | |
| 1054 | * @param pend Function that will implement a new pending |
- | |
| 1055 | * operations fibril. |
- | |
| 1056 | */ |
- | |
| 1057 | void async_set_pending(async_pending_t pend) |
- | |
| 1058 | { |
- | |
| 1059 | pending = pend; |
- | |
| 1060 | } |
- | |
| 1061 | - | ||
| 1062 | /** Pseudo-synchronous message sending - fast version. |
1000 | /** Pseudo-synchronous message sending - fast version. |
| 1063 | * |
1001 | * |
| 1064 | * Send message asynchronously and return only after the reply arrives. |
1002 | * Send message asynchronously and return only after the reply arrives. |
| 1065 | * |
1003 | * |
| 1066 | * This function can only transfer 4 register payload arguments. For |
1004 | * This function can only transfer 4 register payload arguments. For |