asserts
[oweals/gnunet.git] / src / util / client.c
index 86b36bfbba10b0d3c4b2e6849858dec5c973e708..88f326573b7bcd8a675ad1d9c55f96292abbc7a7 100644 (file)
@@ -34,7 +34,7 @@
 #include "gnunet_server_lib.h"
 #include "gnunet_scheduler_lib.h"
 
-#define DEBUG_CLIENT GNUNET_NO
+#define DEBUG_CLIENT GNUNET_YES
 
 /**
  * How often do we re-try tranmsitting requests before giving up?
@@ -136,7 +136,6 @@ struct TransmitGetResponseContext
   void *rn_cls;
 };
 
-
 /**
  * Struct to refer to a GNUnet TCP connection.
  * This is more than just a socket because if the server
@@ -540,55 +539,6 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock,
 }
 
 
-/**
- * If possible, write a shutdown message to the target
- * buffer and destroy the client connection.
- *
- * @param cls the "struct GNUNET_CLIENT_Connection" to destroy
- * @param size number of bytes available in buf
- * @param buf NULL on error, otherwise target buffer
- * @return number of bytes written to buf
- */
-static size_t
-write_shutdown (void *cls, size_t size, void *buf)
-{
-  struct GNUNET_MessageHeader *msg;
-  struct GNUNET_CLIENT_Connection *sock = cls;
-
-  GNUNET_CLIENT_disconnect (sock, GNUNET_YES);
-  if (size < sizeof (struct GNUNET_MessageHeader))
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                  _("Failed to transmit shutdown request to client.\n"));
-      return 0;                 /* client disconnected */
-    }
-  msg = (struct GNUNET_MessageHeader *) buf;
-  msg->type = htons (GNUNET_MESSAGE_TYPE_SHUTDOWN);
-  msg->size = htons (sizeof (struct GNUNET_MessageHeader));
-  return sizeof (struct GNUNET_MessageHeader);
-}
-
-
-/**
- * Request that the service should shutdown.
- * Afterwards, the connection will automatically be
- * disconnected.  Hence the "sock" should not
- * be used by the caller after this call
- * (calling this function frees "sock" after a while).
- *
- * @param sock the socket connected to the service
- */
-void
-GNUNET_CLIENT_service_shutdown (struct GNUNET_CLIENT_Connection *sock)
-{
-  GNUNET_CONNECTION_notify_transmit_ready (sock->sock,
-                                           sizeof (struct
-                                                   GNUNET_MessageHeader),
-                                           GNUNET_TIME_UNIT_FOREVER_REL,
-                                           &write_shutdown, sock);
-}
-
-
 /**
  * Report service unavailable.
  */
@@ -648,6 +598,7 @@ write_test (void *cls, size_t size, void *buf)
                   _("Failure to transmit TEST request.\n"));
 #endif
       service_test_error (conn->sched, conn->test_cb, conn->test_cb_cls);
+      GNUNET_CLIENT_disconnect (conn, GNUNET_NO);
       return 0;                 /* client disconnected */
     }
 #if DEBUG_CLIENT