* This is the function run by the threads */
| 606 | * This is the function run by the threads |
| 607 | */ |
| 608 | void *handle_socket(void *arg) |
| 609 | { |
| 610 | struct handle_data *handle_data_arg = (struct handle_data *)arg; |
| 611 | FILE *fsockin; |
| 612 | FILE *fsockout; |
| 613 | int retcode; |
| 614 | char host[NI_MAXHOST]; |
| 615 | char serv[NI_MAXSERV]; |
| 616 | |
| 617 | #ifdef __MINGW32__ |
| 618 | int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY); |
| 619 | |
| 620 | if (sock_osfhandle == -1) |
| 621 | { |
| 622 | rig_debug(RIG_DEBUG_ERR, "_open_osfhandle error: %s\n", strerror(errno)); |
| 623 | goto handle_exit; |
| 624 | } |
| 625 | |
| 626 | fsockin = _fdopen(sock_osfhandle, "rb"); |
| 627 | #elif defined(ANDROID) || defined(__ANDROID__) |
| 628 | // fdsan does not allow fdopen the same fd twice in Android |
| 629 | fsockin = fdopen(dup(handle_data_arg->sock), "rb"); |
| 630 | #else |
| 631 | fsockin = fdopen(handle_data_arg->sock, "rb"); |
| 632 | #endif |
| 633 | |
| 634 | if (!fsockin) |
| 635 | { |
| 636 | rig_debug(RIG_DEBUG_ERR, "fdopen in: %s\n", strerror(errno)); |
| 637 | goto handle_exit; |
| 638 | } |
| 639 | |
| 640 | #ifdef __MINGW32__ |
| 641 | fsockout = _fdopen(sock_osfhandle, "wb"); |
| 642 | #elif defined(ANDROID) || defined(__ANDROID__) |
| 643 | // fdsan does not allow fdopen the same fd twice in Android |
| 644 | fsockout = fdopen(dup(handle_data_arg->sock), "wb"); |
| 645 | #else |
| 646 | fsockout = fdopen(handle_data_arg->sock, "wb"); |
| 647 | #endif |
| 648 | |
| 649 | if (!fsockout) |
| 650 | { |
| 651 | rig_debug(RIG_DEBUG_ERR, "fdopen out: %s\n", strerror(errno)); |
| 652 | fclose(fsockin); |
| 653 | goto handle_exit; |
| 654 | } |
| 655 | |
| 656 | do |
| 657 | { |
| 658 | retcode = rotctl_parse(handle_data_arg->rot, fsockin, fsockout, NULL, 0, 1, 0, |
| 659 | '\r'); |
| 660 | |
| 661 | if (ferror(fsockin) || ferror(fsockout)) |
| 662 | { |
| 663 | retcode = 1; |
| 664 | } |
| 665 | } |
nothing calls this directly
no test coverage detected