GNUnet  0.11.x
Data Structures | Macros | Functions | Variables
testbed_api_cmd_netjail_stop.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testbed_ng_service.h"
Include dependency graph for testbed_api_cmd_netjail_stop.c:

Go to the source code of this file.

Data Structures

struct  NetJailState
 

Macros

#define NETJAIL_STOP_SCRIPT   "./../testbed/netjail_stop.sh"
 

Functions

static void netjail_stop_cleanup (void *cls, const struct GNUNET_TESTING_Command *cmd)
 
static int netjail_stop_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 
static void child_completed_callback (void *cls, enum GNUNET_OS_ProcessStatusType type, long unsigned int exit_code)
 
static void netjail_stop_run (void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
 Run the "hello world" CMD. More...
 
static int netjail_stop_finish (void *cls, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
 
struct GNUNET_TESTING_Command GNUNET_TESTBED_cmd_netjail_stop (const char *label, char *local_m, char *global_n)
 Create command. More...
 

Variables

struct GNUNET_ChildWaitHandlecwh
 

Macro Definition Documentation

◆ NETJAIL_STOP_SCRIPT

#define NETJAIL_STOP_SCRIPT   "./../testbed/netjail_stop.sh"

Definition at line 32 of file testbed_api_cmd_netjail_stop.c.

Referenced by netjail_stop_run().

Function Documentation

◆ netjail_stop_cleanup()

static void netjail_stop_cleanup ( void *  cls,
const struct GNUNET_TESTING_Command cmd 
)
static
Parameters
clsclosure
cmdcurrent CMD being cleaned up.

Definition at line 58 of file testbed_api_cmd_netjail_stop.c.

References GNUNET_assert, GNUNET_OK, GNUNET_OS_process_destroy(), GNUNET_OS_process_kill(), GNUNET_OS_process_wait(), GNUNET_wait_child_cancel(), ns, and NetJailState::stop_proc.

Referenced by GNUNET_TESTBED_cmd_netjail_stop().

60 {
61  struct NetJailState *ns = cls;
62 
63  if (NULL != cwh)
64  {
66  cwh = NULL;
67  }
68  if (NULL != ns->stop_proc)
69  {
70  GNUNET_assert (0 ==
72  SIGKILL));
76  ns->stop_proc = NULL;
77  }
78 }
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
Definition: os_priority.c:287
struct GNUNET_OS_Process * stop_proc
The process id of the start script.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_ChildWaitHandle * cwh
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Definition: gnunet-abd.c:41
void GNUNET_wait_child_cancel(struct GNUNET_ChildWaitHandle *cwh)
Stop waiting on this child.
int GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
Definition: os_priority.c:983
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
Definition: os_priority.c:225
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netjail_stop_traits()

static int netjail_stop_traits ( void *  cls,
const void **  ret,
const char *  trait,
unsigned int  index 
)
static
Parameters
clsclosure.
[out]retresult
traitname of the trait.
indexindex number of the object to offer.
Returns
GNUNET_OK on success.

Definition at line 91 of file testbed_api_cmd_netjail_stop.c.

References GNUNET_OK.

Referenced by GNUNET_TESTBED_cmd_netjail_stop().

95 {
96  return GNUNET_OK;
97 }
Here is the caller graph for this function:

◆ child_completed_callback()

static void child_completed_callback ( void *  cls,
enum GNUNET_OS_ProcessStatusType  type,
long unsigned int  exit_code 
)
static

Definition at line 101 of file testbed_api_cmd_netjail_stop.c.

References NetJailState::finished, GNUNET_OS_process_destroy(), GNUNET_SYSERR, GNUNET_YES, ns, and NetJailState::stop_proc.

Referenced by netjail_stop_run().

104 {
105  struct NetJailState *ns = cls;
106 
107  cwh = NULL;
108  if (0 == exit_code)
109  {
110  ns->finished = GNUNET_YES;
111  }
112  else
113  {
114  ns->finished = GNUNET_SYSERR;
115  }
117  ns->stop_proc = NULL;
118 }
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
Definition: os_priority.c:287
struct GNUNET_OS_Process * stop_proc
The process id of the start script.
struct GNUNET_ChildWaitHandle * cwh
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Definition: gnunet-abd.c:41
static long unsigned int exit_code
Handler exit code.
Definition: gnunet-qr.c:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netjail_stop_run()

static void netjail_stop_run ( void *  cls,
const struct GNUNET_TESTING_Command cmd,
struct GNUNET_TESTING_Interpreter is 
)
static

Run the "hello world" CMD.

Parameters
clsclosure.
cmdCMD being run.
isinterpreter state.

Definition at line 129 of file testbed_api_cmd_netjail_stop.c.

References child_completed_callback(), NetJailState::global_n, GNUNET_break, GNUNET_OS_INHERIT_STD_ERR, GNUNET_OS_start_process_vap(), GNUNET_wait_child(), NetJailState::local_m, NETJAIL_STOP_SCRIPT, ns, and NetJailState::stop_proc.

Referenced by GNUNET_TESTBED_cmd_netjail_stop().

132 {
133  struct NetJailState *ns = cls;
134  char *const script_argv[] = {NETJAIL_STOP_SCRIPT,
135  ns->local_m,
136  ns->global_n,
137  NULL};
138 
140  NULL,
141  NULL,
142  NULL,
144  script_argv);
145 
148  ns);
149  GNUNET_break (NULL != cwh);
150 
151 }
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:91
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:604
struct GNUNET_OS_Process * stop_proc
The process id of the start script.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_ChildWaitHandle * cwh
#define NETJAIL_STOP_SCRIPT
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Definition: gnunet-abd.c:41
static void child_completed_callback(void *cls, enum GNUNET_OS_ProcessStatusType type, long unsigned int exit_code)
struct GNUNET_ChildWaitHandle * GNUNET_wait_child(struct GNUNET_OS_Process *proc, GNUNET_ChildCompletedCallback cb, void *cb_cls)
Starts the handling of the child processes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netjail_stop_finish()

static int netjail_stop_finish ( void *  cls,
GNUNET_SCHEDULER_TaskCallback  cont,
void *  cont_cls 
)
static

Definition at line 155 of file testbed_api_cmd_netjail_stop.c.

References NetJailState::finished, and ns.

Referenced by GNUNET_TESTBED_cmd_netjail_stop().

158 {
159  struct NetJailState *ns = cls;
160 
161  if (ns->finished)
162  {
163  cont (cont_cls);
164  }
165  return ns->finished;
166 }
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Definition: gnunet-abd.c:41
Here is the caller graph for this function:

Variable Documentation

◆ cwh

Definition at line 34 of file testbed_api_cmd_netjail_stop.c.

Referenced by GNUNET_wait_child(), and maint_child_death().