Changeset bf9e6fc in mainline for uspace/srv/net/inetsrv/addrobj.c
- Timestamp:
- 2012-05-13T10:01:08Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ce1836e
- Parents:
- f8dbc12
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/inetsrv/addrobj.c
rf8dbc12 rbf9e6fc 48 48 #include "inet_util.h" 49 49 50 static inet_addrobj_t *inet_addrobj_find_by_name_locked(const char *, inet_link_t *); 51 50 52 static FIBRIL_MUTEX_INITIALIZE(addr_list_lock); 51 53 static LIST_INITIALIZE(addr_list); … … 77 79 } 78 80 79 void inet_addrobj_add(inet_addrobj_t *addr) 80 { 81 fibril_mutex_lock(&addr_list_lock); 81 int inet_addrobj_add(inet_addrobj_t *addr) 82 { 83 inet_addrobj_t *aobj; 84 85 fibril_mutex_lock(&addr_list_lock); 86 aobj = inet_addrobj_find_by_name_locked(addr->name, addr->ilink); 87 if (aobj != NULL) { 88 /* Duplicate address name */ 89 fibril_mutex_unlock(&addr_list_lock); 90 return EEXISTS; 91 } 92 82 93 list_append(&addr->addr_list, &addr_list); 83 94 fibril_mutex_unlock(&addr_list_lock); 95 96 return EOK; 84 97 } 85 98 … … 130 143 * @return Address object 131 144 */ 132 inet_addrobj_t *inet_addrobj_find_by_name(const char *name, inet_link_t *ilink) 133 { 134 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name('%s', '%s')", 145 static inet_addrobj_t *inet_addrobj_find_by_name_locked(const char *name, inet_link_t *ilink) 146 { 147 assert(fibril_mutex_is_locked(&addr_list_lock)); 148 149 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name_locked('%s', '%s')", 135 150 name, ilink->svc_name); 136 151 137 fibril_mutex_lock(&addr_list_lock);138 139 152 list_foreach(addr_list, link) { 140 153 inet_addrobj_t *naddr = list_get_instance(link, … … 142 155 143 156 if (naddr->ilink == ilink && str_cmp(naddr->name, name) == 0) { 144 fibril_mutex_unlock(&addr_list_lock); 145 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name: found %p", 157 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name_locked: found %p", 146 158 naddr); 147 159 return naddr; … … 149 161 } 150 162 151 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name: Not found"); 152 fibril_mutex_unlock(&addr_list_lock); 163 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name_locked: Not found"); 153 164 154 165 return NULL; 166 } 167 168 169 /** Find address object on a link, with a specific name. 170 * 171 * @param name Address object name 172 * @param ilink Inet link 173 * @return Address object 174 */ 175 inet_addrobj_t *inet_addrobj_find_by_name(const char *name, inet_link_t *ilink) 176 { 177 inet_addrobj_t *aobj; 178 179 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name('%s', '%s')", 180 name, ilink->svc_name); 181 182 fibril_mutex_lock(&addr_list_lock); 183 aobj = inet_addrobj_find_by_name_locked(name, ilink); 184 fibril_mutex_unlock(&addr_list_lock); 185 186 return aobj; 155 187 } 156 188
Note:
See TracChangeset
for help on using the changeset viewer.