Changeset 1a0fb3f8 in mainline
- Timestamp:
- 2010-01-04T22:47:30Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ede63e4
- Parents:
- b648ae4
- Location:
- uspace/srv/net
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/app/ping/ping.c
rb648ae4 r1a0fb3f8 236 236 } 237 237 238 icmp_phone = icmp_connect_module( SERVICE_ICMP );238 icmp_phone = icmp_connect_module( SERVICE_ICMP, ICMP_CONNECT_TIMEOUT ); 239 239 if( icmp_phone < 0 ){ 240 240 fprintf( stderr, "ICMP connect error %d\n", icmp_phone ); 241 return icmp_phone; 241 242 } 242 243 -
uspace/srv/net/include/icmp_common.h
rb648ae4 r1a0fb3f8 40 40 #include <ipc/services.h> 41 41 42 #include <sys/time.h> 43 44 /** Default timeout for incoming connections in microseconds. 45 */ 46 #define ICMP_CONNECT_TIMEOUT ( 1 * 1000 * 1000 ) 47 42 48 /** Connects to the ICMP module. 43 49 * @param service The ICMP module service. Ignored parameter. 50 * @param[in] timeout The connection timeout in microseconds. No timeout if set to zero (0). 44 51 * @returns The ICMP module phone on success. 45 52 * @returns The ICMP socket identifier if called by the bundle module. 53 * @returns ETIMEOUT if the connection timeouted. 46 54 */ 47 int icmp_connect_module( services_t service );55 int icmp_connect_module( services_t service, suseconds_t timeout ); 48 56 49 57 #endif -
uspace/srv/net/include/socket.h
rb648ae4 r1a0fb3f8 62 62 * @returns ENOMEM if there is not enough memory left. 63 63 * @returns Other error codes as defined for the NET_SOCKET message. 64 * @returns Other error codes as defined for the bind_service_timeout() function. 64 65 */ 65 66 int socket( int domain, int type, int protocol ); -
uspace/srv/net/modules.c
rb648ae4 r1a0fb3f8 41 41 #include <ipc/services.h> 42 42 43 #include <sys/time.h> 44 43 45 #include "err.h" 44 46 #include "modules.h" 45 47 46 /** The time between connect requests .48 /** The time between connect requests in microseconds. 47 49 */ 48 #define MODULE_WAIT_TIME 1000050 #define MODULE_WAIT_TIME ( 10 * 1000 ) 49 51 50 52 int connect_to_service( services_t need ){ 53 return connect_to_service_timeout( need, 0 ); 54 } 55 56 int connect_to_service_timeout( services_t need, suseconds_t timeout ){ 51 57 int phone; 52 58 int res; 53 59 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 } 57 69 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 );59 70 } 60 return phone;61 71 } 62 72 63 73 int 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 77 int bind_service_timeout( services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout ){ 64 78 ERROR_DECLARE; 65 79 … … 67 81 ipcarg_t phonehash; 68 82 69 phone = connect_to_service ( need);83 phone = connect_to_service_timeout( need, timeout ); 70 84 if( phone >= 0 ){ 71 85 if( ERROR_OCCURRED( ipc_connect_to_me( phone, arg1, arg2, arg3, & phonehash ))){ -
uspace/srv/net/modules.h
rb648ae4 r1a0fb3f8 43 43 #include <ipc/services.h> 44 44 45 #include <sys/time.h> 46 45 47 /** Converts the data length between different types. 46 48 * @param[in] type_from The source type. … … 68 70 int connect_to_service( services_t need ); 69 71 72 /** Connects to the needed module. 73 * @param[in] need The needed module service. 74 * @param[in] timeout The connection timeout in microseconds. No timeout if set to zero (0). 75 * @returns The phone of the needed service. 76 * @returns ETIMEOUT if the connection timeouted. 77 */ 78 int connect_to_service_timeout( services_t need, suseconds_t timeout ); 79 70 80 /** Creates bidirectional connection with the needed module service and registers the message receiver. 71 81 * @param[in] need The needed module service. … … 78 88 */ 79 89 int bind_service( services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver ); 90 91 /** Creates bidirectional connection with the needed module service and registers the message receiver. 92 * @param[in] need The needed module service. 93 * @param[in] arg1 The first parameter. 94 * @param[in] arg2 The second parameter. 95 * @param[in] arg3 The third parameter. 96 * @param[in] client_receiver The message receiver. 97 * @param[in] timeout The connection timeout in microseconds. No timeout if set to zero (0). 98 * @returns The phone of the needed service. 99 * @returns ETIMEOUT if the connection timeouted. 100 * @returns Other error codes as defined for the ipc_connect_to_me() function. 101 */ 102 int bind_service_timeout( services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout ); 80 103 81 104 /** Answers the call. -
uspace/srv/net/socket/socket_client.c
rb648ae4 r1a0fb3f8 71 71 #define SOCKET_MAX_ACCEPTED_SIZE 0 72 72 73 /** Default timeout for connections in microseconds. 74 */ 75 #define SOCKET_CONNECT_TIMEOUT ( 1 * 1000 * 1000 ) 76 73 77 /** Type definition of the socket specific data. 74 78 * @see socket … … 180 184 * Connects to the TCP module if necessary. 181 185 * @returns The TCP module phone. 186 * @returns Other error codes as defined for the bind_service_timeout() function. 182 187 */ 183 188 static int socket_get_tcp_phone( void ); … … 186 191 * Connects to the UDP module if necessary. 187 192 * @returns The UDP module phone. 193 * @returns Other error codes as defined for the bind_service_timeout() function. 188 194 */ 189 195 static int socket_get_udp_phone( void ); … … 262 268 static int socket_get_tcp_phone( void ){ 263 269 if( socket_globals.tcp_phone < 0 ){ 264 socket_globals.tcp_phone = bind_service ( SERVICE_TCP, 0, 0, SERVICE_TCP, socket_connection);270 socket_globals.tcp_phone = bind_service_timeout( SERVICE_TCP, 0, 0, SERVICE_TCP, socket_connection, SOCKET_CONNECT_TIMEOUT ); 265 271 } 266 272 return socket_globals.tcp_phone; … … 269 275 static int socket_get_udp_phone( void ){ 270 276 if( socket_globals.udp_phone < 0 ){ 271 socket_globals.udp_phone = bind_service ( SERVICE_UDP, 0, 0, SERVICE_UDP, socket_connection);277 socket_globals.udp_phone = bind_service_timeout( SERVICE_UDP, 0, 0, SERVICE_UDP, socket_connection, SOCKET_CONNECT_TIMEOUT ); 272 278 } 273 279 return socket_globals.udp_phone; … … 426 432 return EPFNOSUPPORT; 427 433 } 434 if( phone < 0 ) return phone; 428 435 // create a new socket structure 429 436 socket = ( socket_ref ) malloc( sizeof( socket_t )); -
uspace/srv/net/tl/icmp/icmp.c
rb648ae4 r1a0fb3f8 45 45 #include <ipc/services.h> 46 46 47 #include <sys/time.h> 47 48 #include <sys/types.h> 48 49 … … 508 509 } 509 510 510 int icmp_connect_module( services_t service ){511 int icmp_connect_module( services_t service, suseconds_t timeout ){ 511 512 icmp_echo_ref echo_data; 512 513 icmp_param_t id; -
uspace/srv/net/tl/icmp/icmp_common.c
rb648ae4 r1a0fb3f8 45 45 #include "icmp_messages.h" 46 46 47 int icmp_connect_module( services_t service ){47 int icmp_connect_module( services_t service, suseconds_t timeout ){ 48 48 int phone; 49 49 50 phone = connect_to_service ( SERVICE_ICMP);50 phone = connect_to_service_timeout( SERVICE_ICMP, timeout ); 51 51 if( phone >= 0 ){ 52 52 async_req_0_0( phone, NET_ICMP_INIT ); -
uspace/srv/net/tl/tcp/tcp.c
rb648ae4 r1a0fb3f8 219 219 fibril_rwlock_initialize( & tcp_globals.lock ); 220 220 fibril_rwlock_write_lock( & tcp_globals.lock ); 221 tcp_globals.icmp_phone = icmp_connect_module( SERVICE_ICMP ); 222 if( tcp_globals.icmp_phone < 0 ){ 223 return tcp_globals.icmp_phone; 224 } 221 tcp_globals.icmp_phone = icmp_connect_module( SERVICE_ICMP, ICMP_CONNECT_TIMEOUT ); 225 222 tcp_globals.ip_phone = ip_bind_service( SERVICE_IP, IPPROTO_TCP, SERVICE_TCP, client_connection, tcp_received_msg ); 226 223 if( tcp_globals.ip_phone < 0 ){ -
uspace/srv/net/tl/udp/udp.c
rb648ae4 r1a0fb3f8 198 198 fibril_rwlock_initialize( & udp_globals.lock ); 199 199 fibril_rwlock_write_lock( & udp_globals.lock ); 200 udp_globals.icmp_phone = icmp_connect_module( SERVICE_ICMP ); 201 if( udp_globals.icmp_phone < 0 ){ 202 return udp_globals.icmp_phone; 203 } 200 udp_globals.icmp_phone = icmp_connect_module( SERVICE_ICMP, ICMP_CONNECT_TIMEOUT ); 204 201 udp_globals.ip_phone = ip_bind_service( SERVICE_IP, IPPROTO_UDP, SERVICE_UDP, client_connection, udp_received_msg ); 205 202 if( udp_globals.ip_phone < 0 ){
Note:
See TracChangeset
for help on using the changeset viewer.