Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/modules.c

    ra64c64d raadf01e  
    5151
    5252void answer_call(ipc_callid_t callid, int result, ipc_call_t * answer, int answer_count){
    53         // choose the most efficient answer function
    5453        if(answer || (! answer_count)){
    5554                switch(answer_count){
     
    8786        ipcarg_t phonehash;
    8887
    89         // connect to the needed service
    9088        phone = connect_to_service_timeout(need, timeout);
    91         // if connected
    9289        if(phone >= 0){
    93                 // request the bidirectional connection
    9490                if(ERROR_OCCURRED(ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash))){
    9591                        ipc_hangup(phone);
     
    106102
    107103int connect_to_service_timeout(services_t need, suseconds_t timeout){
    108         int phone;
     104        if (timeout <= 0)
     105                return async_connect_me_to_blocking(PHONE_NS, need, 0, 0);
     106       
     107        while(true){
     108                int phone;
    109109
    110         // if no timeout is set
    111         if (timeout <= 0){
    112                 return async_connect_me_to_blocking(PHONE_NS, need, 0, 0);
    113         }
    114 
    115         while(true){
    116110                phone = async_connect_me_to(PHONE_NS, need, 0, 0);
    117                 if((phone >= 0) || (phone != ENOENT)){
     111                if((phone >= 0) || (phone != ENOENT))
    118112                        return phone;
    119                 }
    120 
    121                 // end if no time is left
     113       
     114                timeout -= MODULE_WAIT_TIME;
    122115                if(timeout <= 0){
    123116                        return ETIMEOUT;
    124117                }
    125118
    126                 // wait the minimum of the module wait time and the timeout
    127                 usleep((timeout <= MODULE_WAIT_TIME) ? timeout : MODULE_WAIT_TIME);
    128                 timeout -= MODULE_WAIT_TIME;
     119                usleep(MODULE_WAIT_TIME);
    129120        }
    130121}
     
    138129                return EBADMEM;
    139130        }
    140 
    141         // fetch the request
    142131        if(! async_data_write_receive(&callid, length)){
    143132                return EINVAL;
    144133        }
    145 
    146         // allocate the buffer
    147134        *data = malloc(*length);
    148135        if(!(*data)){
    149136                return ENOMEM;
    150137        }
    151 
    152         // fetch the data
    153138        if(ERROR_OCCURRED(async_data_write_finalize(callid, * data, * length))){
    154139                free(data);
     
    162147        ipc_callid_t callid;
    163148
    164         // fetch the request
    165149        if(! async_data_read_receive(&callid, &length)){
    166150                return EINVAL;
    167151        }
    168 
    169         // check the requested data size
    170152        if(length < data_length){
    171153                async_data_read_finalize(callid, data, length);
    172154                return EOVERFLOW;
    173155        }
    174 
    175         // send the data
    176156        return async_data_read_finalize(callid, data, data_length);
    177157}
    178158
    179159void refresh_answer(ipc_call_t * answer, int * answer_count){
    180 
    181160        if(answer_count){
    182161                *answer_count = 0;
    183162        }
    184 
    185163        if(answer){
    186164                IPC_SET_RETVAL(*answer, 0);
Note: See TracChangeset for help on using the changeset viewer.