36 #define DEFAULT_MAX_PARALLEL_REQUESTS (1024 * 10) 41 #define DEFAULT_MAX_PARALLEL_DOWNLOADS 16 59 "Starting job %p (%u active)\n",
88 "Stopping job %p (%u active)\n",
115 unsigned int num_downloads_waiting;
116 unsigned int num_downloads_active;
117 unsigned int num_downloads_expired;
118 unsigned int num_probes_active;
119 unsigned int num_probes_waiting;
120 unsigned int num_probes_expired;
121 int num_probes_change;
122 int num_downloads_change;
131 num_probes_waiting = 0;
132 num_downloads_waiting = 0;
138 num_probes_waiting++;
142 num_downloads_waiting++;
151 num_probes_active = 0;
152 num_probes_expired = 0;
153 num_downloads_active = 0;
154 num_downloads_expired = 0;
156 while (NULL != (qe = next))
167 num_probes_expired++;
185 num_downloads_expired++;
190 num_downloads_active++;
201 num_downloads_active + num_probes_active);
203 "PA: %u, PE: %u, PW: %u; DA: %u, DE: %u, DW: %u\n",
207 num_downloads_active,
208 num_downloads_expired,
209 num_downloads_waiting);
216 num_probes_change = -
GNUNET_MIN (num_probes_active, num_downloads_waiting);
219 num_downloads_change =
225 num_downloads_change = num_downloads_waiting;
234 num_probes_change = 0;
236 GNUNET_break (num_downloads_change <= num_downloads_waiting);
238 "Changing %d probes and %d/%u/%u downloads\n",
240 num_downloads_change,
245 while (NULL != (qe = next))
250 if (num_probes_change < 0)
254 if (0 == num_probes_change)
263 while ((NULL != (qe = next)) &&
264 ((num_probes_change > 0) || (num_downloads_change > 0)))
270 if (num_probes_change > 0)
280 if ((num_downloads_change > 0) &&
286 num_downloads_change--;
288 else if (num_downloads_change > 0)
302 "AD: %u, MP: %u; %d probes and %d downloads to start, will run again in %s\n",
306 num_downloads_change,
466 if (UINT64_MAX == offset)
491 _ (
"Could not open file `%s': %s"),
502 _ (
"Could not read file `%s': %s"),
510 _ (
"Short read reading from file `%s'!"),
569 if (UINT64_MAX == offset)
647 "%s%s%s%s%s%s%s.dir%s%s",
750 if ((NULL == ent) || (0 == strlen (ent)))
756 if (NULL != filename)
758 if ((0 != unlink (filename)) && (ENOENT != errno))
781 if ((NULL == ent) || (0 == strlen (ent)))
787 if (NULL == filename)
789 if (0 != unlink (filename))
967 (int64_t *) &ret->
data.
file.file_size))
983 if (ret->
data.
file.reader_cls == NULL)
1012 (int64_t *) &ret->
data.
file.file_size))
1035 (int64_t *) &ret->
data.
file.file_size)) ||
1062 (int64_t *) &ret->
data.
file.file_size)) ||
1083 (int32_t *) &dsize)) ||
1087 "contents completed",
1104 if (NULL != filename)
1129 if (NULL != filename)
1173 _ (
"Failed to resume publishing information `%s': %s\n"),
1184 if (0 != unlink (fn))
1211 while (
'\0' != *nxt)
1217 if ((NULL == end) || (0 == strlen (end)))
1311 char buf[32 * 1024];
1319 while (off < fi->
data.file.file_size)
1409 "replication level",
1485 "contents completed",
1538 if (0 != unlink (fn))
1671 if (NULL == fi_root)
1691 if (NULL == pc->
dsh)
1724 _ (
"Failure while resuming publishing operation `%s': %s\n"),
1739 _ (
"Failed to resume publishing operation `%s': %s\n"),
1746 if (0 != unlink (filename))
1802 ((NULL != pc->
ns) &&
1962 (int32_t *) &dr->
depth)) ||
2125 if (NULL == dc->
emsg)
2148 if (0 != unlink (fn))
2185 : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
2247 : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
2269 const char *category;
2287 in_pause = (sc->
task != NULL) ?
'r' :
'\0';
2294 &in_pause,
sizeof(in_pause))) ||
2354 (int32_t *) &state)) ||
2468 _ (
"Failure while resuming unindexing operation `%s': %s\n"),
2479 _ (
"Failed to resume unindexing operation `%s': %s\n"),
2508 const char *serialization);
2585 "mandatory missing",
2593 "availability success",
2597 "availability trials",
2618 if (NULL != download)
2627 _ (
"Failed to resume sub-download `%s': %s\n"),
2635 if (NULL != update_srch)
2645 _ (
"Failed to resume sub-search `%s': %s\n"),
2661 _ (
"Failure while resuming search operation `%s': %s\n"),
2672 if (NULL != sr->
uri)
2674 if (NULL != sr->
meta)
2681 _ (
"Failure while resuming search operation `%s': %s\n"),
2748 pi.
value.
search.specifics.resume_result.result = sr;
2749 pi.
value.
search.specifics.resume_result.availability_rank =
2751 pi.
value.
search.specifics.resume_result.availability_certainty =
2753 pi.
value.
search.specifics.resume_result.applicability_rank =
2823 : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
2828 if (NULL != sc->
uri)
2863 "Failed to resume sub-download `%s': could not open file `%s'\n"),
2873 _ (
"Failed to resume sub-download `%s': %s\n"),
2895 if (NULL != dc->
meta)
2897 if (NULL != dc->
uri)
2953 (int64_t *) &dc->
offset),
2955 (int64_t *) &dc->
length),
2970 (int32_t *) &options)) ||
2972 (int32_t *) &status)))
2987 if (NULL == dc->
emsg)
3012 if ((NULL == parent) && (NULL == search))
3072 if ((NULL != psearch_result) && (NULL != psearch_result->
update_search))
3080 if (NULL != psearch_result)
3096 (int32_t *) &options)) ||
3119 if ((
'\0' == in_pause) &&
3124 _ (
"Could not resume running search, will resume as paused search\n"));
3155 if (0 != stat (filename, &buf))
3160 if (S_ISDIR (buf.st_mode))
3180 _ (
"Failure while resuming search operation `%s': %s\n"),
3209 if (0 != unlink (filename))
3219 _ (
"Failure while resuming download operation `%s': %s\n"),
3284 va_start (ap, flags);
int GNUNET_FS_uri_loc_get_peer_identity(const struct GNUNET_FS_Uri *uri, struct GNUNET_PeerIdentity *peer)
Obtain the identity of the peer offering the data.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void * client_info
Client info for this search result.
struct GNUNET_TIME_Absolute expiration_time
At what time should the block expire? Data blocks (DBLOCKS and IBLOCKS) may still be used even if the...
uint32_t optional_support
Number of optional keywords under which this result was also found.
static int deserialize_download_file(void *cls, const char *filename)
Function called with a filename of serialized download operation to deserialize.
This is a probe (low priority).
Structure specifying a writing operation on an IO handle.
char * nid
ID of the content in the namespace, NULL if we have no namespace.
int GNUNET_FS_uri_test_ksk(const struct GNUNET_FS_Uri *uri)
Is this a keyword URI?
Open the file for reading.
char * serialization
Short name under which we are serializing the state of this operation.
#define GNUNET_BIO_read_spec_end()
End of specifications marker.
static void deserialization_master(const char *master_path, GNUNET_FileNameCallback proc, struct GNUNET_FS_Handle *h)
Deserialize informatin about pending operations.
static char * dir
Set to the directory where runtime files are stored.
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
struct GNUNET_SCHEDULER_Task * task
ID of a task that is using this struct and that must be cancelled when the search is being stopped (i...
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_subtract(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Subtract a given relative duration from the given start time.
Context for controlling a download.
int GNUNET_BIO_read_int32(struct GNUNET_BIO_ReadHandle *h, const char *what, int32_t *i)
Read an (u)int32_t.
struct GNUNET_FS_DownloadContext * download
ID of an associated download based on this search result (or NULL for none).
void GNUNET_FS_file_information_sync_(struct GNUNET_FS_FileInformation *fi)
Create a temporary file on disk to store the current state of fi in.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
uint64_t rel_value_us
The actual value.
GNUNET_FS_Flags
General (global) option flags for file-sharing.
static struct GNUNET_FS_SearchContext * deserialize_search(struct GNUNET_FS_Handle *h, struct GNUNET_BIO_ReadHandle *rh, struct GNUNET_FS_SearchResult *psearch_result, const char *serialization)
Deserialize a search.
struct GNUNET_TIME_Relative avg_block_latency
Average time we take for a single request to be satisfied.
static int end
Set if we are to shutdown all services (including ARM).
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_FS_SearchResult * psearch_result
For update-searches, link to the search result that triggered the update search; otherwise NULL...
struct GNUNET_FS_ProgressInfo::@25::@27 download
Values for all "GNUNET_FS_STATUS_DOWNLOAD_*" events.
enum GNUNET_FS_DownloadOptions options
Options for the download.
struct GNUNET_FS_Handle * h
Global FS context.
struct GNUNET_GETOPT_CommandLineOption options[]
#define GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD
Name of the directory with downloads that are part of another download or a search.
static int fip_signal_resume(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
Signal the FS's progress function that we are resuming an upload.
static char * make_serialization_file_name_in_dir(struct GNUNET_FS_Handle *h, const char *ext, const char *uni)
Create a new random name for serialization.
struct DownloadRequest ** children
Array (!) of child-requests, or NULL for the bottom of the tree.
uint32_t ksk_offset
Current offset in KSK removal.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
struct GNUNET_BIO_ReadHandle * GNUNET_BIO_read_open_file(const char *fn)
Open a file for reading.
struct GNUNET_FS_Uri * GNUNET_FS_uri_parse(const char *uri, char **emsg)
Convert a UTF-8 String to a URI.
struct GNUNET_SCHEDULER_Task * queue_job
Task that processes the jobs in the running and pending queues (and moves jobs around as needed)...
struct GNUNET_FS_DownloadContext * child_head
Head of list of child downloads.
#define DEFAULT_MAX_PARALLEL_DOWNLOADS
How many downloads can we have outstanding in parallel at a time by default?
void GNUNET_FS_download_sync_(struct GNUNET_FS_DownloadContext *dc)
Synchronize this download struct with its mirror on disk.
Master context for most FS operations.
enum GNUNET_FS_SearchOptions options
Options for the search.
#define GNUNET_TIME_UNIT_MINUTES
One minute.
int GNUNET_BIO_write_int64(struct GNUNET_BIO_WriteHandle *h, const char *what, int64_t i)
Write an (u)int64_t.
void GNUNET_FS_search_sync_(struct GNUNET_FS_SearchContext *sc)
Synchronize this search struct with its mirror on disk.
static int start
Set if we are to start default services (including ARM).
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
char * emsg
Error message (non-NULL if this operation failed).
struct GNUNET_TIME_Absolute start_time
When did we start?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_FS_unindex_do_remove_(struct GNUNET_FS_UnindexContext *uc)
Connect to the datastore and remove the blocks.
struct GNUNET_FS_SearchContext * sc
Search context this result belongs to; can be NULL for probes that come from a directory result...
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
uint8_t * keyword_bitmap
Bitmap that specifies precisely which keywords have been matched already.
static void stop_job(struct GNUNET_FS_QueueEntry *qe)
Stop the given job (send signal, remove from active queue, update counters and state).
size_t GNUNET_FS_data_reader_copy_(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Function that provides data by copying from a buffer.
struct GNUNET_FS_QueueEntry * pending_head
Head of DLL of pending jobs.
void GNUNET_FS_download_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_DownloadContext *dc)
Fill in all of the generic fields for a download event and call the callback.
struct DownloadRequest * top_request
Top-level download request.
struct GNUNET_FS_DownloadContext * parent
Parent download (used when downloading files in directories).
GNUNET_FS_SearchOptions
Options for searching.
struct GNUNET_ATS_TEST_Topology * top
static struct GNUNET_FS_UnindexContext * uc
static void remove_sync_file_in_dir(struct GNUNET_FS_Handle *h, const char *ext, const char *uni, const char *ent)
Remove serialization/deserialization file from disk.
uint64_t offset
Offset of the corresponding block.
Last option in the VARARG list.
Keyword search key (query with keywords).
static void process_job_queue(void *cls)
Process the jobs in the job queue, possibly starting some and stopping others.
Nobody is allowed to do anything to the file.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static void free_search_context(struct GNUNET_FS_SearchContext *sc)
Free memory allocated by the search context and its children.
static int ret
Return value of the commandline.
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
static struct GNUNET_BIO_WriteHandle * get_write_handle(struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
Return a write handle for serialization.
enum GNUNET_FS_PublishOptions options
Options for publishing.
unsigned int active_blocks
How many blocks do the active downloads have?
int GNUNET_BIO_read_spec_commit(struct GNUNET_BIO_ReadHandle *h, struct GNUNET_BIO_ReadSpec *rs)
Execute the read specifications in order.
char * filename
Where are we writing the data (name of the file, can be NULL!).
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service.
struct GNUNET_FS_Handle * h
Handle to the global fs context.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
char * serialization
Filename used for serializing information about this operation (should be determined using 'mktemp')...
Private ECC key encoded for transmission.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
struct GNUNET_DISK_FileHandle * fd
File descriptor, NULL if it has not yet been opened.
size_t GNUNET_FS_data_reader_file_(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Function that provides data by reading from a file.
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_int64(const char *what, int64_t *i)
Create the specification to read an (u)int64_t.
struct ContentHashKey chk
CHK for the request for this block (set during reconstruction to what we have on disk, later to what we want to have).
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_object(const char *what, void *source, size_t size)
Create the specification to read some bytes.
int GNUNET_FS_uri_test_sks(const struct GNUNET_FS_Uri *uri)
Is this a namespace URI?
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
struct GNUNET_HashCode file_id
Hash of the file's contents (once computed).
We've calculated the CHK bottom-up based on what we have on disk, which may not be what the desired C...
Run as background job (higher than idle, lower than default).
enum UnindexState state
Current operatinonal phase.
struct GNUNET_CRYPTO_FileHashContext * GNUNET_CRYPTO_hash_file(enum GNUNET_SCHEDULER_Priority priority, const char *filename, size_t blocksize, GNUNET_CRYPTO_HashCompletedCallback callback, void *callback_cls)
Compute the hash of an entire file.
enum BlockRequestState state
State in the FSM.
unsigned int num_children
Number of entries in children array.
struct GNUNET_FS_QueueEntry * running_head
Head of DLL of running jobs.
void GNUNET_FS_stop(struct GNUNET_FS_Handle *h)
Close our connection with the file-sharing service.
char * temp_filename
Where are we writing the data temporarily (name of the file, can be NULL!); used if we do not have a ...
#define GNUNET_malloc_large(size)
Wrapper around malloc.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
Handle for controlling an unindexing operation.
struct GNUNET_FS_ProgressInfo::@25::@29 unindex
Values for all "GNUNET_FS_STATUS_UNINDEX_*" events.
static struct GNUNET_FS_FileInformation * find_file_position(struct GNUNET_FS_FileInformation *pos, const char *srch)
Find the entry in the file information struct where the serialization filename matches the given name...
static struct GNUNET_BIO_WriteHandle * get_write_handle_in_dir(struct GNUNET_FS_Handle *h, const char *ext, const char *uni, const char *ent)
Return a write handle for serialization.
uint64_t abs_value_us
The actual value.
unsigned int max_parallel_requests
Maximum number of parallel requests.
int GNUNET_BIO_read_close(struct GNUNET_BIO_ReadHandle *h, char **emsg)
Close an open handle.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD
Name of the directory with master downloads (not associated with search or part of another download)...
struct GNUNET_CRYPTO_FileHashContext * fhc
Context for hashing of the file.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Find out which keywords apply.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
struct GNUNET_FS_Uri * uri
List of keywords that we're looking for.
We're notifying the FS service about the unindexing.
void * GNUNET_FS_publish_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_PublishContext *pc, const struct GNUNET_FS_FileInformation *p, uint64_t offset)
Fill in all of the generic fields for a publish event and call the callback.
struct GNUNET_FS_Handle * GNUNET_FS_start(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls, enum GNUNET_FS_Flags flags,...)
Setup a connection to the file-sharing service.
Initial state, block has only been allocated (since it is relevant to the overall download request)...
void GNUNET_FS_dequeue_(struct GNUNET_FS_QueueEntry *qe)
Dequeue a job from the queue.
uint64_t old_file_size
What was the size of the file on disk that we're downloading before we started? Used to detect if the...
struct GNUNET_FS_SearchContext * update_search
If this search result triggered an update search, this field links to the update search.
struct TopLevelActivity * top_tail
Tail of DLL of top-level activities.
int GNUNET_FS_uri_test_loc(const struct GNUNET_FS_Uri *uri)
Is this a location URI?
uint32_t anonymity
Anonymity level for the search.
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
#define GNUNET_BIO_write_spec_end()
End of specifications marker.
static struct GNUNET_FS_FileInformation * deserialize_fi_node(struct GNUNET_FS_Handle *h, const char *fn, struct GNUNET_BIO_ReadHandle *rh)
Using the given serialization filename, try to deserialize the file-information tree associated with ...
uint64_t length
How many bytes starting from offset are desired? This is NOT the overall length of the file! ...
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static int signal_result_resume(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over search results signaling resume to the client for each result.
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP, >1: with cover traffic).
unsigned int GNUNET_FS_compute_depth(uint64_t flen)
Compute the depth of the CHK tree.
int GNUNET_BIO_read(struct GNUNET_BIO_ReadHandle *h, const char *what, void *result, size_t len)
Read some contents into a buffer.
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_string(const char *what, const char *s)
Create the specification to write a 0-terminated string.
struct GNUNET_TIME_Absolute queue_time
Time the job was originally queued.
void GNUNET_FS_search_signal_suspend_(void *cls)
Create SUSPEND event for the given search operation and then clean up our state (without stop signal)...
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_meta_data(const char *what, struct GNUNET_CONTAINER_MetaData **result)
Create the specification to read a metadata container.
union GNUNET_FS_ProgressInfo::@25 value
Values that depend on the event type.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
static void signal_search_resume(struct GNUNET_FS_SearchContext *sc)
Signal resuming of a search to our clients (for the top level search and all sub-searches).
void GNUNET_FS_search_start_probe_(struct GNUNET_FS_SearchResult *sr)
Start download probes for the given search result.
struct TopLevelActivity * top
Our top-level activity entry.
char * GNUNET_DISK_mktemp(const char *t)
Create an (empty) temporary file on disk.
void GNUNET_FS_publish_sync_(struct GNUNET_FS_PublishContext *pc)
Synchronize this publishing struct with its mirror on disk.
struct GNUNET_FS_DownloadContext * next
Next download belonging to the same parent.
char * serialization
Name of the file on disk we use for persistence.
int active
GNUNET_YES if the job is active now.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
void GNUNET_FS_download_signal_suspend_(void *cls)
Create SUSPEND event for the given download operation and then clean up our state (without stop signa...
enum State state
current state of profiling
char * serialization
Random portion of filename we use for syncing state of this download.
uint32_t availability_trials
Number of availability trials that we have performed for this search result.
static char * value
Value of the record to add/remove.
#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX
Name of the directory with unindex operations.
int GNUNET_FS_search_start_searching_(struct GNUNET_FS_SearchContext *sc)
Build the request and actually initiate the search using the GNUnet FS service.
struct GNUNET_FS_ProgressInfo::@25::@28 search
Values for all "GNUNET_FS_STATUS_SEARCH_*" events.
enum GNUNET_FS_QueuePriority priority
How important is this download?
void GNUNET_FS_unindex_do_remove_kblocks_(struct GNUNET_FS_UnindexContext *uc)
If necessary, connect to the datastore and remove the KBlocks.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
struct GNUNET_CONTAINER_MultiHashMap * master_result_map
Map that contains a struct GNUNET_FS_SearchResult for each result that was found in the search...
static void deserialize_download(struct GNUNET_FS_Handle *h, struct GNUNET_BIO_ReadHandle *rh, struct GNUNET_FS_DownloadContext *parent, struct GNUNET_FS_SearchResult *search, const char *serialization)
Deserialize a download.
static char * fn
Filename of the unique file.
Information we store for each search result.
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
static char * get_serialization_file_name_in_dir(struct GNUNET_FS_Handle *h, const char *ext, const char *uni, const char *ent)
Return the full filename where we would store state information (for serialization/deserialization) t...
static struct GNUNET_BIO_ReadHandle * get_read_handle(struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
Return a read handle for deserialization.
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void *(* GNUNET_FS_ProgressCallback)(void *cls, const struct GNUNET_FS_ProgressInfo *info)
Notification of FS to a client about the progress of an operation.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
char * nuid
ID for future updates, NULL if we have no namespace or no updates.
enum GNUNET_FS_Status status
Specific status code (determines the event type).
uint32_t availability_success
Number of availability tests that have succeeded for this result.
Internal option used to flag this download as a 'probe' for a search result.
We're telling the datastore to remove KBlocks.
UnindexState
Phases of unindex processing (state machine).
static void free_download_context(struct GNUNET_FS_DownloadContext *dc)
Free this download context and all of its descendants.
void GNUNET_FS_search_result_sync_(struct GNUNET_FS_SearchResult *sr)
Synchronize this search result with its mirror on disk.
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
We've checked the block on the path down the tree, and the content on disk did match the desired CHK...
struct GNUNET_TIME_Absolute start_time
When did we start?
Last event when a search is being resumed; note that "GNUNET_FS_SEARCH_START" will not be generated i...
struct GNUNET_FS_QueueEntry * GNUNET_FS_queue_(struct GNUNET_FS_Handle *h, GNUNET_SCHEDULER_TaskCallback start, GNUNET_SCHEDULER_TaskCallback stop, void *cls, unsigned int blocks, enum GNUNET_FS_QueuePriority priority)
Add a job to the queue.
uint16_t status
See PRISM_STATUS_*-constants.
#define CHK_PER_INODE
Pick a multiple of 2 here to achive 8-byte alignment! We also probably want DBlocks to have (roughly)...
void GNUNET_FS_publish_main_(void *cls)
Main function that performs the upload.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
char * client_name
Name of our client.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
struct TopLevelActivity * top_head
Head of DLL of top-level activities.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
Insert an element into a DLL after the given other element.
static void start_job(struct GNUNET_FS_QueueEntry *qe)
Start the given job (send signal, remove from pending queue, update counters and state).
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Structure specifying a reading operation on an IO handle.
struct GNUNET_CONTAINER_MultiHashMap * active
Map of active requests (those waiting for a response).
#define DEFAULT_MAX_PARALLEL_REQUESTS
How many block requests can we have outstanding in parallel at a time by default? ...
GNUNET_FS_OPTIONS
Options specified in the VARARGs portion of GNUNET_FS_start.
Handle for buffered writing.
We've encountered a fatal error.
static void signal_download_resume(struct GNUNET_FS_DownloadContext *dc)
Send the 'resume' signal to the callback; also actually resume the download (put it in the queue)...
We've calculated the CHK bottom-up based on the meta data.
uint64_t offset
What is the first offset that we're interested in?
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Handle for controlling a publication process.
void GNUNET_FS_download_start_task_(void *cls)
Task that creates the initial (top-level) download request for the file.
static struct DownloadRequest * read_download_request(struct GNUNET_BIO_ReadHandle *rh)
Read a download request tree.
void * GNUNET_FS_search_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc)
Fill in all of the generic fields for a search event and call the callback.
struct GNUNET_FS_Uri * ksk_uri
Keywords found (telling us which KBlocks to remove).
char * filename
Name of the file that we are unindexing.
We've successfully downloaded this block, but the children still need to be either downloaded or veri...
int GNUNET_BIO_read_string(struct GNUNET_BIO_ReadHandle *h, const char *what, char **result, size_t max_length)
Read 0-terminated string.
GNUNET_SCHEDULER_TaskCallback start
Function to call when the job is started.
#define GNUNET_FS_SYNC_PATH_CHILD_SEARCH
Name of the directory with sub-searches (namespace-updates).
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
struct GNUNET_SCHEDULER_Task * task
ID of a task that is using this struct and that must be cancelled when the download is being stopped ...
int GNUNET_FS_uri_test_chk(const struct GNUNET_FS_Uri *uri)
Is this a file (or directory) URI?
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
This block and all of its children have been downloaded successfully (full completion propagates up)...
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
struct GNUNET_FS_QueueEntry * running_tail
Tail of DLL of running jobs.
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_string(const char *what, char **result, size_t max_length)
Create the specification to read a 0-terminated string.
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_meta_data(const char *what, const struct GNUNET_CONTAINER_MetaData *m)
Create the specification to write a metadata container.
void * ssf_cls
Closure for 'ssf' (some struct GNUNET_FS_XXXHandle*)
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open_file(const char *fn)
Open a file for writing.
struct GNUNET_FS_Handle * h
Handle to FS primary context.
unsigned int active_downloads
How many actual downloads do we have running right now?
#define GNUNET_FS_SYNC_PATH_FILE_INFO
Name of the directory with files that are being published.
struct GNUNET_FS_SearchResult * search
Associated search (used when downloading files based on search results), or NULL for none...
static struct GNUNET_FS_FileInformation * deserialize_file_information(struct GNUNET_FS_Handle *h, const char *filename)
Using the given serialization filename, try to deserialize the file-information tree associated with ...
struct GNUNET_TIME_Relative GNUNET_TIME_relative_min(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the minimum of two relative time values.
struct GNUNET_HashCode key
The key used in the DHT.
char * emsg
Error message, NULL if we're doing OK.
static char * get_serialization_file_name(struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
Return the full filename where we would store state information (for serialization/deserialization).
static int deserialize_search_file(void *cls, const char *filename)
Function called with a filename of serialized search operation to deserialize.
struct GNUNET_TIME_Absolute start_time
Time the job was started last.
GNUNET_FS_DownloadOptions
Options for downloading.
void * GNUNET_FS_make_file_reader_context_(const char *filename)
Create the closure for the GNUNET_FS_data_reader_file_() callback.
int has_finished
Flag set upon transitive completion (includes child downloads).
int all_done
Set to GNUNET_YES if all processing has completed.
static char * get_download_sync_filename(struct GNUNET_FS_DownloadContext *dc, const char *uni, const char *ext)
Compute the name of the sync file (or directory) for the given download context.
Select the desired amount of parallelism (this option should be followed by an "unsigned int" giving ...
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Settings for publishing a block (which may of course also apply to an entire directory or file)...
static int write_start_time(struct GNUNET_BIO_WriteHandle *wh, struct GNUNET_TIME_Absolute timestamp)
Serialize a start-time.
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h, char **emsg)
Close an IO handle.
static struct GNUNET_FS_SearchContext * sc
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
static char * get_serialization_short_name(const char *fullname)
Given a serialization name (full absolute path), return the basename of the file (without the path)...
struct GNUNET_CONTAINER_MetaData * meta
Metadata for the search result.
Maximum number of requests that should be pending at a given point in time (invidivual downloads may ...
Notification that this download is being resumed.
enum GNUNET_FS_UriType type
Type of the URI.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
int GNUNET_FS_meta_data_test_for_directory(const struct GNUNET_CONTAINER_MetaData *md)
Does the meta-data claim that this is a directory? Checks if the mime-type is that of a GNUnet direct...
void GNUNET_FS_unindex_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_UnindexContext *uc, uint64_t offset)
Fill in all of the generic fields for an unindex event and call the callback.
struct GNUNET_HashCode key
Key for the search result based on the URI.
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, const char *what, int32_t i)
Write an (u)int32_t.
void GNUNET_FS_unindex_sync_(struct GNUNET_FS_UnindexContext *uc)
Synchronize this unindex struct with its mirror on disk.
void GNUNET_FS_unindex_signal_suspend_(void *cls)
Create SUSPEND event for the given unindex operation and then clean up our state (without stop signal...
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_int32(const char *what, int32_t *i)
Create the specification to read an (u)int32_t.
union GNUNET_FS_Uri::@13 data
struct TopLevelActivity * GNUNET_FS_make_top(struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, void *ssf_cls)
Create a top-level activity entry.
We got a block back that matched the query but did not hash to the key (malicious publisher or hash c...
Allow multiple values with the same key.
uint32_t replication_level
How often should we try to migrate the block to other peers? Only used if "CONTENT_PUSHING" is set to...
Event generated for each search result when the respective search is resumed.
Notification that we have resumed sharing a file structure.
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
struct GNUNET_TIME_Relative run_time
Total amount of time the job has been running (except for the current run).
#define GNUNET_FS_SYNC_PATH_MASTER_SEARCH
Name of the directory with top-level searches.
struct GNUNET_FS_DownloadContext * child_tail
Tail of list of child downloads.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
uint32_t mandatory_missing
Number of mandatory keywords for which we have NOT yet found the search result; when this value hits ...
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
int GNUNET_BIO_write_spec_commit(struct GNUNET_BIO_WriteHandle *h, struct GNUNET_BIO_WriteSpec *ws)
Execute the write specifications in order.
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
static char * make_serialization_file_name(struct GNUNET_FS_Handle *h, const char *ext)
Create a new random name for serialization.
unsigned int blocks
How many blocks do the active downloads have?
void(* SuspendSignalFunction)(void *cls)
Function signature of the functions that can be called to trigger suspend signals and clean-up for to...
struct GNUNET_FS_ProgressInfo::@25::@26 publish
Values for all "GNUNET_FS_STATUS_PUBLISH_*" events.
We're currently hashing the file.
void GNUNET_FS_publish_signal_suspend_(void *cls)
Create SUSPEND event for the given publish operation and then clean up our state (without stop signal...
#define HASHING_BLOCKSIZE
Blocksize to use when hashing files for indexing (blocksize for IO, not for the DBlocks).
Seek an absolute position (from the start of the file).
uint64_t GNUNET_FS_uri_chk_get_file_size(const struct GNUNET_FS_Uri *uri)
What is the size of the file that this URI refers to?
struct GNUNET_FS_QueueEntry * next
This is a linked list.
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_int32(const char *what, int32_t *i)
Create the specification to write an (u)int32_t.
shared definitions for the FS library
We're telling the datastore to delete the respective DBlocks and IBlocks.
struct GNUNET_CRYPTO_EcdsaPrivateKey * ns
Namespace that we are publishing in, NULL if we have no namespace.
void GNUNET_FS_file_information_inspect(struct GNUNET_FS_FileInformation *dir, GNUNET_FS_FileInformationProcessor proc, void *proc_cls)
Inspect a file or directory in a publish-structure.
struct GNUNET_PeerIdentity target
Identity of the peer having the content, or all-zeros if we don't know of such a peer.
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *what, const char *s)
Write a 0-terminated string.
A Universal Resource Identifier (URI), opaque.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
static int free_result(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over search results freeing each.
static int read_start_time(struct GNUNET_BIO_ReadHandle *rh, struct GNUNET_TIME_Absolute *timestamp)
Deserialize a start-time.
Handle for controlling a search.
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
static struct GNUNET_CONTAINER_MetaData * meta
Meta-data provided via command-line option.
void GNUNET_FS_unindex_do_extract_keywords_(struct GNUNET_FS_UnindexContext *uc)
Extract the keywords for KBlock removal.
void * upcb_cls
Closure for upcb.
struct GNUNET_FS_Uri::@13::@14 ksk
struct ContentHashKey chk
The content hash key of the last block we processed, will in the end be set to the CHK from the URI...
enum GNUNET_GenericReturnValue(* GNUNET_FileNameCallback)(void *cls, const char *filename)
Function called with a filename.
char * filename
Name of the file to read.
#define GNUNET_log(kind,...)
static int write_download_request(struct GNUNET_BIO_WriteHandle *wh, struct DownloadRequest *dr)
Serialize a download request.
void GNUNET_FS_file_information_destroy(struct GNUNET_FS_FileInformation *fi, GNUNET_FS_FileInformationProcessor cleaner, void *cleaner_cls)
Destroy publish-structure.
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
uint32_t anonymity
Desired level of anonymity.
struct GNUNET_FS_Handle * h
Handle to the global FS context.
GNUNET_SCHEDULER_TaskCallback stop
Function to call when the job needs to stop (or is done / dequeued).
unsigned int treedepth
The depth of the file-tree.
uint32_t content_priority
How important is it for us to store the block? If we run out of space, the highest-priority, non-expired blocks will be kept.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH
Name of the directory with publishing operations.
struct GNUNET_CONTAINER_MetaData * meta
Known meta-data for the file (can be NULL).
static int deserialize_subdownload(void *cls, const char *filename)
Function called with a filename of serialized sub-download to deserialize.
struct GNUNET_FS_QueueEntry * pending_tail
Tail of DLL of pending jobs.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
int GNUNET_BIO_read_meta_data(struct GNUNET_BIO_ReadHandle *h, const char *what, struct GNUNET_CONTAINER_MetaData **result)
Read a metadata container.
static int deserialize_search_result(void *cls, const char *filename)
Function called with a filename of serialized search result to deserialize.
char * emsg
Error message, NULL on success.
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_int64(const char *what, int64_t *i)
Create the specification to write an (u)int64_t.
Time for absolute times used by GNUnet, in microseconds.
void * cls
Closure for start and stop.
struct GNUNET_TIME_Absolute start_time
Time download was started.
char * serialization
Name under which this search result is stored on disk.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
uint64_t completed
How many bytes have we already received within the specified range (DBlocks only).
struct GNUNET_FS_Uri * uri
URI that identifies the file that we are downloading.
Notification that we resumed unindexing of a file.
static int deserialize_unindex_file(void *cls, const char *filename)
Function called with a filename of serialized unindexing operation to deserialize.
We track all of the top-level activities of FS so that we can signal 'suspend' on shutdown...
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_FS_free_download_request_(struct DownloadRequest *dr)
(recursively) free download request structure
struct GNUNET_FS_Handle * h
Global FS context.
uint32_t data
The data value.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
unsigned int max_parallel_downloads
Maximum number of parallel downloads.
int GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const char *what, const void *buffer, size_t n)
Write a buffer to a handle.
void GNUNET_FS_unindex_process_hash_(void *cls, const struct GNUNET_HashCode *file_id)
Function called once the hash of the file that is being unindexed has been computed.
struct DownloadRequest * parent
Parent in the CHK-tree.
char * emsg
Error message, NULL if there were no errors.
void * client_info
Pointer we keep for the client.
int skip_next_fi_callback
Flag set to GNUNET_YES if the next callback from GNUNET_FS_file_information_inspect should be skipped...
Information about an active download request.
Handle used to access files (and pipes).
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_saturating_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Saturating multiply relative time by a given factor.
static int copy_from_reader(struct GNUNET_BIO_WriteHandle *wh, struct GNUNET_FS_FileInformation *fi)
Copy all of the data from the reader to the write handle.
int GNUNET_BIO_read_int64(struct GNUNET_BIO_ReadHandle *h, const char *what, int64_t *i)
Read an (u)int64_t.
unsigned int depth
Depth of the corresponding block in the tree.
Closure for GNUNET_FS_data_reader_file_().
We've determined the real, desired CHK for this block (full tree reconstruction failed), request is now pending.
#define GNUNET_malloc(size)
Wrapper around malloc.
void GNUNET_FS_remove_sync_file_(struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
Remove serialization/deserialization file from disk.
GNUNET_FS_QueuePriority
Priorities for the queue.
static int deserialize_publish_file(void *cls, const char *filename)
Function called with a filename of serialized publishing operation to deserialize.
Handle for buffered reading.
static struct GNUNET_FS_DownloadContext * dc
SuspendSignalFunction ssf
Function to call for suspend-signalling and clean up.
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
unsigned int start_times
How often have we (re)started this download?
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
Time for relative time used by GNUnet, in microseconds.
Is persistence of operations desired? (will create SUSPEND/RESUME events).
enum GNUNET_FS_Flags flags
General flags.
void GNUNET_FS_remove_sync_dir_(struct GNUNET_FS_Handle *h, const char *ext, const char *uni)
Remove serialization/deserialization directory from disk.
struct GNUNET_FS_QueueEntry * job_queue
Our entry in the job queue.
Merkle-tree-ish-CHK file encoding for GNUnet.
uint64_t file_size
Overall size of the file.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.