Changeset 936835e in mainline for uspace/srv


Ignore:
Timestamp:
2010-03-07T15:35:32Z (16 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
836dd794
Parents:
aadf01e (diff), b5cbff4 (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, revision 311

Location:
uspace/srv/net
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/socket/socket_client.c

    raadf01e r936835e  
    580580                fibril_rwlock_write_unlock(&socket_globals.lock);
    581581                fibril_condvar_wait(&socket->accept_signal, &socket->accept_lock);
     582                // drop the accept lock to avoid deadlock
     583                fibril_mutex_unlock(&socket->accept_lock);
    582584                fibril_rwlock_write_lock(&socket_globals.lock);
     585                fibril_mutex_lock(&socket->accept_lock);
    583586        }
    584587        -- socket->blocked;
     
    801804                fibril_rwlock_read_unlock(&socket_globals.lock);
    802805                fibril_condvar_wait(&socket->receive_signal, &socket->receive_lock);
     806                // drop the receive lock to avoid deadlock
     807                fibril_mutex_unlock(&socket->receive_lock);
    803808                fibril_rwlock_read_lock(&socket_globals.lock);
     809                fibril_mutex_lock(&socket->receive_lock);
    804810        }
    805811        -- socket->blocked;
  • uspace/srv/net/tl/icmp/icmp.c

    raadf01e r936835e  
    175175/** Requests an echo message.
    176176 *  Sends a packet with specified parameters to the target host and waits for the reply upto the given timeout.
    177  *  Blocks the caller until the reply or the timeout occurres.
     177 *  Blocks the caller until the reply or the timeout occurs.
    178178 *  @param[in] id The message identifier.
    179179 *  @param[in] sequence The message sequence parameter.
     
    221221
    222222/** Tries to set the pending reply result as the received message type.
    223  *  If the reply data are still present, the reply timeouted and the parent fibril is awaken.
    224  *  The global lock is not released in this case to be reused by the parent fibril.
     223 *  If the reply data is not present, the reply timed out and the other fibril
     224 *  is already awake.
    225225 *  Releases the packet.
    226226 *  @param[in] packet The received reply message.
     
    334334        }
    335335
    336         // unlock the globals and wait for a reply
     336        // unlock the globals so that we can wait for the reply
    337337        fibril_rwlock_write_unlock(&icmp_globals.lock);
    338338
     
    340340        icmp_send_packet(ICMP_ECHO, 0, packet, header, 0, ttl, tos, dont_fragment);
    341341
    342         // wait for a reply
     342        // wait for the reply
    343343        // timeout in microseconds
    344344        if(ERROR_OCCURRED(fibril_condvar_wait_timeout(&reply->condvar, &reply->mutex, timeout * 1000))){
    345345                result = ERROR_CODE;
    346 
    347                 // lock the globals again and clean up
    348                 fibril_rwlock_write_lock(&icmp_globals.lock);
    349346        }else{
    350347                // read the result
    351348                result = reply->result;
    352 
    353                 // release the reply structure
    354                 fibril_mutex_unlock(&reply->mutex);
    355         }
     349        }
     350
     351        // drop the reply mutex before locking the globals again
     352        fibril_mutex_unlock(&reply->mutex);
     353        fibril_rwlock_write_lock(&icmp_globals.lock);
    356354
    357355        // destroy the reply structure
     
    636634                // set the result
    637635                reply->result = type;
    638                 // notify the main fibril
     636                // notify the waiting fibril
    639637                fibril_condvar_signal(&reply->condvar);
    640         }else{
    641                 // unlock only if no reply
    642                 fibril_rwlock_write_unlock(&icmp_globals.lock);
    643         }
     638        }
     639        fibril_rwlock_write_unlock(&icmp_globals.lock);
    644640        return EOK;
    645641}
  • uspace/srv/net/tl/udp/udp.c

    raadf01e r936835e  
    418418        struct sockaddr * addr;
    419419        size_t addrlen;
    420         fibril_rwlock_t lock;
    421420        ipc_call_t answer;
    422421        int answer_count;
     
    433432
    434433        socket_cores_initialize(&local_sockets);
    435         fibril_rwlock_initialize(&lock);
    436434
    437435        while(keep_on_going){
     
    453451                                break;
    454452                        case NET_SOCKET:
    455                                 fibril_rwlock_write_lock(&lock);
    456453                                *SOCKET_SET_SOCKET_ID(answer) = SOCKET_GET_SOCKET_ID(call);
    457454                                res = socket_create(&local_sockets, app_phone, NULL, SOCKET_SET_SOCKET_ID(answer));
    458                                 fibril_rwlock_write_unlock(&lock);
    459455                                if(res == EOK){
    460456                                        if(tl_get_ip_packet_dimension(udp_globals.ip_phone, &udp_globals.dimensions, DEVICE_INVALID_ID, &packet_dimension) == EOK){
     
    469465                                res = data_receive((void **) &addr, &addrlen);
    470466                                if(res == EOK){
    471                                         fibril_rwlock_read_lock(&lock);
    472467                                        fibril_rwlock_write_lock(&udp_globals.lock);
    473468                                        res = socket_bind(&local_sockets, &udp_globals.sockets, SOCKET_GET_SOCKET_ID(call), addr, addrlen, UDP_FREE_PORTS_START, UDP_FREE_PORTS_END, udp_globals.last_used_port);
    474469                                        fibril_rwlock_write_unlock(&udp_globals.lock);
    475                                         fibril_rwlock_read_unlock(&lock);
    476470                                        free(addr);
    477471                                }
     
    480474                                res = data_receive((void **) &addr, &addrlen);
    481475                                if(res == EOK){
    482                                         fibril_rwlock_read_lock(&lock);
    483476                                        fibril_rwlock_write_lock(&udp_globals.lock);
    484477                                        res = udp_sendto_message(&local_sockets, SOCKET_GET_SOCKET_ID(call), addr, addrlen, SOCKET_GET_DATA_FRAGMENTS(call), SOCKET_SET_DATA_FRAGMENT_SIZE(answer), SOCKET_GET_FLAGS(call));
     
    488481                                                answer_count = 2;
    489482                                        }
    490                                         fibril_rwlock_read_unlock(&lock);
    491483                                        free(addr);
    492484                                }
    493485                                break;
    494486                        case NET_SOCKET_RECVFROM:
    495                                 fibril_rwlock_read_lock(&lock);
    496487                                fibril_rwlock_write_lock(&udp_globals.lock);
    497488                                res = udp_recvfrom_message(&local_sockets, SOCKET_GET_SOCKET_ID(call), SOCKET_GET_FLAGS(call), &addrlen);
    498489                                fibril_rwlock_write_unlock(&udp_globals.lock);
    499                                 fibril_rwlock_read_unlock(&lock);
    500490                                if(res > 0){
    501491                                        *SOCKET_SET_READ_DATA_LENGTH(answer) = res;
     
    506496                                break;
    507497                        case NET_SOCKET_CLOSE:
    508                                 fibril_rwlock_write_lock(&lock);
    509498                                fibril_rwlock_write_lock(&udp_globals.lock);
    510499                                res = socket_destroy(udp_globals.net_phone, SOCKET_GET_SOCKET_ID(call), &local_sockets, &udp_globals.sockets, NULL);
    511500                                fibril_rwlock_write_unlock(&udp_globals.lock);
    512                                 fibril_rwlock_write_unlock(&lock);
    513501                                break;
    514502                        case NET_SOCKET_GETSOCKOPT:
Note: See TracChangeset for help on using the changeset viewer.