Changeset fff7ef4 in mainline for uspace/lib/c/generic/dnsr.c
- Timestamp:
- 2013-04-26T07:34:42Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 48171fc4
- Parents:
- 287d729
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/dnsr.c
r287d729 rfff7ef4 30 30 #include <assert.h> 31 31 #include <errno.h> 32 #include <fibril_synch.h> 32 33 #include <inet/dnsr.h> 33 34 #include <ipc/dnsr.h> … … 37 38 #include <str.h> 38 39 40 static FIBRIL_MUTEX_INITIALIZE(dnsr_sess_mutex); 41 39 42 static async_sess_t *dnsr_sess = NULL; 40 43 41 int dnsr_init(void)44 static async_exch_t *dnsr_exchange_begin(void) 42 45 { 46 async_sess_t *sess; 43 47 service_id_t dnsr_svc; 44 int rc;45 48 46 assert(dnsr_sess == NULL);49 fibril_mutex_lock(&dnsr_sess_mutex); 47 50 48 rc = loc_service_get_id(SERVICE_NAME_DNSR, &dnsr_svc, 49 IPC_FLAG_BLOCKING); 50 if (rc != EOK) 51 return ENOENT; 51 if (dnsr_sess == NULL) { 52 (void) loc_service_get_id(SERVICE_NAME_DNSR, &dnsr_svc, 53 IPC_FLAG_BLOCKING); 52 54 53 dnsr_sess = loc_service_connect(EXCHANGE_SERIALIZE, dnsr_svc, 54 IPC_FLAG_BLOCKING); 55 if (dnsr_sess == NULL) 56 return ENOENT; 55 dnsr_sess = loc_service_connect(EXCHANGE_SERIALIZE, dnsr_svc, 56 IPC_FLAG_BLOCKING); 57 } 57 58 58 return EOK; 59 sess = dnsr_sess; 60 fibril_mutex_unlock(&dnsr_sess_mutex); 61 62 return async_exchange_begin(sess); 63 } 64 65 static void dnsr_exchange_end(async_exch_t *exch) 66 { 67 async_exchange_end(exch); 59 68 } 60 69 61 70 int dnsr_name2host(const char *name, dnsr_hostinfo_t **rinfo) 62 71 { 63 async_exch_t *exch = async_exchange_begin(dnsr_sess);72 async_exch_t *exch = dnsr_exchange_begin(); 64 73 dnsr_hostinfo_t *info; 65 74 … … 68 77 sysarg_t retval = async_data_write_start(exch, name, str_size(name)); 69 78 70 async_exchange_end(exch);79 dnsr_exchange_end(exch); 71 80 72 81 if (retval != EOK) { … … 102 111 { 103 112 sysarg_t addr; 104 async_exch_t *exch = async_exchange_begin(dnsr_sess);113 async_exch_t *exch = dnsr_exchange_begin(); 105 114 106 115 int rc = async_req_0_1(exch, DNSR_GET_SRVADDR, &addr); 107 async_exchange_end(exch);116 dnsr_exchange_end(exch); 108 117 109 118 if (rc != EOK) … … 116 125 int dnsr_set_srvaddr(inet_addr_t *srvaddr) 117 126 { 118 async_exch_t *exch = async_exchange_begin(dnsr_sess);127 async_exch_t *exch = dnsr_exchange_begin(); 119 128 120 129 int rc = async_req_1_0(exch, DNSR_SET_SRVADDR, srvaddr->ipv4); 121 async_exchange_end(exch);130 dnsr_exchange_end(exch); 122 131 123 132 if (rc != EOK)
Note:
See TracChangeset
for help on using the changeset viewer.