Changeset 57dea62 in mainline
- Timestamp:
- 2015-08-22T03:58:28Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 566992e1
- Parents:
- 9cfbf2f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
r9cfbf2f r57dea62 189 189 /** If reply was received. */ 190 190 bool done; 191 191 192 192 /** If the message / reply should be discarded on arrival. */ 193 193 bool forget; 194 194 195 195 /** If already destroyed. */ 196 196 bool destroyed; … … 266 266 { 267 267 struct timeval tv = { 0, 0 }; 268 268 269 269 to->inlist = false; 270 270 to->occurred = false; … … 289 289 static amsg_t *amsg_create(void) 290 290 { 291 amsg_t *msg; 292 293 msg = malloc(sizeof(amsg_t)); 291 amsg_t *msg = malloc(sizeof(amsg_t)); 294 292 if (msg) { 295 293 msg->done = false; … … 300 298 awaiter_initialize(&msg->wdata); 301 299 } 302 300 303 301 return msg; 304 302 } … … 869 867 } 870 868 871 msg_t *msg = list_get_instance(list_first(&conn->msg_queue), msg_t, link); 869 msg_t *msg = list_get_instance(list_first(&conn->msg_queue), 870 msg_t, link); 872 871 list_remove(&msg->link); 873 872 … … 937 936 if (!client) 938 937 return NULL; 938 939 939 if (!client->data) { 940 940 async_client_put(client); 941 941 return NULL; 942 942 } 943 943 944 944 return client->data; 945 945 } … … 948 948 { 949 949 client_t *client = async_client_get(client_id, false); 950 950 951 951 assert(client); 952 952 assert(client->data); 953 953 954 954 /* Drop the reference we got in async_get_client_data_by_hash(). */ 955 955 async_client_put(client); 956 956 957 957 /* Drop our own reference we got at the beginning of this function. */ 958 958 async_client_put(client); … … 1346 1346 1347 1347 msg->done = true; 1348 1348 1349 1349 if (msg->forget) { 1350 1350 assert(msg->wdata.active); … … 1354 1354 fibril_add_ready(msg->wdata.fid); 1355 1355 } 1356 1356 1357 1357 futex_up(&async_futex); 1358 1358 } … … 1446 1446 1447 1447 futex_down(&async_futex); 1448 1448 1449 1449 assert(!msg->forget); 1450 1450 assert(!msg->destroyed); 1451 1451 1452 1452 if (msg->done) { 1453 1453 futex_up(&async_futex); … … 1490 1490 1491 1491 amsg_t *msg = (amsg_t *) amsgid; 1492 1492 1493 1493 futex_down(&async_futex); 1494 1494 1495 1495 assert(!msg->forget); 1496 1496 assert(!msg->destroyed); 1497 1497 1498 1498 if (msg->done) { 1499 1499 futex_up(&async_futex); … … 1507 1507 if (timeout < 0) 1508 1508 timeout = 0; 1509 1509 1510 1510 getuptime(&msg->wdata.to_event.expires); 1511 1511 tv_add_diff(&msg->wdata.to_event.expires, timeout); … … 1560 1560 { 1561 1561 amsg_t *msg = (amsg_t *) amsgid; 1562 1562 1563 1563 assert(msg); 1564 1564 assert(!msg->forget); 1565 1565 assert(!msg->destroyed); 1566 1566 1567 1567 futex_down(&async_futex); 1568 1568 1569 if (msg->done) { 1569 1570 amsg_destroy(msg); … … 1572 1573 msg->forget = true; 1573 1574 } 1575 1574 1576 futex_up(&async_futex); 1575 1577 } … … 2697 2699 } 2698 2700 2699 void * _data;2701 void *arg_data; 2700 2702 2701 2703 if (nullterm) 2702 _data = malloc(size + 1);2704 arg_data = malloc(size + 1); 2703 2705 else 2704 _data = malloc(size);2705 2706 if ( _data == NULL) {2706 arg_data = malloc(size); 2707 2708 if (arg_data == NULL) { 2707 2709 ipc_answer_0(callid, ENOMEM); 2708 2710 return ENOMEM; 2709 2711 } 2710 2712 2711 int rc = async_data_write_finalize(callid, _data, size);2713 int rc = async_data_write_finalize(callid, arg_data, size); 2712 2714 if (rc != EOK) { 2713 free( _data);2715 free(arg_data); 2714 2716 return rc; 2715 2717 } 2716 2718 2717 2719 if (nullterm) 2718 ((char *) _data)[size] = 0;2719 2720 *data = _data;2720 ((char *) arg_data)[size] = 0; 2721 2722 *data = arg_data; 2721 2723 if (received != NULL) 2722 2724 *received = size; … … 2937 2939 { 2938 2940 assert(callid); 2939 2941 2940 2942 ipc_call_t call; 2941 2943 *callid = async_get_call(&call); 2942 2944 2943 2945 if (IPC_GET_IMETHOD(call) != IPC_M_STATE_CHANGE_AUTHORIZE) 2944 2946 return false; … … 2950 2952 if (arg3) 2951 2953 *arg3 = IPC_GET_ARG3(call); 2952 2954 2953 2955 return true; 2954 2956 }
Note:
See TracChangeset
for help on using the changeset viewer.