Changeset 37ea333 in mainline for uspace/lib/hound/src/protocol.c
- Timestamp:
- 2013-03-23T13:56:35Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fd7c98b
- Parents:
- d768d4c8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/hound/src/protocol.c
rd768d4c8 r37ea333 139 139 140 140 static int hound_server_read_data(void *stream); 141 static int hound_server_write_data(void *stream); 141 142 static const hound_server_iface_t *server_iface; 142 143 … … 194 195 } 195 196 case IPC_M_HOUND_STREAM_ENTER: { 196 if (!server_iface || !server_iface->add_stream) { 197 if (!server_iface || !server_iface->add_stream 198 || !server_iface->is_record_context) { 197 199 async_answer_0(callid, ENOTSUP); 198 200 break; … … 213 215 break; 214 216 } 215 //TODO consider record context 216 hound_server_read_data(stream); 217 const bool rec = server_iface->is_record_context( 218 server_iface->server, id); 219 if (rec) { 220 hound_server_write_data(stream); 221 } else { 222 hound_server_read_data(stream); 223 } 217 224 break; 218 225 } … … 245 252 int ret = async_data_write_finalize(callid, buffer, size); 246 253 if (ret == EOK) { 247 server_iface->stream_data_write(stream, buffer, size); 248 } else { 249 async_answer_0(callid, ret); 250 } 254 ret = server_iface->stream_data_write(stream, buffer, size); 255 } 256 async_answer_0(callid, ret); 251 257 } 252 258 //TODO drain? 259 const int ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT 260 ? EOK : EINVAL; 261 262 async_answer_0(callid, ret); 263 return ret; 264 } 265 266 static int hound_server_write_data(void *stream) 267 { 268 if (!server_iface || !server_iface->stream_data_read) 269 return ENOTSUP; 270 271 ipc_callid_t callid; 272 ipc_call_t call; 273 size_t size = 0; 274 while (async_data_read_receive_call(&callid, &call, &size)) { 275 char *buffer = malloc(size); 276 if (!buffer) { 277 async_answer_0(callid, ENOMEM); 278 continue; 279 } 280 int ret = server_iface->stream_data_read(stream, buffer, size); 281 if (ret == EOK) { 282 ret = async_data_read_finalize(callid, buffer, size); 283 } 284 async_answer_0(callid, ret); 285 } 253 286 const int ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT 254 287 ? EOK : EINVAL;
Note:
See TracChangeset
for help on using the changeset viewer.