gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r8901 - in gnunet/src: include util
Date: Sun, 30 Aug 2009 15:06:23 -0600

Author: durner
Date: 2009-08-30 15:06:23 -0600 (Sun, 30 Aug 2009)
New Revision: 8901

Modified:
   gnunet/src/include/gnunet_network_lib.h
   gnunet/src/util/connection.c
   gnunet/src/util/network.c
   gnunet/src/util/server.c
   gnunet/src/util/service.c
   gnunet/src/util/test_connection.c
   gnunet/src/util/test_connection_addressing.c
   gnunet/src/util/test_connection_receive_cancel.c
   gnunet/src/util/test_connection_timeout.c
   gnunet/src/util/test_service.c
Log:
docs & GNUnet-style return codes

Modified: gnunet/src/include/gnunet_network_lib.h
===================================================================
--- gnunet/src/include/gnunet_network_lib.h     2009-08-30 20:48:51 UTC (rev 
8900)
+++ gnunet/src/include/gnunet_network_lib.h     2009-08-30 21:06:23 UTC (rev 
8901)
@@ -51,93 +51,243 @@
 #include "gnunet_disk_lib.h"
 #include "gnunet_time_lib.h"
 
-
+/**
+ * accept a new connection on a socket
+ *
+ * @param desc bound socket
+ * @param address address of the connecting peer, may be NULL
+ * @param address_len length of address
+ * @return client socket
+ */
 struct GNUNET_NETWORK_Handle *
 GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc,
                              struct sockaddr *address,
                              socklen_t *address_len);
 
+/**
+ * Make a non-inheritable to child processes
+ * @param socket
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ * @warning Not implemented on Windows
+ */
 int
 GNUNET_NETWORK_socket_set_inheritable (const struct GNUNET_NETWORK_Handle
                                        *desc);
 
-
+/**
+ * Bind to a connected socket
+ * @param desc socket
+ * @param address address to be bound
+ * @param address_len length of address
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
                     const struct sockaddr *address, socklen_t address_len);
 
+/**
+ * Close a socket
+ * @param desc socket
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc);
 
+/**
+ * Connect a socket
+ * @param desc socket
+ * @param address peer address
+ * @param length of address
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc,
                        const struct sockaddr *address, socklen_t address_len);
 
+/**
+ * Get socket options
+ * @param desc socket
+ * @param level protocol level of the option
+ * @param optname identifier of the option
+ * @param optval options
+ * @param optlen length of optval
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int GNUNET_NETWORK_socket_getsockopt(const struct GNUNET_NETWORK_Handle *desc, 
int level, int optname,
        void *optval, socklen_t *optlen);
 
+/**
+ * Listen on a socket
+ * @param desc socket
+ * @param backlog length of the listen queue
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc, 
int backlog);
 
-ssize_t GNUNET_NETWORK_socket_read (const struct GNUNET_NETWORK_Handle *desc, 
void *buf,
-                        size_t nbyte);
-
+/**
+ * Read data from a connected socket
+ * @param desc socket
+ * @param buffer buffer
+ * @param length length of buffer
+ * @param flags type of message reception
+ */
 ssize_t GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle *desc, 
void *buffer,
                         size_t length, int flags);
 
+/**
+ * Check if sockets meet certain conditions
+ * @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
+ */
 int GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
     struct GNUNET_NETWORK_FDSet *wfds, struct GNUNET_NETWORK_FDSet *efds,
     struct GNUNET_TIME_Relative timeout);
 
 /**
  * Set if a socket should use blocking or non-blocking IO.
- *
+ * @param fd socket
+ * @param doBlock blocking mode
  * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, int 
doBlock);
 
+/**
+ * Send data
+ * @param desc socket
+ * @param buffer data to send
+ * @param length size of the buffer
+ * @param flags type of message transmission
+ * @return number of bytes sent, GNUNET_SYSERR on error
+ */
 ssize_t GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle *desc,
                         const void *buffer, size_t length, int flags);
 
+/**
+ * Send data
+ * @param desc socket
+ * @param message data to send
+ * @param length size of the data
+ * @param flags type of message transmission
+ * @param dest_addr destination address
+ * @param dest_len length of address
+ * @return number of bytes sent, GNUNET_SYSERR on error
+ */
 ssize_t GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle *desc,
                           const void *message, size_t length, int flags,
                           const struct sockaddr *dest_addr,
                           socklen_t dest_len);
 
+/**
+ * Set socket option
+ * @param fd socket
+ * @param level protocol level of the option
+ * @param option_name option identifier
+ * @param option_value value to set
+ * @param option_len size of option_value
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int GNUNET_NETWORK_socket_setsockopt(struct GNUNET_NETWORK_Handle *fd, int 
level, int option_name,
        const void *option_value, socklen_t option_len);
 
+/**
+ * Shut down socket operations
+ * @param desc socket
+ * @param how type of shutdown
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, int 
how);
 
+/**
+ * Create a new socket
+ * @param domain domain of the socket
+ * @param type socket type
+ * @param protocol network protocol
+ * @return new socket, NULL on error
+ */
 struct GNUNET_NETWORK_Handle *GNUNET_NETWORK_socket_socket (int domain, int 
type, int protocol);
 
-ssize_t GNUNET_NETWORK_socket_write (const struct GNUNET_NETWORK_Handle *desc,
-                         const void *buf, size_t nbyte);
-
-
+/**
+ * Reset FD set
+ * @param fds fd set
+ */
 void GNUNET_NETWORK_fdset_zero(struct GNUNET_NETWORK_FDSet *fds);
 
+/**
+ * Add a socket to the FD set
+ * @param fds fd set
+ * @param desc socket to add
+ */
 void GNUNET_NETWORK_fdset_set(struct GNUNET_NETWORK_FDSet *fds,
     const struct GNUNET_NETWORK_Handle *desc);
 
+/**
+ * Check whether a socket is part of the fd set
+ * @param fds fd set
+ * @param desc socket
+ */
 int GNUNET_NETWORK_fdset_isset(const struct GNUNET_NETWORK_FDSet *fds,
     const struct GNUNET_NETWORK_Handle *desc);
 
+/**
+ * Add one fd set to another
+ * @param dst the fd set to add to
+ * @param src the fd set to add from
+ */
 void GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst,
     const struct GNUNET_NETWORK_FDSet *src);
 
+/**
+ * Copy one fd set to another
+ * @param to destination
+ * @param from source
+ */
 void GNUNET_NETWORK_fdset_copy(struct GNUNET_NETWORK_FDSet *to,
     const struct GNUNET_NETWORK_FDSet *from);
 
+/**
+ * Copy a native fd set
+ * @param to destination
+ * @param from native source set
+ * @param the biggest socket number in from + 1
+ */
 void GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to, const 
fd_set *from,
     int nfds);
 
+/**
+ * Add a file handle to the fd set
+ * @param fds fd set
+ * @param h the file handle to add
+ */
 void GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds,
     const struct GNUNET_DISK_FileHandle *h);
 
+/**
+ * Check if a file handle is part of an fd set
+ * @param fds fd set
+ * @param h file handle
+ * @return GNUNET_YES if the file handle is part of the set
+ */
 int GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds,
     const struct GNUNET_DISK_FileHandle *h);
 
+/**
+ * Checks if two fd sets overlap
+ * @param fds1 first fd set
+ * @param fds2 second fd set
+ * @return GNUNET_YES if they do overlap, GNUNET_NO otherwise
+ */
 int GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1, 
const struct GNUNET_NETWORK_FDSet *fds2);
 
+/**
+ * Creates an fd set
+ * @return a new fd set
+ */
 struct GNUNET_NETWORK_FDSet *GNUNET_NETWORK_fdset_create (void);
 
+/**
+ * Releases the associated memory of an fd set
+ * @param fds fd set
+ */
 void GNUNET_NETWORK_fdset_destroy (struct GNUNET_NETWORK_FDSet *fds);
 
 

Modified: gnunet/src/util/connection.c
===================================================================
--- gnunet/src/util/connection.c        2009-08-30 20:48:51 UTC (rev 8900)
+++ gnunet/src/util/connection.c        2009-08-30 21:06:23 UTC (rev 8901)
@@ -276,7 +276,7 @@
   if (addrlen > sizeof (addr))
     {
       GNUNET_break (0);
-      GNUNET_break (0 == GNUNET_NETWORK_socket_close (sock));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
       return NULL;
     }
 
@@ -310,7 +310,7 @@
                    _("Access denied to `%s'\n"),
                    GNUNET_a2s(uaddr, addrlen));
       GNUNET_break (0 == GNUNET_NETWORK_socket_shutdown (sock, SHUT_RDWR));
-      GNUNET_break (0 == GNUNET_NETWORK_socket_close (sock));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
       GNUNET_free (uaddr);
       return NULL;
     }
@@ -436,7 +436,7 @@
       if (GNUNET_SYSERR == GNUNET_NETWORK_socket_set_blocking (s, GNUNET_NO))
         {
           /* we'll treat this one as fatal */
-          GNUNET_break (0 == GNUNET_NETWORK_socket_close (s));
+          GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s));
           return GNUNET_SYSERR;
         }
 #if DEBUG_CONNECTION
@@ -445,13 +445,13 @@
                  GNUNET_a2s(sock->ai_pos->ai_addr,
                             sock->ai_pos->ai_addrlen));
 #endif
-      if ((0 != GNUNET_NETWORK_socket_connect (s,
+      if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (s,
                          sock->ai_pos->ai_addr,
                          sock->ai_pos->ai_addrlen)) && (errno != EINPROGRESS))
         {
           /* maybe refused / unsupported address, try next */
           GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "connect");
-          GNUNET_break (0 == GNUNET_NETWORK_socket_close (s));
+          GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s));
           sock->ai_pos = sock->ai_pos->ai_next;
           continue;
         }
@@ -497,7 +497,7 @@
                  GNUNET_a2s(sock->addr, sock->addrlen));
 #endif
       /* connect failed / timed out */
-      GNUNET_break (0 == GNUNET_NETWORK_socket_close (sock->sock));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock->sock));
       sock->sock = NULL;
       if (GNUNET_SYSERR == try_connect (sock))
         {
@@ -619,7 +619,7 @@
   if (GNUNET_SYSERR == GNUNET_NETWORK_socket_set_blocking (s, GNUNET_NO))
     {
       /* we'll treat this one as fatal */
-      GNUNET_break (0 == GNUNET_NETWORK_socket_close (s));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s));
       return NULL;
     }
 #if DEBUG_CONNECTION
@@ -627,11 +627,11 @@
              _("Trying to connect to `%s'\n"),
              GNUNET_a2s(serv_addr, addrlen));
 #endif
-  if ((0 != GNUNET_NETWORK_socket_connect (s, serv_addr, addrlen)) && (errno 
!= EINPROGRESS))
+  if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (s, serv_addr, addrlen)) && 
(errno != EINPROGRESS))
     {
       /* maybe refused / unsupported address, try next */
       GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "connect");
-      GNUNET_break (0 == GNUNET_NETWORK_socket_close (s));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s));
       return NULL;
     }
   ret = GNUNET_CONNECTION_create_from_existing (sched, s, maxbuf);
@@ -706,7 +706,7 @@
         }
     }
   if (sock->sock != NULL)
-    GNUNET_break (0 == GNUNET_NETWORK_socket_close (sock->sock));
+    GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock->sock));
   GNUNET_free_non_null (sock->addr);
   if (sock->ai != NULL)
     freeaddrinfo (sock->ai);      
@@ -1075,7 +1075,7 @@
       if (NULL != sock->sock)
        {
          GNUNET_NETWORK_socket_shutdown (sock->sock, SHUT_RDWR);
-         GNUNET_break (0 == GNUNET_NETWORK_socket_close (sock->sock));
+         GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock->sock));
          sock->sock = NULL;
        }
       transmit_error (sock);
@@ -1115,7 +1115,7 @@
       GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send");
 #endif
       GNUNET_NETWORK_socket_shutdown (sock->sock, SHUT_RDWR);
-      GNUNET_break (0 == GNUNET_NETWORK_socket_close (sock->sock));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock->sock));
       sock->sock = NULL;
       transmit_error (sock);
       return;

Modified: gnunet/src/util/network.c
===================================================================
--- gnunet/src/util/network.c   2009-08-30 20:48:51 UTC (rev 8900)
+++ gnunet/src/util/network.c   2009-08-30 21:06:23 UTC (rev 8901)
@@ -51,6 +51,14 @@
 #define FD_COPY(s, d) (memcpy ((d), (s), sizeof (fd_set)))
 #endif
 
+/**
+ * accept a new connection on a socket
+ *
+ * @param desc bound socket
+ * @param address address of the connecting peer, may be NULL
+ * @param address_len length of address
+ * @return client socket
+ */
 struct GNUNET_NETWORK_Handle *
 GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc,
                               struct sockaddr *address,
@@ -67,6 +75,13 @@
   return ret;
 }
 
+/**
+ * Bind to a connected socket
+ * @param desc socket
+ * @param address address to be bound
+ * @param address_len length of address
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int
 GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
                             const struct sockaddr *address,
@@ -79,12 +94,13 @@
   if (SOCKET_ERROR == ret)
     SetErrnoFromWinsockError (WSAGetLastError ());
 #endif
-  return ret;
+  return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
 }
 
 /**
  * Set if a socket should use blocking or non-blocking IO.
- *
+ * @param fd socket
+ * @param doBlock blocking mode
  * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
@@ -123,6 +139,11 @@
 #endif
 }
 
+/**
+ * Close a socket
+ * @param desc socket
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int
 GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc)
 {
@@ -141,9 +162,16 @@
     }
 #endif
 
-  return ret;
+  return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
 }
 
+/**
+ * Connect a socket
+ * @param desc socket
+ * @param address peer address
+ * @param length of address
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int
 GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc,
                                const struct sockaddr *address,
@@ -156,9 +184,18 @@
   if (SOCKET_ERROR == ret)
     SetErrnoFromWinsockError (WSAGetLastError ());
 #endif
-  return ret;
+  return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
 }
 
+/**
+ * Get socket options
+ * @param desc socket
+ * @param level protocol level of the option
+ * @param optname identifier of the option
+ * @param optval options
+ * @param optlen length of optval
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int
 GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc,
                                   int level, int optname, void *optval,
@@ -173,9 +210,15 @@
   else if (SOCKET_ERROR == ret)
     SetErrnoFromWinsockError (WSAGetLastError ());
 #endif
-  return ret;
+  return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
 }
 
+/**
+ * Listen on a socket
+ * @param desc socket
+ * @param backlog length of the listen queue
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int
 GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc,
                               int backlog)
@@ -188,9 +231,16 @@
     SetErrnoFromWinsockError (WSAGetLastError ());
 #endif
 
-  return ret;
+  return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
 }
 
+/**
+ * Read data from a connected socket
+ * @param desc socket
+ * @param buffer buffer
+ * @param length length of buffer
+ * @param flags type of message reception
+ */
 ssize_t
 GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle * desc,
                             void *buffer, size_t length, int flags)
@@ -206,6 +256,14 @@
   return ret;
 }
 
+/**
+ * Send data
+ * @param desc socket
+ * @param buffer data to send
+ * @param length size of the buffer
+ * @param flags type of message transmission
+ * @return number of bytes sent, GNUNET_SYSERR on error
+ */
 ssize_t
 GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle * desc,
                             const void *buffer, size_t length, int flags)
@@ -221,6 +279,16 @@
   return ret;
 }
 
+/**
+ * Send data
+ * @param desc socket
+ * @param message data to send
+ * @param length size of the data
+ * @param flags type of message transmission
+ * @param dest_addr destination address
+ * @param dest_len length of address
+ * @return number of bytes sent, GNUNET_SYSERR on error
+ */
 ssize_t
 GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle * desc,
                               const void *message, size_t length, int flags,
@@ -238,6 +306,15 @@
   return ret;
 }
 
+/**
+ * Set socket option
+ * @param fd socket
+ * @param level protocol level of the option
+ * @param option_name option identifier
+ * @param option_value value to set
+ * @param option_len size of option_value
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int
 GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd,
                                   int level, int option_name,
@@ -252,9 +329,16 @@
     SetErrnoFromWinsockError (WSAGetLastError ());
 #endif
 
-  return ret;
+  return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
 }
 
+/**
+ * Create a new socket
+ * @param domain domain of the socket
+ * @param type socket type
+ * @param protocol network protocol
+ * @return new socket, NULL on error
+ */
 struct GNUNET_NETWORK_Handle *
 GNUNET_NETWORK_socket_socket (int domain, int type, int protocol)
 {
@@ -276,6 +360,12 @@
   return ret;
 }
 
+/**
+ * Shut down socket operations
+ * @param desc socket
+ * @param how type of shutdown
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
 int
 GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc,
                                 int how)
@@ -288,9 +378,15 @@
     SetErrnoFromWinsockError (WSAGetLastError ());
 #endif
 
-  return ret;
+  return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
 }
 
+/**
+ * Make a non-inheritable to child processes
+ * @param socket
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ * @warning Not implemented on Windows
+ */
 int
 GNUNET_NETWORK_socket_set_inheritable (const struct GNUNET_NETWORK_Handle
                                        *desc)
@@ -306,6 +402,10 @@
 #endif
 }
 
+/**
+ * Reset FD set
+ * @param fds fd set
+ */
 void
 GNUNET_NETWORK_fdset_zero (struct GNUNET_NETWORK_FDSet *fds)
 {
@@ -318,6 +418,11 @@
 #endif
 }
 
+/**
+ * Add a socket to the FD set
+ * @param fds fd set
+ * @param desc socket to add
+ */
 void
 GNUNET_NETWORK_fdset_set (struct GNUNET_NETWORK_FDSet *fds,
                           const struct GNUNET_NETWORK_Handle *desc)
@@ -328,6 +433,11 @@
     fds->nsds = desc->fd + 1;
 }
 
+/**
+ * Check whether a socket is part of the fd set
+ * @param fds fd set
+ * @param desc socket
+ */
 int
 GNUNET_NETWORK_fdset_isset (const struct GNUNET_NETWORK_FDSet *fds,
                             const struct GNUNET_NETWORK_Handle *desc)
@@ -335,6 +445,11 @@
   return FD_ISSET (desc->fd, &fds->sds);
 }
 
+/**
+ * Add one fd set to another
+ * @param dst the fd set to add to
+ * @param src the fd set to add from
+ */
 void
 GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst,
                           const struct GNUNET_NETWORK_FDSet *src)
@@ -350,6 +465,11 @@
       }
 }
 
+/**
+ * Copy one fd set to another
+ * @param to destination
+ * @param from source
+ */
 void
 GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to,
                            const struct GNUNET_NETWORK_FDSet *from)
@@ -370,6 +490,12 @@
 #endif
 }
 
+/**
+ * Copy a native fd set
+ * @param to destination
+ * @param from native source set
+ * @param the biggest socket number in from + 1
+ */
 void
 GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to,
                                   const fd_set * from, int nfds)
@@ -378,6 +504,11 @@
   to->nsds = nfds;
 }
 
+/**
+ * Add a file handle to the fd set
+ * @param fds fd set
+ * @param h the file handle to add
+ */
 void
 GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds,
                                  const struct GNUNET_DISK_FileHandle *h)
@@ -397,6 +528,12 @@
 #endif
 }
 
+/**
+ * Check if a file handle is part of an fd set
+ * @param fds fd set
+ * @param h file handle
+ * @return GNUNET_YES if the file handle is part of the set
+ */
 int
 GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds,
                                    const struct GNUNET_DISK_FileHandle *h)
@@ -409,6 +546,12 @@
 #endif
 }
 
+/**
+ * Checks if two fd sets overlap
+ * @param fds1 first fd set
+ * @param fds2 second fd set
+ * @return GNUNET_YES if they do overlap, GNUNET_NO otherwise
+ */
 int
 GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1,
                               const struct GNUNET_NETWORK_FDSet *fds2)
@@ -426,6 +569,10 @@
   return GNUNET_NO;
 }
 
+/**
+ * Creates an fd set
+ * @return a new fd set
+ */
 struct GNUNET_NETWORK_FDSet *
 GNUNET_NETWORK_fdset_create ()
 {
@@ -440,6 +587,10 @@
   return fds;
 }
 
+/**
+ * Releases the associated memory of an fd set
+ * @param fds fd set
+ */
 void
 GNUNET_NETWORK_fdset_destroy (struct GNUNET_NETWORK_FDSet *fds)
 {
@@ -449,6 +600,14 @@
   GNUNET_free (fds);
 }
 
+/**
+ * Check if sockets meet certain conditions
+ * @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
+ */
 int
 GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
                               struct GNUNET_NETWORK_FDSet *wfds,
@@ -516,23 +675,6 @@
   else
     FD_ZERO(&sock_except);
 
-  /*
-  if (rfds)
-    FD_COPY (&rfds->sds, &sock_read);
-  else
-    FD_ZERO(&sock_read);
-
-  if (wfds)
-    FD_COPY (&wfds->sds, &sock_write);
-  else
-    FD_ZERO(&sock_write);
-
-  if (efds)
-    FD_COPY (&efds->sds, &sock_except);
-  else
-    FD_ZERO(&sock_except);
-*/
-
   /* multiplex between winsock select() and waiting on the handles */
 
   FD_ZERO (&aread);

Modified: gnunet/src/util/server.c
===================================================================
--- gnunet/src/util/server.c    2009-08-30 20:48:51 UTC (rev 8900)
+++ gnunet/src/util/server.c    2009-08-30 21:06:23 UTC (rev 8901)
@@ -324,7 +324,7 @@
     {
       /* shutdown was initiated */
       GNUNET_assert (server->listen_socket != NULL);
-      GNUNET_break (0 == GNUNET_NETWORK_socket_close (server->listen_socket));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close 
(server->listen_socket));
       server->listen_socket = NULL;
       if (server->do_shutdown)
         destroy_server (server);
@@ -402,20 +402,20 @@
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                          "setsockopt");
   /* bind the socket */
-  if (GNUNET_NETWORK_socket_bind (sock, serverAddr, socklen) < 0)
+  if (GNUNET_NETWORK_socket_bind (sock, serverAddr, socklen) != GNUNET_OK)
     {
       GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind");
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   _
                   ("`%s' failed for port %d. Is the service already 
running?\n"),
                   "bind", port);
-      GNUNET_break (0 == GNUNET_NETWORK_socket_close (sock));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
       return NULL;
     }
   if (0 != GNUNET_NETWORK_socket_listen (sock, 5))
     {
       GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "listen");
-      GNUNET_break (0 == GNUNET_NETWORK_socket_close (sock));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
       return NULL;
     }
 #if DEBUG_SERVER
@@ -468,7 +468,7 @@
   ret->shutpipe = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileDescriptor 
*[2]));
   if (NULL == (ret->shutpipe = GNUNET_DISK_pipe (GNUNET_NO)))
     {
-      GNUNET_break (0 == GNUNET_NETWORK_socket_close (lsock));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (lsock));
       GNUNET_free (ret->shutpipe);
       GNUNET_free (ret);
       return NULL;

Modified: gnunet/src/util/service.c
===================================================================
--- gnunet/src/util/service.c   2009-08-30 20:48:51 UTC (rev 8900)
+++ gnunet/src/util/service.c   2009-08-30 21:06:23 UTC (rev 8901)
@@ -836,7 +836,7 @@
             }
         }
       if (NULL != desc)
-        GNUNET_break (0 == GNUNET_NETWORK_socket_close (desc));
+        GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (desc));
     }
 
 

Modified: gnunet/src/util/test_connection.c
===================================================================
--- gnunet/src/util/test_connection.c   2009-08-30 20:48:51 UTC (rev 8900)
+++ gnunet/src/util/test_connection.c   2009-08-30 21:06:23 UTC (rev 8901)
@@ -66,7 +66,7 @@
                 "setsockopt");
   GNUNET_assert (GNUNET_NETWORK_socket_bind (desc, 
                                             (const struct sockaddr*) &sa,
-                                            sizeof (sa)) >= 0);
+                                            sizeof (sa)) == GNUNET_OK);
   GNUNET_NETWORK_socket_listen (desc, 5);
   return desc;
 }

Modified: gnunet/src/util/test_connection_addressing.c
===================================================================
--- gnunet/src/util/test_connection_addressing.c        2009-08-30 20:48:51 UTC 
(rev 8900)
+++ gnunet/src/util/test_connection_addressing.c        2009-08-30 21:06:23 UTC 
(rev 8901)
@@ -65,7 +65,7 @@
                 "setsockopt");
   GNUNET_assert (GNUNET_NETWORK_socket_bind (desc,
                                             (const struct sockaddr*) &sa,
-                                            sizeof (sa)) >= 0);
+                                            sizeof (sa)) == GNUNET_OK);
   GNUNET_NETWORK_socket_listen (desc, 5);
   return desc;
 }

Modified: gnunet/src/util/test_connection_receive_cancel.c
===================================================================
--- gnunet/src/util/test_connection_receive_cancel.c    2009-08-30 20:48:51 UTC 
(rev 8900)
+++ gnunet/src/util/test_connection_receive_cancel.c    2009-08-30 21:06:23 UTC 
(rev 8901)
@@ -66,7 +66,7 @@
                 "setsockopt");
   GNUNET_assert (GNUNET_NETWORK_socket_bind (desc,
                                             (const struct sockaddr*) &sa,
-                                            sizeof (sa)) >= 0);
+                                            sizeof (sa)) == GNUNET_OK);
   GNUNET_NETWORK_socket_listen (desc, 5);
   return desc;
 }

Modified: gnunet/src/util/test_connection_timeout.c
===================================================================
--- gnunet/src/util/test_connection_timeout.c   2009-08-30 20:48:51 UTC (rev 
8900)
+++ gnunet/src/util/test_connection_timeout.c   2009-08-30 21:06:23 UTC (rev 
8901)
@@ -59,7 +59,7 @@
                 "setsockopt");
   GNUNET_assert (GNUNET_NETWORK_socket_bind (desc, 
                                             (const struct sockaddr*) &sa, 
-                                            sizeof (sa)) >= 0);
+                                            sizeof (sa)) == GNUNET_OK);
   GNUNET_NETWORK_socket_listen (desc, 5);
   return desc;
 }

Modified: gnunet/src/util/test_service.c
===================================================================
--- gnunet/src/util/test_service.c      2009-08-30 20:48:51 UTC (rev 8900)
+++ gnunet/src/util/test_service.c      2009-08-30 21:06:23 UTC (rev 8901)
@@ -326,7 +326,7 @@
     }
   else
     {
-      GNUNET_break (0 == GNUNET_NETWORK_socket_close (s));
+      GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s));
       ret += check6 ();
       ret += check6d ();        /* with daemonization */
     }





reply via email to

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