GNUnet 0.22.1
gnunet-auto-share.c File Reference

automatically publish files on GNUnet More...

#include "platform.h"
#include "gnunet_util_lib.h"
Include dependency graph for gnunet-auto-share.c:

Go to the source code of this file.

Data Structures

struct  WorkItem
 Item in our work queue (or in the set of files/directories we have successfully published). More...
 

Macros

#define MAX_DELAY   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
 
#define MIN_DELAY   GNUNET_TIME_UNIT_MINUTES
 

Functions

static char * get_state_file ()
 Compute the name of the state database file we will use. More...
 
static void load_state ()
 Load the set of work_finished items from disk. More...
 
static int write_item (void *cls, const struct GNUNET_HashCode *key, void *value)
 Write work item from the work_finished map to the given write handle. More...
 
static void save_state ()
 Save the set of work_finished items on disk. More...
 
static void do_stop_task (void *cls)
 Task run on shutdown. More...
 
static void schedule_next_task (void)
 Decide what the next task is (working or scanning) and schedule it. More...
 
static void maint_child_death (void *cls)
 Task triggered whenever we receive a SIGCHLD (child process died). More...
 
static void sighandler_child_death ()
 Signal handler called for SIGCHLD. More...
 
static void work (void *cls)
 Function called to process work items. More...
 
static int determine_id (void *cls, const char *filename)
 Recursively scan the given file/directory structure to determine a unique ID that represents the current state of the hierarchy. More...
 
static int add_file (void *cls, const char *filename)
 Function called with a filename (or directory name) to publish (if it has changed since the last time we published it). More...
 
static void scan (void *cls)
 Periodically run task to update our view of the directory to share. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
 Main function that will be run by the scheduler. More...
 
static int free_item (void *cls, const struct GNUNET_HashCode *key, void *value)
 Free memory associated with the work item from the work_finished map. More...
 
int main (int argc, char *const *argv)
 The main function to automatically publish content to GNUnet. More...
 

Variables

static int ret
 Global return value from 'main'. More...
 
static unsigned int verbose
 Are we running 'verbosely'? More...
 
static const struct GNUNET_CONFIGURATION_Handlecfg
 Configuration to use. More...
 
static char * cfg_filename
 Name of the configuration file. More...
 
static int disable_extractor
 Disable extractor option to use for publishing. More...
 
static int do_disable_creation_time
 Disable creation time option to use for publishing. More...
 
static struct GNUNET_SCHEDULER_Taskrun_task
 Handle for the main task that does scanning and working. More...
 
static unsigned int anonymity_level = 1
 Anonymity level option to use for publishing. More...
 
static unsigned int content_priority = 365
 Content priority option to use for publishing. More...
 
static unsigned int replication_level = 1
 Replication level option to use for publishing. More...
 
static const char * dir_name
 Top-level directory we monitor to auto-publish. More...
 
static struct WorkItemwork_head
 Head of linked list of files still to publish. More...
 
static struct WorkItemwork_tail
 Tail of linked list of files still to publish. More...
 
static struct GNUNET_CONTAINER_MultiHashMapwork_finished
 Map from the hash of the filename (!) to a struct WorkItem that was finished. More...
 
static int do_shutdown
 Set to GNUNET_YES if we are shutting down. More...
 
static struct GNUNET_TIME_Absolute start_time
 Start time of the current round; used to determine how long one iteration takes (which influences how fast we schedule the next one). More...
 
static struct GNUNET_DISK_PipeHandlesigpipe
 Pipe used to communicate 'gnunet-publish' completion (SIGCHLD) via signal. More...
 
static struct GNUNET_OS_Processpublish_proc
 Handle to the 'gnunet-publish' process that we executed. More...
 

Detailed Description

automatically publish files on GNUnet

Author
Christian Grothoff

TODO:

  • support loading meta data / keywords from resource file
  • add stability timer (a la buildbot)

Definition in file gnunet-auto-share.c.

Macro Definition Documentation

◆ MAX_DELAY

Definition at line 32 of file gnunet-auto-share.c.

◆ MIN_DELAY

#define MIN_DELAY   GNUNET_TIME_UNIT_MINUTES

Definition at line 34 of file gnunet-auto-share.c.

Function Documentation

◆ get_state_file()

static char * get_state_file ( )
static

Compute the name of the state database file we will use.

Definition at line 164 of file gnunet-auto-share.c.

165{
166 char *retval;
167
168 GNUNET_asprintf (&retval,
169 "%s%s.auto-share",
170 dir_name,
171 (DIR_SEPARATOR == dir_name[strlen (dir_name) - 1])
172 ? ""
174 return retval;
175}
static const char * dir_name
Top-level directory we monitor to auto-publish.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define DIR_SEPARATOR
Definition: platform.h:165
#define DIR_SEPARATOR_STR
Definition: platform.h:166

References dir_name, DIR_SEPARATOR, DIR_SEPARATOR_STR, and GNUNET_asprintf().

Referenced by load_state(), and save_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_state()

static void load_state ( )
static

Load the set of work_finished items from disk.

Definition at line 182 of file gnunet-auto-share.c.

183{
184 char *fn;
185 struct GNUNET_BIO_ReadHandle *rh;
186 uint32_t n;
187 struct GNUNET_HashCode id;
188 struct WorkItem *wi;
189 char *emsg;
190
191 emsg = NULL;
192 fn = get_state_file ();
194 GNUNET_free (fn);
195 if (NULL == rh)
196 return;
197 fn = NULL;
198 if (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "number of files",
199 (int32_t *) &n))
200 goto error;
201 while (n-- > 0)
202 {
203 struct GNUNET_BIO_ReadSpec rs[] = {
204 GNUNET_BIO_read_spec_string ("filename", &fn, 1024),
205 GNUNET_BIO_read_spec_object ("id", &id, sizeof(struct GNUNET_HashCode)),
207 };
209 goto error;
210 wi = GNUNET_new (struct WorkItem);
211 wi->id = id;
212 wi->filename = fn;
214 "Loaded serialization ID for `%s' is `%s'\n",
215 wi->filename,
216 GNUNET_h2s (&id));
217 fn = NULL;
218 GNUNET_CRYPTO_hash (wi->filename, strlen (wi->filename), &id);
222 &id,
223 wi,
225 }
226 if (GNUNET_OK == GNUNET_BIO_read_close (rh, &emsg))
227 return;
228 rh = NULL;
229error:
230 GNUNET_free (fn);
231 if (NULL != rh)
232 (void) GNUNET_BIO_read_close (rh, &emsg);
234 _ ("Failed to load state: %s\n"),
235 emsg);
236 GNUNET_free (emsg);
237}
static struct GNUNET_CONTAINER_MultiHashMap * work_finished
Map from the hash of the filename (!) to a struct WorkItem that was finished.
static char * get_state_file()
Compute the name of the state database file we will use.
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
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.
Definition: bio.c:954
enum GNUNET_GenericReturnValue GNUNET_BIO_read_spec_commit(struct GNUNET_BIO_ReadHandle *h, struct GNUNET_BIO_ReadSpec *rs)
Execute the read specifications in order.
Definition: bio.c:1106
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_object(const char *what, void *result, size_t size)
Create the specification to read a certain amount of bytes.
Definition: bio.c:906
#define GNUNET_BIO_read_spec_end()
End of specifications marker.
enum GNUNET_GenericReturnValue GNUNET_BIO_read_close(struct GNUNET_BIO_ReadHandle *h, char **emsg)
Close an open handle.
Definition: bio.c:162
enum GNUNET_GenericReturnValue GNUNET_BIO_read_int32(struct GNUNET_BIO_ReadHandle *h, const char *what, int32_t *i)
Read an (u)int32_t.
Definition: bio.c:427
struct GNUNET_BIO_ReadHandle * GNUNET_BIO_read_open_file(const char *fn)
Open a file for reading.
Definition: bio.c:114
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
enum GNUNET_GenericReturnValue 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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_log(kind,...)
@ GNUNET_OK
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
Handle for buffered reading.
Definition: bio.c:69
Structure specifying a reading operation on an IO handle.
GNUNET_BIO_ReadHandler rh
Function performing data deserialization.
A 512-bit hashcode.
Item in our work queue (or in the set of files/directories we have successfully published).
char * filename
Filename of the work item.
struct GNUNET_HashCode id
Unique identity for this work item (used to detect if we need to do the work again).

References _, WorkItem::filename, get_state_file(), GNUNET_BIO_read_close(), GNUNET_BIO_read_int32(), GNUNET_BIO_read_open_file(), GNUNET_BIO_read_spec_commit(), GNUNET_BIO_read_spec_end, GNUNET_BIO_read_spec_object(), GNUNET_BIO_read_spec_string(), GNUNET_break, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_new, GNUNET_OK, WorkItem::id, id, GNUNET_BIO_ReadSpec::rh, and work_finished.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_item()

static int write_item ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Write work item from the work_finished map to the given write handle.

Parameters
clsthe struct GNUNET_BIO_WriteHandle *
keykey of the item in the map (unused)
valuethe struct WorkItem to write
Returns
GNUNET_OK to continue to iterate (if write worked)

Definition at line 249 of file gnunet-auto-share.c.

250{
251 struct GNUNET_BIO_WriteHandle *wh = cls;
252 struct WorkItem *wi = value;
253
254 struct GNUNET_BIO_WriteSpec ws[] = {
255 GNUNET_BIO_write_spec_string ("auto-share-write-item-filename",
256 wi->filename),
257 GNUNET_BIO_write_spec_object ("id", &wi->id, sizeof(struct
260 };
262 "Saving serialization ID of file `%s' with value `%s'\n",
263 wi->filename,
264 GNUNET_h2s (&wi->id));
266 return GNUNET_SYSERR; /* write error, abort iteration */
267 return GNUNET_OK;
268}
static char * value
Value of the record to add/remove.
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_string(const char *what, const char *s)
Create the specification to write a 0-terminated string.
Definition: bio.c:1199
#define GNUNET_BIO_write_spec_end()
End of specifications marker.
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_object(const char *what, void *source, size_t size)
Create the specification to read some bytes.
Definition: bio.c:1152
enum GNUNET_GenericReturnValue GNUNET_BIO_write_spec_commit(struct GNUNET_BIO_WriteHandle *h, struct GNUNET_BIO_WriteSpec *ws)
Execute the write specifications in order.
Definition: bio.c:1357
@ GNUNET_SYSERR
Handle for buffered writing.
Definition: bio.c:466
Structure specifying a writing operation on an IO handle.
GNUNET_BIO_WriteHandler wh
Function performing data serialization.

References WorkItem::filename, GNUNET_BIO_write_spec_commit(), GNUNET_BIO_write_spec_end, GNUNET_BIO_write_spec_object(), GNUNET_BIO_write_spec_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_OK, GNUNET_SYSERR, WorkItem::id, value, and GNUNET_BIO_WriteSpec::wh.

Referenced by save_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_state()

static void save_state ( )
static

Save the set of work_finished items on disk.

Definition at line 275 of file gnunet-auto-share.c.

276{
277 uint32_t n;
278 struct GNUNET_BIO_WriteHandle *wh;
279 char *fn;
280
282 fn = get_state_file ();
284 if (NULL == wh)
285 {
287 _ ("Failed to save state to file %s\n"),
288 fn);
289 GNUNET_free (fn);
290 return;
291 }
292 if (GNUNET_OK != GNUNET_BIO_write_int32 (wh, "size of state", n))
293 {
294 (void) GNUNET_BIO_write_close (wh, NULL);
296 _ ("Failed to save state to file %s\n"),
297 fn);
298 GNUNET_free (fn);
299 return;
300 }
302 if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
304 _ ("Failed to save state to file %s\n"),
305 fn);
306 GNUNET_free (fn);
307}
static int write_item(void *cls, const struct GNUNET_HashCode *key, void *value)
Write work item from the work_finished map to the given write handle.
enum GNUNET_GenericReturnValue GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h, char **emsg)
Close an IO handle.
Definition: bio.c:556
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open_file(const char *fn)
Open a file for writing.
Definition: bio.c:508
enum GNUNET_GenericReturnValue GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, const char *what, int32_t i)
Write an (u)int32_t.
Definition: bio.c:845
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.

References _, get_state_file(), GNUNET_BIO_write_close(), GNUNET_BIO_write_int32(), GNUNET_BIO_write_open_file(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_OK, work_finished, and write_item().

Referenced by maint_child_death().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_stop_task()

static void do_stop_task ( void *  cls)
static

Task run on shutdown.

Serializes our current state to disk.

Parameters
clsclosure, unused

Definition at line 316 of file gnunet-auto-share.c.

317{
319 if (NULL != publish_proc)
320 {
322 return;
323 }
324 if (NULL != run_task)
325 {
327 run_task = NULL;
328 }
329}
static struct GNUNET_SCHEDULER_Task * run_task
Handle for the main task that does scanning and working.
static int do_shutdown
Set to GNUNET_YES if we are shutting down.
static struct GNUNET_OS_Process * publish_proc
Handle to the 'gnunet-publish' process that we executed.
@ GNUNET_YES
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
Definition: os_priority.c:210
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:979

References do_shutdown, GNUNET_OS_process_kill(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, publish_proc, and run_task.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ schedule_next_task()

static void schedule_next_task ( void  )
static

Decide what the next task is (working or scanning) and schedule it.

Definition at line 618 of file gnunet-auto-share.c.

619{
620 struct GNUNET_TIME_Relative delay;
621
622 if (GNUNET_YES == do_shutdown)
623 return;
624 GNUNET_assert (NULL == run_task);
625 if (NULL == work_head)
626 {
627 /* delay by at most 4h, at least 1s, and otherwise in between depending
628 on how long it took to scan */
630 delay = GNUNET_TIME_relative_saturating_multiply (delay, 100);
631 delay = GNUNET_TIME_relative_min (delay, MAX_DELAY);
632 delay = GNUNET_TIME_relative_max (delay, MIN_DELAY);
634 }
635 else
636 {
638 }
639}
static struct WorkItem * work_head
Head of linked list of files still to publish.
#define MAX_DELAY
static struct GNUNET_TIME_Absolute start_time
Start time of the current round; used to determine how long one iteration takes (which influences how...
static void scan(void *cls)
Periodically run task to update our view of the directory to share.
#define MIN_DELAY
static void work(void *cls)
Function called to process work items.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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.
Definition: scheduler.c:1303
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.
Definition: scheduler.c:1276
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.
Definition: time.c:344
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...
Definition: time.c:438
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.
Definition: time.c:533
struct GNUNET_TIME_Relative GNUNET_TIME_relative_max(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the maximum of two relative time values.
Definition: time.c:352
Time for relative time used by GNUnet, in microseconds.

References do_shutdown, GNUNET_assert, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_max(), GNUNET_TIME_relative_min(), GNUNET_TIME_relative_saturating_multiply(), GNUNET_YES, MAX_DELAY, MIN_DELAY, run_task, scan(), start_time, work(), and work_head.

Referenced by maint_child_death(), and scan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ maint_child_death()

static void maint_child_death ( void *  cls)
static

Task triggered whenever we receive a SIGCHLD (child process died).

Parameters
clsthe struct WorkItem we were working on

Definition at line 346 of file gnunet-auto-share.c.

347{
348 struct WorkItem *wi = cls;
349 struct GNUNET_HashCode key;
351 unsigned long code;
352 int retval;
353 char c;
354 const struct GNUNET_DISK_FileHandle *pr;
355 const struct GNUNET_SCHEDULER_TaskContext *tc;
356
357 run_task = NULL;
361 {
362 /* shutdown scheduled us, someone else will kill child,
363 we should just try again */
365 pr,
367 wi);
368 return;
369 }
370 /* consume the signal */
371 GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof(c)));
372
373 retval = GNUNET_OS_process_status (publish_proc, &type, &code);
374 GNUNET_assert (GNUNET_SYSERR != retval);
375 if (GNUNET_NO == retval)
376 {
377 /* process still running? Then where did the SIGCHLD come from?
378 Well, let's declare it spurious (kernel bug?) and keep rolling.
379 */
380 GNUNET_break (0);
382 pr,
384 wi);
385 return;
386 }
387 GNUNET_assert (GNUNET_OK == retval);
388
390 publish_proc = NULL;
391
392 if (GNUNET_YES == do_shutdown)
393 {
394 GNUNET_free (wi->filename);
395 GNUNET_free (wi);
396 return;
397 }
398 if ((GNUNET_OS_PROCESS_EXITED == type) && (0 == code))
399 {
401 _ ("Publication of `%s' done\n"),
402 wi->filename);
403 GNUNET_CRYPTO_hash (wi->filename, strlen (wi->filename), &key);
407 &key,
408 wi,
410 }
411 else
412 {
414 }
415 save_state ();
417}
static void schedule_next_task(void)
Decide what the next task is (working or scanning) and schedule it.
static void maint_child_death(void *cls)
Task triggered whenever we receive a SIGCHLD (child process died).
static struct WorkItem * work_tail
Tail of linked list of files still to publish.
static struct GNUNET_DISK_PipeHandle * sigpipe
Pipe used to communicate 'gnunet-publish' completion (SIGCHLD) via signal.
static void save_state()
Save the set of work_finished items on disk.
struct GNUNET_HashCode key
The key used in the DHT.
static uint32_t type
Type string converted to DNS type value.
const struct GNUNET_DISK_FileHandle * GNUNET_DISK_pipe_handle(const struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd n)
Get the handle to a particular pipe end.
Definition: disk.c:1618
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.
Definition: disk.c:623
@ GNUNET_DISK_PIPE_END_READ
The reading-end of a pipe.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
@ GNUNET_NO
@ GNUNET_ERROR_TYPE_INFO
GNUNET_OS_ProcessStatusType
Process status types.
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
Definition: os_priority.c:260
enum GNUNET_GenericReturnValue GNUNET_OS_process_status(struct GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusType *type, unsigned long *code)
Retrieve the status of a process.
Definition: os_priority.c:860
@ GNUNET_OS_PROCESS_EXITED
The process exited with a return code.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_file(struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition: scheduler.c:1660
const struct GNUNET_SCHEDULER_TaskContext * GNUNET_SCHEDULER_get_task_context(void)
Obtain the reasoning why the current task was started.
Definition: scheduler.c:757
@ GNUNET_SCHEDULER_REASON_READ_READY
The reading socket is ready.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:430
Handle used to access files (and pipes).
Context information passed to each scheduler task.
enum GNUNET_SCHEDULER_Reason reason
Reason why the task is run now.

References _, do_shutdown, WorkItem::filename, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash(), GNUNET_DISK_file_read(), GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_pipe_handle(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_OS_process_destroy(), GNUNET_OS_PROCESS_EXITED, GNUNET_OS_process_status(), GNUNET_SCHEDULER_add_read_file(), GNUNET_SCHEDULER_get_task_context(), GNUNET_SCHEDULER_REASON_READ_READY, GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, key, maint_child_death(), publish_proc, GNUNET_SCHEDULER_TaskContext::reason, run_task, save_state(), schedule_next_task(), sigpipe, tc, type, work_finished, work_head, and work_tail.

Referenced by maint_child_death(), and work().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sighandler_child_death()

static void sighandler_child_death ( void  )
static

Signal handler called for SIGCHLD.

Triggers the respective handler by writing to the trigger pipe.

Definition at line 425 of file gnunet-auto-share.c.

426{
427 static char c;
428 int old_errno = errno; /* back-up errno */
429
431 1 ==
434 &c,
435 sizeof(c)));
436 errno = old_errno; /* restore errno */
437}
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:687
@ GNUNET_DISK_PIPE_END_WRITE
The writing-end of a pipe.

References GNUNET_break, GNUNET_DISK_file_write(), GNUNET_DISK_PIPE_END_WRITE, GNUNET_DISK_pipe_handle(), and sigpipe.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ work()

static void work ( void *  cls)
static

Function called to process work items.

Parameters
clsclosure, NULL

Definition at line 446 of file gnunet-auto-share.c.

447{
448 static const char *argv[14];
449 static char anon_level[20];
450 static char content_prio[20];
451 static char repl_level[20];
452 struct WorkItem *wi;
453 const struct GNUNET_DISK_FileHandle *pr;
454 int argc;
455
456 run_task = NULL;
457 wi = work_head;
459 argc = 0;
460 argv[argc++] = "gnunet-publish";
461 if (verbose)
462 argv[argc++] = "-V";
464 argv[argc++] = "-D";
466 argv[argc++] = "-d";
467 argv[argc++] = "-c";
468 argv[argc++] = cfg_filename;
469 GNUNET_snprintf (anon_level, sizeof(anon_level), "%u", anonymity_level);
470 argv[argc++] = "-a";
471 argv[argc++] = anon_level;
472 GNUNET_snprintf (content_prio, sizeof(content_prio), "%u", content_priority);
473 argv[argc++] = "-p";
474 argv[argc++] = content_prio;
475 GNUNET_snprintf (repl_level, sizeof(repl_level), "%u", replication_level);
476 argv[argc++] = "-r";
477 argv[argc++] = repl_level;
478 argv[argc++] = wi->filename;
479 argv[argc] = NULL;
480 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Publishing `%s'\n"), wi->filename);
481 GNUNET_assert (NULL == publish_proc);
483 NULL,
484 NULL,
485 NULL,
486 "gnunet-publish",
487 (char * const*)argv);
488 if (NULL == publish_proc)
489 {
491 _ ("Failed to run `%s'\n"),
492 "gnunet-publish");
494 run_task =
496 return;
497 }
500 pr,
502 wi);
503}
static int disable_extractor
Disable extractor option to use for publishing.
static unsigned int verbose
Are we running 'verbosely'?
static unsigned int content_priority
Content priority option to use for publishing.
static int do_disable_creation_time
Disable creation time option to use for publishing.
static char * cfg_filename
Name of the configuration file.
static unsigned int anonymity_level
Anonymity level option to use for publishing.
static unsigned int replication_level
Replication level option to use for publishing.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
@ GNUNET_ERROR_TYPE_ERROR
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
struct GNUNET_OS_Process * GNUNET_OS_start_process_vap(enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, struct GNUNET_DISK_PipeHandle *pipe_stderr, const char *filename, char *const argv[])
Start a process.
Definition: os_priority.c:574
@ GNUNET_OS_USE_PIPE_CONTROL
Should a pipe be used to send signals to the child?
#define GNUNET_TIME_UNIT_MINUTES
One minute.

References _, anonymity_level, cfg_filename, content_priority, disable_extractor, do_disable_creation_time, WorkItem::filename, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_pipe_handle(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_OS_start_process_vap(), GNUNET_OS_USE_PIPE_CONTROL, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_read_file(), GNUNET_snprintf(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_MINUTES, maint_child_death(), publish_proc, replication_level, run_task, sigpipe, verbose, work(), work_head, and work_tail.

Referenced by dns_post_request_handler(), schedule_next_task(), and work().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ determine_id()

static int determine_id ( void *  cls,
const char *  filename 
)
static

Recursively scan the given file/directory structure to determine a unique ID that represents the current state of the hierarchy.

Parameters
clswhere to store the unique ID we are computing
filenamefile to scan
Returns
GNUNET_OK (always)

Definition at line 515 of file gnunet-auto-share.c.

516{
517 struct GNUNET_HashCode *id = cls;
518 struct stat sbuf;
519 struct GNUNET_HashCode fx[2];
520 struct GNUNET_HashCode ft;
521
522 if (0 != stat (filename, &sbuf))
523 {
525 return GNUNET_OK;
526 }
527 GNUNET_CRYPTO_hash (filename, strlen (filename), &fx[0]);
528 if (! S_ISDIR (sbuf.st_mode))
529 {
530 uint64_t fattr[2];
531
532 fattr[0] = GNUNET_htonll (sbuf.st_size);
533 fattr[0] = GNUNET_htonll (sbuf.st_mtime);
534
535 GNUNET_CRYPTO_hash (fattr, sizeof(fattr), &fx[1]);
536 }
537 else
538 {
539 memset (&fx[1], 1, sizeof(struct GNUNET_HashCode));
541 }
542 /* use hash here to make hierarchical structure distinct from
543 all files on the same level */
544 GNUNET_CRYPTO_hash (fx, sizeof(fx), &ft);
545 /* use XOR here so that order of the files in the directory
546 does not matter! */
547 GNUNET_CRYPTO_hash_xor (&ft, id, id);
548 return GNUNET_OK;
549}
static int determine_id(void *cls, const char *filename)
Recursively scan the given file/directory structure to determine a unique ID that represents the curr...
static char * filename
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
Definition: disk.c:815
void GNUNET_CRYPTO_hash_xor(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = a ^ b
Definition: crypto_hash.c:135
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
#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...

References determine_id(), filename, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_xor(), GNUNET_DISK_directory_scan(), GNUNET_ERROR_TYPE_WARNING, GNUNET_htonll(), GNUNET_log_strerror_file, and GNUNET_OK.

Referenced by add_file(), and determine_id().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_file()

static int add_file ( void *  cls,
const char *  filename 
)
static

Function called with a filename (or directory name) to publish (if it has changed since the last time we published it).

This function is called for the top-level files only.

Parameters
clsclosure, NULL
filenamecomplete filename (absolute path)
Returns
GNUNET_OK to continue to iterate, GNUNET_SYSERR during shutdown

Definition at line 562 of file gnunet-auto-share.c.

563{
564 struct WorkItem *wi;
565 struct GNUNET_HashCode key;
566 struct GNUNET_HashCode id;
567
568 if (GNUNET_YES == do_shutdown)
569 return GNUNET_SYSERR;
570 if ((NULL != strstr (filename, "/.auto-share")) ||
571 (NULL != strstr (filename, "\\.auto-share")))
572 return GNUNET_OK; /* skip internal file */
575 memset (&id, 0, sizeof(struct GNUNET_HashCode));
576 determine_id (&id, filename);
577 if (NULL != wi)
578 {
579 if (0 == memcmp (&id, &wi->id, sizeof(struct GNUNET_HashCode)))
580 return GNUNET_OK; /* skip: we did this one already */
581 /* contents changed, need to re-do the directory... */
583 GNUNET_YES ==
585 }
586 else
587 {
588 wi = GNUNET_new (struct WorkItem);
590 }
591 wi->id = id;
593 if (GNUNET_YES == do_shutdown)
594 return GNUNET_SYSERR;
595 return GNUNET_OK;
596}
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.

References determine_id(), do_shutdown, WorkItem::filename, filename, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CRYPTO_hash(), GNUNET_new, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, GNUNET_YES, WorkItem::id, id, key, work_finished, work_head, and work_tail.

Referenced by scan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scan()

static void scan ( void *  cls)
static

Periodically run task to update our view of the directory to share.

Parameters
clsNULL

Definition at line 605 of file gnunet-auto-share.c.

606{
607 run_task = NULL;
611}
static int add_file(void *cls, const char *filename)
Function called with a filename (or directory name) to publish (if it has changed since the last time...
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111

References add_file(), dir_name, GNUNET_DISK_directory_scan(), GNUNET_TIME_absolute_get(), run_task, schedule_next_task(), and start_time.

Referenced by run(), and schedule_next_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle c 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cconfiguration

Definition at line 651 of file gnunet-auto-share.c.

655{
656 /* check arguments */
657 if ((NULL == args[0]) || (NULL != args[1]) ||
659 {
660 printf (_ (
661 "You must specify one and only one directory name for automatic publication.\n"));
662 ret = -1;
663 return;
664 }
665 cfg_filename = GNUNET_strdup (cfgfile);
666 cfg = c;
667 dir_name = args[0];
669 load_state ();
671 &scan,
672 NULL);
674}
static void load_state()
Load the set of work_finished items from disk.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
static int ret
Global return value from 'main'.
static void do_stop_task(void *cls)
Task run on shutdown.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition: disk.c:404
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
@ GNUNET_SCHEDULER_PRIORITY_IDLE
Run when otherwise idle.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1338
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.
Definition: scheduler.c:1230

References _, consensus-simulation::args, cfg, cfg_filename, dir_name, do_stop_task(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_DISK_directory_test(), GNUNET_NO, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_strdup, GNUNET_YES, load_state(), ret, run_task, scan(), and work_finished.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_item()

static int free_item ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Free memory associated with the work item from the work_finished map.

Parameters
clsNULL (unused)
keykey of the item in the map (unused)
valuethe struct WorkItem to free
Returns
GNUNET_OK to continue to iterate

Definition at line 686 of file gnunet-auto-share.c.

687{
688 struct WorkItem *wi = value;
689
690 GNUNET_free (wi->filename);
691 GNUNET_free (wi);
692 return GNUNET_OK;
693}

References WorkItem::filename, GNUNET_free, GNUNET_OK, and value.

Referenced by main().

Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function to automatically publish content to GNUnet.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 704 of file gnunet-auto-share.c.

705{
708 "anonymity",
709 "LEVEL",
711 "set the desired LEVEL of sender-anonymity"),
713
715 'd',
716 "disable-creation-time",
718 "disable adding the creation time to the metadata of the uploaded file"),
720
722 'D',
723 "disable-extractor",
724 gettext_noop ("do not use libextractor to add keywords or metadata"),
726
728 "priority",
729 "PRIORITY",
731 "specify the priority of the content"),
733
735 "replication",
736 "LEVEL",
738 "set the desired replication LEVEL"),
740
742
744 };
745 struct WorkItem *wi;
746 int ok;
748
749 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
750 return 2;
752 GNUNET_assert (NULL != sigpipe);
753 shc_chld =
755 ok =
756 (GNUNET_OK ==
758 argc,
759 argv,
760 "gnunet-auto-share [OPTIONS] FILENAME",
761 gettext_noop ("Automatically publish files from a directory on GNUnet"),
762 options,
763 &run,
764 NULL))
765 ? ret
766 : 1;
767 if (NULL != work_finished)
768 {
770 &free_item,
771 NULL);
773 }
774 while (NULL != (wi = work_head))
775 {
777 GNUNET_free (wi->filename);
778 GNUNET_free (wi);
779 }
781 shc_chld = NULL;
783 sigpipe = NULL;
785 cfg_filename = NULL;
786 GNUNET_free_nz ((void *) argv);
787 return ok;
788}
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static struct GNUNET_SIGNAL_Context * shc_chld
#define gettext_noop(String)
Definition: gettext.h:74
static int free_item(void *cls, const struct GNUNET_HashCode *key, void *value)
Free memory associated with the work item from the work_finished map.
static void sighandler_child_death()
Signal handler called for SIGCHLD.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
struct GNUNET_DISK_PipeHandle * GNUNET_DISK_pipe(enum GNUNET_DISK_PipeFlags pf)
Creates an interprocess channel.
Definition: disk.c:1445
enum GNUNET_GenericReturnValue GNUNET_DISK_pipe_close(struct GNUNET_DISK_PipeHandle *p)
Closes an interprocess channel.
Definition: disk.c:1588
@ GNUNET_DISK_PF_NONE
No special options, use non-blocking read/write operations.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
#define GNUNET_free_nz(ptr)
Wrapper around free.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition: program.c:400
struct GNUNET_SIGNAL_Context * GNUNET_SIGNAL_handler_install(int signal, GNUNET_SIGNAL_Handler handler)
Install a signal handler that will be run if the given signal is received.
Definition: signal.c:52
void GNUNET_SIGNAL_handler_uninstall(struct GNUNET_SIGNAL_Context *ctx)
Uninstall a previously installed signal handler.
Definition: signal.c:78
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1253
#define GNUNET_SIGCHLD
Definition: platform.h:42
Definition of a command line option.

References anonymity_level, cfg_filename, content_priority, disable_extractor, do_disable_creation_time, WorkItem::filename, free_item(), gettext_noop, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_PF_NONE, GNUNET_DISK_pipe(), GNUNET_DISK_pipe_close(), GNUNET_free, GNUNET_free_nz, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_uint(), GNUNET_GETOPT_option_verbose(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_SIGCHLD, GNUNET_SIGNAL_handler_install(), GNUNET_SIGNAL_handler_uninstall(), GNUNET_STRINGS_get_utf8_args(), options, replication_level, ret, run(), shc_chld, sighandler_child_death(), sigpipe, verbose, work_finished, work_head, and work_tail.

Here is the call graph for this function:

Variable Documentation

◆ ret

int ret
static

Global return value from 'main'.

Definition at line 69 of file gnunet-auto-share.c.

Referenced by main(), and run().

◆ verbose

unsigned int verbose
static

Are we running 'verbosely'?

Definition at line 74 of file gnunet-auto-share.c.

Referenced by main(), and work().

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Configuration to use.

Definition at line 79 of file gnunet-auto-share.c.

Referenced by run().

◆ cfg_filename

◆ disable_extractor

int disable_extractor
static

Disable extractor option to use for publishing.

Definition at line 89 of file gnunet-auto-share.c.

Referenced by GNUNET_FS_directory_scan_start(), main(), and work().

◆ do_disable_creation_time

int do_disable_creation_time
static

Disable creation time option to use for publishing.

Definition at line 94 of file gnunet-auto-share.c.

Referenced by main(), and work().

◆ run_task

struct GNUNET_SCHEDULER_Task* run_task
static

Handle for the main task that does scanning and working.

Definition at line 99 of file gnunet-auto-share.c.

Referenced by do_stop_task(), maint_child_death(), run(), scan(), schedule_next_task(), and work().

◆ anonymity_level

unsigned int anonymity_level = 1
static

Anonymity level option to use for publishing.

Definition at line 104 of file gnunet-auto-share.c.

Referenced by GSF_pending_request_create_(), main(), and work().

◆ content_priority

unsigned int content_priority = 365
static

Content priority option to use for publishing.

Definition at line 109 of file gnunet-auto-share.c.

Referenced by main(), and work().

◆ replication_level

unsigned int replication_level = 1
static

Replication level option to use for publishing.

Definition at line 114 of file gnunet-auto-share.c.

Referenced by check_dht_local_put(), handle_dht_local_put(), main(), and work().

◆ dir_name

const char* dir_name
static

Top-level directory we monitor to auto-publish.

Definition at line 119 of file gnunet-auto-share.c.

Referenced by get_state_file(), GNUNET_DISK_directory_scan(), run(), and scan().

◆ work_head

struct WorkItem* work_head
static

Head of linked list of files still to publish.

Definition at line 124 of file gnunet-auto-share.c.

Referenced by add_file(), main(), maint_child_death(), schedule_next_task(), and work().

◆ work_tail

struct WorkItem* work_tail
static

Tail of linked list of files still to publish.

Definition at line 129 of file gnunet-auto-share.c.

Referenced by add_file(), main(), maint_child_death(), and work().

◆ work_finished

struct GNUNET_CONTAINER_MultiHashMap* work_finished
static

Map from the hash of the filename (!) to a struct WorkItem that was finished.

Definition at line 135 of file gnunet-auto-share.c.

Referenced by add_file(), load_state(), main(), maint_child_death(), run(), and save_state().

◆ do_shutdown

int do_shutdown
static

Set to GNUNET_YES if we are shutting down.

Definition at line 140 of file gnunet-auto-share.c.

Referenced by add_file(), do_stop_task(), maint_child_death(), and schedule_next_task().

◆ start_time

struct GNUNET_TIME_Absolute start_time
static

Start time of the current round; used to determine how long one iteration takes (which influences how fast we schedule the next one).

Definition at line 147 of file gnunet-auto-share.c.

Referenced by run(), scan(), and schedule_next_task().

◆ sigpipe

struct GNUNET_DISK_PipeHandle* sigpipe
static

Pipe used to communicate 'gnunet-publish' completion (SIGCHLD) via signal.

Definition at line 152 of file gnunet-auto-share.c.

Referenced by main(), maint_child_death(), sighandler_child_death(), and work().

◆ publish_proc

struct GNUNET_OS_Process* publish_proc
static

Handle to the 'gnunet-publish' process that we executed.

Definition at line 157 of file gnunet-auto-share.c.

Referenced by do_stop_task(), maint_child_death(), and work().