diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-10-07 08:51:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-10-07 08:51:00 +0000 |
commit | 5a4ffefaef89776bf7f983501d9267f42e6435d1 (patch) | |
tree | 8bf7176c48f19b36562000f941e080c7850f4549 /src/transport/transport_api.c | |
parent | 69823c5446ae906ef0b0328daa5d4514cd525f82 (diff) | |
download | gnunet-5a4ffefaef89776bf7f983501d9267f42e6435d1.tar.gz gnunet-5a4ffefaef89776bf7f983501d9267f42e6435d1.zip |
-fix NPE
Diffstat (limited to 'src/transport/transport_api.c')
-rw-r--r-- | src/transport/transport_api.c | 94 |
1 files changed, 50 insertions, 44 deletions
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 5d34beeac..f1aefc203 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -826,8 +826,11 @@ demultiplexer (void *cls, | |||
826 | } | 826 | } |
827 | GNUNET_break (GNUNET_NO == n->is_ready); | 827 | GNUNET_break (GNUNET_NO == n->is_ready); |
828 | n->is_ready = GNUNET_YES; | 828 | n->is_ready = GNUNET_YES; |
829 | GNUNET_SCHEDULER_cancel (n->unready_warn_task); | 829 | if (NULL != n->unready_warn_task) |
830 | n->unready_warn_task = NULL; | 830 | { |
831 | GNUNET_SCHEDULER_cancel (n->unready_warn_task); | ||
832 | n->unready_warn_task = NULL; | ||
833 | } | ||
831 | if ((NULL != n->th) && (NULL == n->hn)) | 834 | if ((NULL != n->th) && (NULL == n->hn)) |
832 | { | 835 | { |
833 | GNUNET_assert (NULL != n->th->timeout_task); | 836 | GNUNET_assert (NULL != n->th->timeout_task); |
@@ -1019,52 +1022,55 @@ transport_notify_ready (void *cls, | |||
1019 | n->hn = NULL; | 1022 | n->hn = NULL; |
1020 | n->th = NULL; | 1023 | n->th = NULL; |
1021 | GNUNET_assert (size >= sizeof (struct OutboundMessage)); | 1024 | GNUNET_assert (size >= sizeof (struct OutboundMessage)); |
1022 | mret = | 1025 | mret = th->notify (th->notify_cls, |
1023 | th->notify (th->notify_cls, size - sizeof (struct OutboundMessage), | 1026 | size - sizeof (struct OutboundMessage), |
1024 | &cbuf[ret + sizeof (struct OutboundMessage)]); | 1027 | &cbuf[ret + sizeof (struct OutboundMessage)]); |
1025 | GNUNET_assert (mret <= size - sizeof (struct OutboundMessage)); | 1028 | GNUNET_assert (mret <= size - sizeof (struct OutboundMessage)); |
1026 | if (0 != mret) | 1029 | if (0 == mret) |
1027 | { | 1030 | { |
1028 | if (NULL != n->unready_warn_task) | 1031 | GNUNET_free (th); |
1029 | n->unready_warn_task | 1032 | continue; |
1030 | = GNUNET_SCHEDULER_add_delayed (UNREADY_WARN_TIME, | ||
1031 | &do_warn_unready, | ||
1032 | n); | ||
1033 | n->last_payload = GNUNET_TIME_absolute_get (); | ||
1034 | n->is_ready = GNUNET_NO; | ||
1035 | GNUNET_assert (mret + sizeof (struct OutboundMessage) < | ||
1036 | GNUNET_SERVER_MAX_MESSAGE_SIZE); | ||
1037 | obm.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND); | ||
1038 | obm.header.size = htons (mret + sizeof (struct OutboundMessage)); | ||
1039 | obm.reserved = htonl (0); | ||
1040 | obm.timeout = | ||
1041 | GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining | ||
1042 | (th->timeout)); | ||
1043 | obm.peer = n->id; | ||
1044 | memcpy (&cbuf[ret], | ||
1045 | &obm, | ||
1046 | sizeof (struct OutboundMessage)); | ||
1047 | ret += (mret + sizeof (struct OutboundMessage)); | ||
1048 | size -= (mret + sizeof (struct OutboundMessage)); | ||
1049 | GNUNET_BANDWIDTH_tracker_consume (&n->out_tracker, | ||
1050 | mret); | ||
1051 | delay = GNUNET_TIME_absolute_get_duration (th->request_start); | ||
1052 | if (delay.rel_value_us > 1000 * 1000) | ||
1053 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
1054 | "Added %u bytes of payload message at %u after %s delay\n", | ||
1055 | mret, | ||
1056 | ret, | ||
1057 | GNUNET_STRINGS_relative_time_to_string (delay, | ||
1058 | GNUNET_YES)); | ||
1059 | else | ||
1060 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1061 | "Added %u bytes of payload message at %u after %s delay\n", | ||
1062 | mret, | ||
1063 | ret, | ||
1064 | GNUNET_STRINGS_relative_time_to_string (delay, | ||
1065 | GNUNET_YES)); | ||
1066 | } | 1033 | } |
1034 | if (NULL != n->unready_warn_task) | ||
1035 | n->unready_warn_task | ||
1036 | = GNUNET_SCHEDULER_add_delayed (UNREADY_WARN_TIME, | ||
1037 | &do_warn_unready, | ||
1038 | n); | ||
1039 | n->last_payload = GNUNET_TIME_absolute_get (); | ||
1040 | n->is_ready = GNUNET_NO; | ||
1041 | GNUNET_assert (mret + sizeof (struct OutboundMessage) < | ||
1042 | GNUNET_SERVER_MAX_MESSAGE_SIZE); | ||
1043 | obm.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND); | ||
1044 | obm.header.size = htons (mret + sizeof (struct OutboundMessage)); | ||
1045 | obm.reserved = htonl (0); | ||
1046 | obm.timeout = | ||
1047 | GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining | ||
1048 | (th->timeout)); | ||
1049 | obm.peer = n->id; | ||
1050 | memcpy (&cbuf[ret], | ||
1051 | &obm, | ||
1052 | sizeof (struct OutboundMessage)); | ||
1053 | ret += (mret + sizeof (struct OutboundMessage)); | ||
1054 | size -= (mret + sizeof (struct OutboundMessage)); | ||
1055 | GNUNET_BANDWIDTH_tracker_consume (&n->out_tracker, | ||
1056 | mret); | ||
1057 | delay = GNUNET_TIME_absolute_get_duration (th->request_start); | ||
1058 | if (delay.rel_value_us > 1000 * 1000) | ||
1059 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
1060 | "Added %u bytes of payload message at %u after %s delay\n", | ||
1061 | mret, | ||
1062 | ret, | ||
1063 | GNUNET_STRINGS_relative_time_to_string (delay, | ||
1064 | GNUNET_YES)); | ||
1065 | else | ||
1066 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1067 | "Added %u bytes of payload message at %u after %s delay\n", | ||
1068 | mret, | ||
1069 | ret, | ||
1070 | GNUNET_STRINGS_relative_time_to_string (delay, | ||
1071 | GNUNET_YES)); | ||
1067 | GNUNET_free (th); | 1072 | GNUNET_free (th); |
1073 | break; | ||
1068 | } | 1074 | } |
1069 | /* if there are more pending messages, try to schedule those */ | 1075 | /* if there are more pending messages, try to schedule those */ |
1070 | schedule_transmission (h); | 1076 | schedule_transmission (h); |