GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock,
int finish_pending_write)
{
- if ((sock->write_buffer_off == 0) && (sock->dns_active != NULL))
- {
- GNUNET_RESOLVER_request_cancel (sock->dns_active);
- sock->dns_active = NULL;
- }
if (GNUNET_NO == finish_pending_write)
{
if (sock->write_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (sock->sched,
sock->write_task);
sock->write_task = GNUNET_SCHEDULER_NO_TASK;
+ sock->write_buffer_off = 0;
}
}
+ if ((sock->write_buffer_off == 0) && (sock->dns_active != NULL))
+ {
+ GNUNET_RESOLVER_request_cancel (sock->dns_active);
+ sock->dns_active = NULL;
+ }
GNUNET_assert (sock->sched != NULL);
GNUNET_SCHEDULER_add_now (sock->sched,
&destroy_continuation, sock);
}
else
{
- GNUNET_SCHEDULER_cancel (h->sh->sched, h->sh->write_task);
- h->sh->write_task = GNUNET_SCHEDULER_NO_TASK;
+ if (h->sh->write_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel (h->sh->sched, h->sh->write_task);
+ h->sh->write_task = GNUNET_SCHEDULER_NO_TASK;
+ }
}
h->notify_ready = NULL;
}