Changeset 60ab6c3 in mainline for uspace/srv/net/modules.c
- Timestamp:
- 2010-03-10T05:46:54Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5782081
- Parents:
- 71b00dcc (diff), b48ebd19 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/modules.c
r71b00dcc r60ab6c3 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 function 53 54 if(answer || (! answer_count)){ 54 55 switch(answer_count){ … … 86 87 ipcarg_t phonehash; 87 88 89 // connect to the needed service 88 90 phone = connect_to_service_timeout(need, timeout); 91 // if connected 89 92 if(phone >= 0){ 93 // request the bidirectional connection 90 94 if(ERROR_OCCURRED(ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash))){ 91 95 ipc_hangup(phone); … … 102 106 103 107 int connect_to_service_timeout(services_t need, suseconds_t timeout){ 104 if (timeout <= 0) 108 int phone; 109 110 // if no timeout is set 111 if (timeout <= 0){ 105 112 return async_connect_me_to_blocking(PHONE_NS, need, 0, 0); 106 113 } 114 107 115 while(true){ 108 int phone; 116 phone = async_connect_me_to(PHONE_NS, need, 0, 0); 117 if((phone >= 0) || (phone != ENOENT)){ 118 return phone; 119 } 109 120 110 phone = async_connect_me_to(PHONE_NS, need, 0, 0); 111 if((phone >= 0) || (phone != ENOENT)) 112 return phone; 113 114 timeout -= MODULE_WAIT_TIME; 121 // end if no time is left 115 122 if(timeout <= 0){ 116 123 return ETIMEOUT; 117 124 } 118 125 119 usleep(MODULE_WAIT_TIME); 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; 120 129 } 121 130 } … … 129 138 return EBADMEM; 130 139 } 140 141 // fetch the request 131 142 if(! async_data_write_receive(&callid, length)){ 132 143 return EINVAL; 133 144 } 145 146 // allocate the buffer 134 147 *data = malloc(*length); 135 148 if(!(*data)){ 136 149 return ENOMEM; 137 150 } 151 152 // fetch the data 138 153 if(ERROR_OCCURRED(async_data_write_finalize(callid, * data, * length))){ 139 154 free(data); … … 147 162 ipc_callid_t callid; 148 163 164 // fetch the request 149 165 if(! async_data_read_receive(&callid, &length)){ 150 166 return EINVAL; 151 167 } 168 169 // check the requested data size 152 170 if(length < data_length){ 153 171 async_data_read_finalize(callid, data, length); 154 172 return EOVERFLOW; 155 173 } 174 175 // send the data 156 176 return async_data_read_finalize(callid, data, data_length); 157 177 } 158 178 159 179 void refresh_answer(ipc_call_t * answer, int * answer_count){ 180 160 181 if(answer_count){ 161 182 *answer_count = 0; 162 183 } 184 163 185 if(answer){ 164 186 IPC_SET_RETVAL(*answer, 0);
Note:
See TracChangeset
for help on using the changeset viewer.