struct GNUNET_DISK_PipeHandle;
+enum GNUNET_FILE_Type {
+ GNUNET_DISK_FILE, GNUNET_PIPE
+};
+
+/**
+ * Handle used to access files (and pipes).
+ */
+struct GNUNET_DISK_FileHandle
+{
+
+#if WINDOWS
+ /**
+ * File handle under W32.
+ */
+ HANDLE h;
+
+ /**
+ * Type
+ */
+ enum GNUNET_FILE_Type type;
+
+ /**
+ * Structure for overlapped reading (for pipes)
+ */
+ OVERLAPPED *oOverlapRead;
+
+ /**
+ * Structure for overlapped writing (for pipes)
+ */
+ OVERLAPPED *oOverlapWrite;
+#else
+
+ /**
+ * File handle on other OSes.
+ */
+ int fd;
+
+#endif /*
+ */
+};
+
+
/* we need size_t, and since it can be both unsigned int
or unsigned long long, this IS platform dependent;
but "stdlib.h" should be portable 'enough' to be
/**
* @brief collection of IO descriptors
*/
-struct GNUNET_NETWORK_FDSet;
+struct GNUNET_NETWORK_FDSet
+{
+
+ /**
+ * Maximum number of any socket socket descriptor in the set (plus one)
+ */
+ int nsds;
+
+ /**
+ * Bitset with the descriptors.
+ */
+ fd_set sds;
+
+#ifdef WINDOWS
+ /**
+ * Linked list of handles
+ */
+ struct GNUNET_CONTAINER_SList *handles;
+#endif
+
+};
+
#include "gnunet_disk_lib.h"
GNUNET_SCHEDULER_TaskContext * tc);
+/**
+ * Signature of the select function used by the scheduler.
+ * GNUNET_NETWORK_socket_select matches it.
+ *
+ * @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
+ */
+typedef int (*GNUNET_SCHEDULER_select) (struct GNUNET_NETWORK_FDSet *rfds,
+ struct GNUNET_NETWORK_FDSet *wfds,
+ struct GNUNET_NETWORK_FDSet *efds,
+ struct GNUNET_TIME_Relative timeout);
/**
* Initialize and run scheduler. This function will return when all
* tasks have completed. On systems with signals, receiving a SIGTERM
GNUNET_SCHEDULER_Task task,
void *task_cls);
+/**
+ * Sets the select function to use in the scheduler (scheduler_select).
+ *
+ * @param new_select new select function to use
+ * @return previously used select function
+ */
+GNUNET_SCHEDULER_select
+GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select);
+
+/**
+ * Gets the select function currently used in the scheduler.
+ *
+ * @return currently used select function
+ */
+GNUNET_SCHEDULER_select
+GNUNET_SCHEDULER_get_select ();
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
* @param cls closure
* @param peer (claimed) identity of the other peer
* @param message the message, NULL if we only care about
- * learning about the delay until we should receive again -- FIXME!
- * @param distance in overlay hops; use 1 unless DV (or 0 if message == NULL)
+ * learning about the delay until we should receive again
* @param session identifier used for this session (NULL for plugins
* that do not offer bi-directional communication to the sender
* using the same "connection")
* @file util/disk.h
* @brief Internal DISK related helper functions
* @author Nils Durner
- */
- \r
+ */
#ifndef GNUNET_DISK_H_
#define GNUNET_DISK_H_
#include "gnunet_disk_lib.h"
- \r
-/**
- * Handle used to access files (and pipes).
- */
-struct GNUNET_DISK_FileHandle
-{
-
-#ifdef MINGW
- /**
- * File handle under W32.
- */
- HANDLE h;
-
- /**
- * Type
- */
- enum {GNUNET_DISK_FILE, GNUNET_PIPE} type;
- /**
- * Structure for overlapped reading (for pipes)
- */
- OVERLAPPED *oOverlapRead;
-
- /**
- * Structure for overlapped writing (for pipes)
- */
- OVERLAPPED *oOverlapWrite;
-#else
-
- /**
- * File handle on other OSes.
- */
- int fd;
-
-#endif /* \r */
};
-\r\r\r
+
/**
* Retrieve OS file handle
*
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise
*/
int GNUNET_DISK_internal_file_handle_ (const struct GNUNET_DISK_FileHandle
- *fh, \rvoid *dst, \rsize_t dst_len);
-\r
+ *fh,
+ void *dst,
+ size_t dst_len);
+
#endif /* GNUNET_DISK_H_ */
};
-struct GNUNET_NETWORK_FDSet
-{
-
- /**
- * Maximum number of any socket socket descriptor in the set (plus one)
- */
- int nsds;
-
- /**
- * Bitset with the descriptors.
- */
- fd_set sds;
-
-#ifdef WINDOWS
- /**
- * Linked list of handles
- */
- struct GNUNET_CONTAINER_SList *handles;
-#endif
-
-};
-
#ifndef FD_COPY
#define FD_COPY(s, d) (memcpy ((d), (s), sizeof (fd_set)))
#endif
return 0;
}
-
/* end of network.c */
*/
static int current_lifeness;
+/**
+ * Function to use as a select() in the scheduler.
+ * Defaults to GNUNET_NETWORK_socket_select ()
+ */
+GNUNET_SCHEDULER_select scheduler_select = GNUNET_NETWORK_socket_select;
+
+/**
+ * Sets the select function to use in the scheduler (scheduler_select).
+ *
+ * @param new_select new select function to use
+ * @return previously used select function
+ */
+GNUNET_SCHEDULER_select
+GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select)
+{
+ GNUNET_SCHEDULER_select old_select = scheduler_select;
+ scheduler_select = new_select;
+ if (scheduler_select == NULL)
+ scheduler_select = GNUNET_NETWORK_socket_select;
+ return old_select;
+}
+
+/**
+ * Gets the select function currently used in the scheduler.
+ *
+ * @return currently used select function
+ */
+GNUNET_SCHEDULER_select
+GNUNET_SCHEDULER_get_select ()
+{
+ return scheduler_select;
+}
+
/**
* Check that the given priority is legal (and return it).
*
/* no blocking, more work already ready! */
timeout = GNUNET_TIME_UNIT_ZERO;
}
- ret = GNUNET_NETWORK_socket_select (rs, ws, NULL, timeout);
+ ret = scheduler_select (rs, ws, NULL, timeout);
if (ret == GNUNET_SYSERR)
{
if (errno == EINTR)