Changes in uspace/srv/net/udp/assoc.c [451481c8:695b6ff] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/udp/assoc.c
r451481c8 r695b6ff 82 82 if (lsock != NULL) 83 83 assoc->ident.local = *lsock; 84 84 85 if (fsock != NULL) 85 86 assoc->ident.foreign = *fsock; … … 185 186 } 186 187 188 /** Set IP link in association. 189 * 190 * @param assoc Association 191 * @param iplink IP link 192 */ 193 void udp_assoc_set_iplink(udp_assoc_t *assoc, service_id_t iplink) 194 { 195 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_set_iplink(%p, %zu)", 196 assoc, iplink); 197 fibril_mutex_lock(&assoc->lock); 198 assoc->ident.iplink = iplink; 199 fibril_mutex_unlock(&assoc->lock); 200 } 201 187 202 /** Set foreign socket in association. 188 203 * … … 251 266 sp.foreign = *fsock; 252 267 253 if (sp.foreign.addr.ipv4 == 0 || sp.foreign.port == 0) 268 if ((inet_addr_is_any(&sp.foreign.addr)) || 269 (sp.foreign.port == UDP_PORT_ANY)) 254 270 return EINVAL; 255 271 … … 279 295 280 296 fibril_mutex_lock(&assoc->lock); 281 while (list_empty(&assoc->rcv_queue) ) {297 while (list_empty(&assoc->rcv_queue) && !assoc->reset) { 282 298 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - waiting"); 283 299 fibril_condvar_wait(&assoc->rcv_queue_cv, &assoc->lock); 300 } 301 302 if (assoc->reset) { 303 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - association was reset"); 304 fibril_mutex_unlock(&assoc->lock); 305 return ECONNABORTED; 284 306 } 285 307 … … 323 345 } 324 346 347 /** Reset association. 348 * 349 * This causes any pendingreceive operations to return immediately with 350 * UDP_ERESET. 351 */ 352 void udp_assoc_reset(udp_assoc_t *assoc) 353 { 354 fibril_mutex_lock(&assoc->lock); 355 assoc->reset = true; 356 fibril_condvar_broadcast(&assoc->rcv_queue_cv); 357 fibril_mutex_unlock(&assoc->lock); 358 } 359 325 360 static int udp_assoc_queue_msg(udp_assoc_t *assoc, udp_sockpair_t *sp, 326 361 udp_msg_t *msg) … … 351 386 static bool udp_socket_match(udp_sock_t *sock, udp_sock_t *patt) 352 387 { 353 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_socket_match(sock=(%x,%u), pat=(%x,%u))",354 sock->addr.ipv4, sock->port, patt->addr.ipv4, patt->port);355 356 if ( patt->addr.ipv4 != UDP_IPV4_ANY&&357 patt->addr.ipv4 != sock->addr.ipv4)388 log_msg(LOG_DEFAULT, LVL_DEBUG, 389 "udp_socket_match(sock=(%u), pat=(%u))", sock->port, patt->port); 390 391 if ((!inet_addr_is_any(&patt->addr)) && 392 (!inet_addr_compare(&patt->addr, &sock->addr))) 358 393 return false; 359 360 if ( patt->port != UDP_PORT_ANY&&361 patt->port != sock->port)394 395 if ((patt->port != UDP_PORT_ANY) && 396 (patt->port != sock->port)) 362 397 return false; 363 398 364 399 log_msg(LOG_DEFAULT, LVL_DEBUG, " -> match"); 365 400 366 401 return true; 367 402 } … … 395 430 { 396 431 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_find_ref(%p)", sp); 397 432 398 433 fibril_mutex_lock(&assoc_list_lock); 399 400 list_foreach(assoc_list, link) { 401 udp_assoc_t *assoc = list_get_instance(link, udp_assoc_t, link); 434 435 list_foreach(assoc_list, link, udp_assoc_t, assoc) { 402 436 udp_sockpair_t *asp = &assoc->ident; 403 log_msg(LOG_DEFAULT, LVL_DEBUG, "compare with assoc (f:(%x,%u), l:(%x,%u))", 404 asp->foreign.addr.ipv4, asp->foreign.port, 405 asp->local.addr.ipv4, asp->local.port); 406 437 407 438 /* Skip unbound associations */ 408 439 if (asp->local.port == UDP_PORT_ANY) 409 440 continue; 410 441 411 442 if (udp_sockpair_match(sp, asp)) { 412 443 log_msg(LOG_DEFAULT, LVL_DEBUG, "Returning assoc %p", assoc); … … 416 447 } 417 448 } 418 449 419 450 fibril_mutex_unlock(&assoc_list_lock); 420 451 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.