Changes in uspace/lib/libc/generic/async.c [8aa42e3:0da4e41] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/async.c
r8aa42e3 r0da4e41 392 392 /* If nothing in queue, wait until something arrives */ 393 393 while (list_empty(&conn->msg_queue)) { 394 if (conn->close_callid) {395 /*396 * Handle the case when the connection was already397 * closed by the client but the server did not notice398 * the first IPC_M_PHONE_HUNGUP call and continues to399 * call async_get_call_timeout(). Repeat400 * IPC_M_PHONE_HUNGUP until the caller notices.401 */402 memset(call, 0, sizeof(ipc_call_t));403 IPC_SET_METHOD(*call, IPC_M_PHONE_HUNGUP);404 futex_up(&async_futex);405 return conn->close_callid;406 }407 408 394 if (usecs) 409 395 async_insert_timeout(&conn->wdata); … … 542 528 list_initialize(&conn->msg_queue); 543 529 conn->callid = callid; 544 conn->close_callid = 0;530 conn->close_callid = false; 545 531 546 532 if (call) … … 1345 1331 } 1346 1332 1347 /** Wrapper for receiving blobs via the async_data_write_*1348 *1349 * This wrapper only makes it more comfortable to use async_data_write_*1350 * functions to receive blobs.1351 *1352 * @param blob Pointer to data pointer (which should be later disposed1353 * by free()). If the operation fails, the pointer is not1354 * touched.1355 * @param max_size Maximum size (in bytes) of the blob to receive. 0 means1356 * no limit.1357 * @param received If not NULL, the size of the received data is stored here.1358 *1359 * @return Zero on success or a value from @ref errno.h on failure.1360 *1361 */1362 int async_data_blob_receive(char **blob, const size_t max_size, size_t *received)1363 {1364 ipc_callid_t callid;1365 size_t size;1366 if (!async_data_write_receive(&callid, &size)) {1367 ipc_answer_0(callid, EINVAL);1368 return EINVAL;1369 }1370 1371 if ((max_size > 0) && (size > max_size)) {1372 ipc_answer_0(callid, EINVAL);1373 return EINVAL;1374 }1375 1376 char *data = (char *) malloc(size);1377 if (data == NULL) {1378 ipc_answer_0(callid, ENOMEM);1379 return ENOMEM;1380 }1381 1382 int rc = async_data_write_finalize(callid, data, size);1383 if (rc != EOK) {1384 free(data);1385 return rc;1386 }1387 1388 *blob = data;1389 if (received != NULL)1390 *received = size;1391 1392 return EOK;1393 }1394 1395 /** Wrapper for receiving strings via the async_data_write_*1396 *1397 * This wrapper only makes it more comfortable to use async_data_write_*1398 * functions to receive strings.1399 *1400 * @param str Pointer to string pointer (which should be later disposed1401 * by free()). If the operation fails, the pointer is not1402 * touched.1403 * @param max_size Maximum size (in bytes) of the string to receive. 0 means1404 * no limit.1405 *1406 * @return Zero on success or a value from @ref errno.h on failure.1407 *1408 */1409 int async_data_string_receive(char **str, const size_t max_size)1410 {1411 ipc_callid_t callid;1412 size_t size;1413 if (!async_data_write_receive(&callid, &size)) {1414 ipc_answer_0(callid, EINVAL);1415 return EINVAL;1416 }1417 1418 if ((max_size > 0) && (size > max_size)) {1419 ipc_answer_0(callid, EINVAL);1420 return EINVAL;1421 }1422 1423 char *data = (char *) malloc(size + 1);1424 if (data == NULL) {1425 ipc_answer_0(callid, ENOMEM);1426 return ENOMEM;1427 }1428 1429 int rc = async_data_write_finalize(callid, data, size);1430 if (rc != EOK) {1431 free(data);1432 return rc;1433 }1434 1435 data[size] = 0;1436 *str = data;1437 return EOK;1438 }1439 1440 1333 /** @} 1441 1334 */
Note:
See TracChangeset
for help on using the changeset viewer.