Changeset 012dd8e in mainline for uspace/lib/c/generic/ns.c
- Timestamp:
- 2019-08-07T09:15:30Z (5 years ago)
- Children:
- e8747bd8
- Parents:
- 780c8ce
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-11-01 00:08:04)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-07 09:15:30)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/ns.c
r780c8ce r012dd8e 38 38 #include <macros.h> 39 39 #include <errno.h> 40 #include "private/ns.h" 40 41 #include "private/taskman.h" 42 43 static async_sess_t *session_ns = NULL; 44 45 static async_exch_t *ns_exchange_begin(void) 46 { 47 /* Lazily connect to our NS */ 48 if (session_ns == NULL) { 49 session_ns = taskman_session_ns(); 50 } 51 52 async_exch_t *exch = async_exchange_begin(session_ns); 53 return exch; 54 } 55 56 static void ns_exchange_end(async_exch_t *exch) 57 { 58 async_exchange_end(exch); 59 } 41 60 42 61 /* … … 49 68 async_port_handler_t handler, void *data) 50 69 { 51 async_sess_t *sess = get_session_primary();52 if (sess == NULL)53 return EIO;54 55 70 port_id_t port; 56 71 errno_t rc = async_create_port(iface, handler, data, &port); … … 58 73 return rc; 59 74 60 async_exch_t *exch = async_exchange_begin(sess);75 async_exch_t *exch = ns_exchange_begin(); 61 76 62 77 ipc_call_t answer; … … 64 79 rc = async_connect_to_me(exch, iface, service, 0); 65 80 66 async_exchange_end(exch);81 ns_exchange_end(exch); 67 82 68 83 if (rc != EOK) { … … 105 120 async_sess_t *service_connect(service_t service, iface_t iface, sysarg_t arg3) 106 121 { 107 async_sess_t *sess = get_session_primary(); 108 if (sess == NULL) 109 return NULL; 110 111 async_exch_t *exch = async_exchange_begin(sess); 122 async_exch_t *exch = ns_exchange_begin(); 112 123 if (exch == NULL) 113 124 return NULL; 114 125 115 async_sess_t * csess =126 async_sess_t *sess = 116 127 async_connect_me_to(exch, iface, service, arg3); 117 async_exchange_end(exch);128 ns_exchange_end(exch); 118 129 119 if ( csess == NULL)130 if (sess == NULL) 120 131 return NULL; 121 132 … … 125 136 * first argument for non-initial connections. 126 137 */ 127 async_sess_args_set( csess, iface, arg3, 0);138 async_sess_args_set(sess, iface, arg3, 0); 128 139 129 140 return csess; … … 133 144 sysarg_t arg3) 134 145 { 135 async_sess_t *sess = get_session_primary(); 146 async_exch_t *exch = ns_exchange_begin(); 147 async_sess_t *sess = 148 async_connect_me_to_blocking(exch, iface, service, arg3); 149 ns_exchange_end(exch); 150 136 151 if (sess == NULL) 137 return NULL;138 139 async_exch_t *exch = async_exchange_begin(sess);140 async_sess_t *csess =141 async_connect_me_to_blocking(exch, iface, service, arg3);142 async_exchange_end(exch);143 144 if (csess == NULL)145 152 return NULL; 146 153 … … 150 157 * first argument for non-initial connections. 151 158 */ 152 async_sess_args_set( csess, iface, arg3, 0);159 async_sess_args_set(sess, iface, arg3, 0); 153 160 154 return csess;161 return sess; 155 162 } 156 163 157 164 errno_t ns_ping(void) 158 165 { 159 async_sess_t *sess = get_session_primary(); 160 if (sess == NULL) 161 return EIO; 162 163 async_exch_t *exch = async_exchange_begin(sess); 166 async_exch_t *exch = ns_exchange_begin(sess); 164 167 errno_t rc = async_req_0_0(exch, NS_PING); 165 async_exchange_end(exch);168 ns_exchange_end(exch); 166 169 167 170 return rc; 168 171 } 169 172 170 171 async_sess_t *get_session_primary(void)172 {173 async_exch_t *exch;174 175 if (sess_primary == NULL) {176 exch = async_exchange_begin(&session_primary);177 sess_primary = async_connect_me_to(exch, 0, 0, 0);178 async_exchange_end(exch);179 if (sess_primary == NULL)180 return NULL;181 }182 183 return sess_primary;184 }185 186 173 /** @} 187 174 */
Note:
See TracChangeset
for help on using the changeset viewer.