[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-gtk] branch master updated: -remove dead windows code
From: |
gnunet |
Subject: |
[gnunet-gtk] branch master updated: -remove dead windows code |
Date: |
Mon, 24 Jan 2022 08:57:53 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet-gtk.
The following commit(s) were added to refs/heads/master by this push:
new d4118cff -remove dead windows code
d4118cff is described below
commit d4118cff296f33d2c805ea5f2d7c405e68de0453
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Mon Jan 24 08:57:48 2022 +0100
-remove dead windows code
---
src/lib/eventloop.c | 348 ----------------------------------------------------
1 file changed, 348 deletions(-)
diff --git a/src/lib/eventloop.c b/src/lib/eventloop.c
index 84ad3974..5dc971c1 100644
--- a/src/lib/eventloop.c
+++ b/src/lib/eventloop.c
@@ -36,11 +36,7 @@
* For non-Windows OSes, that is. For Windows it's always 64, because
* that's the limit anyway.
*/
-#ifdef WINDOWS
-#define INITIAL_POLL_ARRAY_SIZE 64
-#else
#define INITIAL_POLL_ARRAY_SIZE 30
-#endif
/**
* Main context for our event loop.
@@ -118,60 +114,6 @@ struct GNUNET_GTK_MainLoop
*/
int argc;
-#if WINDOWS
- /**
- * Array to hold pipe handles during a select() call
- */
- struct GNUNET_DISK_FileHandle **read_array;
-
- /**
- * Allocated length of read_array
- */
- int read_array_length;
-
- /**
- * Event to fire when a socket is ready for reading
- */
- HANDLE hEventRead;
-
- /**
- * Event to fire when a socket is ready for writing
- */
- HANDLE hEventWrite;
-
- /**
- * Event to fire when a socket had an error
- */
- HANDLE hEventException;
-
- /**
- * Event that is permanently enabled and is used to signal a pipe
- * that is ready for writing (asynchronous pipes are always writable)
- */
- HANDLE hEventPipeWrite;
-
- /**
- * Event that is permanently enabled and is used to signal a pipe
- * that is ready for reading (used to wake up early on a pipe that
- * is known to be readable)
- */
- HANDLE hEventReadReady;
-
- /**
- * A list to hold file handles that are ready for reading
- */
- struct GNUNET_CONTAINER_SList *handles_read;
-
- /**
- * A list to hold file handles that are ready for writing
- */
- struct GNUNET_CONTAINER_SList *handles_write;
-
- /**
- * A list to hold file handles that are broken
- */
- struct GNUNET_CONTAINER_SList *handles_except;
-#endif
};
@@ -365,295 +307,6 @@ keepalive_task (void *cls)
}
-#ifdef WINDOWS
-/**
- * FIXME.
- */
-struct _select_params_gtk
-{
- /**
- * Read set.
- */
- struct GNUNET_NETWORK_FDSet *rfds;
-
- /**
- * Write set.
- */
- struct GNUNET_NETWORK_FDSet *wfds;
-
- /**
- * Except set.
- */
- struct GNUNET_NETWORK_FDSet *efds;
-
- /**
- * Timeout for select().
- */
- struct GNUNET_TIME_Relative timeout;
-
- /**
- * FIXME.
- */
- HANDLE event_to_that_wakes_us_up;
-
- /**
- * FIXME.
- */
- HANDLE event_to_signal_we_woke_up;
-
- /**
- * FIXME.
- */
- HANDLE event_to_wait_for_a_job;
-
- /**
- * Set to return value from select.
- */
- int status;
-};
-
-static unsigned __stdcall _gnunet_selector_thread (void *p)
-{
- struct _select_params_gtk *sp = p;
-
- while (1)
- {
- WaitForSingleObject (sp->event_to_wait_for_a_job, INFINITE);
- ResetEvent (sp->event_to_wait_for_a_job);
- sp->status =
- GNUNET_NETWORK_socket_select (sp->rfds, sp->wfds, sp->efds, sp->timeout);
- SetEvent (sp->event_to_signal_we_woke_up);
- }
- return 0;
-}
-
-
-static int
-handle_gui_events (struct GNUNET_GTK_MainLoop *ml,
- gint max_priority,
- gint need_gfds)
-{
- /* Take care of GUI events.
- * Dispatching the events here will eventually crash the scheduler, must do
this
- * from within a task (currently we're not in a task, but in a select()
call, remember)
- * Startup reason is used to pass the scheduler sanity check.
- */
- if (NULL == ml->gmc)
- return GNUNET_NO;
- if (g_main_context_check (ml->gmc,
- max_priority,
- ml->cached_poll_array,
- need_gfds))
- {
- GNUNET_SCHEDULER_add_with_reason_and_priority (&dispatch_gtk_task,
- ml,
-
GNUNET_SCHEDULER_REASON_STARTUP,
-
GNUNET_SCHEDULER_PRIORITY_UI);
- return GNUNET_YES;
- }
- return GNUNET_NO;
-}
-
-
-/**
- * Replacement for the GNUnet scheduler's "select" that integrates the
- * Gtk event loop. We run g_poll() in the main thread and run
- * GNUnet's own select() in a separate thread in parallel.
- * Then we process the Gtk events (by adding a task to do so to the GNUnet
- * scheduler), and, if applicable, return the GNUnet-scheduler events back
- * to GNUnet.
- *
- * @param cls the 'struct GNUNET_GTK_MainLoop'
- * @param rfds set of sockets to be checked for readability
- * @param wfds set of sockets to be checked for writability
- * @param efds set of sockets to be checked for exceptions
- * @param timeout relative value when to return
- * @return number of selected sockets, GNUNET_SYSERR on error
- */
-static int
-gnunet_gtk_select (void *cls,
- struct GNUNET_NETWORK_FDSet *rfds,
- struct GNUNET_NETWORK_FDSet *wfds,
- struct GNUNET_NETWORK_FDSet *efds,
- const struct GNUNET_TIME_Relative timeout)
-{
- struct GNUNET_GTK_MainLoop *ml = cls;
- int gnunet_select_result;
- struct GNUNET_TIME_Relative timeout_from_delay;
- gint delay;
- gint need_gfds;
- gint max_priority;
- gint g_poll_result;
- DWORD wait_result;
-
- static struct GNUNET_NETWORK_FDSet *standin_rfds;
- static HANDLE wakeup_event_for_gnunet;
- static HANDLE gnunet_woke_up_event;
- static HANDLE gnunet_selector_thread_job_event;
- static struct GNUNET_DISK_FileHandle *wakeup_event_for_gnunet_fh;
- static struct _select_params_gtk *sp;
-
- /* To be safe, we do g_poll in the main thread (MSDN does mention
- * something about message queue being per-thread, and g_poll does
- * wait for messages), unless glib main loop is not running,
- * in which case we just use gnunet select right here.
- */
- static HANDLE gnunet_select_subthread;
-
- static gsize initialized = 0;
-
- if (ml->gml == NULL || TRUE != g_main_loop_is_running (ml->gml))
- return GNUNET_NETWORK_socket_select (rfds, wfds, efds, timeout);
-
- if (g_once_init_enter (&initialized))
- {
- wakeup_event_for_gnunet = CreateEvent (NULL, TRUE, FALSE, NULL);
- gnunet_woke_up_event = CreateEvent (NULL, TRUE, FALSE, NULL);
- standin_rfds = GNUNET_NETWORK_fdset_create ();
- wakeup_event_for_gnunet_fh =
- GNUNET_DISK_get_handle_from_w32_handle (wakeup_event_for_gnunet);
- gnunet_selector_thread_job_event = CreateEvent (NULL, TRUE, FALSE, NULL);
- sp = GNUNET_new (struct _select_params_gtk);
-
- sp->event_to_signal_we_woke_up = gnunet_woke_up_event;
- sp->event_to_that_wakes_us_up = wakeup_event_for_gnunet;
- sp->event_to_wait_for_a_job = gnunet_selector_thread_job_event;
-
- gnunet_select_subthread =
- (HANDLE) _beginthreadex (NULL, 0, _gnunet_selector_thread, sp, 0, NULL);
-
- g_once_init_leave (&initialized, 1);
- }
-
- if (wakeup_event_for_gnunet == NULL || gnunet_woke_up_event == NULL ||
- gnunet_select_subthread == NULL || wakeup_event_for_gnunet_fh == NULL ||
- gnunet_selector_thread_job_event == NULL)
- {
- GNUNET_break (0);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%s",
- _ ("Failed to initialize GNUnet-GTK select\n"));
- return GNUNET_SYSERR;
- }
-
- timeout_from_delay = GNUNET_TIME_UNIT_ZERO;
- /* Optimization hack: assume that at least one of the fds
- * is not NULL and not empty.
- */
- gnunet_select_result =
- GNUNET_NETWORK_socket_select (rfds, wfds, efds, timeout_from_delay);
- if (gnunet_select_result < 0)
- return gnunet_select_result;
-
- if (ml->cached_poll_array_size == 0)
- resize_cached_poll_array (ml, INITIAL_POLL_ARRAY_SIZE);
-
- delay = INT_MAX;
- need_gfds = -1;
- if (NULL != ml->gmc)
- {
- g_main_context_prepare (ml->gmc, &max_priority);
- need_gfds = g_main_context_query (ml->gmc,
- max_priority,
- &delay,
- ml->cached_poll_array,
- ml->cached_poll_array_size);
- if (ml->cached_poll_array_size < need_gfds + 1)
- {
- GNUNET_break (0);
- GNUNET_log (
- GNUNET_ERROR_TYPE_ERROR,
- _ ("Ran out of handle space - g_poll() needs %d handles, has %d!\n"),
- need_gfds + 1,
- ml->cached_poll_array_size);
- return GNUNET_SYSERR;
- }
- }
- if (timeout.rel_value_us != GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
- {
- if (delay >= 0)
- delay = GNUNET_MIN (timeout.rel_value_us /
- GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us,
- delay);
- else
- delay = timeout.rel_value_us /
GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us;
- }
-
- g_poll_result = g_poll (ml->cached_poll_array, need_gfds, 0);
- if (g_poll_result < 0)
- {
- GNUNET_break (0);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "g_poll() returned %d\n",
- g_poll_result);
- return GNUNET_SYSERR;
- }
- g_poll_result =
- (GNUNET_YES == handle_gui_events (ml, max_priority, need_gfds)) ? 1 : 0;
-
- if ((gnunet_select_result > 0) || (g_poll_result > 0) || (delay == 0))
- {
- return gnunet_select_result + g_poll_result;
- }
-
- if (rfds == NULL)
- rfds = standin_rfds;
-
- ResetEvent (wakeup_event_for_gnunet);
- ResetEvent (gnunet_woke_up_event);
-
- GNUNET_NETWORK_fdset_handle_set_first (rfds, wakeup_event_for_gnunet_fh);
-
- sp->status = 0;
- /* Optimization hack: assume that at least one of the fds
- * is not NULL and not empty.
- */
- sp->rfds = rfds;
- sp->wfds = wfds;
- sp->efds = efds;
-
- sp->timeout =
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, delay);
- ml->cached_poll_array[need_gfds].fd = (intptr_t) gnunet_woke_up_event;
- ml->cached_poll_array[need_gfds].events = G_IO_IN;
-
- /* Wakes up the gnunet selector thread */
- SetEvent (gnunet_selector_thread_job_event);
-
- /* During this call, if gnunet select threads wakes up first,
- * it will set gnunet_woke_up_event, waking us up.
- */
- g_poll_result = g_poll (ml->cached_poll_array, need_gfds + 1, delay);
-
- SetEvent (wakeup_event_for_gnunet);
-
- wait_result = WaitForSingleObject (gnunet_woke_up_event, INFINITE);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Finished waiting for the gnunet select thread: %lu %d\n",
- wait_result,
- sp->status);
-
- g_poll_result =
- (GNUNET_YES == handle_gui_events (ml, max_priority, need_gfds)) ? 1 : 0;
-
- if (-1 == sp->status)
- {
- return GNUNET_SYSERR;
- }
-
- if (GNUNET_NETWORK_fdset_handle_isset (rfds, wakeup_event_for_gnunet_fh))
- sp->status -= 1;
-
- if (-1 == sp->status)
- {
- GNUNET_break (0);
- }
-
- return sp->status + g_poll_result;
-}
-
-#else
-
#ifndef FD_COPY
#define FD_COPY(s, d) (memcpy ((d), (s), sizeof (fd_set)))
#endif
@@ -823,7 +476,6 @@ gnunet_gtk_select (void *cls,
return result;
}
-#endif
/**
* Actual main function run right after GNUnet's scheduler
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet-gtk] branch master updated: -remove dead windows code,
gnunet <=