Changes in uspace/srv/net/modules.c [a64c64d:aadf01e] in mainline
- File:
-
- 1 edited
-
uspace/srv/net/modules.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/modules.c
ra64c64d raadf01e 51 51 52 52 void answer_call(ipc_callid_t callid, int result, ipc_call_t * answer, int answer_count){ 53 // choose the most efficient answer function54 53 if(answer || (! answer_count)){ 55 54 switch(answer_count){ … … 87 86 ipcarg_t phonehash; 88 87 89 // connect to the needed service90 88 phone = connect_to_service_timeout(need, timeout); 91 // if connected92 89 if(phone >= 0){ 93 // request the bidirectional connection94 90 if(ERROR_OCCURRED(ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash))){ 95 91 ipc_hangup(phone); … … 106 102 107 103 int 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; 109 109 110 // if no timeout is set111 if (timeout <= 0){112 return async_connect_me_to_blocking(PHONE_NS, need, 0, 0);113 }114 115 while(true){116 110 phone = async_connect_me_to(PHONE_NS, need, 0, 0); 117 if((phone >= 0) || (phone != ENOENT)) {111 if((phone >= 0) || (phone != ENOENT)) 118 112 return phone; 119 } 120 121 // end if no time is left 113 114 timeout -= MODULE_WAIT_TIME; 122 115 if(timeout <= 0){ 123 116 return ETIMEOUT; 124 117 } 125 118 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); 129 120 } 130 121 } … … 138 129 return EBADMEM; 139 130 } 140 141 // fetch the request142 131 if(! async_data_write_receive(&callid, length)){ 143 132 return EINVAL; 144 133 } 145 146 // allocate the buffer147 134 *data = malloc(*length); 148 135 if(!(*data)){ 149 136 return ENOMEM; 150 137 } 151 152 // fetch the data153 138 if(ERROR_OCCURRED(async_data_write_finalize(callid, * data, * length))){ 154 139 free(data); … … 162 147 ipc_callid_t callid; 163 148 164 // fetch the request165 149 if(! async_data_read_receive(&callid, &length)){ 166 150 return EINVAL; 167 151 } 168 169 // check the requested data size170 152 if(length < data_length){ 171 153 async_data_read_finalize(callid, data, length); 172 154 return EOVERFLOW; 173 155 } 174 175 // send the data176 156 return async_data_read_finalize(callid, data, data_length); 177 157 } 178 158 179 159 void refresh_answer(ipc_call_t * answer, int * answer_count){ 180 181 160 if(answer_count){ 182 161 *answer_count = 0; 183 162 } 184 185 163 if(answer){ 186 164 IPC_SET_RETVAL(*answer, 0);
Note:
See TracChangeset
for help on using the changeset viewer.
