GNUNET_DISK_pipe_close (handle->helper_in);
GNUNET_DISK_pipe_close (handle->helper_out);
- GNUNET_SERVER_mst_destroy(handle->mst);
+ GNUNET_SERVER_mst_destroy (handle->mst);
}
+extern GNUNET_SCHEDULER_TaskIdentifier shs_task;
+
/**
* Read from the helper-process
*/
helper_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tsdkctx)
{
struct GNUNET_VPN_HELPER_Handle *handle = cls;
+
/* no message can be bigger then 64k */
char buf[65535];
/* On read-error, restart the helper */
if (t <= 0)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Read error for header from vpn-helper: %m\n");
- stop_helper (handle);
-
- /* Restart the helper */
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- handle->restart_task, handle);
- return;
- }
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Read error for header from vpn-helper: %m\n");
+ stop_helper (handle);
+
+ /* Restart the helper */
+ shs_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ handle->restart_task, handle);
+ return;
+ }
if (GNUNET_SYSERR ==
GNUNET_SERVER_mst_receive (handle->mst, handle->client, buf, t, 0, 0))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "SYSERR from mst\n");
- stop_helper (handle);
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "SYSERR from mst\n");
+ stop_helper (handle);
- /* Restart the helper */
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- handle->restart_task, handle);
- return;
+ /* Restart the helper */
+ shs_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ handle->restart_task, handle);
+ return;
- }
+ }
GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
- handle->fh_from_helper, &helper_read,
- handle);
+ handle->fh_from_helper, &helper_read, handle);
}
void
GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls)
{
struct GNUNET_VPN_HELPER_Handle *handle =
- GNUNET_malloc (sizeof (struct GNUNET_VPN_HELPER_Handle));
+ GNUNET_malloc (sizeof (struct GNUNET_VPN_HELPER_Handle));
handle->helper_in = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO);
handle->helper_out = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES);
handle->restart_task = restart_task;
if (handle->helper_in == NULL || handle->helper_out == NULL)
- {
- GNUNET_free (handle);
- return NULL;
- }
+ {
+ GNUNET_free (handle);
+ return NULL;
+ }
handle->helper_proc =
- GNUNET_OS_start_process (handle->helper_in, handle->helper_out,
- "gnunet-helper-vpn", process_name, ifname,
- ipv6addr, ipv6prefix, ipv4addr, ipv4mask, NULL);
+ GNUNET_OS_start_process (handle->helper_in, handle->helper_out,
+ "gnunet-helper-vpn", process_name, ifname,
+ ipv6addr, ipv6prefix, ipv4addr, ipv4mask, NULL);
handle->fh_from_helper =
- GNUNET_DISK_pipe_handle (handle->helper_out, GNUNET_DISK_PIPE_END_READ);
+ GNUNET_DISK_pipe_handle (handle->helper_out, GNUNET_DISK_PIPE_END_READ);
handle->fh_to_helper =
- GNUNET_DISK_pipe_handle (handle->helper_in, GNUNET_DISK_PIPE_END_WRITE);
+ GNUNET_DISK_pipe_handle (handle->helper_in, GNUNET_DISK_PIPE_END_WRITE);
GNUNET_DISK_pipe_close_end (handle->helper_out, GNUNET_DISK_PIPE_END_WRITE);
GNUNET_DISK_pipe_close_end (handle->helper_in, GNUNET_DISK_PIPE_END_READ);
handle->mst = GNUNET_SERVER_mst_create (cb, cb_cls);
GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
- handle->fh_from_helper, &helper_read,
- handle);
+ handle->fh_from_helper, &helper_read, handle);
return handle;
}