Changeset 8080262 in mainline for uspace/lib/c/generic/async/server.c
- Timestamp:
- 2018-07-30T18:55:22Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2965d18
- Parents:
- b4c8a7b
- git-author:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-30 18:07:46)
- git-committer:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-30 18:55:22)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async/server.c
rb4c8a7b r8080262 111 111 #include <errno.h> 112 112 #include <sys/time.h> 113 #include <libarch/barrier.h>114 113 #include <stdbool.h> 115 114 #include <stdlib.h> … … 125 124 #define DPRINTF(...) ((void) 0) 126 125 127 /** Async framework global futex */128 futex_t async_futex = FUTEX_INITIALIZER;129 130 126 /** Call data */ 131 127 typedef struct { … … 250 246 static sysarg_t notification_avail = 0; 251 247 252 /* The remaining structures are guarded by async_futex. */ 248 static FIBRIL_RMUTEX_INITIALIZE(conn_mutex); 253 249 static hash_table_t conn_hash_table; 254 250 … … 430 426 * Remove myself from the connection hash table. 431 427 */ 432 f utex_lock(&async_futex);428 fibril_rmutex_lock(&conn_mutex); 433 429 hash_table_remove(&conn_hash_table, &(conn_key_t){ 434 430 .task_id = fibril_connection->in_task_id, 435 431 .phone_hash = fibril_connection->in_phone_hash 436 432 }); 437 f utex_unlock(&async_futex);433 fibril_rmutex_unlock(&conn_mutex); 438 434 439 435 /* … … 517 513 /* Add connection to the connection hash table */ 518 514 519 f utex_lock(&async_futex);515 fibril_rmutex_lock(&conn_mutex); 520 516 hash_table_insert(&conn_hash_table, &conn->link); 521 f utex_unlock(&async_futex);522 523 fibril_ add_ready(conn->fid);517 fibril_rmutex_unlock(&conn_mutex); 518 519 fibril_start(conn->fid); 524 520 525 521 return conn->fid; … … 618 614 assert(call); 619 615 620 f utex_lock(&async_futex);616 fibril_rmutex_lock(&conn_mutex); 621 617 622 618 ht_link_t *link = hash_table_find(&conn_hash_table, &(conn_key_t){ … … 625 621 }); 626 622 if (!link) { 627 f utex_unlock(&async_futex);623 fibril_rmutex_unlock(&conn_mutex); 628 624 return false; 629 625 } … … 634 630 msg_t *msg = malloc(sizeof(*msg)); 635 631 if (!msg) { 636 f utex_unlock(&async_futex);632 fibril_rmutex_unlock(&conn_mutex); 637 633 return false; 638 634 } … … 644 640 conn->close_chandle = call->cap_handle; 645 641 642 fibril_rmutex_unlock(&conn_mutex); 643 646 644 /* If the connection fibril is waiting for an event, activate it */ 647 645 fibril_notify(&conn->msg_arrived); 648 649 futex_unlock(&async_futex);650 646 return true; 651 647 } … … 960 956 } 961 957 962 f utex_lock(&async_futex);958 fibril_rmutex_lock(&conn_mutex); 963 959 964 960 /* If nothing in queue, wait until something arrives */ … … 974 970 memset(call, 0, sizeof(ipc_call_t)); 975 971 IPC_SET_IMETHOD(*call, IPC_M_PHONE_HUNGUP); 976 f utex_unlock(&async_futex);972 fibril_rmutex_unlock(&conn_mutex); 977 973 return true; 978 974 } 979 975 980 976 // TODO: replace with cvar 981 f utex_unlock(&async_futex);977 fibril_rmutex_unlock(&conn_mutex); 982 978 983 979 errno_t rc = fibril_wait_timeout(&conn->msg_arrived, expires); … … 985 981 return false; 986 982 987 f utex_lock(&async_futex);983 fibril_rmutex_lock(&conn_mutex); 988 984 } 989 985 … … 995 991 free(msg); 996 992 997 f utex_unlock(&async_futex);993 fibril_rmutex_unlock(&conn_mutex); 998 994 return true; 999 995 }
Note:
See TracChangeset
for help on using the changeset viewer.