silcd: handle SIGNOFF notify for local clients correctly
[silc.git] / apps / silcd / silcd.c
index 0a5c9fc6a0249d00ca33277d5a1ab549f3298322..3d4db10eab7133df3875aa3393dbdbe5358f3777 100644 (file)
@@ -245,9 +245,7 @@ SILC_TASK_CALLBACK(got_hup)
 
 SILC_TASK_CALLBACK(stop_server)
 {
-  /* Stop scheduler, the program will stop eventually after noticing
-     that the scheduler is down. */
-  silc_schedule_stop(silcd->schedule);
+  silc_server_stop(silcd);
 }
 
 /* Dump server statistics into a file into /tmp directory */
@@ -464,7 +462,7 @@ static DebugLevel debug_levels[] = {
   { 7, "silcd\\.c,server\\.c,command\\.c,server_backup\\.c,packet_send\\.c" },
 
   /* All basic stuff from silcd/ */
-  { 10, "silc_server_*" },
+  { 10, "silc_server_*,*silc_id_create_*" },
 
   /* All from silcd/ */
   { 15, "*silcd*,*serverid*,silc_server_*,*idlist*" },
@@ -673,8 +671,9 @@ int main(int argc, char **argv)
     silc_pkcs_register_default();
     silc_hash_register_default();
     silc_hmac_register_default();
-    silc_create_key_pair(opt_pkcs, opt_bits, pubfile, prvfile,
-                        opt_identifier, "", NULL, NULL, FALSE);
+    if (!silc_create_key_pair(opt_pkcs, opt_bits, pubfile, prvfile,
+                             opt_identifier, "", NULL, NULL, FALSE))
+      exit(1);
     exit(0);
   }
 
@@ -746,15 +745,14 @@ int main(int argc, char **argv)
       silc_file_writefile(pidfile, buf, strlen(buf));
     }
 
-    silc_server_drop_privs(silcd);
   }
+  silc_server_drop_privs(silcd);
 
   /* Run the server. When this returns the server has been stopped
      and we will exit. */
   silc_server_run(silcd);
 
-  /* Stop the server and free it. */
-  silc_server_stop(silcd);
+  /* Free server */
   silc_server_config_destroy(silcd->config);
   silc_server_free(silcd);