Changeset 00aece0 in mainline for uspace/lib/c/generic/async.c
- Timestamp:
- 2012-02-18T16:47:38Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4449c6c
- Parents:
- bd5f3b7 (diff), f943dd3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
uspace/lib/c/generic/async.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
rbd5f3b7 r00aece0 118 118 #define CONN_HASH_TABLE_BUCKETS 32 119 119 120 /** Session data */ 121 struct async_sess { 122 /** List of inactive exchanges */ 123 list_t exch_list; 124 125 /** Exchange management style */ 126 exch_mgmt_t mgmt; 127 128 /** Session identification */ 129 int phone; 130 131 /** First clone connection argument */ 132 sysarg_t arg1; 133 134 /** Second clone connection argument */ 135 sysarg_t arg2; 136 137 /** Third clone connection argument */ 138 sysarg_t arg3; 139 140 /** Exchange mutex */ 141 fibril_mutex_t mutex; 142 143 /** Number of opened exchanges */ 144 atomic_t refcnt; 145 146 /** Mutex for stateful connections */ 147 fibril_mutex_t remote_state_mtx; 148 149 /** Data for stateful connections */ 150 void *remote_state_data; 151 }; 152 153 /** Exchange data */ 154 struct async_exch { 155 /** Link into list of inactive exchanges */ 156 link_t sess_link; 157 158 /** Link into global list of inactive exchanges */ 159 link_t global_link; 160 161 /** Session pointer */ 162 async_sess_t *sess; 163 164 /** Exchange identification */ 165 int phone; 166 }; 167 120 168 /** Async framework global futex */ 121 169 atomic_t async_futex = FUTEX_INITIALIZER; … … 134 182 ipc_call_t call; 135 183 } msg_t; 184 185 /** Message data */ 186 typedef struct { 187 awaiter_t wdata; 188 189 /** If reply was received. */ 190 bool done; 191 192 /** Pointer to where the answer data is stored. */ 193 ipc_call_t *dataptr; 194 195 sysarg_t retval; 196 } amsg_t; 136 197 137 198 /* Client connection data */ … … 196 257 void async_set_client_data_constructor(async_client_data_ctor_t ctor) 197 258 { 259 assert(async_client_data_create == default_client_data_constructor); 198 260 async_client_data_create = ctor; 199 261 } … … 201 263 void async_set_client_data_destructor(async_client_data_dtor_t dtor) 202 264 { 265 assert(async_client_data_destroy == default_client_data_destructor); 203 266 async_client_data_destroy = dtor; 204 267 } … … 242 305 void async_set_client_connection(async_client_conn_t conn) 243 306 { 307 assert(client_connection == default_client_connection); 244 308 client_connection = conn; 245 309 } … … 1777 1841 int async_hangup(async_sess_t *sess) 1778 1842 { 1843 async_exch_t *exch; 1844 1779 1845 assert(sess); 1780 1846 … … 1782 1848 return EBUSY; 1783 1849 1850 fibril_mutex_lock(&async_sess_mutex); 1851 1784 1852 int rc = async_hangup_internal(sess->phone); 1785 if (rc == EOK) 1786 free(sess); 1853 1854 while (!list_empty(&sess->exch_list)) { 1855 exch = (async_exch_t *) 1856 list_get_instance(list_first(&sess->exch_list), 1857 async_exch_t, sess_link); 1858 1859 list_remove(&exch->sess_link); 1860 list_remove(&exch->global_link); 1861 async_hangup_internal(exch->phone); 1862 free(exch); 1863 } 1864 1865 free(sess); 1866 1867 fibril_mutex_unlock(&async_sess_mutex); 1787 1868 1788 1869 return rc; … … 1920 2001 * 1921 2002 * @param exch Exchange for sending the message. 1922 * @param dst Destination address space area base.1923 2003 * @param size Size of the destination address space area. 1924 2004 * @param arg User defined argument. 1925 2005 * @param flags Storage for the received flags. Can be NULL. 2006 * @param dst Destination address space area base. Cannot be NULL. 1926 2007 * 1927 2008 * @return Zero on success or a negative error code from errno.h. 1928 2009 * 1929 2010 */ 1930 int async_share_in_start(async_exch_t *exch, void *dst, size_t size,1931 sysarg_t arg, unsigned int *flags)2011 int async_share_in_start(async_exch_t *exch, size_t size, sysarg_t arg, 2012 unsigned int *flags, void **dst) 1932 2013 { 1933 2014 if (exch == NULL) 1934 2015 return ENOENT; 1935 2016 1936 sysarg_t tmp_flags; 1937 int res = async_req_3_2(exch, IPC_M_SHARE_IN, (sysarg_t) dst, 1938 (sysarg_t) size, arg, NULL, &tmp_flags); 2017 sysarg_t _flags = 0; 2018 sysarg_t _dst = (sysarg_t) -1; 2019 int res = async_req_2_4(exch, IPC_M_SHARE_IN, (sysarg_t) size, 2020 arg, NULL, &_flags, NULL, &_dst); 1939 2021 1940 2022 if (flags) 1941 *flags = (unsigned int) tmp_flags; 1942 2023 *flags = (unsigned int) _flags; 2024 2025 *dst = (void *) _dst; 1943 2026 return res; 1944 2027 } … … 1969 2052 return false; 1970 2053 1971 *size = (size_t) IPC_GET_ARG 2(data);2054 *size = (size_t) IPC_GET_ARG1(data); 1972 2055 return true; 1973 2056 } … … 1975 2058 /** Wrapper for answering the IPC_M_SHARE_IN calls using the async framework. 1976 2059 * 1977 * This wrapper only makes it more comfortable to answer IPC_M_ DATA_READ2060 * This wrapper only makes it more comfortable to answer IPC_M_SHARE_IN 1978 2061 * calls so that the user doesn't have to remember the meaning of each IPC 1979 2062 * argument. … … 2053 2136 * 2054 2137 */ 2055 int async_share_out_finalize(ipc_callid_t callid, void * dst)2138 int async_share_out_finalize(ipc_callid_t callid, void **dst) 2056 2139 { 2057 2140 return ipc_share_out_finalize(callid, dst);
Note:
See TracChangeset
for help on using the changeset viewer.
