* This is the function run by the threads */
| 589 | * This is the function run by the threads |
| 590 | */ |
| 591 | void *handle_socket(void *arg) |
| 592 | { |
| 593 | struct handle_data *handle_data_arg = (struct handle_data *)arg; |
| 594 | FILE *fsockin; |
| 595 | FILE *fsockout; |
| 596 | int retcode; |
| 597 | char host[NI_MAXHOST]; |
| 598 | char serv[NI_MAXSERV]; |
| 599 | |
| 600 | #ifdef __MINGW32__ |
| 601 | int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY); |
| 602 | |
| 603 | if (sock_osfhandle == -1) |
| 604 | { |
| 605 | rig_debug(RIG_DEBUG_ERR, "_open_osfhandle error: %s\n", strerror(errno)); |
| 606 | goto handle_exit; |
| 607 | } |
| 608 | |
| 609 | fsockin = _fdopen(sock_osfhandle, "rb"); |
| 610 | #else |
| 611 | fsockin = fdopen(handle_data_arg->sock, "rb"); |
| 612 | #endif |
| 613 | |
| 614 | if (!fsockin) |
| 615 | { |
| 616 | rig_debug(RIG_DEBUG_ERR, "fdopen in: %s\n", strerror(errno)); |
| 617 | goto handle_exit; |
| 618 | } |
| 619 | |
| 620 | #ifdef __MINGW32__ |
| 621 | fsockout = _fdopen(sock_osfhandle, "wb"); |
| 622 | #else |
| 623 | fsockout = fdopen(handle_data_arg->sock, "wb"); |
| 624 | #endif |
| 625 | |
| 626 | if (!fsockout) |
| 627 | { |
| 628 | rig_debug(RIG_DEBUG_ERR, "fdopen out: %s\n", strerror(errno)); |
| 629 | fclose(fsockin); |
| 630 | goto handle_exit; |
| 631 | } |
| 632 | |
| 633 | do |
| 634 | { |
| 635 | retcode = ampctl_parse(handle_data_arg->amp, fsockin, fsockout, NULL, 0); |
| 636 | |
| 637 | if (ferror(fsockin) || ferror(fsockout)) |
| 638 | { |
| 639 | retcode = 1; |
| 640 | } |
| 641 | } |
| 642 | while (retcode == 0 || retcode == 2); |
| 643 | |
| 644 | if ((retcode = getnameinfo((struct sockaddr const *)&handle_data_arg->cli_addr, |
| 645 | handle_data_arg->clilen, |
| 646 | host, |
| 647 | sizeof(host), |
| 648 | serv, |
nothing calls this directly
no test coverage detected