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

Bug#394543: mldonkey-server: Possible fix and some more info



Package: mldonkey-server
Version: 2.8.1-2
Followup-For: Bug #394543

On my machine it doesn't take as long to shut down mldonkey-server but
the problem is the same here.

To make it a little more obvious I have written the following little
bash script:

  #!/bin/sh

  sudo /etc/init.d/mldonkey-server stop

  # as long as there are process with UID of mldonkey the
  # mldonkey-server isn't really shutdown IMHO (provided the UID is
  # used by the mldonkey-server only)
  while ps -u mldonkey
  do 
    echo "mldonkey-server still running!"
    echo "will sleep 1 more second..."
    echo
    sleep 1
  done


Executing the script, when the server has been running for a while
(meaning the server is _REALLY_ running and _NOT_ in the middle of
its startup process), gives the following output on my machine:

"
Stopping MLDonkey: mlnet.
  PID TTY          TIME CMD
16924 ?        00:00:00 mldonkey_server
16929 ?        00:00:19 mlnet
16931 ?        00:00:00 logger
16933 ?        00:00:00 logger
17206 ?        00:00:00 sh
mldonkey-server still running!
will sleep 1 more second...

  PID TTY          TIME CMD
16924 ?        00:00:00 mldonkey_server
17216 ?        00:00:00 logger <defunct>
mldonkey-server still running!
will sleep 1 more second...

  PID TTY          TIME CMD
"

So it is ovious, that, when the init script says mldonkey-server has
been stopped, the server is still running. I appended a patch, that
might fix that problem by simply using the sleep loop applied in my
liitle script above. It seems to suffice to wait until 
"mldonkey_server" has disappeared from the process table, since
according to my logs that is also the process that removes the .pid file:

log: "mldonkey_server: Removing pidfile: /var/run/mldonkey/mlnet.pid"

On my machine it works fine so far except for one special case I
run across incidentally. If I choose to start "mldonkey-server" and
almost immediatly stop it after the .pidfile was just created it will
fail due to unclean shutdown of "mldonkey_server" (note the "_" instead
of "-"!). In this case the following happens from my POV:

  In my /var/log/messages I discovered that
  /var/run/mldonkey/mlnet.pid is created before the "Core" of "mlnet"
  is running. And when one attempts to stop the daemon before the core
  is really up and running, it will take about 5 minutes to stop the
  "mlnet" core, as this seems to be the timeout for sending the
  SIGKILL to all processes of "mldonkey_server" (see log snippet below)
  SIGTERM is considered to have failed. But the logger process still
  remains in the output of ps!

    log:

    Nov  7 05:16:13 Hellraiser mldonkey_server: Terminate process
    Nov  7 05:16:13 Hellraiser mldonkey_server: Stopping processes PID ( 2199 2201 2203 )
    Nov  7 05:16:13 Hellraiser mldonkey_server: Waiting termination of process 2199
    Nov  7 05:16:14 Hellraiser mldonkey_server: Process 2199 terminated
    Nov  7 05:16:14 Hellraiser mldonkey_server: Waiting termination of process 2201
    Nov  7 05:16:14 Hellraiser mldonkey_server: Process 2201 terminated
    Nov  7 05:16:14 Hellraiser mldonkey_server: Waiting termination of process 2203
    Nov  7 05:16:14 Hellraiser mldonkey_server: Process 2203 terminated
    Nov  7 05:16:14 Hellraiser mldonkey_server: Process stopped PID ( 2199 2201 2203 )
    Nov  7 05:16:14 Hellraiser mldonkey_server: MLDonkey server end
    Nov  7 05:16:14 Hellraiser mldonkey_server: Removing pidfile: /var/run/mldonkey/mlnet.pid
    Nov  7 05:16:15 Hellraiser mldonkey_server: Set niceness of the process: 18
    Nov  7 05:16:15 Hellraiser mldonkey_server: Set uid/gid of the process (110, 1002)
    Nov  7 05:16:15 Hellraiser mldonkey_server: Set umask of the process: 18
    Nov  7 05:16:15 Hellraiser mldonkey_server: Chdir to chdir dir: /var/lib/mldonkey
    Nov  7 05:16:15 Hellraiser mldonkey_server: Fork the process
    Nov  7 05:16:15 Hellraiser mldonkey_server: Reset the group leader
    Nov  7 05:16:15 Hellraiser mldonkey_server: Fork a second time the process
    Nov  7 05:16:15 Hellraiser mldonkey_server: Close standard IO
    Nov  7 05:16:15 Hellraiser mldonkey_server: Process is running in the background
--> Nov  7 05:16:15 Hellraiser mldonkey_server: Writing PID (2486) to pidfile: /var/run/mldonkey/mlnet.pid
    Nov  7 05:16:15 Hellraiser mldonkey_server: Launching MLnet process
    Nov  7 05:16:15 Hellraiser mldonkey_server: Launching MLnet stderr logger
    Nov  7 05:16:15 Hellraiser mldonkey_server: Launching MLnet stdout logger
    Nov  7 05:16:15 Hellraiser mlnet_error: 2006/11/07 05:16:15 [cO] Starting MLDonkey 2.8.1 ...
    Nov  7 05:16:15 Hellraiser mlnet_error: 2006/11/07 05:16:15 [cO] Language DE, locale UTF-8, ulimit for open files 1024
    Nov  7 05:16:15 Hellraiser mlnet_error: 2006/11/07 05:16:15 [cO] MLDonkey is working in .
    Nov  7 05:16:15 Hellraiser mlnet_error: 2006/11/07 05:16:15 Loading language resource /var/lib/mldonkey/mlnet_strings.de_DE.UTF-8
    Nov  7 05:16:15 Hellraiser mlnet_error: 2006/11/07 05:16:15 [cO] loaded language resource file
    Nov  7 05:16:15 Hellraiser mlnet_error: 2006/11/07 05:16:15 [DNS] Resolving [Hellraiser] ...
    Nov  7 05:16:15 Hellraiser mlnet_error: 2006/11/07 05:16:15 [DNS] Resolving [www.mldonkey.org] ...
    Nov  7 05:16:15 Hellraiser mlnet_error: 2006/11/07 05:16:15 [IPblock] loading /var/lib/mldonkey/blocklist.p2p
--> Nov  7 05:16:16 Hellraiser mldonkey_server: Terminate process
    Nov  7 05:16:16 Hellraiser mldonkey_server: Stopping processes PID ( 2491 2493 2495 )
    Nov  7 05:16:16 Hellraiser mldonkey_server: Waiting termination of process 2491
    Nov  7 05:16:25 Hellraiser mlnet_error: 2006/11/07 05:16:25 [IPblock] 136447 ranges loaded - optimized to 136447
    Nov  7 05:16:25 Hellraiser mlnet_error: 2006/11/07 05:16:25 [cUd] converting 2 users to new format
    Nov  7 05:16:26 Hellraiser mlnet_error: 2006/11/07 05:16:26 [cCO] Options correctly saved
    Nov  7 05:16:26 Hellraiser mlnet_error: 2006/11/07 05:16:26 [dMain] Check http://www.mldonkey.net/ for updates
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] enabling networks:
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] ---- enabling Donkey ----
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [EDK] loading sources completed
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] using port 8662 (client_port TCP)
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] using port 8666 (client_port UDP)
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] using port 11918 (kademlia_port UDP)
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] ---- enabling interfaces ----
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] using port 4080 (http_port)
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] using port 4000 (telnet_port)
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] using port 4001 (gui_port)
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] using port 1213 (gift_port)
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 disabled networks: BitTorrent FileTP G2 Gnutella 
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] To command: telnet 127.0.0.1 4000
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] Or with browser: http://127.0.0.1:4080
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] For a GUI check out http://sancho-gui.sourceforge.net
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] Connect to IP 127.0.0.1, port 4001
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] If you connect from a remote machine adjust allowed_ips
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] mldonkey is now running as user mldonkey
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [dMain] mldonkey is now running as uid 110
    Nov  7 05:16:27 Hellraiser mlnet_error: 2006/11/07 05:16:27 [cCO] Options correctly saved
--> Nov  7 05:16:28 Hellraiser mlnet_error: 2006/11/07 05:16:28 [dMain] Core started
--> Nov  7 05:16:28 Hellraiser mlnet_error: 2006/11/07 05:16:28 [dMain] Core started
    Nov  7 05:16:28 Hellraiser mlnet_error: 2006/11/07 05:16:28 [dMain] Option log_file is empty, disable logging completely...
    Nov  7 05:16:28 Hellraiser mlnet_error: 2006/11/07 05:16:28 [dMain] Disabling output to console, to enable: stdout true
    Nov  7 05:21:16 Hellraiser mldonkey_server: Process 2491 not responding, taking measure: SIGKILL
    Nov  7 05:21:16 Hellraiser mldonkey_server: Waiting termination of process 2493
    Nov  7 05:21:16 Hellraiser mldonkey_server: Process stopped PID ( 2491 2493 2495 )

output of "date && ps -u mldonkey":
    
    Di 7. Nov 06:10:49 CET 2006
     PID TTY          TIME CMD
    2493 ?        00:00:00 logger
    2495 ?        00:00:00 logger

So there are still 2 PID's related to the user "mldonkey". Since thoes
were considered stopped by the mldonkey_server, mldonkey_server
stopped itself, so the patched init script would falsely tell you,
that it stopped mldonkey (hopefully this will be the only special case).
Anyway that would happen after 5 minutes! So when stopping manually,
one should notice, that something went wrong (or at least think about 
the idea of immediatly stopping a just started service ;).



Best Regards

Marcus Blumhagen


-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing'), (150, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-2-k7-lsm
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)

Versions of packages mldonkey-server depends on:
ii  adduser                      3.99        Add and remove users and groups
ii  debconf [debconf-2.0]        1.5.8       Debian configuration management sy
ii  dpkg                         1.13.22     package maintenance system for Deb
ii  libbz2-1.0                   1.0.3-6     high-quality block-sorting file co
ii  libc6                        2.3.6.ds1-7 GNU C Library: Shared libraries
ii  libgcc1                      1:4.1.1-13  GCC support library
ii  libgd2-noxpm                 2.0.33-5.1  GD Graphics Library version 2 (wit
ii  libpng12-0                   1.2.8rel-7  PNG library - runtime
ii  libstdc++6                   4.1.1-13    The GNU Standard C++ Library v3
ii  mime-support                 3.37-1      MIME files 'mime.types' & 'mailcap
ii  ucf                          2.0016      Update Configuration File: preserv
ii  zlib1g                       1:1.2.3-13  compression library - runtime

mldonkey-server recommends no packages.

-- debconf information excluded
--- /etc/init.d/mldonkey-server	2006-11-07 01:55:48.000000000 +0100
+++ /etc/init.d/mldonkey-server.new	2006-11-07 01:55:37.000000000 +0100
@@ -107,6 +107,10 @@
   stop)
     echo -n "Stopping $DESC: $NAME"
     start-stop-daemon --stop --oknodo --pidfile $PIDFILE
+    while ps -A | grep -q mldonkey_server
+    do
+      sleep 1
+    done
     echo "."
   ;;
   reload)
@@ -116,7 +120,6 @@
   ;;
   force-reload|restart)
     $0 stop
-    sleep 1
     $0 start
   ;;
   *)

Attachment: signature.asc
Description: Digital signature


Reply to: