-fix
[oweals/gnunet.git] / src / fs / fs_download.c
index d21386390a770b45aab197b750540a6272005dcd..d91c9e824462d049ce9611eec0075b6bcf032c35 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001-2011 Christian Grothoff (and other contributing authors)
+     (C) 2001-2012 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -21,9 +21,6 @@
  * @file fs/fs_download.c
  * @brief download methods
  * @author Christian Grothoff
- *
- * TODO:
- * - different priority for scheduling probe downloads?
  */
 #include "platform.h"
 #include "gnunet_constants.h"
@@ -183,6 +180,9 @@ struct ProcessResultClosure
    */
   int do_store;
 
+  /**
+   * When did we last transmit the request?
+   */
   struct GNUNET_TIME_Absolute last_transmission;
 
 };
@@ -240,7 +240,8 @@ encrypt_existing_match (struct GNUNET_FS_DownloadContext *dc,
     return GNUNET_SYSERR;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Matching block for `%s' at offset %llu already present, no need for download!\n",
+              "Matching %u byte block for `%s' at offset %llu already present, no need for download!\n",
+             (unsigned int) len,
               dc->filename, (unsigned long long) dr->offset);
   /* already got it! */
   prc.dc = dc;
@@ -383,6 +384,16 @@ check_completed (struct GNUNET_FS_DownloadContext *dc)
     GNUNET_FS_dequeue_ (dc->job_queue);
     dc->job_queue = NULL;
   }
+  if (GNUNET_SCHEDULER_NO_TASK != dc->task)
+  {
+    GNUNET_SCHEDULER_cancel (dc->task);
+    dc->task = GNUNET_SCHEDULER_NO_TASK;
+  }
+  if (dc->rfh != NULL)
+  {
+    GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (dc->rfh));
+    dc->rfh = NULL;
+  }
   GNUNET_FS_download_sync_ (dc);
 
   /* signal completion */
@@ -517,6 +528,7 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
     pi.value.download.specifics.progress.data_len = dlen;
     pi.value.download.specifics.progress.depth = 0;
     pi.value.download.specifics.progress.trust_offered = 0;
+    pi.value.download.specifics.progress.block_download_duration = GNUNET_TIME_UNIT_ZERO;
     GNUNET_FS_download_make_status_ (&pi, dc);
     if ((NULL != dc->filename) &&
         (0 !=
@@ -618,7 +630,6 @@ try_top_down_reconstruction (struct GNUNET_FS_DownloadContext *dc,
   uint64_t total;
   size_t len;
   unsigned int i;
-  unsigned int chk_off;
   struct DownloadRequest *drc;
   uint64_t child_block_size;
   const struct ContentHashKey *chks;
@@ -670,12 +681,11 @@ try_top_down_reconstruction (struct GNUNET_FS_DownloadContext *dc,
     drc = dr->children[i];
     GNUNET_assert (drc->offset >= dr->offset);
     child_block_size = GNUNET_FS_tree_compute_tree_size (drc->depth);
-    GNUNET_assert (0 == (drc->offset - dr->offset) % child_block_size);
-    chk_off = (drc->offset - dr->offset) / child_block_size;
+    GNUNET_assert (0 == (drc->offset - dr->offset) % child_block_size);     
     if (drc->state == BRS_INIT)
     {
       drc->state = BRS_CHK_SET;
-      drc->chk = chks[chk_off];
+      drc->chk = chks[drc->chk_idx];
       try_top_down_reconstruction (dc, drc);
     }
     if (drc->state != BRS_DOWNLOAD_UP)
@@ -937,7 +947,8 @@ process_result_with_request (void *cls, const GNUNET_HashCode * key,
   struct ContentHashKey *chkarr;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received block `%s' matching pending request at depth %u and offset %llu/%llu\n",
+              "Received %u byte block `%s' matching pending request at depth %u and offset %llu/%llu\n",
+             (unsigned int) prc->size,
               GNUNET_h2s (key), dr->depth, (unsigned long long) dr->offset,
               (unsigned long long) GNUNET_ntohll (dc->uri->data.
                                                   chk.file_length));
@@ -1063,11 +1074,11 @@ process_result_with_request (void *cls, const GNUNET_HashCode * key,
   pi.value.download.specifics.progress.depth = dr->depth;
   pi.value.download.specifics.progress.trust_offered = 0;
   if (prc->last_transmission.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
-    pi.value.download.specifics.progress.block_download_duration =
-        GNUNET_TIME_absolute_get_duration (prc->last_transmission);
+    pi.value.download.specifics.progress.block_download_duration 
+      = GNUNET_TIME_absolute_get_duration (prc->last_transmission);
   else
-    pi.value.download.specifics.progress.block_download_duration.rel_value = 
-        GNUNET_TIME_UNIT_FOREVER_REL.rel_value;
+    pi.value.download.specifics.progress.block_download_duration
+      = GNUNET_TIME_UNIT_ZERO; /* found locally */
   GNUNET_FS_download_make_status_ (&pi, dc);
   if (dr->depth == 0)
     propagate_up (dr);
@@ -1109,9 +1120,10 @@ process_result_with_request (void *cls, const GNUNET_HashCode * key,
     switch (drc->state)
     {
     case BRS_INIT:
-      drc->chk = chkarr[dr->chk_idx];
+      drc->chk = chkarr[drc->chk_idx];
       drc->state = BRS_CHK_SET;
-      schedule_block_download (dc, drc);
+      if (GNUNET_YES == dc->issue_requests)
+       schedule_block_download (dc, drc);
       break;
     case BRS_RECONSTRUCT_DOWN:
       GNUNET_assert (0);
@@ -1516,18 +1528,23 @@ create_download_request (struct DownloadRequest *parent,
     if (dr_offset < file_start_offset)
       head_skip = file_start_offset / child_block_size;
     else
-      head_skip = dr_offset / child_block_size;
+      head_skip = 0;
 
     /* calculate index of last block at this level that is interesting (rounded up) */
-    dr->num_children = (file_start_offset + desired_length) / child_block_size;
+    dr->num_children = (file_start_offset + desired_length - dr_offset) / child_block_size;
     if (dr->num_children * child_block_size <
-        file_start_offset + desired_length)
+        file_start_offset + desired_length - dr_offset)
       dr->num_children++;       /* round up */
-
-    /* now we can get the total number of children for this block */
-    dr->num_children -= head_skip;
     if (dr->num_children > CHK_PER_INODE)
       dr->num_children = CHK_PER_INODE; /* cap at max */
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Block at offset %llu and depth %u has %u children\n",
+               (unsigned long long) dr_offset,
+               depth,
+               dr->num_children);
+
+    /* now we can get the total number of *interesting* children for this block */
+    dr->num_children -= head_skip;
 
     /* why else would we have gotten here to begin with? (that'd be a bad logic error) */
     GNUNET_assert (dr->num_children > 0);
@@ -1556,12 +1573,7 @@ reconstruct_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_FS_DownloadContext *dc = cls;
 
-  /* clean up state from tree encoder */
-  if (dc->te != NULL)
-  {
-    GNUNET_FS_tree_encoder_finish (dc->te, NULL, NULL);
-    dc->te = NULL;
-  }
+  /* clean up state from tree encoder */  
   if (dc->task != GNUNET_SCHEDULER_NO_TASK)
   {
     GNUNET_SCHEDULER_cancel (dc->task);
@@ -1573,6 +1585,9 @@ reconstruct_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     dc->rfh = NULL;
   }
   /* start "normal" download */
+  dc->issue_requests = GNUNET_YES;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Starting normal download\n");
   schedule_block_download (dc, dc->top_request);
 }
 
@@ -1626,11 +1641,34 @@ reconstruct_cb (void *cls, const struct ContentHashKey *chk, uint64_t offset,
   dr = dc->top_request;
   while (dr->depth > depth)
   {
-    blen = GNUNET_FS_tree_compute_tree_size (dr->depth);
+    GNUNET_assert (dr->num_children > 0);
+    blen = GNUNET_FS_tree_compute_tree_size (dr->depth - 1);
     chld = (offset - dr->offset) / blen;
-    GNUNET_assert (chld < dr->num_children);
-    dr = dr->children[chld];
+    if (chld < dr->children[0]->chk_idx)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Block %u < %u irrelevant for our range\n",
+                 chld,
+                 dr->children[dr->num_children-1]->chk_idx);
+      dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc);
+      return; /* irrelevant block */
+    }
+    if (chld > dr->children[dr->num_children-1]->chk_idx)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Block %u > %u irrelevant for our range\n",
+                 chld,
+                 dr->children[dr->num_children-1]->chk_idx);
+      dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc);
+      return; /* irrelevant block */
+    }
+    dr = dr->children[chld - dr->children[0]->chk_idx];
   }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Matched TE block with request at offset %llu and depth %u in state %d\n",
+             (unsigned long long) dr->offset,
+             dr->depth,
+             dr->state);
   /* FIXME: this code needs more testing and might
      need to handle more states... */
   switch (dr->state)
@@ -1646,11 +1684,14 @@ reconstruct_cb (void *cls, const struct ContentHashKey *chk, uint64_t offset,
   case BRS_CHK_SET:
     if (0 == memcmp (chk, &dr->chk, sizeof (struct ContentHashKey)))
     {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Reconstruction succeeded, can use block at offset %llu, depth %u\n",
+                 (unsigned long long) offset,
+                 depth);
       /* block matches, hence tree below matches;
        * this request is done! */
       dr->state = BRS_DOWNLOAD_UP;
-      GNUNET_break (GNUNET_NO ==
-                   GNUNET_CONTAINER_multihashmap_remove (dc->active, &dr->chk.query, dr));
+      (void) GNUNET_CONTAINER_multihashmap_remove (dc->active, &dr->chk.query, dr);
       if (GNUNET_YES == dr->is_pending)
       {
        GNUNET_break (0); /* how did we get here? */
@@ -1670,6 +1711,7 @@ reconstruct_cb (void *cls, const struct ContentHashKey *chk, uint64_t offset,
       pi.value.download.specifics.progress.data_len = 0;
       pi.value.download.specifics.progress.depth = 0;
       pi.value.download.specifics.progress.trust_offered = 0;
+      pi.value.download.specifics.progress.block_download_duration = GNUNET_TIME_UNIT_ZERO;
       GNUNET_FS_download_make_status_ (&pi, dc);
       /* FIXME: duplicated code from 'process_result_with_request - refactor */
       if (dc->completed == dc->length)
@@ -1690,6 +1732,11 @@ reconstruct_cb (void *cls, const struct ContentHashKey *chk, uint64_t offset,
        }
       }
     }
+    else
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Reconstruction failed, need to download block at offset %llu, depth %u\n",
+                 (unsigned long long) offset,
+                 depth);
     break;
   case BRS_DOWNLOAD_DOWN:
     break;
@@ -1701,12 +1748,9 @@ reconstruct_cb (void *cls, const struct ContentHashKey *chk, uint64_t offset,
     GNUNET_assert (0);
     break;
   }
+  dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc);
   if ((dr == dc->top_request) && (dr->state == BRS_DOWNLOAD_UP))
-  {
     check_completed (dc);
-    return;
-  }
-  dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc);
 }
 
 
@@ -1872,18 +1916,21 @@ GNUNET_FS_download_start_task_ (void *cls,
   }
   if (dc->rfh != NULL)
   {
-    /* finally, try bottom-up */
+    /* finally, actually run bottom-up */
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Trying bottom-up reconstruction of file `%s'\n", dc->filename);
     dc->te =
-        GNUNET_FS_tree_encoder_create (dc->h, dc->old_file_size, dc, &fh_reader,
-                                       &reconstruct_cb, NULL,
-                                       &reconstruct_cont);
+      GNUNET_FS_tree_encoder_create (dc->h, 
+                                    GNUNET_FS_uri_chk_get_file_size (dc->uri),
+                                    dc, &fh_reader,
+                                    &reconstruct_cb, NULL,
+                                    &reconstruct_cont);
     dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc);
   }
   else
   {
     /* simple, top-level download */
+    dc->issue_requests = GNUNET_YES;
     schedule_block_download (dc, dc->top_request);
   }
   if (dc->top_request->state == BRS_DOWNLOAD_UP)
@@ -1953,16 +2000,7 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
 
 
 /**
- * Download parts of a file.  Note that this will store
- * the blocks at the respective offset in the given file.  Also, the
- * download is still using the blocking of the underlying FS
- * encoding.  As a result, the download may *write* outside of the
- * given boundaries (if offset and length do not match the 32k FS
- * block boundaries). <p>
- *
- * This function should be used to focus a download towards a
- * particular portion of the file (optimization), not to strictly
- * limit the download to exactly those bytes.
+ * Helper function to setup the download context.
  *
  * @param h handle to the file sharing subsystem
  * @param uri the URI of the file (determines what to download); CHK or LOC URI
@@ -1978,38 +2016,27 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
  * @param anonymity anonymity level to use for the download
  * @param options various options
  * @param cctx initial value for the client context for this download
- * @param parent parent download to associate this download with (use NULL
- *        for top-level downloads; useful for manually-triggered recursive downloads)
  * @return context that can be used to control this download
  */
 struct GNUNET_FS_DownloadContext *
-GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
-                          const struct GNUNET_FS_Uri *uri,
-                          const struct GNUNET_CONTAINER_MetaData *meta,
-                          const char *filename, const char *tempname,
-                          uint64_t offset, uint64_t length, uint32_t anonymity,
-                          enum GNUNET_FS_DownloadOptions options, void *cctx,
-                          struct GNUNET_FS_DownloadContext *parent)
+create_download_context (struct GNUNET_FS_Handle *h,
+                        const struct GNUNET_FS_Uri *uri,
+                        const struct GNUNET_CONTAINER_MetaData *meta,
+                        const char *filename, const char *tempname,
+                        uint64_t offset, uint64_t length, uint32_t anonymity,
+                        enum GNUNET_FS_DownloadOptions options, void *cctx)
 {
   struct GNUNET_FS_DownloadContext *dc;
 
   GNUNET_assert (GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri));
-
   if ((offset + length < offset) ||
       (offset + length > GNUNET_FS_uri_chk_get_file_size (uri)))
   {
     GNUNET_break (0);
     return NULL;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting download `%s' of %llu bytes\n",
-              filename, (unsigned long long) length);
   dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext));
   dc->h = h;
-  dc->parent = parent;
-  if (parent != NULL)
-  {
-    GNUNET_CONTAINER_DLL_insert (parent->child_head, parent->child_tail, dc);
-  }
   dc->uri = GNUNET_FS_uri_dup (uri);
   dc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
   dc->client_info = cctx;
@@ -2018,7 +2045,7 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
   {
     dc->filename = GNUNET_strdup (filename);
     if (GNUNET_YES == GNUNET_DISK_file_test (filename))
-      GNUNET_DISK_file_size (filename, &dc->old_file_size, GNUNET_YES);
+      GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (filename, &dc->old_file_size, GNUNET_YES, GNUNET_YES));
   }
   if (GNUNET_FS_uri_test_loc (dc->uri))
     GNUNET_assert (GNUNET_OK ==
@@ -2031,22 +2058,74 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
       GNUNET_CONTAINER_multihashmap_create (1 + 2 * (length / DBLOCK_SIZE));
   dc->treedepth =
       GNUNET_FS_compute_depth (GNUNET_FS_uri_chk_get_file_size (dc->uri));
-  if ((filename == NULL) && (is_recursive_download (dc)))
+  if ((NULL == filename) && (is_recursive_download (dc)))
   {
-    if (tempname != NULL)
+    if (NULL != tempname)
       dc->temp_filename = GNUNET_strdup (tempname);
     else
       dc->temp_filename = GNUNET_DISK_mktemp ("gnunet-directory-download-tmp");
   }
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download tree has depth %u\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+             "Starting download `%s' of %llu bytes with tree depth %u\n",
+             filename,
+             (unsigned long long) length,
               dc->treedepth);
-  if (parent == NULL)
-  {
+  dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc);
+  return dc;
+}
+
+
+/**
+ * Download parts of a file.  Note that this will store
+ * the blocks at the respective offset in the given file.  Also, the
+ * download is still using the blocking of the underlying FS
+ * encoding.  As a result, the download may *write* outside of the
+ * given boundaries (if offset and length do not match the 32k FS
+ * block boundaries). <p>
+ *
+ * This function should be used to focus a download towards a
+ * particular portion of the file (optimization), not to strictly
+ * limit the download to exactly those bytes.
+ *
+ * @param h handle to the file sharing subsystem
+ * @param uri the URI of the file (determines what to download); CHK or LOC URI
+ * @param meta known metadata for the file (can be NULL)
+ * @param filename where to store the file, maybe NULL (then no file is
+ *        created on disk and data must be grabbed from the callbacks)
+ * @param tempname where to store temporary file data, not used if filename is non-NULL;
+ *        can be NULL (in which case we will pick a name if needed); the temporary file
+ *        may already exist, in which case we will try to use the data that is there and
+ *        if it is not what is desired, will overwrite it
+ * @param offset at what offset should we start the download (typically 0)
+ * @param length how many bytes should be downloaded starting at offset
+ * @param anonymity anonymity level to use for the download
+ * @param options various options
+ * @param cctx initial value for the client context for this download
+ * @param parent parent download to associate this download with (use NULL
+ *        for top-level downloads; useful for manually-triggered recursive downloads)
+ * @return context that can be used to control this download
+ */
+struct GNUNET_FS_DownloadContext *
+GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
+                          const struct GNUNET_FS_Uri *uri,
+                          const struct GNUNET_CONTAINER_MetaData *meta,
+                          const char *filename, const char *tempname,
+                          uint64_t offset, uint64_t length, uint32_t anonymity,
+                          enum GNUNET_FS_DownloadOptions options, void *cctx,
+                          struct GNUNET_FS_DownloadContext *parent)
+{
+  struct GNUNET_FS_DownloadContext *dc;
+
+  dc = create_download_context (h, uri, meta, filename, tempname,
+                               offset, length, anonymity, options, cctx);
+  if (NULL == dc)
+    return NULL;
+  dc->parent = parent;
+  if (NULL != parent)
+    GNUNET_CONTAINER_DLL_insert (parent->child_head, parent->child_tail, dc);
+  else
     dc->top =
         GNUNET_FS_make_top (dc->h, &GNUNET_FS_download_signal_suspend_, dc);
-  }
-  dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc);
   return dc;
 }
 
@@ -2096,62 +2175,22 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h,
 {
   struct GNUNET_FS_DownloadContext *dc;
 
-  if ((sr == NULL) || (sr->download != NULL))
+  if ((NULL == sr) || (NULL != sr->download))
   {
     GNUNET_break (0);
     return NULL;
   }
-  GNUNET_assert (GNUNET_FS_uri_test_chk (sr->uri) ||
-                 GNUNET_FS_uri_test_loc (sr->uri));
-  if ((offset + length < offset) ||
-      (offset + length > sr->uri->data.chk.file_length))
-  {
-    GNUNET_break (0);
+  dc = create_download_context (h, sr->uri, sr->meta, filename, tempname,
+                               offset, length, anonymity, options, cctx);
+  if (NULL == dc)
     return NULL;
-  }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting download `%s' of %llu bytes\n",
-              filename, (unsigned long long) length);
-  dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext));
-  dc->h = h;
   dc->search = sr;
   sr->download = dc;
-  if (sr->probe_ctx != NULL)
+  if (NULL != sr->probe_ctx)
   {
     GNUNET_FS_download_stop (sr->probe_ctx, GNUNET_YES);
     sr->probe_ctx = NULL;
   }
-  dc->uri = GNUNET_FS_uri_dup (sr->uri);
-  dc->meta = GNUNET_CONTAINER_meta_data_duplicate (sr->meta);
-  dc->client_info = cctx;
-  dc->start_time = GNUNET_TIME_absolute_get ();
-  if (NULL != filename)
-  {
-    dc->filename = GNUNET_strdup (filename);
-    if (GNUNET_YES == GNUNET_DISK_file_test (filename))
-      GNUNET_DISK_file_size (filename, &dc->old_file_size, GNUNET_YES);
-  }
-  if (GNUNET_FS_uri_test_loc (dc->uri))
-    GNUNET_assert (GNUNET_OK ==
-                   GNUNET_FS_uri_loc_get_peer_identity (dc->uri, &dc->target));
-  dc->offset = offset;
-  dc->length = length;
-  dc->anonymity = anonymity;
-  dc->options = options;
-  dc->active =
-      GNUNET_CONTAINER_multihashmap_create (1 + 2 * (length / DBLOCK_SIZE));
-  dc->treedepth =
-      GNUNET_FS_compute_depth (GNUNET_ntohll (dc->uri->data.chk.file_length));
-  if ((filename == NULL) && (is_recursive_download (dc)))
-  {
-    if (tempname != NULL)
-      dc->temp_filename = GNUNET_strdup (tempname);
-    else
-      dc->temp_filename = GNUNET_DISK_mktemp ("gnunet-directory-download-tmp");
-  }
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download tree has depth %u\n",
-              dc->treedepth);
-  dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc);
   return dc;
 }
 
@@ -2190,8 +2229,6 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete)
 
   if (dc->top != NULL)
     GNUNET_FS_end_top (dc->h, dc->top);
-
-
   if (dc->task != GNUNET_SCHEDULER_NO_TASK)
   {
     GNUNET_SCHEDULER_cancel (dc->task);