diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-09-05 11:35:44 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-09-05 11:47:44 +0200 |
commit | b0918f1e382ac02b8529c365ab69cf6194d12fd3 (patch) | |
tree | 7c3754f073a10d5387f5761b43a58efb4392f0e0 /src/util/service.c | |
parent | 74c328220897196de3d93710e74666230a57cfee (diff) | |
download | gnunet-b0918f1e382ac02b8529c365ab69cf6194d12fd3.tar.gz gnunet-b0918f1e382ac02b8529c365ab69cf6194d12fd3.zip |
fix logging issue reported by Raphael
Diffstat (limited to 'src/util/service.c')
-rw-r--r-- | src/util/service.c | 690 |
1 files changed, 351 insertions, 339 deletions
diff --git a/src/util/service.c b/src/util/service.c index ba0271a38..73a73cbea 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -39,9 +39,12 @@ | |||
39 | 39 | ||
40 | #define LOG(kind,...) GNUNET_log_from (kind, "util-service", __VA_ARGS__) | 40 | #define LOG(kind,...) GNUNET_log_from (kind, "util-service", __VA_ARGS__) |
41 | 41 | ||
42 | #define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-service", syscall) | 42 | #define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, \ |
43 | "util-service", \ | ||
44 | syscall) | ||
43 | 45 | ||
44 | #define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util-service", syscall, filename) | 46 | #define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file ( \ |
47 | kind, "util-service", syscall, filename) | ||
45 | 48 | ||
46 | 49 | ||
47 | /** | 50 | /** |
@@ -83,30 +86,30 @@ struct ServiceListenContext | |||
83 | */ | 86 | */ |
84 | enum SuspendReason | 87 | enum SuspendReason |
85 | { | 88 | { |
86 | /** | 89 | /** |
87 | * We are running normally. | 90 | * We are running normally. |
88 | */ | 91 | */ |
89 | SUSPEND_STATE_NONE = 0, | 92 | SUSPEND_STATE_NONE = 0, |
90 | 93 | ||
91 | /** | 94 | /** |
92 | * Application requested it. | 95 | * Application requested it. |
93 | */ | 96 | */ |
94 | SUSPEND_STATE_APP = 1, | 97 | SUSPEND_STATE_APP = 1, |
95 | 98 | ||
96 | /** | 99 | /** |
97 | * OS ran out of file descriptors. | 100 | * OS ran out of file descriptors. |
98 | */ | 101 | */ |
99 | SUSPEND_STATE_EMFILE = 2, | 102 | SUSPEND_STATE_EMFILE = 2, |
100 | 103 | ||
101 | /** | 104 | /** |
102 | * Both reasons, APP and EMFILE apply. | 105 | * Both reasons, APP and EMFILE apply. |
103 | */ | 106 | */ |
104 | SUSPEND_STATE_APP_AND_EMFILE = 3, | 107 | SUSPEND_STATE_APP_AND_EMFILE = 3, |
105 | 108 | ||
106 | /** | 109 | /** |
107 | * Suspension because service was permanently shutdown. | 110 | * Suspension because service was permanently shutdown. |
108 | */ | 111 | */ |
109 | SUSPEND_STATE_SHUTDOWN = 4 | 112 | SUSPEND_STATE_SHUTDOWN = 4 |
110 | }; | 113 | }; |
111 | 114 | ||
112 | 115 | ||
@@ -449,7 +452,7 @@ check_ipv4_listed (const struct GNUNET_STRINGS_IPv4NetworkPolicy *list, | |||
449 | return GNUNET_NO; | 452 | return GNUNET_NO; |
450 | i = 0; | 453 | i = 0; |
451 | while ( (0 != list[i].network.s_addr) || | 454 | while ( (0 != list[i].network.s_addr) || |
452 | (0 != list[i].netmask.s_addr) ) | 455 | (0 != list[i].netmask.s_addr) ) |
453 | { | 456 | { |
454 | if ((add->s_addr & list[i].netmask.s_addr) == | 457 | if ((add->s_addr & list[i].netmask.s_addr) == |
455 | (list[i].network.s_addr & list[i].netmask.s_addr)) | 458 | (list[i].network.s_addr & list[i].netmask.s_addr)) |
@@ -477,7 +480,7 @@ check_ipv6_listed (const struct GNUNET_STRINGS_IPv6NetworkPolicy *list, | |||
477 | if (NULL == list) | 480 | if (NULL == list) |
478 | return GNUNET_NO; | 481 | return GNUNET_NO; |
479 | i = 0; | 482 | i = 0; |
480 | NEXT: | 483 | NEXT: |
481 | while (0 != GNUNET_is_zero (&list[i].network)) | 484 | while (0 != GNUNET_is_zero (&list[i].network)) |
482 | { | 485 | { |
483 | for (j = 0; j < sizeof (struct in6_addr) / sizeof (int); j++) | 486 | for (j = 0; j < sizeof (struct in6_addr) / sizeof (int); j++) |
@@ -509,28 +512,28 @@ do_send (void *cls) | |||
509 | 512 | ||
510 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 513 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
511 | "service: sending message with type %u\n", | 514 | "service: sending message with type %u\n", |
512 | ntohs(client->msg->type)); | 515 | ntohs (client->msg->type)); |
513 | 516 | ||
514 | 517 | ||
515 | client->send_task = NULL; | 518 | client->send_task = NULL; |
516 | buf = (const char *) client->msg; | 519 | buf = (const char *) client->msg; |
517 | left = ntohs (client->msg->size) - client->msg_pos; | 520 | left = ntohs (client->msg->size) - client->msg_pos; |
518 | ret = GNUNET_NETWORK_socket_send (client->sock, | 521 | ret = GNUNET_NETWORK_socket_send (client->sock, |
519 | &buf[client->msg_pos], | 522 | &buf[client->msg_pos], |
520 | left); | 523 | left); |
521 | GNUNET_assert (ret <= (ssize_t) left); | 524 | GNUNET_assert (ret <= (ssize_t) left); |
522 | if (0 == ret) | 525 | if (0 == ret) |
523 | { | 526 | { |
524 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 527 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
525 | "no data send"); | 528 | "no data send"); |
526 | GNUNET_MQ_inject_error (client->mq, | 529 | GNUNET_MQ_inject_error (client->mq, |
527 | GNUNET_MQ_ERROR_WRITE); | 530 | GNUNET_MQ_ERROR_WRITE); |
528 | return; | 531 | return; |
529 | } | 532 | } |
530 | if (-1 == ret) | 533 | if (-1 == ret) |
531 | { | 534 | { |
532 | if ( (EAGAIN == errno) || | 535 | if ( (EAGAIN == errno) || |
533 | (EINTR == errno) ) | 536 | (EINTR == errno) ) |
534 | { | 537 | { |
535 | /* ignore */ | 538 | /* ignore */ |
536 | ret = 0; | 539 | ret = 0; |
@@ -544,7 +547,7 @@ do_send (void *cls) | |||
544 | "socket send returned with error code %i", | 547 | "socket send returned with error code %i", |
545 | errno); | 548 | errno); |
546 | GNUNET_MQ_inject_error (client->mq, | 549 | GNUNET_MQ_inject_error (client->mq, |
547 | GNUNET_MQ_ERROR_WRITE); | 550 | GNUNET_MQ_ERROR_WRITE); |
548 | return; | 551 | return; |
549 | } | 552 | } |
550 | } | 553 | } |
@@ -558,9 +561,9 @@ do_send (void *cls) | |||
558 | GNUNET_assert (NULL == client->drop_task); | 561 | GNUNET_assert (NULL == client->drop_task); |
559 | client->send_task | 562 | client->send_task |
560 | = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, | 563 | = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, |
561 | client->sock, | 564 | client->sock, |
562 | &do_send, | 565 | &do_send, |
563 | client); | 566 | client); |
564 | return; | 567 | return; |
565 | } | 568 | } |
566 | GNUNET_MQ_impl_send_continue (client->mq); | 569 | GNUNET_MQ_impl_send_continue (client->mq); |
@@ -594,9 +597,9 @@ service_mq_send (struct GNUNET_MQ_Handle *mq, | |||
594 | client->msg_pos = 0; | 597 | client->msg_pos = 0; |
595 | client->send_task | 598 | client->send_task |
596 | = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, | 599 | = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, |
597 | client->sock, | 600 | client->sock, |
598 | &do_send, | 601 | &do_send, |
599 | client); | 602 | client); |
600 | } | 603 | } |
601 | 604 | ||
602 | 605 | ||
@@ -663,12 +666,14 @@ warn_no_client_continue (void *cls) | |||
663 | client->warn_task | 666 | client->warn_task |
664 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 667 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
665 | &warn_no_client_continue, | 668 | &warn_no_client_continue, |
666 | client); | 669 | client); |
667 | LOG (GNUNET_ERROR_TYPE_WARNING, | 670 | LOG (GNUNET_ERROR_TYPE_WARNING, |
668 | _("Processing code for message of type %u did not call `GNUNET_SERVICE_client_continue' after %s\n"), | 671 | _ ( |
672 | "Processing code for message of type %u did not call `GNUNET_SERVICE_client_continue' after %s\n"), | ||
669 | (unsigned int) client->warn_type, | 673 | (unsigned int) client->warn_type, |
670 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (client->warn_start), | 674 | GNUNET_STRINGS_relative_time_to_string ( |
671 | GNUNET_YES)); | 675 | GNUNET_TIME_absolute_get_duration (client->warn_start), |
676 | GNUNET_YES)); | ||
672 | } | 677 | } |
673 | 678 | ||
674 | 679 | ||
@@ -700,8 +705,8 @@ service_client_mst_cb (void *cls, | |||
700 | GNUNET_assert (NULL == client->warn_task); | 705 | GNUNET_assert (NULL == client->warn_task); |
701 | client->warn_task | 706 | client->warn_task |
702 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 707 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
703 | &warn_no_client_continue, | 708 | &warn_no_client_continue, |
704 | client); | 709 | client); |
705 | GNUNET_MQ_inject_message (client->mq, | 710 | GNUNET_MQ_inject_message (client->mq, |
706 | message); | 711 | message); |
707 | if (NULL != client->drop_task) | 712 | if (NULL != client->drop_task) |
@@ -724,9 +729,9 @@ service_client_recv (void *cls) | |||
724 | 729 | ||
725 | client->recv_task = NULL; | 730 | client->recv_task = NULL; |
726 | ret = GNUNET_MST_read (client->mst, | 731 | ret = GNUNET_MST_read (client->mst, |
727 | client->sock, | 732 | client->sock, |
728 | GNUNET_NO, | 733 | GNUNET_NO, |
729 | GNUNET_YES); | 734 | GNUNET_YES); |
730 | if (GNUNET_SYSERR == ret) | 735 | if (GNUNET_SYSERR == ret) |
731 | { | 736 | { |
732 | /* client closed connection (or IO error) */ | 737 | /* client closed connection (or IO error) */ |
@@ -739,7 +744,7 @@ service_client_recv (void *cls) | |||
739 | } | 744 | } |
740 | if (GNUNET_NO == ret) | 745 | if (GNUNET_NO == ret) |
741 | return; /* more messages in buffer, wait for application | 746 | return; /* more messages in buffer, wait for application |
742 | to be done processing */ | 747 | to be done processing */ |
743 | GNUNET_assert (GNUNET_OK == ret); | 748 | GNUNET_assert (GNUNET_OK == ret); |
744 | if (GNUNET_YES == client->needs_continue) | 749 | if (GNUNET_YES == client->needs_continue) |
745 | return; | 750 | return; |
@@ -748,9 +753,9 @@ service_client_recv (void *cls) | |||
748 | /* MST needs more data, re-schedule read job */ | 753 | /* MST needs more data, re-schedule read job */ |
749 | client->recv_task | 754 | client->recv_task |
750 | = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 755 | = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
751 | client->sock, | 756 | client->sock, |
752 | &service_client_recv, | 757 | &service_client_recv, |
753 | client); | 758 | client); |
754 | } | 759 | } |
755 | 760 | ||
756 | 761 | ||
@@ -781,7 +786,7 @@ start_client (struct GNUNET_SERVICE_Handle *sh, | |||
781 | &service_mq_error_handler, | 786 | &service_mq_error_handler, |
782 | client); | 787 | client); |
783 | client->mst = GNUNET_MST_create (&service_client_mst_cb, | 788 | client->mst = GNUNET_MST_create (&service_client_mst_cb, |
784 | client); | 789 | client); |
785 | if (NULL != sh->connect_cb) | 790 | if (NULL != sh->connect_cb) |
786 | client->user_context = sh->connect_cb (sh->cb_cls, | 791 | client->user_context = sh->connect_cb (sh->cb_cls, |
787 | client, | 792 | client, |
@@ -790,9 +795,9 @@ start_client (struct GNUNET_SERVICE_Handle *sh, | |||
790 | client->user_context); | 795 | client->user_context); |
791 | client->recv_task | 796 | client->recv_task |
792 | = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 797 | = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
793 | client->sock, | 798 | client->sock, |
794 | &service_client_recv, | 799 | &service_client_recv, |
795 | client); | 800 | client); |
796 | } | 801 | } |
797 | 802 | ||
798 | 803 | ||
@@ -820,8 +825,8 @@ accept_client (void *cls) | |||
820 | 825 | ||
821 | addrlen = sizeof (sa); | 826 | addrlen = sizeof (sa); |
822 | sock = GNUNET_NETWORK_socket_accept (slc->listen_socket, | 827 | sock = GNUNET_NETWORK_socket_accept (slc->listen_socket, |
823 | (struct sockaddr *) &sa, | 828 | (struct sockaddr *) &sa, |
824 | &addrlen); | 829 | &addrlen); |
825 | if (NULL == sock) | 830 | if (NULL == sock) |
826 | { | 831 | { |
827 | if (EMFILE == errno) | 832 | if (EMFILE == errno) |
@@ -838,21 +843,21 @@ accept_client (void *cls) | |||
838 | GNUNET_assert (addrlen == sizeof (struct sockaddr_in)); | 843 | GNUNET_assert (addrlen == sizeof (struct sockaddr_in)); |
839 | v4 = (const struct sockaddr_in *) &sa; | 844 | v4 = (const struct sockaddr_in *) &sa; |
840 | ok = ( ( (NULL == sh->v4_allowed) || | 845 | ok = ( ( (NULL == sh->v4_allowed) || |
841 | (check_ipv4_listed (sh->v4_allowed, | 846 | (check_ipv4_listed (sh->v4_allowed, |
842 | &v4->sin_addr))) && | 847 | &v4->sin_addr))) && |
843 | ( (NULL == sh->v4_denied) || | 848 | ( (NULL == sh->v4_denied) || |
844 | (! check_ipv4_listed (sh->v4_denied, | 849 | (! check_ipv4_listed (sh->v4_denied, |
845 | &v4->sin_addr)) ) ); | 850 | &v4->sin_addr)) ) ); |
846 | break; | 851 | break; |
847 | case AF_INET6: | 852 | case AF_INET6: |
848 | GNUNET_assert (addrlen == sizeof (struct sockaddr_in6)); | 853 | GNUNET_assert (addrlen == sizeof (struct sockaddr_in6)); |
849 | v6 = (const struct sockaddr_in6 *) &sa; | 854 | v6 = (const struct sockaddr_in6 *) &sa; |
850 | ok = ( ( (NULL == sh->v6_allowed) || | 855 | ok = ( ( (NULL == sh->v6_allowed) || |
851 | (check_ipv6_listed (sh->v6_allowed, | 856 | (check_ipv6_listed (sh->v6_allowed, |
852 | &v6->sin6_addr))) && | 857 | &v6->sin6_addr))) && |
853 | ( (NULL == sh->v6_denied) || | 858 | ( (NULL == sh->v6_denied) || |
854 | (! check_ipv6_listed (sh->v6_denied, | 859 | (! check_ipv6_listed (sh->v6_denied, |
855 | &v6->sin6_addr)) ) ); | 860 | &v6->sin6_addr)) ) ); |
856 | break; | 861 | break; |
857 | #ifndef WINDOWS | 862 | #ifndef WINDOWS |
858 | case AF_UNIX: | 863 | case AF_UNIX: |
@@ -861,34 +866,34 @@ accept_client (void *cls) | |||
861 | #endif | 866 | #endif |
862 | default: | 867 | default: |
863 | LOG (GNUNET_ERROR_TYPE_WARNING, | 868 | LOG (GNUNET_ERROR_TYPE_WARNING, |
864 | _("Unknown address family %d\n"), | 869 | _ ("Unknown address family %d\n"), |
865 | sa.ss_family); | 870 | sa.ss_family); |
866 | return; | 871 | return; |
867 | } | 872 | } |
868 | if (! ok) | 873 | if (! ok) |
869 | { | 874 | { |
870 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 875 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
871 | "Service rejected incoming connection from %s due to policy.\n", | 876 | "Service rejected incoming connection from %s due to policy.\n", |
872 | GNUNET_a2s ((const struct sockaddr *) &sa, | 877 | GNUNET_a2s ((const struct sockaddr *) &sa, |
873 | addrlen)); | 878 | addrlen)); |
874 | GNUNET_break (GNUNET_OK == | 879 | GNUNET_break (GNUNET_OK == |
875 | GNUNET_NETWORK_socket_close (sock)); | 880 | GNUNET_NETWORK_socket_close (sock)); |
876 | continue; | 881 | continue; |
877 | } | 882 | } |
878 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 883 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
879 | "Service accepted incoming connection from %s.\n", | 884 | "Service accepted incoming connection from %s.\n", |
880 | GNUNET_a2s ((const struct sockaddr *) &sa, | 885 | GNUNET_a2s ((const struct sockaddr *) &sa, |
881 | addrlen)); | 886 | addrlen)); |
882 | start_client (slc->sh, | 887 | start_client (slc->sh, |
883 | sock); | 888 | sock); |
884 | } | 889 | } |
885 | if (0 != sh->suspend_state) | 890 | if (0 != sh->suspend_state) |
886 | return; | 891 | return; |
887 | slc->listen_task | 892 | slc->listen_task |
888 | = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 893 | = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
889 | slc->listen_socket, | 894 | slc->listen_socket, |
890 | &accept_client, | 895 | &accept_client, |
891 | slc); | 896 | slc); |
892 | } | 897 | } |
893 | 898 | ||
894 | 899 | ||
@@ -915,9 +920,9 @@ do_resume (struct GNUNET_SERVICE_Handle *sh, | |||
915 | GNUNET_assert (NULL == slc->listen_task); | 920 | GNUNET_assert (NULL == slc->listen_task); |
916 | slc->listen_task | 921 | slc->listen_task |
917 | = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 922 | = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
918 | slc->listen_socket, | 923 | slc->listen_socket, |
919 | &accept_client, | 924 | &accept_client, |
920 | slc); | 925 | slc); |
921 | } | 926 | } |
922 | } | 927 | } |
923 | 928 | ||
@@ -949,8 +954,8 @@ service_main (void *cls) | |||
949 | 954 | ||
950 | if (NULL != sh->service_init_cb) | 955 | if (NULL != sh->service_init_cb) |
951 | sh->service_init_cb (sh->cb_cls, | 956 | sh->service_init_cb (sh->cb_cls, |
952 | sh->cfg, | 957 | sh->cfg, |
953 | sh); | 958 | sh); |
954 | } | 959 | } |
955 | 960 | ||
956 | 961 | ||
@@ -971,8 +976,8 @@ process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret, | |||
971 | char *opt; | 976 | char *opt; |
972 | 977 | ||
973 | if (! GNUNET_CONFIGURATION_have_value (sh->cfg, | 978 | if (! GNUNET_CONFIGURATION_have_value (sh->cfg, |
974 | sh->service_name, | 979 | sh->service_name, |
975 | option)) | 980 | option)) |
976 | { | 981 | { |
977 | *ret = NULL; | 982 | *ret = NULL; |
978 | return GNUNET_OK; | 983 | return GNUNET_OK; |
@@ -981,14 +986,14 @@ process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret, | |||
981 | GNUNET_CONFIGURATION_get_value_string (sh->cfg, | 986 | GNUNET_CONFIGURATION_get_value_string (sh->cfg, |
982 | sh->service_name, | 987 | sh->service_name, |
983 | option, | 988 | option, |
984 | &opt)); | 989 | &opt)); |
985 | if (NULL == (*ret = GNUNET_STRINGS_parse_ipv4_policy (opt))) | 990 | if (NULL == (*ret = GNUNET_STRINGS_parse_ipv4_policy (opt))) |
986 | { | 991 | { |
987 | LOG (GNUNET_ERROR_TYPE_WARNING, | 992 | LOG (GNUNET_ERROR_TYPE_WARNING, |
988 | _("Could not parse IPv4 network specification `%s' for `%s:%s'\n"), | 993 | _ ("Could not parse IPv4 network specification `%s' for `%s:%s'\n"), |
989 | opt, | 994 | opt, |
990 | sh->service_name, | 995 | sh->service_name, |
991 | option); | 996 | option); |
992 | GNUNET_free (opt); | 997 | GNUNET_free (opt); |
993 | return GNUNET_SYSERR; | 998 | return GNUNET_SYSERR; |
994 | } | 999 | } |
@@ -1014,8 +1019,8 @@ process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret, | |||
1014 | char *opt; | 1019 | char *opt; |
1015 | 1020 | ||
1016 | if (! GNUNET_CONFIGURATION_have_value (sh->cfg, | 1021 | if (! GNUNET_CONFIGURATION_have_value (sh->cfg, |
1017 | sh->service_name, | 1022 | sh->service_name, |
1018 | option)) | 1023 | option)) |
1019 | { | 1024 | { |
1020 | *ret = NULL; | 1025 | *ret = NULL; |
1021 | return GNUNET_OK; | 1026 | return GNUNET_OK; |
@@ -1024,14 +1029,14 @@ process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret, | |||
1024 | GNUNET_CONFIGURATION_get_value_string (sh->cfg, | 1029 | GNUNET_CONFIGURATION_get_value_string (sh->cfg, |
1025 | sh->service_name, | 1030 | sh->service_name, |
1026 | option, | 1031 | option, |
1027 | &opt)); | 1032 | &opt)); |
1028 | if (NULL == (*ret = GNUNET_STRINGS_parse_ipv6_policy (opt))) | 1033 | if (NULL == (*ret = GNUNET_STRINGS_parse_ipv6_policy (opt))) |
1029 | { | 1034 | { |
1030 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1035 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1031 | _("Could not parse IPv6 network specification `%s' for `%s:%s'\n"), | 1036 | _ ("Could not parse IPv6 network specification `%s' for `%s:%s'\n"), |
1032 | opt, | 1037 | opt, |
1033 | sh->service_name, | 1038 | sh->service_name, |
1034 | option); | 1039 | option); |
1035 | GNUNET_free (opt); | 1040 | GNUNET_free (opt); |
1036 | return GNUNET_SYSERR; | 1041 | return GNUNET_SYSERR; |
1037 | } | 1042 | } |
@@ -1062,8 +1067,8 @@ add_unixpath (struct sockaddr **saddrs, | |||
1062 | un = GNUNET_new (struct sockaddr_un); | 1067 | un = GNUNET_new (struct sockaddr_un); |
1063 | un->sun_family = AF_UNIX; | 1068 | un->sun_family = AF_UNIX; |
1064 | GNUNET_strlcpy (un->sun_path, | 1069 | GNUNET_strlcpy (un->sun_path, |
1065 | unixpath, | 1070 | unixpath, |
1066 | sizeof (un->sun_path)); | 1071 | sizeof (un->sun_path)); |
1067 | #ifdef LINUX | 1072 | #ifdef LINUX |
1068 | if (GNUNET_YES == abstract) | 1073 | if (GNUNET_YES == abstract) |
1069 | un->sun_path[0] = '\0'; | 1074 | un->sun_path[0] = '\0'; |
@@ -1103,9 +1108,9 @@ add_unixpath (struct sockaddr **saddrs, | |||
1103 | */ | 1108 | */ |
1104 | static int | 1109 | static int |
1105 | get_server_addresses (const char *service_name, | 1110 | get_server_addresses (const char *service_name, |
1106 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1111 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1107 | struct sockaddr ***addrs, | 1112 | struct sockaddr ***addrs, |
1108 | socklen_t **addr_lens) | 1113 | socklen_t **addr_lens) |
1109 | { | 1114 | { |
1110 | int disablev6; | 1115 | int disablev6; |
1111 | struct GNUNET_NETWORK_Handle *desc; | 1116 | struct GNUNET_NETWORK_Handle *desc; |
@@ -1128,46 +1133,46 @@ get_server_addresses (const char *service_name, | |||
1128 | desc = NULL; | 1133 | desc = NULL; |
1129 | disablev6 = GNUNET_NO; | 1134 | disablev6 = GNUNET_NO; |
1130 | if ( (GNUNET_NO == | 1135 | if ( (GNUNET_NO == |
1131 | GNUNET_NETWORK_test_pf (PF_INET6)) || | 1136 | GNUNET_NETWORK_test_pf (PF_INET6)) || |
1132 | (GNUNET_YES == | 1137 | (GNUNET_YES == |
1133 | GNUNET_CONFIGURATION_get_value_yesno (cfg, | 1138 | GNUNET_CONFIGURATION_get_value_yesno (cfg, |
1134 | service_name, | 1139 | service_name, |
1135 | "DISABLEV6") ) ) | 1140 | "DISABLEV6") ) ) |
1136 | disablev6 = GNUNET_YES; | 1141 | disablev6 = GNUNET_YES; |
1137 | 1142 | ||
1138 | port = 0; | 1143 | port = 0; |
1139 | if (GNUNET_CONFIGURATION_have_value (cfg, | 1144 | if (GNUNET_CONFIGURATION_have_value (cfg, |
1140 | service_name, | 1145 | service_name, |
1141 | "PORT")) | 1146 | "PORT")) |
1142 | { | 1147 | { |
1143 | if (GNUNET_OK != | 1148 | if (GNUNET_OK != |
1144 | GNUNET_CONFIGURATION_get_value_number (cfg, | 1149 | GNUNET_CONFIGURATION_get_value_number (cfg, |
1145 | service_name, | 1150 | service_name, |
1146 | "PORT", | 1151 | "PORT", |
1147 | &port)) | 1152 | &port)) |
1148 | { | 1153 | { |
1149 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1154 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1150 | _("Require valid port number for service `%s' in configuration!\n"), | 1155 | _ ("Require valid port number for service `%s' in configuration!\n"), |
1151 | service_name); | 1156 | service_name); |
1152 | } | 1157 | } |
1153 | if (port > 65535) | 1158 | if (port > 65535) |
1154 | { | 1159 | { |
1155 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1160 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1156 | _("Require valid port number for service `%s' in configuration!\n"), | 1161 | _ ("Require valid port number for service `%s' in configuration!\n"), |
1157 | service_name); | 1162 | service_name); |
1158 | return GNUNET_SYSERR; | 1163 | return GNUNET_SYSERR; |
1159 | } | 1164 | } |
1160 | } | 1165 | } |
1161 | 1166 | ||
1162 | if (GNUNET_CONFIGURATION_have_value (cfg, | 1167 | if (GNUNET_CONFIGURATION_have_value (cfg, |
1163 | service_name, | 1168 | service_name, |
1164 | "BINDTO")) | 1169 | "BINDTO")) |
1165 | { | 1170 | { |
1166 | GNUNET_break (GNUNET_OK == | 1171 | GNUNET_break (GNUNET_OK == |
1167 | GNUNET_CONFIGURATION_get_value_string (cfg, | 1172 | GNUNET_CONFIGURATION_get_value_string (cfg, |
1168 | service_name, | 1173 | service_name, |
1169 | "BINDTO", | 1174 | "BINDTO", |
1170 | &hostname)); | 1175 | &hostname)); |
1171 | } | 1176 | } |
1172 | else | 1177 | else |
1173 | hostname = NULL; | 1178 | hostname = NULL; |
@@ -1177,13 +1182,13 @@ get_server_addresses (const char *service_name, | |||
1177 | #ifdef AF_UNIX | 1182 | #ifdef AF_UNIX |
1178 | if ((GNUNET_YES == | 1183 | if ((GNUNET_YES == |
1179 | GNUNET_CONFIGURATION_have_value (cfg, | 1184 | GNUNET_CONFIGURATION_have_value (cfg, |
1180 | service_name, | 1185 | service_name, |
1181 | "UNIXPATH")) && | 1186 | "UNIXPATH")) && |
1182 | (GNUNET_OK == | 1187 | (GNUNET_OK == |
1183 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 1188 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
1184 | service_name, | 1189 | service_name, |
1185 | "UNIXPATH", | 1190 | "UNIXPATH", |
1186 | &unixpath)) && | 1191 | &unixpath)) && |
1187 | (0 < strlen (unixpath))) | 1192 | (0 < strlen (unixpath))) |
1188 | { | 1193 | { |
1189 | /* probe UNIX support */ | 1194 | /* probe UNIX support */ |
@@ -1192,12 +1197,12 @@ get_server_addresses (const char *service_name, | |||
1192 | if (strlen (unixpath) >= sizeof (s_un.sun_path)) | 1197 | if (strlen (unixpath) >= sizeof (s_un.sun_path)) |
1193 | { | 1198 | { |
1194 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1199 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1195 | _("UNIXPATH `%s' too long, maximum length is %llu\n"), | 1200 | _ ("UNIXPATH `%s' too long, maximum length is %llu\n"), |
1196 | unixpath, | 1201 | unixpath, |
1197 | (unsigned long long) sizeof (s_un.sun_path)); | 1202 | (unsigned long long) sizeof (s_un.sun_path)); |
1198 | unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath); | 1203 | unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath); |
1199 | LOG (GNUNET_ERROR_TYPE_INFO, | 1204 | LOG (GNUNET_ERROR_TYPE_INFO, |
1200 | _("Using `%s' instead\n"), | 1205 | _ ("Using `%s' instead\n"), |
1201 | unixpath); | 1206 | unixpath); |
1202 | } | 1207 | } |
1203 | #ifdef LINUX | 1208 | #ifdef LINUX |
@@ -1208,32 +1213,33 @@ get_server_addresses (const char *service_name, | |||
1208 | abstract = GNUNET_NO; | 1213 | abstract = GNUNET_NO; |
1209 | #endif | 1214 | #endif |
1210 | if ( (GNUNET_YES != abstract) && | 1215 | if ( (GNUNET_YES != abstract) && |
1211 | (GNUNET_OK != | 1216 | (GNUNET_OK != |
1212 | GNUNET_DISK_directory_create_for_file (unixpath)) ) | 1217 | GNUNET_DISK_directory_create_for_file (unixpath)) ) |
1213 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | 1218 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, |
1214 | "mkdir", | 1219 | "mkdir", |
1215 | unixpath); | 1220 | unixpath); |
1216 | } | 1221 | } |
1217 | if (NULL != unixpath) | 1222 | if (NULL != unixpath) |
1218 | { | 1223 | { |
1219 | desc = GNUNET_NETWORK_socket_create (AF_UNIX, | 1224 | desc = GNUNET_NETWORK_socket_create (AF_UNIX, |
1220 | SOCK_STREAM, | 1225 | SOCK_STREAM, |
1221 | 0); | 1226 | 0); |
1222 | if (NULL == desc) | 1227 | if (NULL == desc) |
1223 | { | 1228 | { |
1224 | if ((ENOBUFS == errno) || | 1229 | if ((ENOBUFS == errno) || |
1225 | (ENOMEM == errno) || | 1230 | (ENOMEM == errno) || |
1226 | (ENFILE == errno) || | 1231 | (ENFILE == errno) || |
1227 | (EACCES == errno)) | 1232 | (EACCES == errno)) |
1228 | { | 1233 | { |
1229 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, | 1234 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, |
1230 | "socket"); | 1235 | "socket"); |
1231 | GNUNET_free_non_null (hostname); | 1236 | GNUNET_free_non_null (hostname); |
1232 | GNUNET_free (unixpath); | 1237 | GNUNET_free (unixpath); |
1233 | return GNUNET_SYSERR; | 1238 | return GNUNET_SYSERR; |
1234 | } | 1239 | } |
1235 | LOG (GNUNET_ERROR_TYPE_INFO, | 1240 | LOG (GNUNET_ERROR_TYPE_INFO, |
1236 | _("Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"), | 1241 | _ ( |
1242 | "Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"), | ||
1237 | service_name, | 1243 | service_name, |
1238 | STRERROR (errno)); | 1244 | STRERROR (errno)); |
1239 | GNUNET_free (unixpath); | 1245 | GNUNET_free (unixpath); |
@@ -1242,7 +1248,7 @@ get_server_addresses (const char *service_name, | |||
1242 | else | 1248 | else |
1243 | { | 1249 | { |
1244 | GNUNET_break (GNUNET_OK == | 1250 | GNUNET_break (GNUNET_OK == |
1245 | GNUNET_NETWORK_socket_close (desc)); | 1251 | GNUNET_NETWORK_socket_close (desc)); |
1246 | desc = NULL; | 1252 | desc = NULL; |
1247 | } | 1253 | } |
1248 | } | 1254 | } |
@@ -1251,7 +1257,8 @@ get_server_addresses (const char *service_name, | |||
1251 | if ((0 == port) && (NULL == unixpath)) | 1257 | if ((0 == port) && (NULL == unixpath)) |
1252 | { | 1258 | { |
1253 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1259 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1254 | _("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"), | 1260 | _ ( |
1261 | "Have neither PORT nor UNIXPATH for service `%s', but one is required\n"), | ||
1255 | service_name); | 1262 | service_name); |
1256 | GNUNET_free_non_null (hostname); | 1263 | GNUNET_free_non_null (hostname); |
1257 | return GNUNET_SYSERR; | 1264 | return GNUNET_SYSERR; |
@@ -1259,13 +1266,13 @@ get_server_addresses (const char *service_name, | |||
1259 | if (0 == port) | 1266 | if (0 == port) |
1260 | { | 1267 | { |
1261 | saddrs = GNUNET_new_array (2, | 1268 | saddrs = GNUNET_new_array (2, |
1262 | struct sockaddr *); | 1269 | struct sockaddr *); |
1263 | saddrlens = GNUNET_new_array (2, | 1270 | saddrlens = GNUNET_new_array (2, |
1264 | socklen_t); | 1271 | socklen_t); |
1265 | add_unixpath (saddrs, | 1272 | add_unixpath (saddrs, |
1266 | saddrlens, | 1273 | saddrlens, |
1267 | unixpath, | 1274 | unixpath, |
1268 | abstract); | 1275 | abstract); |
1269 | GNUNET_free_non_null (unixpath); | 1276 | GNUNET_free_non_null (unixpath); |
1270 | GNUNET_free_non_null (hostname); | 1277 | GNUNET_free_non_null (hostname); |
1271 | *addrs = saddrs; | 1278 | *addrs = saddrs; |
@@ -1280,19 +1287,19 @@ get_server_addresses (const char *service_name, | |||
1280 | hostname, | 1287 | hostname, |
1281 | service_name); | 1288 | service_name); |
1282 | memset (&hints, | 1289 | memset (&hints, |
1283 | 0, | 1290 | 0, |
1284 | sizeof (struct addrinfo)); | 1291 | sizeof (struct addrinfo)); |
1285 | if (disablev6) | 1292 | if (disablev6) |
1286 | hints.ai_family = AF_INET; | 1293 | hints.ai_family = AF_INET; |
1287 | hints.ai_protocol = IPPROTO_TCP; | 1294 | hints.ai_protocol = IPPROTO_TCP; |
1288 | if ((0 != (ret = getaddrinfo (hostname, | 1295 | if ((0 != (ret = getaddrinfo (hostname, |
1289 | NULL, | 1296 | NULL, |
1290 | &hints, | 1297 | &hints, |
1291 | &res))) || | 1298 | &res))) || |
1292 | (NULL == res)) | 1299 | (NULL == res)) |
1293 | { | 1300 | { |
1294 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1301 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1295 | _("Failed to resolve `%s': %s\n"), | 1302 | _ ("Failed to resolve `%s': %s\n"), |
1296 | hostname, | 1303 | hostname, |
1297 | gai_strerror (ret)); | 1304 | gai_strerror (ret)); |
1298 | GNUNET_free (hostname); | 1305 | GNUNET_free (hostname); |
@@ -1305,14 +1312,14 @@ get_server_addresses (const char *service_name, | |||
1305 | { | 1312 | { |
1306 | next = pos->ai_next; | 1313 | next = pos->ai_next; |
1307 | if ( (disablev6) && | 1314 | if ( (disablev6) && |
1308 | (pos->ai_family == AF_INET6) ) | 1315 | (pos->ai_family == AF_INET6) ) |
1309 | continue; | 1316 | continue; |
1310 | i++; | 1317 | i++; |
1311 | } | 1318 | } |
1312 | if (0 == i) | 1319 | if (0 == i) |
1313 | { | 1320 | { |
1314 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1321 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1315 | _("Failed to find %saddress for `%s'.\n"), | 1322 | _ ("Failed to find %saddress for `%s'.\n"), |
1316 | disablev6 ? "IPv4 " : "", | 1323 | disablev6 ? "IPv4 " : "", |
1317 | hostname); | 1324 | hostname); |
1318 | freeaddrinfo (res); | 1325 | freeaddrinfo (res); |
@@ -1324,16 +1331,16 @@ get_server_addresses (const char *service_name, | |||
1324 | if (NULL != unixpath) | 1331 | if (NULL != unixpath) |
1325 | resi++; | 1332 | resi++; |
1326 | saddrs = GNUNET_new_array (resi + 1, | 1333 | saddrs = GNUNET_new_array (resi + 1, |
1327 | struct sockaddr *); | 1334 | struct sockaddr *); |
1328 | saddrlens = GNUNET_new_array (resi + 1, | 1335 | saddrlens = GNUNET_new_array (resi + 1, |
1329 | socklen_t); | 1336 | socklen_t); |
1330 | i = 0; | 1337 | i = 0; |
1331 | if (NULL != unixpath) | 1338 | if (NULL != unixpath) |
1332 | { | 1339 | { |
1333 | add_unixpath (saddrs, | 1340 | add_unixpath (saddrs, |
1334 | saddrlens, | 1341 | saddrlens, |
1335 | unixpath, | 1342 | unixpath, |
1336 | abstract); | 1343 | abstract); |
1337 | i++; | 1344 | i++; |
1338 | } | 1345 | } |
1339 | next = res; | 1346 | next = res; |
@@ -1341,27 +1348,27 @@ get_server_addresses (const char *service_name, | |||
1341 | { | 1348 | { |
1342 | next = pos->ai_next; | 1349 | next = pos->ai_next; |
1343 | if ( (disablev6) && | 1350 | if ( (disablev6) && |
1344 | (AF_INET6 == pos->ai_family) ) | 1351 | (AF_INET6 == pos->ai_family) ) |
1345 | continue; | 1352 | continue; |
1346 | if ( (IPPROTO_TCP != pos->ai_protocol) && | 1353 | if ( (IPPROTO_TCP != pos->ai_protocol) && |
1347 | (0 != pos->ai_protocol) ) | 1354 | (0 != pos->ai_protocol) ) |
1348 | continue; /* not TCP */ | 1355 | continue; /* not TCP */ |
1349 | if ( (SOCK_STREAM != pos->ai_socktype) && | 1356 | if ( (SOCK_STREAM != pos->ai_socktype) && |
1350 | (0 != pos->ai_socktype) ) | 1357 | (0 != pos->ai_socktype) ) |
1351 | continue; /* huh? */ | 1358 | continue; /* huh? */ |
1352 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1359 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1353 | "Service `%s' will bind to `%s'\n", | 1360 | "Service `%s' will bind to `%s'\n", |
1354 | service_name, | 1361 | service_name, |
1355 | GNUNET_a2s (pos->ai_addr, | 1362 | GNUNET_a2s (pos->ai_addr, |
1356 | pos->ai_addrlen)); | 1363 | pos->ai_addrlen)); |
1357 | if (AF_INET == pos->ai_family) | 1364 | if (AF_INET == pos->ai_family) |
1358 | { | 1365 | { |
1359 | GNUNET_assert (sizeof (struct sockaddr_in) == pos->ai_addrlen); | 1366 | GNUNET_assert (sizeof (struct sockaddr_in) == pos->ai_addrlen); |
1360 | saddrlens[i] = pos->ai_addrlen; | 1367 | saddrlens[i] = pos->ai_addrlen; |
1361 | saddrs[i] = GNUNET_malloc (saddrlens[i]); | 1368 | saddrs[i] = GNUNET_malloc (saddrlens[i]); |
1362 | GNUNET_memcpy (saddrs[i], | 1369 | GNUNET_memcpy (saddrs[i], |
1363 | pos->ai_addr, | 1370 | pos->ai_addr, |
1364 | saddrlens[i]); | 1371 | saddrlens[i]); |
1365 | ((struct sockaddr_in *) saddrs[i])->sin_port = htons (port); | 1372 | ((struct sockaddr_in *) saddrs[i])->sin_port = htons (port); |
1366 | } | 1373 | } |
1367 | else | 1374 | else |
@@ -1371,8 +1378,8 @@ get_server_addresses (const char *service_name, | |||
1371 | saddrlens[i] = pos->ai_addrlen; | 1378 | saddrlens[i] = pos->ai_addrlen; |
1372 | saddrs[i] = GNUNET_malloc (saddrlens[i]); | 1379 | saddrs[i] = GNUNET_malloc (saddrlens[i]); |
1373 | GNUNET_memcpy (saddrs[i], | 1380 | GNUNET_memcpy (saddrs[i], |
1374 | pos->ai_addr, | 1381 | pos->ai_addr, |
1375 | saddrlens[i]); | 1382 | saddrlens[i]); |
1376 | ((struct sockaddr_in6 *) saddrs[i])->sin6_port = htons (port); | 1383 | ((struct sockaddr_in6 *) saddrs[i])->sin6_port = htons (port); |
1377 | } | 1384 | } |
1378 | i++; | 1385 | i++; |
@@ -1392,15 +1399,15 @@ get_server_addresses (const char *service_name, | |||
1392 | resi++; | 1399 | resi++; |
1393 | i = 0; | 1400 | i = 0; |
1394 | saddrs = GNUNET_new_array (resi + 1, | 1401 | saddrs = GNUNET_new_array (resi + 1, |
1395 | struct sockaddr *); | 1402 | struct sockaddr *); |
1396 | saddrlens = GNUNET_new_array (resi + 1, | 1403 | saddrlens = GNUNET_new_array (resi + 1, |
1397 | socklen_t); | 1404 | socklen_t); |
1398 | if (NULL != unixpath) | 1405 | if (NULL != unixpath) |
1399 | { | 1406 | { |
1400 | add_unixpath (saddrs, | 1407 | add_unixpath (saddrs, |
1401 | saddrlens, | 1408 | saddrlens, |
1402 | unixpath, | 1409 | unixpath, |
1403 | abstract); | 1410 | abstract); |
1404 | i++; | 1411 | i++; |
1405 | } | 1412 | } |
1406 | saddrlens[i] = sizeof (struct sockaddr_in); | 1413 | saddrlens[i] = sizeof (struct sockaddr_in); |
@@ -1418,16 +1425,16 @@ get_server_addresses (const char *service_name, | |||
1418 | if (NULL != unixpath) | 1425 | if (NULL != unixpath) |
1419 | resi++; | 1426 | resi++; |
1420 | saddrs = GNUNET_new_array (resi + 1, | 1427 | saddrs = GNUNET_new_array (resi + 1, |
1421 | struct sockaddr *); | 1428 | struct sockaddr *); |
1422 | saddrlens = GNUNET_new_array (resi + 1, | 1429 | saddrlens = GNUNET_new_array (resi + 1, |
1423 | socklen_t); | 1430 | socklen_t); |
1424 | i = 0; | 1431 | i = 0; |
1425 | if (NULL != unixpath) | 1432 | if (NULL != unixpath) |
1426 | { | 1433 | { |
1427 | add_unixpath (saddrs, | 1434 | add_unixpath (saddrs, |
1428 | saddrlens, | 1435 | saddrlens, |
1429 | unixpath, | 1436 | unixpath, |
1430 | abstract); | 1437 | abstract); |
1431 | i++; | 1438 | i++; |
1432 | } | 1439 | } |
1433 | saddrlens[i] = sizeof (struct sockaddr_in6); | 1440 | saddrlens[i] = sizeof (struct sockaddr_in6); |
@@ -1481,8 +1488,8 @@ receive_sockets_from_parent (struct GNUNET_SERVICE_Handle *sh) | |||
1481 | * to create a GNUnet API that boxes a HANDLE (the way it is done with socks) | 1488 | * to create a GNUnet API that boxes a HANDLE (the way it is done with socks) |
1482 | */ | 1489 | */ |
1483 | lsocks_pipe = (HANDLE) strtoul (env_buf, | 1490 | lsocks_pipe = (HANDLE) strtoul (env_buf, |
1484 | NULL, | 1491 | NULL, |
1485 | 10); | 1492 | 10); |
1486 | if ( (0 == lsocks_pipe) || | 1493 | if ( (0 == lsocks_pipe) || |
1487 | (INVALID_HANDLE_VALUE == lsocks_pipe)) | 1494 | (INVALID_HANDLE_VALUE == lsocks_pipe)) |
1488 | return NULL; | 1495 | return NULL; |
@@ -1494,16 +1501,16 @@ receive_sockets_from_parent (struct GNUNET_SERVICE_Handle *sh) | |||
1494 | DWORD rd; | 1501 | DWORD rd; |
1495 | 1502 | ||
1496 | ret = ReadFile (lsocks_pipe, | 1503 | ret = ReadFile (lsocks_pipe, |
1497 | &count, | 1504 | &count, |
1498 | sizeof (count), | 1505 | sizeof (count), |
1499 | &rd, | 1506 | &rd, |
1500 | NULL); | 1507 | NULL); |
1501 | if ( (0 == ret) || | 1508 | if ( (0 == ret) || |
1502 | (sizeof (count) != rd) || | 1509 | (sizeof (count) != rd) || |
1503 | (0 == count) ) | 1510 | (0 == count) ) |
1504 | break; | 1511 | break; |
1505 | lsocks = GNUNET_new_array (count + 1, | 1512 | lsocks = GNUNET_new_array (count + 1, |
1506 | struct GNUNET_NETWORK_Handle *); | 1513 | struct GNUNET_NETWORK_Handle *); |
1507 | 1514 | ||
1508 | fail2 = 1; | 1515 | fail2 = 1; |
1509 | for (i = 0; i < count; i++) | 1516 | for (i = 0; i < count; i++) |
@@ -1513,28 +1520,28 @@ receive_sockets_from_parent (struct GNUNET_SERVICE_Handle *sh) | |||
1513 | SOCKET s; | 1520 | SOCKET s; |
1514 | 1521 | ||
1515 | ret = ReadFile (lsocks_pipe, | 1522 | ret = ReadFile (lsocks_pipe, |
1516 | &size, | 1523 | &size, |
1517 | sizeof (size), | 1524 | sizeof (size), |
1518 | &rd, | 1525 | &rd, |
1519 | NULL); | 1526 | NULL); |
1520 | if ( (0 == ret) || | 1527 | if ( (0 == ret) || |
1521 | (sizeof (size) != rd) || | 1528 | (sizeof (size) != rd) || |
1522 | (sizeof (pi) != size) ) | 1529 | (sizeof (pi) != size) ) |
1523 | break; | 1530 | break; |
1524 | ret = ReadFile (lsocks_pipe, | 1531 | ret = ReadFile (lsocks_pipe, |
1525 | &pi, | 1532 | &pi, |
1526 | sizeof (pi), | 1533 | sizeof (pi), |
1527 | &rd, | 1534 | &rd, |
1528 | NULL); | 1535 | NULL); |
1529 | if ( (0 == ret) || | 1536 | if ( (0 == ret) || |
1530 | (sizeof (pi) != rd)) | 1537 | (sizeof (pi) != rd)) |
1531 | break; | 1538 | break; |
1532 | s = WSASocketA (pi.iAddressFamily, | 1539 | s = WSASocketA (pi.iAddressFamily, |
1533 | pi.iSocketType, | 1540 | pi.iSocketType, |
1534 | pi.iProtocol, | 1541 | pi.iProtocol, |
1535 | &pi, | 1542 | &pi, |
1536 | 0, | 1543 | 0, |
1537 | WSA_FLAG_OVERLAPPED); | 1544 | WSA_FLAG_OVERLAPPED); |
1538 | lsocks[i] = GNUNET_NETWORK_socket_box_native (s); | 1545 | lsocks[i] = GNUNET_NETWORK_socket_box_native (s); |
1539 | if (NULL == lsocks[i]) | 1546 | if (NULL == lsocks[i]) |
1540 | break; | 1547 | break; |
@@ -1552,10 +1559,10 @@ receive_sockets_from_parent (struct GNUNET_SERVICE_Handle *sh) | |||
1552 | if (fail) | 1559 | if (fail) |
1553 | { | 1560 | { |
1554 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1561 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1555 | _("Could not access a pre-bound socket, will try to bind myself\n")); | 1562 | _ ("Could not access a pre-bound socket, will try to bind myself\n")); |
1556 | for (i = 0; (i < count) && (NULL != lsocks[i]); i++) | 1563 | for (i = 0; (i < count) && (NULL != lsocks[i]); i++) |
1557 | GNUNET_break (GNUNET_OK == | 1564 | GNUNET_break (GNUNET_OK == |
1558 | GNUNET_NETWORK_socket_close (lsocks[i])); | 1565 | GNUNET_NETWORK_socket_close (lsocks[i])); |
1559 | GNUNET_free (lsocks); | 1566 | GNUNET_free (lsocks); |
1560 | return NULL; | 1567 | return NULL; |
1561 | } | 1568 | } |
@@ -1573,7 +1580,7 @@ receive_sockets_from_parent (struct GNUNET_SERVICE_Handle *sh) | |||
1573 | */ | 1580 | */ |
1574 | static struct GNUNET_NETWORK_Handle * | 1581 | static struct GNUNET_NETWORK_Handle * |
1575 | open_listen_socket (const struct sockaddr *server_addr, | 1582 | open_listen_socket (const struct sockaddr *server_addr, |
1576 | socklen_t socklen) | 1583 | socklen_t socklen) |
1577 | { | 1584 | { |
1578 | struct GNUNET_NETWORK_Handle *sock; | 1585 | struct GNUNET_NETWORK_Handle *sock; |
1579 | uint16_t port; | 1586 | uint16_t port; |
@@ -1596,19 +1603,19 @@ open_listen_socket (const struct sockaddr *server_addr, | |||
1596 | break; | 1603 | break; |
1597 | } | 1604 | } |
1598 | sock = GNUNET_NETWORK_socket_create (server_addr->sa_family, | 1605 | sock = GNUNET_NETWORK_socket_create (server_addr->sa_family, |
1599 | SOCK_STREAM, | 1606 | SOCK_STREAM, |
1600 | 0); | 1607 | 0); |
1601 | if (NULL == sock) | 1608 | if (NULL == sock) |
1602 | { | 1609 | { |
1603 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, | 1610 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, |
1604 | "socket"); | 1611 | "socket"); |
1605 | errno = 0; | 1612 | errno = 0; |
1606 | return NULL; | 1613 | return NULL; |
1607 | } | 1614 | } |
1608 | /* bind the socket */ | 1615 | /* bind the socket */ |
1609 | if (GNUNET_OK != GNUNET_NETWORK_socket_bind (sock, | 1616 | if (GNUNET_OK != GNUNET_NETWORK_socket_bind (sock, |
1610 | server_addr, | 1617 | server_addr, |
1611 | socklen)) | 1618 | socklen)) |
1612 | { | 1619 | { |
1613 | eno = errno; | 1620 | eno = errno; |
1614 | if (EADDRINUSE != errno) | 1621 | if (EADDRINUSE != errno) |
@@ -1617,43 +1624,44 @@ open_listen_socket (const struct sockaddr *server_addr, | |||
1617 | * fail if we already took the port on IPv6; if both IPv4 and | 1624 | * fail if we already took the port on IPv6; if both IPv4 and |
1618 | * IPv6 binds fail, then our caller will log using the | 1625 | * IPv6 binds fail, then our caller will log using the |
1619 | * errno preserved in 'eno' */ | 1626 | * errno preserved in 'eno' */ |
1620 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, | ||
1621 | "bind"); | ||
1622 | if (0 != port) | 1627 | if (0 != port) |
1623 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1628 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1624 | _("`%s' failed for port %d (%s).\n"), | 1629 | _ ("`%s' failed for port %d (%s).\n"), |
1625 | "bind", | 1630 | "bind", |
1626 | port, | 1631 | port, |
1627 | (AF_INET == server_addr->sa_family) ? "IPv4" : "IPv6"); | 1632 | (AF_INET == server_addr->sa_family) ? "IPv4" : "IPv6"); |
1633 | else | ||
1634 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, | ||
1635 | "bind"); | ||
1628 | eno = 0; | 1636 | eno = 0; |
1629 | } | 1637 | } |
1630 | else | 1638 | else |
1631 | { | 1639 | { |
1632 | if (0 != port) | 1640 | if (0 != port) |
1633 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1641 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1634 | _("`%s' failed for port %d (%s): address already in use\n"), | 1642 | _ ("`%s' failed for port %d (%s): address already in use\n"), |
1635 | "bind", port, | 1643 | "bind", port, |
1636 | (AF_INET == server_addr->sa_family) ? "IPv4" : "IPv6"); | 1644 | (AF_INET == server_addr->sa_family) ? "IPv4" : "IPv6"); |
1637 | else if (AF_UNIX == server_addr->sa_family) | 1645 | else if (AF_UNIX == server_addr->sa_family) |
1638 | { | 1646 | { |
1639 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1647 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1640 | _("`%s' failed for `%s': address already in use\n"), | 1648 | _ ("`%s' failed for `%s': address already in use\n"), |
1641 | "bind", | 1649 | "bind", |
1642 | GNUNET_a2s (server_addr, socklen)); | 1650 | GNUNET_a2s (server_addr, socklen)); |
1643 | } | 1651 | } |
1644 | } | 1652 | } |
1645 | GNUNET_break (GNUNET_OK == | 1653 | GNUNET_break (GNUNET_OK == |
1646 | GNUNET_NETWORK_socket_close (sock)); | 1654 | GNUNET_NETWORK_socket_close (sock)); |
1647 | errno = eno; | 1655 | errno = eno; |
1648 | return NULL; | 1656 | return NULL; |
1649 | } | 1657 | } |
1650 | if (GNUNET_OK != GNUNET_NETWORK_socket_listen (sock, | 1658 | if (GNUNET_OK != GNUNET_NETWORK_socket_listen (sock, |
1651 | 5)) | 1659 | 5)) |
1652 | { | 1660 | { |
1653 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, | 1661 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, |
1654 | "listen"); | 1662 | "listen"); |
1655 | GNUNET_break (GNUNET_OK == | 1663 | GNUNET_break (GNUNET_OK == |
1656 | GNUNET_NETWORK_socket_close (sock)); | 1664 | GNUNET_NETWORK_socket_close (sock)); |
1657 | errno = 0; | 1665 | errno = 0; |
1658 | return NULL; | 1666 | return NULL; |
1659 | } | 1667 | } |
@@ -1694,20 +1702,20 @@ setup_service (struct GNUNET_SERVICE_Handle *sh) | |||
1694 | #endif | 1702 | #endif |
1695 | 1703 | ||
1696 | if (GNUNET_CONFIGURATION_have_value | 1704 | if (GNUNET_CONFIGURATION_have_value |
1697 | (sh->cfg, | 1705 | (sh->cfg, |
1698 | sh->service_name, | 1706 | sh->service_name, |
1699 | "TOLERANT")) | 1707 | "TOLERANT")) |
1700 | { | 1708 | { |
1701 | if (GNUNET_SYSERR == | 1709 | if (GNUNET_SYSERR == |
1702 | (tolerant = | 1710 | (tolerant = |
1703 | GNUNET_CONFIGURATION_get_value_yesno (sh->cfg, | 1711 | GNUNET_CONFIGURATION_get_value_yesno (sh->cfg, |
1704 | sh->service_name, | 1712 | sh->service_name, |
1705 | "TOLERANT"))) | 1713 | "TOLERANT"))) |
1706 | { | 1714 | { |
1707 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1715 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1708 | _("Specified value for `%s' of service `%s' is invalid\n"), | 1716 | _ ("Specified value for `%s' of service `%s' is invalid\n"), |
1709 | "TOLERANT", | 1717 | "TOLERANT", |
1710 | sh->service_name); | 1718 | sh->service_name); |
1711 | return GNUNET_SYSERR; | 1719 | return GNUNET_SYSERR; |
1712 | } | 1720 | } |
1713 | } | 1721 | } |
@@ -1719,31 +1727,32 @@ setup_service (struct GNUNET_SERVICE_Handle *sh) | |||
1719 | errno = 0; | 1727 | errno = 0; |
1720 | if ( (NULL != (nfds = getenv ("LISTEN_FDS"))) && | 1728 | if ( (NULL != (nfds = getenv ("LISTEN_FDS"))) && |
1721 | (1 == SSCANF (nfds, | 1729 | (1 == SSCANF (nfds, |
1722 | "%u%1s", | 1730 | "%u%1s", |
1723 | &cnt, | 1731 | &cnt, |
1724 | dummy)) && | 1732 | dummy)) && |
1725 | (cnt > 0) && | 1733 | (cnt > 0) && |
1726 | (cnt < FD_SETSIZE) && | 1734 | (cnt < FD_SETSIZE) && |
1727 | (cnt + 4 < FD_SETSIZE) ) | 1735 | (cnt + 4 < FD_SETSIZE) ) |
1728 | { | 1736 | { |
1729 | lsocks = GNUNET_new_array (cnt + 1, | 1737 | lsocks = GNUNET_new_array (cnt + 1, |
1730 | struct GNUNET_NETWORK_Handle *); | 1738 | struct GNUNET_NETWORK_Handle *); |
1731 | while (0 < cnt--) | 1739 | while (0 < cnt--) |
1732 | { | 1740 | { |
1733 | flags = fcntl (3 + cnt, | 1741 | flags = fcntl (3 + cnt, |
1734 | F_GETFD); | 1742 | F_GETFD); |
1735 | if ( (flags < 0) || | 1743 | if ( (flags < 0) || |
1736 | (0 != (flags & FD_CLOEXEC)) || | 1744 | (0 != (flags & FD_CLOEXEC)) || |
1737 | (NULL == | 1745 | (NULL == |
1738 | (lsocks[cnt] = GNUNET_NETWORK_socket_box_native (3 + cnt)))) | 1746 | (lsocks[cnt] = GNUNET_NETWORK_socket_box_native (3 + cnt)))) |
1739 | { | 1747 | { |
1740 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1748 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1741 | _("Could not access pre-bound socket %u, will try to bind myself\n"), | 1749 | _ ( |
1750 | "Could not access pre-bound socket %u, will try to bind myself\n"), | ||
1742 | (unsigned int) 3 + cnt); | 1751 | (unsigned int) 3 + cnt); |
1743 | cnt++; | 1752 | cnt++; |
1744 | while (NULL != lsocks[cnt]) | 1753 | while (NULL != lsocks[cnt]) |
1745 | GNUNET_break (GNUNET_OK == | 1754 | GNUNET_break (GNUNET_OK == |
1746 | GNUNET_NETWORK_socket_close (lsocks[cnt++])); | 1755 | GNUNET_NETWORK_socket_close (lsocks[cnt++])); |
1747 | GNUNET_free (lsocks); | 1756 | GNUNET_free (lsocks); |
1748 | lsocks = NULL; | 1757 | lsocks = NULL; |
1749 | break; | 1758 | break; |
@@ -1772,8 +1781,8 @@ setup_service (struct GNUNET_SERVICE_Handle *sh) | |||
1772 | slc->sh = sh; | 1781 | slc->sh = sh; |
1773 | slc->listen_socket = *ls; | 1782 | slc->listen_socket = *ls; |
1774 | GNUNET_CONTAINER_DLL_insert (sh->slc_head, | 1783 | GNUNET_CONTAINER_DLL_insert (sh->slc_head, |
1775 | sh->slc_tail, | 1784 | sh->slc_tail, |
1776 | slc); | 1785 | slc); |
1777 | } | 1786 | } |
1778 | GNUNET_free (lsocks); | 1787 | GNUNET_free (lsocks); |
1779 | } | 1788 | } |
@@ -1784,9 +1793,9 @@ setup_service (struct GNUNET_SERVICE_Handle *sh) | |||
1784 | int num; | 1793 | int num; |
1785 | 1794 | ||
1786 | num = get_server_addresses (sh->service_name, | 1795 | num = get_server_addresses (sh->service_name, |
1787 | sh->cfg, | 1796 | sh->cfg, |
1788 | &addrs, | 1797 | &addrs, |
1789 | &addrlens); | 1798 | &addrlens); |
1790 | if (GNUNET_SYSERR == num) | 1799 | if (GNUNET_SYSERR == num) |
1791 | return GNUNET_SYSERR; | 1800 | return GNUNET_SYSERR; |
1792 | 1801 | ||
@@ -1797,7 +1806,7 @@ setup_service (struct GNUNET_SERVICE_Handle *sh) | |||
1797 | slc = GNUNET_new (struct ServiceListenContext); | 1806 | slc = GNUNET_new (struct ServiceListenContext); |
1798 | slc->sh = sh; | 1807 | slc->sh = sh; |
1799 | slc->listen_socket = open_listen_socket (addrs[i], | 1808 | slc->listen_socket = open_listen_socket (addrs[i], |
1800 | addrlens[i]); | 1809 | addrlens[i]); |
1801 | GNUNET_free (addrs[i]); | 1810 | GNUNET_free (addrs[i]); |
1802 | if (NULL == slc->listen_socket) | 1811 | if (NULL == slc->listen_socket) |
1803 | { | 1812 | { |
@@ -1807,8 +1816,8 @@ setup_service (struct GNUNET_SERVICE_Handle *sh) | |||
1807 | continue; | 1816 | continue; |
1808 | } | 1817 | } |
1809 | GNUNET_CONTAINER_DLL_insert (sh->slc_head, | 1818 | GNUNET_CONTAINER_DLL_insert (sh->slc_head, |
1810 | sh->slc_tail, | 1819 | sh->slc_tail, |
1811 | slc); | 1820 | slc); |
1812 | } | 1821 | } |
1813 | GNUNET_free_non_null (addrlens); | 1822 | GNUNET_free_non_null (addrlens); |
1814 | GNUNET_free_non_null (addrs); | 1823 | GNUNET_free_non_null (addrs); |
@@ -1817,7 +1826,8 @@ setup_service (struct GNUNET_SERVICE_Handle *sh) | |||
1817 | { | 1826 | { |
1818 | /* All attempts to bind failed, hard failure */ | 1827 | /* All attempts to bind failed, hard failure */ |
1819 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1828 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1820 | _("Could not bind to any of the ports I was supposed to, refusing to run!\n")); | 1829 | _ ( |
1830 | "Could not bind to any of the ports I was supposed to, refusing to run!\n")); | ||
1821 | return GNUNET_SYSERR; | 1831 | return GNUNET_SYSERR; |
1822 | } | 1832 | } |
1823 | } | 1833 | } |
@@ -1825,24 +1835,24 @@ setup_service (struct GNUNET_SERVICE_Handle *sh) | |||
1825 | sh->require_found = tolerant ? GNUNET_NO : GNUNET_YES; | 1835 | sh->require_found = tolerant ? GNUNET_NO : GNUNET_YES; |
1826 | sh->match_uid | 1836 | sh->match_uid |
1827 | = GNUNET_CONFIGURATION_get_value_yesno (sh->cfg, | 1837 | = GNUNET_CONFIGURATION_get_value_yesno (sh->cfg, |
1828 | sh->service_name, | 1838 | sh->service_name, |
1829 | "UNIX_MATCH_UID"); | 1839 | "UNIX_MATCH_UID"); |
1830 | sh->match_gid | 1840 | sh->match_gid |
1831 | = GNUNET_CONFIGURATION_get_value_yesno (sh->cfg, | 1841 | = GNUNET_CONFIGURATION_get_value_yesno (sh->cfg, |
1832 | sh->service_name, | 1842 | sh->service_name, |
1833 | "UNIX_MATCH_GID"); | 1843 | "UNIX_MATCH_GID"); |
1834 | process_acl4 (&sh->v4_denied, | 1844 | process_acl4 (&sh->v4_denied, |
1835 | sh, | 1845 | sh, |
1836 | "REJECT_FROM"); | 1846 | "REJECT_FROM"); |
1837 | process_acl4 (&sh->v4_allowed, | 1847 | process_acl4 (&sh->v4_allowed, |
1838 | sh, | 1848 | sh, |
1839 | "ACCEPT_FROM"); | 1849 | "ACCEPT_FROM"); |
1840 | process_acl6 (&sh->v6_denied, | 1850 | process_acl6 (&sh->v6_denied, |
1841 | sh, | 1851 | sh, |
1842 | "REJECT_FROM6"); | 1852 | "REJECT_FROM6"); |
1843 | process_acl6 (&sh->v6_allowed, | 1853 | process_acl6 (&sh->v6_allowed, |
1844 | sh, | 1854 | sh, |
1845 | "ACCEPT_FROM6"); | 1855 | "ACCEPT_FROM6"); |
1846 | return GNUNET_OK; | 1856 | return GNUNET_OK; |
1847 | } | 1857 | } |
1848 | 1858 | ||
@@ -1861,9 +1871,9 @@ get_user_name (struct GNUNET_SERVICE_Handle *sh) | |||
1861 | 1871 | ||
1862 | if (GNUNET_OK != | 1872 | if (GNUNET_OK != |
1863 | GNUNET_CONFIGURATION_get_value_filename (sh->cfg, | 1873 | GNUNET_CONFIGURATION_get_value_filename (sh->cfg, |
1864 | sh->service_name, | 1874 | sh->service_name, |
1865 | "USERNAME", | 1875 | "USERNAME", |
1866 | &un)) | 1876 | &un)) |
1867 | return NULL; | 1877 | return NULL; |
1868 | return un; | 1878 | return un; |
1869 | } | 1879 | } |
@@ -1890,9 +1900,9 @@ set_user_id (struct GNUNET_SERVICE_Handle *sh) | |||
1890 | if (NULL == pws) | 1900 | if (NULL == pws) |
1891 | { | 1901 | { |
1892 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1902 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1893 | _("Cannot obtain information about user `%s': %s\n"), | 1903 | _ ("Cannot obtain information about user `%s': %s\n"), |
1894 | user, | 1904 | user, |
1895 | errno == 0 ? _("No such user") : STRERROR (errno)); | 1905 | errno == 0 ? _ ("No such user") : STRERROR (errno)); |
1896 | GNUNET_free (user); | 1906 | GNUNET_free (user); |
1897 | return GNUNET_SYSERR; | 1907 | return GNUNET_SYSERR; |
1898 | } | 1908 | } |
@@ -1900,20 +1910,20 @@ set_user_id (struct GNUNET_SERVICE_Handle *sh) | |||
1900 | (0 != setegid (pws->pw_gid)) || | 1910 | (0 != setegid (pws->pw_gid)) || |
1901 | #if HAVE_INITGROUPS | 1911 | #if HAVE_INITGROUPS |
1902 | (0 != initgroups (user, | 1912 | (0 != initgroups (user, |
1903 | pws->pw_gid)) || | 1913 | pws->pw_gid)) || |
1904 | #endif | 1914 | #endif |
1905 | (0 != setuid (pws->pw_uid)) || | 1915 | (0 != setuid (pws->pw_uid)) || |
1906 | (0 != seteuid (pws->pw_uid))) | 1916 | (0 != seteuid (pws->pw_uid))) |
1907 | { | 1917 | { |
1908 | if ((0 != setregid (pws->pw_gid, | 1918 | if ((0 != setregid (pws->pw_gid, |
1909 | pws->pw_gid)) || | 1919 | pws->pw_gid)) || |
1910 | (0 != setreuid (pws->pw_uid, | 1920 | (0 != setreuid (pws->pw_uid, |
1911 | pws->pw_uid))) | 1921 | pws->pw_uid))) |
1912 | { | 1922 | { |
1913 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1923 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1914 | _("Cannot change user/group to `%s': %s\n"), | 1924 | _ ("Cannot change user/group to `%s': %s\n"), |
1915 | user, | 1925 | user, |
1916 | STRERROR (errno)); | 1926 | STRERROR (errno)); |
1917 | GNUNET_free (user); | 1927 | GNUNET_free (user); |
1918 | return GNUNET_SYSERR; | 1928 | return GNUNET_SYSERR; |
1919 | } | 1929 | } |
@@ -1938,9 +1948,9 @@ get_pid_file_name (struct GNUNET_SERVICE_Handle *sh) | |||
1938 | 1948 | ||
1939 | if (GNUNET_OK != | 1949 | if (GNUNET_OK != |
1940 | GNUNET_CONFIGURATION_get_value_filename (sh->cfg, | 1950 | GNUNET_CONFIGURATION_get_value_filename (sh->cfg, |
1941 | sh->service_name, | 1951 | sh->service_name, |
1942 | "PIDFILE", | 1952 | "PIDFILE", |
1943 | &pif)) | 1953 | &pif)) |
1944 | return NULL; | 1954 | return NULL; |
1945 | return pif; | 1955 | return pif; |
1946 | } | 1956 | } |
@@ -1960,8 +1970,8 @@ pid_file_delete (struct GNUNET_SERVICE_Handle *sh) | |||
1960 | return; /* no PID file */ | 1970 | return; /* no PID file */ |
1961 | if (0 != UNLINK (pif)) | 1971 | if (0 != UNLINK (pif)) |
1962 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, | 1972 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
1963 | "unlink", | 1973 | "unlink", |
1964 | pif); | 1974 | pif); |
1965 | GNUNET_free (pif); | 1975 | GNUNET_free (pif); |
1966 | } | 1976 | } |
1967 | 1977 | ||
@@ -1983,14 +1993,14 @@ detach_terminal (struct GNUNET_SERVICE_Handle *sh) | |||
1983 | if (0 != PIPE (filedes)) | 1993 | if (0 != PIPE (filedes)) |
1984 | { | 1994 | { |
1985 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, | 1995 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, |
1986 | "pipe"); | 1996 | "pipe"); |
1987 | return GNUNET_SYSERR; | 1997 | return GNUNET_SYSERR; |
1988 | } | 1998 | } |
1989 | pid = fork (); | 1999 | pid = fork (); |
1990 | if (pid < 0) | 2000 | if (pid < 0) |
1991 | { | 2001 | { |
1992 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, | 2002 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, |
1993 | "fork"); | 2003 | "fork"); |
1994 | return GNUNET_SYSERR; | 2004 | return GNUNET_SYSERR; |
1995 | } | 2005 | } |
1996 | if (0 != pid) | 2006 | if (0 != pid) |
@@ -2001,10 +2011,10 @@ detach_terminal (struct GNUNET_SERVICE_Handle *sh) | |||
2001 | GNUNET_break (0 == CLOSE (filedes[1])); | 2011 | GNUNET_break (0 == CLOSE (filedes[1])); |
2002 | c = 'X'; | 2012 | c = 'X'; |
2003 | if (1 != READ (filedes[0], | 2013 | if (1 != READ (filedes[0], |
2004 | &c, | 2014 | &c, |
2005 | sizeof (char))) | 2015 | sizeof (char))) |
2006 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, | 2016 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, |
2007 | "read"); | 2017 | "read"); |
2008 | fflush (stdout); | 2018 | fflush (stdout); |
2009 | switch (c) | 2019 | switch (c) |
2010 | { | 2020 | { |
@@ -2012,15 +2022,15 @@ detach_terminal (struct GNUNET_SERVICE_Handle *sh) | |||
2012 | exit (0); | 2022 | exit (0); |
2013 | case 'I': | 2023 | case 'I': |
2014 | LOG (GNUNET_ERROR_TYPE_INFO, | 2024 | LOG (GNUNET_ERROR_TYPE_INFO, |
2015 | _("Service process failed to initialize\n")); | 2025 | _ ("Service process failed to initialize\n")); |
2016 | break; | 2026 | break; |
2017 | case 'S': | 2027 | case 'S': |
2018 | LOG (GNUNET_ERROR_TYPE_INFO, | 2028 | LOG (GNUNET_ERROR_TYPE_INFO, |
2019 | _("Service process could not initialize server function\n")); | 2029 | _ ("Service process could not initialize server function\n")); |
2020 | break; | 2030 | break; |
2021 | case 'X': | 2031 | case 'X': |
2022 | LOG (GNUNET_ERROR_TYPE_INFO, | 2032 | LOG (GNUNET_ERROR_TYPE_INFO, |
2023 | _("Service process failed to report status\n")); | 2033 | _ ("Service process failed to report status\n")); |
2024 | break; | 2034 | break; |
2025 | } | 2035 | } |
2026 | exit (1); /* child reported error */ | 2036 | exit (1); /* child reported error */ |
@@ -2029,7 +2039,7 @@ detach_terminal (struct GNUNET_SERVICE_Handle *sh) | |||
2029 | GNUNET_break (0 == CLOSE (1)); | 2039 | GNUNET_break (0 == CLOSE (1)); |
2030 | GNUNET_break (0 == CLOSE (filedes[0])); | 2040 | GNUNET_break (0 == CLOSE (filedes[0])); |
2031 | nullfd = OPEN ("/dev/null", | 2041 | nullfd = OPEN ("/dev/null", |
2032 | O_RDWR | O_APPEND); | 2042 | O_RDWR | O_APPEND); |
2033 | if (nullfd < 0) | 2043 | if (nullfd < 0) |
2034 | return GNUNET_SYSERR; | 2044 | return GNUNET_SYSERR; |
2035 | /* set stdin/stdout to /dev/null */ | 2045 | /* set stdin/stdout to /dev/null */ |
@@ -2037,7 +2047,7 @@ detach_terminal (struct GNUNET_SERVICE_Handle *sh) | |||
2037 | (dup2 (nullfd, 1) < 0) ) | 2047 | (dup2 (nullfd, 1) < 0) ) |
2038 | { | 2048 | { |
2039 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, | 2049 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, |
2040 | "dup2"); | 2050 | "dup2"); |
2041 | (void) CLOSE (nullfd); | 2051 | (void) CLOSE (nullfd); |
2042 | return GNUNET_SYSERR; | 2052 | return GNUNET_SYSERR; |
2043 | } | 2053 | } |
@@ -2046,7 +2056,7 @@ detach_terminal (struct GNUNET_SERVICE_Handle *sh) | |||
2046 | pid = setsid (); | 2056 | pid = setsid (); |
2047 | if (-1 == pid) | 2057 | if (-1 == pid) |
2048 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, | 2058 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, |
2049 | "setsid"); | 2059 | "setsid"); |
2050 | sh->ready_confirm_fd = filedes[1]; | 2060 | sh->ready_confirm_fd = filedes[1]; |
2051 | #else | 2061 | #else |
2052 | /* FIXME: we probably need to do something else | 2062 | /* FIXME: we probably need to do something else |
@@ -2080,7 +2090,7 @@ teardown_service (struct GNUNET_SERVICE_Handle *sh) | |||
2080 | if (NULL != slc->listen_task) | 2090 | if (NULL != slc->listen_task) |
2081 | GNUNET_SCHEDULER_cancel (slc->listen_task); | 2091 | GNUNET_SCHEDULER_cancel (slc->listen_task); |
2082 | GNUNET_break (GNUNET_OK == | 2092 | GNUNET_break (GNUNET_OK == |
2083 | GNUNET_NETWORK_socket_close (slc->listen_socket)); | 2093 | GNUNET_NETWORK_socket_close (slc->listen_socket)); |
2084 | GNUNET_free (slc); | 2094 | GNUNET_free (slc); |
2085 | } | 2095 | } |
2086 | } | 2096 | } |
@@ -2112,7 +2122,7 @@ return_agpl (void *cls, | |||
2112 | slen); | 2122 | slen); |
2113 | mq = GNUNET_SERVICE_client_get_mq (client); | 2123 | mq = GNUNET_SERVICE_client_get_mq (client); |
2114 | GNUNET_MQ_send (mq, | 2124 | GNUNET_MQ_send (mq, |
2115 | env); | 2125 | env); |
2116 | GNUNET_SERVICE_client_continue (client); | 2126 | GNUNET_SERVICE_client_continue (client); |
2117 | } | 2127 | } |
2118 | 2128 | ||
@@ -2273,7 +2283,8 @@ GNUNET_SERVICE_run_ (int argc, | |||
2273 | GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename), | 2283 | GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename), |
2274 | GNUNET_GETOPT_option_flag ('d', | 2284 | GNUNET_GETOPT_option_flag ('d', |
2275 | "daemonize", | 2285 | "daemonize", |
2276 | gettext_noop ("do daemonize (detach from terminal)"), | 2286 | gettext_noop ( |
2287 | "do daemonize (detach from terminal)"), | ||
2277 | &do_daemonize), | 2288 | &do_daemonize), |
2278 | GNUNET_GETOPT_option_help (NULL), | 2289 | GNUNET_GETOPT_option_help (NULL), |
2279 | GNUNET_GETOPT_option_loglevel (&loglev), | 2290 | GNUNET_GETOPT_option_loglevel (&loglev), |
@@ -2284,8 +2295,8 @@ GNUNET_SERVICE_run_ (int argc, | |||
2284 | 2295 | ||
2285 | err = 1; | 2296 | err = 1; |
2286 | memset (&sh, | 2297 | memset (&sh, |
2287 | 0, | 2298 | 0, |
2288 | sizeof (sh)); | 2299 | sizeof (sh)); |
2289 | xdg = getenv ("XDG_CONFIG_HOME"); | 2300 | xdg = getenv ("XDG_CONFIG_HOME"); |
2290 | if (NULL != xdg) | 2301 | if (NULL != xdg) |
2291 | GNUNET_asprintf (&cfg_filename, | 2302 | GNUNET_asprintf (&cfg_filename, |
@@ -2294,7 +2305,8 @@ GNUNET_SERVICE_run_ (int argc, | |||
2294 | DIR_SEPARATOR_STR, | 2305 | DIR_SEPARATOR_STR, |
2295 | GNUNET_OS_project_data_get ()->config_file); | 2306 | GNUNET_OS_project_data_get ()->config_file); |
2296 | else | 2307 | else |
2297 | cfg_filename = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file); | 2308 | cfg_filename = GNUNET_strdup ( |
2309 | GNUNET_OS_project_data_get ()->user_config_file); | ||
2298 | sh.ready_confirm_fd = -1; | 2310 | sh.ready_confirm_fd = -1; |
2299 | sh.options = options; | 2311 | sh.options = options; |
2300 | sh.cfg = cfg = GNUNET_CONFIGURATION_create (); | 2312 | sh.cfg = cfg = GNUNET_CONFIGURATION_create (); |
@@ -2311,9 +2323,9 @@ GNUNET_SERVICE_run_ (int argc, | |||
2311 | opt_cfg_filename = NULL; | 2323 | opt_cfg_filename = NULL; |
2312 | do_daemonize = 0; | 2324 | do_daemonize = 0; |
2313 | ret = GNUNET_GETOPT_run (service_name, | 2325 | ret = GNUNET_GETOPT_run (service_name, |
2314 | service_options, | 2326 | service_options, |
2315 | argc, | 2327 | argc, |
2316 | argv); | 2328 | argv); |
2317 | if (GNUNET_SYSERR == ret) | 2329 | if (GNUNET_SYSERR == ret) |
2318 | goto shutdown; | 2330 | goto shutdown; |
2319 | if (GNUNET_NO == ret) | 2331 | if (GNUNET_NO == ret) |
@@ -2322,8 +2334,8 @@ GNUNET_SERVICE_run_ (int argc, | |||
2322 | goto shutdown; | 2334 | goto shutdown; |
2323 | } | 2335 | } |
2324 | if (GNUNET_OK != GNUNET_log_setup (service_name, | 2336 | if (GNUNET_OK != GNUNET_log_setup (service_name, |
2325 | loglev, | 2337 | loglev, |
2326 | logfile)) | 2338 | logfile)) |
2327 | { | 2339 | { |
2328 | GNUNET_break (0); | 2340 | GNUNET_break (0); |
2329 | goto shutdown; | 2341 | goto shutdown; |
@@ -2331,41 +2343,41 @@ GNUNET_SERVICE_run_ (int argc, | |||
2331 | if (NULL != opt_cfg_filename) | 2343 | if (NULL != opt_cfg_filename) |
2332 | { | 2344 | { |
2333 | if ( (GNUNET_YES != | 2345 | if ( (GNUNET_YES != |
2334 | GNUNET_DISK_file_test (opt_cfg_filename)) || | 2346 | GNUNET_DISK_file_test (opt_cfg_filename)) || |
2335 | (GNUNET_SYSERR == | 2347 | (GNUNET_SYSERR == |
2336 | GNUNET_CONFIGURATION_load (cfg, | 2348 | GNUNET_CONFIGURATION_load (cfg, |
2337 | opt_cfg_filename)) ) | 2349 | opt_cfg_filename)) ) |
2338 | { | 2350 | { |
2339 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2351 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2340 | _("Malformed configuration file `%s', exit ...\n"), | 2352 | _ ("Malformed configuration file `%s', exit ...\n"), |
2341 | opt_cfg_filename); | 2353 | opt_cfg_filename); |
2342 | goto shutdown; | 2354 | goto shutdown; |
2343 | } | 2355 | } |
2344 | } | 2356 | } |
2345 | else | 2357 | else |
2346 | { | 2358 | { |
2347 | if (GNUNET_YES == | 2359 | if (GNUNET_YES == |
2348 | GNUNET_DISK_file_test (cfg_filename)) | 2360 | GNUNET_DISK_file_test (cfg_filename)) |
2349 | { | 2361 | { |
2350 | if (GNUNET_SYSERR == | 2362 | if (GNUNET_SYSERR == |
2351 | GNUNET_CONFIGURATION_load (cfg, | 2363 | GNUNET_CONFIGURATION_load (cfg, |
2352 | cfg_filename)) | 2364 | cfg_filename)) |
2353 | { | 2365 | { |
2354 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2366 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2355 | _("Malformed configuration file `%s', exit ...\n"), | 2367 | _ ("Malformed configuration file `%s', exit ...\n"), |
2356 | cfg_filename); | 2368 | cfg_filename); |
2357 | goto shutdown; | 2369 | goto shutdown; |
2358 | } | 2370 | } |
2359 | } | 2371 | } |
2360 | else | 2372 | else |
2361 | { | 2373 | { |
2362 | if (GNUNET_SYSERR == | 2374 | if (GNUNET_SYSERR == |
2363 | GNUNET_CONFIGURATION_load (cfg, | 2375 | GNUNET_CONFIGURATION_load (cfg, |
2364 | NULL)) | 2376 | NULL)) |
2365 | { | 2377 | { |
2366 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2378 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2367 | _("Malformed configuration, exit ...\n")); | 2379 | _ ("Malformed configuration, exit ...\n")); |
2368 | goto shutdown; | 2380 | goto shutdown; |
2369 | } | 2381 | } |
2370 | } | 2382 | } |
2371 | } | 2383 | } |
@@ -2385,39 +2397,39 @@ GNUNET_SERVICE_run_ (int argc, | |||
2385 | (NULL != opt_cfg_filename) ? opt_cfg_filename : cfg_filename); | 2397 | (NULL != opt_cfg_filename) ? opt_cfg_filename : cfg_filename); |
2386 | if ((GNUNET_OK == | 2398 | if ((GNUNET_OK == |
2387 | GNUNET_CONFIGURATION_get_value_number (sh.cfg, | 2399 | GNUNET_CONFIGURATION_get_value_number (sh.cfg, |
2388 | "TESTING", | 2400 | "TESTING", |
2389 | "SKEW_OFFSET", | 2401 | "SKEW_OFFSET", |
2390 | &skew_offset)) && | 2402 | &skew_offset)) && |
2391 | (GNUNET_OK == | 2403 | (GNUNET_OK == |
2392 | GNUNET_CONFIGURATION_get_value_number (sh.cfg, | 2404 | GNUNET_CONFIGURATION_get_value_number (sh.cfg, |
2393 | "TESTING", | 2405 | "TESTING", |
2394 | "SKEW_VARIANCE", | 2406 | "SKEW_VARIANCE", |
2395 | &skew_variance))) | 2407 | &skew_variance))) |
2396 | { | 2408 | { |
2397 | clock_offset = skew_offset - skew_variance; | 2409 | clock_offset = skew_offset - skew_variance; |
2398 | GNUNET_TIME_set_offset (clock_offset); | 2410 | GNUNET_TIME_set_offset (clock_offset); |
2399 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2411 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2400 | "Skewing clock by %dll ms\n", | 2412 | "Skewing clock by %dll ms\n", |
2401 | clock_offset); | 2413 | clock_offset); |
2402 | } | 2414 | } |
2403 | GNUNET_RESOLVER_connect (sh.cfg); | 2415 | GNUNET_RESOLVER_connect (sh.cfg); |
2404 | 2416 | ||
2405 | /* actually run service */ | 2417 | /* actually run service */ |
2406 | err = 0; | 2418 | err = 0; |
2407 | GNUNET_SCHEDULER_run (&service_main, | 2419 | GNUNET_SCHEDULER_run (&service_main, |
2408 | &sh); | 2420 | &sh); |
2409 | /* shutdown */ | 2421 | /* shutdown */ |
2410 | if (1 == do_daemonize) | 2422 | if (1 == do_daemonize) |
2411 | pid_file_delete (&sh); | 2423 | pid_file_delete (&sh); |
2412 | 2424 | ||
2413 | shutdown: | 2425 | shutdown: |
2414 | if (-1 != sh.ready_confirm_fd) | 2426 | if (-1 != sh.ready_confirm_fd) |
2415 | { | 2427 | { |
2416 | if (1 != WRITE (sh.ready_confirm_fd, | 2428 | if (1 != WRITE (sh.ready_confirm_fd, |
2417 | err ? "I" : "S", | 2429 | err ? "I" : "S", |
2418 | 1)) | 2430 | 1)) |
2419 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, | 2431 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, |
2420 | "write"); | 2432 | "write"); |
2421 | GNUNET_break (0 == CLOSE (sh.ready_confirm_fd)); | 2433 | GNUNET_break (0 == CLOSE (sh.ready_confirm_fd)); |
2422 | } | 2434 | } |
2423 | #if HAVE_MALLINFO | 2435 | #if HAVE_MALLINFO |
@@ -2425,22 +2437,22 @@ shutdown: | |||
2425 | char *counter; | 2437 | char *counter; |
2426 | 2438 | ||
2427 | if ( (GNUNET_YES == | 2439 | if ( (GNUNET_YES == |
2428 | GNUNET_CONFIGURATION_have_value (sh.cfg, | 2440 | GNUNET_CONFIGURATION_have_value (sh.cfg, |
2429 | service_name, | 2441 | service_name, |
2430 | "GAUGER_HEAP")) && | 2442 | "GAUGER_HEAP")) && |
2431 | (GNUNET_OK == | 2443 | (GNUNET_OK == |
2432 | GNUNET_CONFIGURATION_get_value_string (sh.cfg, | 2444 | GNUNET_CONFIGURATION_get_value_string (sh.cfg, |
2433 | service_name, | 2445 | service_name, |
2434 | "GAUGER_HEAP", | 2446 | "GAUGER_HEAP", |
2435 | &counter)) ) | 2447 | &counter)) ) |
2436 | { | 2448 | { |
2437 | struct mallinfo mi; | 2449 | struct mallinfo mi; |
2438 | 2450 | ||
2439 | mi = mallinfo (); | 2451 | mi = mallinfo (); |
2440 | GAUGER (service_name, | 2452 | GAUGER (service_name, |
2441 | counter, | 2453 | counter, |
2442 | mi.usmblks, | 2454 | mi.usmblks, |
2443 | "blocks"); | 2455 | "blocks"); |
2444 | GNUNET_free (counter); | 2456 | GNUNET_free (counter); |
2445 | } | 2457 | } |
2446 | } | 2458 | } |
@@ -2500,7 +2512,7 @@ resume_client_receive (void *cls) | |||
2500 | c->recv_task = NULL; | 2512 | c->recv_task = NULL; |
2501 | /* first, check if there is still something in the buffer */ | 2513 | /* first, check if there is still something in the buffer */ |
2502 | ret = GNUNET_MST_next (c->mst, | 2514 | ret = GNUNET_MST_next (c->mst, |
2503 | GNUNET_YES); | 2515 | GNUNET_YES); |
2504 | if (GNUNET_SYSERR == ret) | 2516 | if (GNUNET_SYSERR == ret) |
2505 | { | 2517 | { |
2506 | if (NULL == c->drop_task) | 2518 | if (NULL == c->drop_task) |
@@ -2517,9 +2529,9 @@ resume_client_receive (void *cls) | |||
2517 | return; | 2529 | return; |
2518 | c->recv_task | 2530 | c->recv_task |
2519 | = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 2531 | = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
2520 | c->sock, | 2532 | c->sock, |
2521 | &service_client_recv, | 2533 | &service_client_recv, |
2522 | c); | 2534 | c); |
2523 | } | 2535 | } |
2524 | 2536 | ||
2525 | 2537 | ||
@@ -2543,7 +2555,7 @@ GNUNET_SERVICE_client_continue (struct GNUNET_SERVICE_Client *c) | |||
2543 | } | 2555 | } |
2544 | c->recv_task | 2556 | c->recv_task |
2545 | = GNUNET_SCHEDULER_add_now (&resume_client_receive, | 2557 | = GNUNET_SCHEDULER_add_now (&resume_client_receive, |
2546 | c); | 2558 | c); |
2547 | } | 2559 | } |
2548 | 2560 | ||
2549 | 2561 | ||
@@ -2587,7 +2599,7 @@ finish_client_drop (void *cls) | |||
2587 | if (GNUNET_NO == c->persist) | 2599 | if (GNUNET_NO == c->persist) |
2588 | { | 2600 | { |
2589 | GNUNET_break (GNUNET_OK == | 2601 | GNUNET_break (GNUNET_OK == |
2590 | GNUNET_NETWORK_socket_close (c->sock)); | 2602 | GNUNET_NETWORK_socket_close (c->sock)); |
2591 | if ( (0 != (SUSPEND_STATE_EMFILE & sh->suspend_state)) && | 2603 | if ( (0 != (SUSPEND_STATE_EMFILE & sh->suspend_state)) && |
2592 | (0 == (SUSPEND_STATE_SHUTDOWN & sh->suspend_state)) ) | 2604 | (0 == (SUSPEND_STATE_SHUTDOWN & sh->suspend_state)) ) |
2593 | do_resume (sh, | 2605 | do_resume (sh, |
@@ -2704,7 +2716,7 @@ void | |||
2704 | GNUNET_SERVICE_client_mark_monitor (struct GNUNET_SERVICE_Client *c) | 2716 | GNUNET_SERVICE_client_mark_monitor (struct GNUNET_SERVICE_Client *c) |
2705 | { | 2717 | { |
2706 | c->is_monitor = GNUNET_YES; | 2718 | c->is_monitor = GNUNET_YES; |
2707 | if ( (0 != (SUSPEND_STATE_SHUTDOWN & c->sh->suspend_state) && | 2719 | if ( ((0 != (SUSPEND_STATE_SHUTDOWN & c->sh->suspend_state))&& |
2708 | (GNUNET_NO == have_non_monitor_clients (c->sh)) ) ) | 2720 | (GNUNET_NO == have_non_monitor_clients (c->sh)) ) ) |
2709 | GNUNET_SERVICE_shutdown (c->sh); | 2721 | GNUNET_SERVICE_shutdown (c->sh); |
2710 | } | 2722 | } |