asserts
[oweals/gnunet.git] / src / util / service.c
index 8597fddf604d3f09e0f806210ef9388887d2b1bf..82e7070a10eca8b471bd9869d964eb0503e7fcda 100644 (file)
@@ -510,11 +510,6 @@ struct GNUNET_SERVICE_Context
    */
   int require_found;
 
-  /**
-   * Can clients ask us to initiate a shutdown?
-   */
-  int allow_shutdown;
-
   /**
    * Our options.
    */
@@ -570,86 +565,6 @@ handle_test (void *cls,
 }
 
 
-static size_t
-transmit_shutdown_deny (void *cls, size_t size, void *buf)
-{
-  struct GNUNET_SERVER_Client *client = cls;
-  struct GNUNET_MessageHeader *msg;
-
-  if (size < sizeof (struct GNUNET_MessageHeader))
-    {
-      return 0;                 /* client disconnected */
-      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-    }
-  msg = (struct GNUNET_MessageHeader *) buf;
-  msg->type = htons (GNUNET_MESSAGE_TYPE_SHUTDOWN_REFUSE);
-  msg->size = htons (sizeof (struct GNUNET_MessageHeader));
-  GNUNET_SERVER_receive_done (client, GNUNET_OK);
-  GNUNET_SERVER_client_drop(client);
-  return sizeof (struct GNUNET_MessageHeader);
-}
-
-static size_t
-transmit_shutdown_ack (void *cls, size_t size, void *buf)
-{
-  struct GNUNET_SERVER_Client *client = cls;
-  struct GNUNET_MessageHeader *msg;
-
-  if (size < sizeof (struct GNUNET_MessageHeader))
-    {
-      return 0;                 /* client disconnected */
-      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-    }
-
-  msg = (struct GNUNET_MessageHeader *) buf;
-  msg->type = htons (GNUNET_MESSAGE_TYPE_SHUTDOWN_ACK);
-  msg->size = htons (sizeof (struct GNUNET_MessageHeader));
-  GNUNET_SERVER_receive_done (client, GNUNET_OK);
-  GNUNET_SERVER_client_drop(client);
-  return sizeof (struct GNUNET_MessageHeader);
-}
-
-/**
- * Handler for SHUTDOWN message.
- *
- * @param cls closure (refers to service)
- * @param client identification of the client
- * @param message the actual message
- */
-static void
-handle_shutdown (void *cls,
-                 struct GNUNET_SERVER_Client *client,
-                 const struct GNUNET_MessageHeader *message)
-{
-  struct GNUNET_SERVICE_Context *service = cls;
-
-  /* FIXME: why is this call necessary???? */
-  GNUNET_SERVER_client_keep(client);
-  if (!service->allow_shutdown)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  _
-                  ("Received shutdown request, but configured to ignore!\n"));
-      GNUNET_SERVER_notify_transmit_ready (client,
-                                           sizeof(struct GNUNET_MessageHeader),
-                                           GNUNET_TIME_UNIT_FOREVER_REL,
-                                           &transmit_shutdown_deny, client);
-      return;
-    }
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              _("Initiating shutdown as requested by client.\n"));
-
-  GNUNET_SERVER_notify_transmit_ready (client,
-                                       sizeof(struct GNUNET_MessageHeader),
-                                       GNUNET_TIME_UNIT_FOREVER_REL,
-                                       &transmit_shutdown_ack, client);
-
-  GNUNET_assert (service->sched != NULL);
-  GNUNET_SERVER_client_persist_ (client);
-  GNUNET_SCHEDULER_shutdown (service->sched);
-}
-
-
 /**
  * Default handlers for all services.  Will be copied and the
  * "callback_cls" fields will be replaced with the specific service
@@ -658,8 +573,6 @@ handle_shutdown (void *cls,
 static const struct GNUNET_SERVER_MessageHandler defhandlers[] = {
   {&handle_test, NULL, GNUNET_MESSAGE_TYPE_TEST,
    sizeof (struct GNUNET_MessageHeader)},
-  {&handle_shutdown, NULL, GNUNET_MESSAGE_TYPE_SHUTDOWN,
-   sizeof (struct GNUNET_MessageHeader)},
   {NULL, NULL, 0, 0}
 };
 
@@ -1009,7 +922,6 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName,
 #endif
           ((struct sockaddr_in *) saddrs[1])->sin_family = AF_INET;
           ((struct sockaddr_in *) saddrs[1])->sin_port = htons (port);
-
         }
     }
   *addrs = saddrs;
@@ -1027,7 +939,6 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName,
  * - TIMEOUT (after how many ms does an inactive service timeout);
  * - MAXBUF (maximum incoming message size supported)
  * - DISABLEV6 (disable support for IPv6, otherwise we use dual-stack)
- * - ALLOW_SHUTDOWN (allow clients to shutdown this service)
  * - BINDTO (hostname or IP address to bind to, otherwise we take everything)
  * - ACCEPT_FROM  (only allow connections from specified IPv4 subnets)
  * - ACCEPT_FROM6 (only allow connections from specified IPv6 subnets)
@@ -1078,24 +989,6 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
     }
   else
     maxbuf = GNUNET_SERVER_MAX_MESSAGE_SIZE;
-  if (GNUNET_CONFIGURATION_have_value (sctx->cfg,
-                                       sctx->serviceName, "ALLOW_SHUTDOWN"))
-    {
-      if (GNUNET_SYSERR ==
-          (sctx->allow_shutdown =
-           GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->serviceName,
-                                                 "ALLOW_SHUTDOWN")))
-       {
-         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                     _("Specified value for `%s' of service `%s' is invalid\n"),
-                     "ALLOW_SHUTDOWN",
-                     sctx->serviceName);
-         return GNUNET_SYSERR;
-       }
-    }
-  else
-    sctx->allow_shutdown = GNUNET_NO;
-
 
   if (GNUNET_CONFIGURATION_have_value (sctx->cfg,
                                        sctx->serviceName, "TOLERANT"))