Changeset a46e56b in mainline for uspace/lib/hound/src/protocol.c
- Timestamp:
- 2018-03-22T06:49:35Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 77f0a1d
- Parents:
- 3e242d2
- git-author:
- Jakub Jermar <jakub@…> (2018-03-21 23:29:06)
- git-committer:
- Jakub Jermar <jakub@…> (2018-03-22 06:49:35)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/hound/src/protocol.c
r3e242d2 ra46e56b 384 384 * @param arg (unused) 385 385 */ 386 void hound_connection_handler(cap_call_handle_t i id, ipc_call_t *icall, void *arg)386 void hound_connection_handler(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg) 387 387 { 388 388 hound_context_id_t id; … … 394 394 /* Accept connection if there is a valid iface*/ 395 395 if (server_iface) { 396 async_answer_0(i id, EOK);396 async_answer_0(icall_handle, EOK); 397 397 } else { 398 async_answer_0(i id, ENOTSUP);398 async_answer_0(icall_handle, ENOTSUP); 399 399 return; 400 400 } … … 402 402 while (1) { 403 403 ipc_call_t call; 404 cap_call_handle_t c allid= async_get_call(&call);404 cap_call_handle_t chandle = async_get_call(&call); 405 405 switch (IPC_GET_IMETHOD(call)) { 406 406 case IPC_M_HOUND_CONTEXT_REGISTER: 407 407 /* check interface functions */ 408 408 if (!server_iface || !server_iface->add_context) { 409 async_answer_0(c allid, ENOTSUP);409 async_answer_0(chandle, ENOTSUP); 410 410 break; 411 411 } … … 416 416 ret = async_data_write_accept(&name, true, 0, 0, 0, 0); 417 417 if (ret != EOK) { 418 async_answer_0(c allid, ret);418 async_answer_0(chandle, ret); 419 419 break; 420 420 } … … 426 426 free(name); 427 427 if (ret != EOK) { 428 async_answer_0(c allid, ret);428 async_answer_0(chandle, ret); 429 429 } else { 430 async_answer_1(c allid, EOK, CAP_HANDLE_RAW(id));430 async_answer_1(chandle, EOK, CAP_HANDLE_RAW(id)); 431 431 } 432 432 break; … … 434 434 /* check interface functions */ 435 435 if (!server_iface || !server_iface->rem_context) { 436 async_answer_0(c allid, ENOTSUP);436 async_answer_0(chandle, ENOTSUP); 437 437 break; 438 438 } … … 442 442 ret = server_iface->rem_context(server_iface->server, 443 443 id); 444 async_answer_0(c allid, ret);444 async_answer_0(chandle, ret); 445 445 break; 446 446 case IPC_M_HOUND_GET_LIST: 447 447 /* check interface functions */ 448 448 if (!server_iface || !server_iface->get_list) { 449 async_answer_0(c allid, ENOTSUP);449 async_answer_0(chandle, ENOTSUP); 450 450 break; 451 451 } … … 475 475 if (count && !sizes) 476 476 ret = ENOMEM; 477 async_answer_1(c allid, ret, count);477 async_answer_1(chandle, ret, count); 478 478 479 479 /* We are done */ … … 509 509 /* check interface functions */ 510 510 if (!server_iface || !server_iface->connect) { 511 async_answer_0(c allid, ENOTSUP);511 async_answer_0(chandle, ENOTSUP); 512 512 break; 513 513 } … … 529 529 free(source); 530 530 free(sink); 531 async_answer_0(c allid, ret);531 async_answer_0(chandle, ret); 532 532 break; 533 533 case IPC_M_HOUND_DISCONNECT: 534 534 /* check interface functions */ 535 535 if (!server_iface || !server_iface->disconnect) { 536 async_answer_0(c allid, ENOTSUP);536 async_answer_0(chandle, ENOTSUP); 537 537 break; 538 538 } … … 553 553 free(source); 554 554 free(sink); 555 async_answer_0(c allid, ret);555 async_answer_0(chandle, ret); 556 556 break; 557 557 case IPC_M_HOUND_STREAM_ENTER: … … 560 560 || !server_iface->add_stream 561 561 || !server_iface->rem_stream) { 562 async_answer_0(c allid, ENOTSUP);562 async_answer_0(chandle, ENOTSUP); 563 563 break; 564 564 } … … 579 579 id, flags, f, bsize, &stream); 580 580 if (ret != EOK) { 581 async_answer_0(c allid, ret);581 async_answer_0(chandle, ret); 582 582 break; 583 583 } … … 586 586 if (rec) { 587 587 if(server_iface->stream_data_read) { 588 async_answer_0(c allid, EOK);588 async_answer_0(chandle, EOK); 589 589 /* start answering read calls */ 590 590 hound_server_write_data(stream); … … 592 592 server_iface->server, stream); 593 593 } else { 594 async_answer_0(c allid, ENOTSUP);594 async_answer_0(chandle, ENOTSUP); 595 595 } 596 596 } else { 597 597 if (server_iface->stream_data_write) { 598 async_answer_0(c allid, EOK);598 async_answer_0(chandle, EOK); 599 599 /* accept write calls */ 600 600 hound_server_read_data(stream); … … 602 602 server_iface->server, stream); 603 603 } else { 604 async_answer_0(c allid, ENOTSUP);604 async_answer_0(chandle, ENOTSUP); 605 605 } 606 606 } … … 609 609 case IPC_M_HOUND_STREAM_DRAIN: 610 610 /* Stream exit/drain is only allowed in stream context*/ 611 async_answer_0(c allid, EINVAL);611 async_answer_0(chandle, EINVAL); 612 612 break; 613 613 default: 614 async_answer_0(c allid, ENOTSUP);614 async_answer_0(chandle, ENOTSUP); 615 615 return; 616 616 } … … 624 624 static void hound_server_read_data(void *stream) 625 625 { 626 cap_call_handle_t c allid;626 cap_call_handle_t chandle; 627 627 ipc_call_t call; 628 628 size_t size = 0; 629 629 errno_t ret_answer = EOK; 630 630 /* accept data write or drain */ 631 while (async_data_write_receive_call(&c allid, &call, &size)631 while (async_data_write_receive_call(&chandle, &call, &size) 632 632 || (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) { 633 633 /* check drain first */ … … 636 636 if (server_iface->drain_stream) 637 637 ret = server_iface->drain_stream(stream); 638 async_answer_0(c allid, ret);638 async_answer_0(chandle, ret); 639 639 continue; 640 640 } … … 642 642 /* there was an error last time */ 643 643 if (ret_answer != EOK) { 644 async_answer_0(c allid, ret_answer);644 async_answer_0(chandle, ret_answer); 645 645 continue; 646 646 } … … 648 648 char *buffer = malloc(size); 649 649 if (!buffer) { 650 async_answer_0(c allid, ENOMEM);650 async_answer_0(chandle, ENOMEM); 651 651 continue; 652 652 } 653 const errno_t ret = async_data_write_finalize(c allid, buffer, size);653 const errno_t ret = async_data_write_finalize(chandle, buffer, size); 654 654 if (ret == EOK) { 655 655 /* push data to stream */ … … 661 661 ? EOK : EINVAL; 662 662 663 async_answer_0(c allid, ret);663 async_answer_0(chandle, ret); 664 664 } 665 665 … … 671 671 { 672 672 673 cap_call_handle_t c allid;673 cap_call_handle_t chandle; 674 674 ipc_call_t call; 675 675 size_t size = 0; 676 676 errno_t ret_answer = EOK; 677 677 /* accept data read and drain */ 678 while (async_data_read_receive_call(&c allid, &call, &size)678 while (async_data_read_receive_call(&chandle, &call, &size) 679 679 || (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) { 680 680 /* drain does not make much sense but it is allowed */ … … 683 683 if (server_iface->drain_stream) 684 684 ret = server_iface->drain_stream(stream); 685 async_answer_0(c allid, ret);685 async_answer_0(chandle, ret); 686 686 continue; 687 687 } 688 688 /* there was an error last time */ 689 689 if (ret_answer != EOK) { 690 async_answer_0(c allid, ret_answer);690 async_answer_0(chandle, ret_answer); 691 691 continue; 692 692 } 693 693 char *buffer = malloc(size); 694 694 if (!buffer) { 695 async_answer_0(c allid, ENOMEM);695 async_answer_0(chandle, ENOMEM); 696 696 continue; 697 697 } … … 699 699 if (ret == EOK) { 700 700 ret_answer = 701 async_data_read_finalize(c allid, buffer, size);701 async_data_read_finalize(chandle, buffer, size); 702 702 } 703 703 } … … 705 705 ? EOK : EINVAL; 706 706 707 async_answer_0(c allid, ret);707 async_answer_0(chandle, ret); 708 708 } 709 709
Note:
See TracChangeset
for help on using the changeset viewer.