gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r16492 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r16492 - in gnunet/src: include util
Date: Sun, 14 Aug 2011 13:08:43 +0200

Author: grothoff
Date: 2011-08-14 13:08:43 +0200 (Sun, 14 Aug 2011)
New Revision: 16492

Modified:
   gnunet/src/include/gnunet_disk_lib.h
   gnunet/src/include/gnunet_network_lib.h
   gnunet/src/include/gnunet_scheduler_lib.h
   gnunet/src/include/gnunet_transport_plugin.h
   gnunet/src/util/disk.h
   gnunet/src/util/network.c
   gnunet/src/util/scheduler.c
Log:
LRN: Added-the-ability-to-substitute-scheduler-select.

Modified: gnunet/src/include/gnunet_disk_lib.h
===================================================================
--- gnunet/src/include/gnunet_disk_lib.h        2011-08-14 11:08:02 UTC (rev 
16491)
+++ gnunet/src/include/gnunet_disk_lib.h        2011-08-14 11:08:43 UTC (rev 
16492)
@@ -36,6 +36,48 @@
 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

Modified: gnunet/src/include/gnunet_network_lib.h
===================================================================
--- gnunet/src/include/gnunet_network_lib.h     2011-08-14 11:08:02 UTC (rev 
16491)
+++ gnunet/src/include/gnunet_network_lib.h     2011-08-14 11:08:43 UTC (rev 
16492)
@@ -45,9 +45,30 @@
 /**
  * @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"
 #include "gnunet_time_lib.h"
 

Modified: gnunet/src/include/gnunet_scheduler_lib.h
===================================================================
--- gnunet/src/include/gnunet_scheduler_lib.h   2011-08-14 11:08:02 UTC (rev 
16491)
+++ gnunet/src/include/gnunet_scheduler_lib.h   2011-08-14 11:08:43 UTC (rev 
16492)
@@ -195,6 +195,20 @@
 
 
 /**
+ * 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
  * (and other similar signals) will cause "GNUNET_SCHEDULER_shutdown"
@@ -494,6 +508,23 @@
                              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

Modified: gnunet/src/include/gnunet_transport_plugin.h
===================================================================
--- gnunet/src/include/gnunet_transport_plugin.h        2011-08-14 11:08:02 UTC 
(rev 16491)
+++ gnunet/src/include/gnunet_transport_plugin.h        2011-08-14 11:08:43 UTC 
(rev 16492)
@@ -92,8 +92,7 @@
  * @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")

Modified: gnunet/src/util/disk.h
===================================================================
--- gnunet/src/util/disk.h      2011-08-14 11:08:02 UTC (rev 16491)
+++ gnunet/src/util/disk.h      2011-08-14 11:08:43 UTC (rev 16492)
@@ -22,52 +22,14 @@
  * @file util/disk.h
  * @brief Internal DISK related helper functions
  * @author Nils Durner
- */ 
-  
+ */
 #ifndef GNUNET_DISK_H_
 #define GNUNET_DISK_H_
   
 #include "gnunet_disk_lib.h"
-  
-/**
- * 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                          /* 
- */
 };
-
-
-
+
 /**
  * Retrieve OS file handle
  *
@@ -78,8 +40,8 @@
  * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
  */ 
 int GNUNET_DISK_internal_file_handle_ (const struct GNUNET_DISK_FileHandle
-                                       *fh, 
-void *dst, 
-size_t dst_len);
-
+                                       *fh, 
+                                      void *dst, 
+                                      size_t dst_len);
+
 #endif  /* GNUNET_DISK_H_ */

Modified: gnunet/src/util/network.c
===================================================================
--- gnunet/src/util/network.c   2011-08-14 11:08:02 UTC (rev 16491)
+++ gnunet/src/util/network.c   2011-08-14 11:08:43 UTC (rev 16492)
@@ -65,28 +65,6 @@
 };
 
 
-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
@@ -1620,5 +1598,4 @@
     return 0;
 }
 
-
 /* end of network.c */

Modified: gnunet/src/util/scheduler.c
===================================================================
--- gnunet/src/util/scheduler.c 2011-08-14 11:08:02 UTC (rev 16491)
+++ gnunet/src/util/scheduler.c 2011-08-14 11:08:43 UTC (rev 16492)
@@ -246,6 +246,39 @@
 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).
  *
  * @param p priority value to check
@@ -806,7 +839,7 @@
           /* 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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]