Changeset 89ac5513 in mainline for uspace/srv/net/udp/assoc.c


Ignore:
Timestamp:
2013-06-23T19:54:53Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ddb1922
Parents:
3abf0760 (diff), 96cbd18 (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.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/udp/assoc.c

    r3abf0760 r89ac5513  
    8282        if (lsock != NULL)
    8383                assoc->ident.local = *lsock;
     84       
    8485        if (fsock != NULL)
    8586                assoc->ident.foreign = *fsock;
     
    251252                sp.foreign = *fsock;
    252253
    253         if (sp.foreign.addr.ipv4 == 0 || sp.foreign.port == 0)
     254        if ((inet_addr_is_any(&sp.foreign.addr)) ||
     255            (sp.foreign.port == UDP_PORT_ANY))
    254256                return EINVAL;
    255257
     
    279281
    280282        fibril_mutex_lock(&assoc->lock);
    281         while (list_empty(&assoc->rcv_queue)) {
     283        while (list_empty(&assoc->rcv_queue) && !assoc->reset) {
    282284                log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - waiting");
    283285                fibril_condvar_wait(&assoc->rcv_queue_cv, &assoc->lock);
     286        }
     287
     288        if (assoc->reset) {
     289                log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - association was reset");
     290                fibril_mutex_unlock(&assoc->lock);
     291                return ECONNABORTED;
    284292        }
    285293
     
    323331}
    324332
     333/** Reset association.
     334 *
     335 * This causes any pendingreceive operations to return immediately with
     336 * UDP_ERESET.
     337 */
     338void udp_assoc_reset(udp_assoc_t *assoc)
     339{
     340        fibril_mutex_lock(&assoc->lock);
     341        assoc->reset = true;
     342        fibril_condvar_broadcast(&assoc->rcv_queue_cv);
     343        fibril_mutex_unlock(&assoc->lock);
     344}
     345
    325346static int udp_assoc_queue_msg(udp_assoc_t *assoc, udp_sockpair_t *sp,
    326347    udp_msg_t *msg)
     
    351372static bool udp_socket_match(udp_sock_t *sock, udp_sock_t *patt)
    352373{
    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)
     374        if ((!inet_addr_is_any(&patt->addr)) &&
     375            (!inet_addr_compare(&patt->addr, &sock->addr)))
    358376                return false;
    359 
    360         if (patt->port != UDP_PORT_ANY &&
    361             patt->port != sock->port)
     377       
     378        if ((patt->port != UDP_PORT_ANY) &&
     379            (patt->port != sock->port))
    362380                return false;
    363 
     381       
    364382        log_msg(LOG_DEFAULT, LVL_DEBUG, " -> match");
    365 
     383       
    366384        return true;
    367385}
     
    395413{
    396414        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_find_ref(%p)", sp);
    397 
     415       
    398416        fibril_mutex_lock(&assoc_list_lock);
    399 
     417       
    400418        list_foreach(assoc_list, link) {
    401419                udp_assoc_t *assoc = list_get_instance(link, udp_assoc_t, link);
    402420                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 
     421               
    407422                /* Skip unbound associations */
    408423                if (asp->local.port == UDP_PORT_ANY)
    409424                        continue;
    410 
     425               
    411426                if (udp_sockpair_match(sp, asp)) {
    412427                        log_msg(LOG_DEFAULT, LVL_DEBUG, "Returning assoc %p", assoc);
     
    416431                }
    417432        }
    418 
     433       
    419434        fibril_mutex_unlock(&assoc_list_lock);
    420435        return NULL;
Note: See TracChangeset for help on using the changeset viewer.