Changeset 8e7c9fe in mainline for uspace/srv/net/ethip/atrans.c
- Timestamp:
- 2014-09-12T03:45:25Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c53b58e
- Parents:
- 3eb0c85 (diff), 105d8d6 (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
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/ethip/atrans.c
r3eb0c85 r8e7c9fe 103 103 } 104 104 105 int atrans_lookup(addr32_t ip_addr, addr48_t mac_addr)105 static int atrans_lookup_locked(addr32_t ip_addr, addr48_t mac_addr) 106 106 { 107 fibril_mutex_lock(&atrans_list_lock);108 107 ethip_atrans_t *atrans = atrans_find(ip_addr); 109 if (atrans == NULL) { 110 fibril_mutex_unlock(&atrans_list_lock); 108 if (atrans == NULL) 111 109 return ENOENT; 112 } 113 114 fibril_mutex_unlock(&atrans_list_lock); 110 115 111 addr48(atrans->mac_addr, mac_addr); 116 112 return EOK; 117 113 } 118 114 119 int atrans_ wait_timeout(suseconds_t timeout)115 int atrans_lookup(addr32_t ip_addr, addr48_t mac_addr) 120 116 { 117 int rc; 118 121 119 fibril_mutex_lock(&atrans_list_lock); 122 int rc = fibril_condvar_wait_timeout(&atrans_cv, &atrans_list_lock, 123 timeout); 120 rc = atrans_lookup_locked(ip_addr, mac_addr); 124 121 fibril_mutex_unlock(&atrans_list_lock); 125 122 123 return rc; 124 } 125 126 static void atrans_lookup_timeout_handler(void *arg) 127 { 128 bool *timedout = (bool *)arg; 129 130 fibril_mutex_lock(&atrans_list_lock); 131 *timedout = true; 132 fibril_mutex_unlock(&atrans_list_lock); 133 fibril_condvar_broadcast(&atrans_cv); 134 } 135 136 int atrans_lookup_timeout(addr32_t ip_addr, suseconds_t timeout, 137 addr48_t mac_addr) 138 { 139 fibril_timer_t *t; 140 bool timedout; 141 int rc; 142 143 t = fibril_timer_create(NULL); 144 if (t == NULL) 145 return ENOMEM; 146 147 timedout = false; 148 fibril_timer_set(t, timeout, atrans_lookup_timeout_handler, &timedout); 149 150 fibril_mutex_lock(&atrans_list_lock); 151 152 while ((rc = atrans_lookup_locked(ip_addr, mac_addr)) == ENOENT && 153 !timedout) { 154 fibril_condvar_wait(&atrans_cv, &atrans_list_lock); 155 } 156 157 fibril_mutex_unlock(&atrans_list_lock); 158 (void) fibril_timer_clear(t); 159 fibril_timer_destroy(t); 160 126 161 return rc; 127 162 }
Note:
See TracChangeset
for help on using the changeset viewer.