Changeset 1a0fb3f8 in mainline for uspace/srv/net/modules.c


Ignore:
Timestamp:
2010-01-04T22:47:30Z (14 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ede63e4
Parents:
b648ae4
Message:

+ icmp and libsocket timeouting connecting

File:
1 edited

Legend:

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

    rb648ae4 r1a0fb3f8  
    4141#include <ipc/services.h>
    4242
     43#include <sys/time.h>
     44
    4345#include "err.h"
    4446#include "modules.h"
    4547
    46 /** The time between connect requests.
     48/** The time between connect requests in microseconds.
    4749 */
    48 #define MODULE_WAIT_TIME        10000
     50#define MODULE_WAIT_TIME        ( 10 * 1000 )
    4951
    5052int connect_to_service( services_t need ){
     53        return connect_to_service_timeout( need, 0 );
     54}
     55
     56int connect_to_service_timeout( services_t need, suseconds_t timeout ){
    5157        int     phone;
    5258        int     res;
    5359
    54         //TODO timeout version?
    55         res = async_req_3_5( PHONE_NS, IPC_M_CONNECT_ME_TO, need, 0, 0, NULL, NULL, NULL, NULL, ( ipcarg_t * ) & phone );
    56         while(( res < 0 ) || ( phone < 0 )){
     60        while( true ){
     61                res = async_req_3_5( PHONE_NS, IPC_M_CONNECT_ME_TO, need, 0, 0, NULL, NULL, NULL, NULL, ( ipcarg_t * ) & phone );
     62                if(( res >= 0 ) && ( phone >= 0 )){
     63                        return phone;
     64                }
     65                if( timeout > 0 ){
     66                        timeout -= MODULE_WAIT_TIME;
     67                        if( timeout <= 0 ) return ETIMEOUT;
     68                }
    5769                usleep( MODULE_WAIT_TIME );
    58                 res = async_req_3_5( PHONE_NS, IPC_M_CONNECT_ME_TO, need, 0, 0, NULL, NULL, NULL, NULL, ( ipcarg_t * ) & phone );
    5970        }
    60         return phone;
    6171}
    6272
    6373int bind_service( services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver ){
     74        return bind_service_timeout( need, arg1, arg2, arg3, client_receiver, 0 );
     75}
     76
     77int bind_service_timeout( services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout ){
    6478        ERROR_DECLARE;
    6579
     
    6781        ipcarg_t        phonehash;
    6882
    69         phone = connect_to_service( need );
     83        phone = connect_to_service_timeout( need, timeout );
    7084        if( phone >= 0 ){
    7185                if( ERROR_OCCURRED( ipc_connect_to_me( phone, arg1, arg2, arg3, & phonehash ))){
Note: See TracChangeset for help on using the changeset viewer.