Re: [systemd-devel] [PATCH] Fix timeout when stopping Type=notify service

2013-10-01 Thread Olivier Brunel
On 10/01/13 05:08, Lennart Poettering wrote:
 On Fri, 20.09.13 22:53, Olivier Brunel (j...@jjacky.com) wrote:
 
 Since 41efeaec a call to service_unwatch_main_pid() is done from
 service_set_main_pid(), which is called upon receiving message MAINPID=

 This had the side effect of not watching pid anymore, and would result in a
 useless timeout when stopping the service, as the unit wouldn't be identified
 from the pid, so not marked stopped which would result in systemd thinking 
 this
 was a timeout.
 
 I commited a different fix now in
 7400b9d2e99938d17b281d7df43680eade18666e, but it's untested. Could you
 check if this makes things work?

Yes, fixes the issue.

Thanks,
-j

 
 ---
 I'm not exactly familiar with systemd's internals, so this might not be the
 correct way to fix this, please correct me if it isn't.

  src/core/service.c | 8 
  1 file changed, 8 insertions(+)

 diff --git a/src/core/service.c b/src/core/service.c
 index 246a86e..1dccdff 100644
 --- a/src/core/service.c
 +++ b/src/core/service.c
 @@ -3388,9 +3388,17 @@ static void service_notify_message(Unit *u, pid_t 
 pid, char **tags) {
  log_warning_unit(u-id,
   Failed to parse notification 
 message %s, e);
  else {
 +int r;
 +
  log_debug_unit(u-id,
 %s: got %s, u-id, e);
  service_set_main_pid(s, pid);
 +r = unit_watch_pid(u, pid);
 +if (r  0)
 +/* FIXME: we need to do something here */
 +log_warning_unit(u-id,
 + Failed to watch PID %lu 
 from service %s,
 + (unsigned long) pid, 
 u-id);
  }
  }
  
 
 
 Lennart
 

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Fix timeout when stopping Type=notify service

2013-09-30 Thread Lennart Poettering
On Fri, 20.09.13 22:53, Olivier Brunel (j...@jjacky.com) wrote:

 Since 41efeaec a call to service_unwatch_main_pid() is done from
 service_set_main_pid(), which is called upon receiving message MAINPID=
 
 This had the side effect of not watching pid anymore, and would result in a
 useless timeout when stopping the service, as the unit wouldn't be identified
 from the pid, so not marked stopped which would result in systemd thinking 
 this
 was a timeout.

I commited a different fix now in
7400b9d2e99938d17b281d7df43680eade18666e, but it's untested. Could you
check if this makes things work?

 ---
 I'm not exactly familiar with systemd's internals, so this might not be the
 correct way to fix this, please correct me if it isn't.
 
  src/core/service.c | 8 
  1 file changed, 8 insertions(+)
 
 diff --git a/src/core/service.c b/src/core/service.c
 index 246a86e..1dccdff 100644
 --- a/src/core/service.c
 +++ b/src/core/service.c
 @@ -3388,9 +3388,17 @@ static void service_notify_message(Unit *u, pid_t pid, 
 char **tags) {
  log_warning_unit(u-id,
   Failed to parse notification 
 message %s, e);
  else {
 +int r;
 +
  log_debug_unit(u-id,
 %s: got %s, u-id, e);
  service_set_main_pid(s, pid);
 +r = unit_watch_pid(u, pid);
 +if (r  0)
 +/* FIXME: we need to do something here */
 +log_warning_unit(u-id,
 + Failed to watch PID %lu 
 from service %s,
 + (unsigned long) pid, u-id);
  }
  }
  


Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Fix timeout when stopping Type=notify service

2013-09-21 Thread Andrey Borzenkov
В Fri, 20 Sep 2013 22:53:52 +0200
Olivier Brunel j...@jjacky.com пишет:

 Since 41efeaec a call to service_unwatch_main_pid() is done from
 service_set_main_pid(), which is called upon receiving message MAINPID=
 
 This had the side effect of not watching pid anymore, and would result in a
 useless timeout when stopping the service, as the unit wouldn't be identified
 from the pid, so not marked stopped which would result in systemd thinking 
 this
 was a timeout.

I confirm that this fixed timeout stopping user manager during shutdown
I observed on openSUSE 13.1 Beta1:
https://bugzilla.novell.com/show_bug.cgi?id=841544 

 ---
 I'm not exactly familiar with systemd's internals, so this might not be the
 correct way to fix this, please correct me if it isn't.
 
  src/core/service.c | 8 
  1 file changed, 8 insertions(+)
 
 diff --git a/src/core/service.c b/src/core/service.c
 index 246a86e..1dccdff 100644
 --- a/src/core/service.c
 +++ b/src/core/service.c
 @@ -3388,9 +3388,17 @@ static void service_notify_message(Unit *u, pid_t pid, 
 char **tags) {
  log_warning_unit(u-id,
   Failed to parse notification 
 message %s, e);
  else {
 +int r;
 +
  log_debug_unit(u-id,
 %s: got %s, u-id, e);
  service_set_main_pid(s, pid);

You probably should sanity check return status and proceed with
unit_watch_pid only if it succeeded. It is not clear what should be
done if it failed - it means service returned bogus value in
notification message, in which case the only logical step is to stop
it as it cannot be trusted anymore? 

 +r = unit_watch_pid(u, pid);
 +if (r  0)
 +/* FIXME: we need to do something here */
 +log_warning_unit(u-id,
 + Failed to watch PID %lu 
 from service %s,
 + (unsigned long) pid, u-id);
  }
  }
  

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Fix timeout when stopping Type=notify service

2013-09-21 Thread Colin Guthrie
'Twas brillig, and Olivier Brunel at 20/09/13 21:53 did gyre and gimble:
 Since 41efeaec a call to service_unwatch_main_pid() is done from
 service_set_main_pid(), which is called upon receiving message MAINPID=
 
 This had the side effect of not watching pid anymore, and would result in a
 useless timeout when stopping the service, as the unit wouldn't be identified
 from the pid, so not marked stopped which would result in systemd thinking 
 this
 was a timeout.

Ahh this sounds like it should address my problem reported the other day
Services remain in deactivating state after all processes have exited
and cgroup is empty.

Will test it out.

Cheers

Col

 ---
 I'm not exactly familiar with systemd's internals, so this might not be the
 correct way to fix this, please correct me if it isn't.
 
  src/core/service.c | 8 
  1 file changed, 8 insertions(+)
 
 diff --git a/src/core/service.c b/src/core/service.c
 index 246a86e..1dccdff 100644
 --- a/src/core/service.c
 +++ b/src/core/service.c
 @@ -3388,9 +3388,17 @@ static void service_notify_message(Unit *u, pid_t pid, 
 char **tags) {
  log_warning_unit(u-id,
   Failed to parse notification 
 message %s, e);
  else {
 +int r;
 +
  log_debug_unit(u-id,
 %s: got %s, u-id, e);
  service_set_main_pid(s, pid);
 +r = unit_watch_pid(u, pid);
 +if (r  0)
 +/* FIXME: we need to do something here */
 +log_warning_unit(u-id,
 + Failed to watch PID %lu 
 from service %s,
 + (unsigned long) pid, u-id);
  }
  }
  
 


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] Fix timeout when stopping Type=notify service

2013-09-20 Thread Olivier Brunel
Since 41efeaec a call to service_unwatch_main_pid() is done from
service_set_main_pid(), which is called upon receiving message MAINPID=

This had the side effect of not watching pid anymore, and would result in a
useless timeout when stopping the service, as the unit wouldn't be identified
from the pid, so not marked stopped which would result in systemd thinking this
was a timeout.
---
I'm not exactly familiar with systemd's internals, so this might not be the
correct way to fix this, please correct me if it isn't.

 src/core/service.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/core/service.c b/src/core/service.c
index 246a86e..1dccdff 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -3388,9 +3388,17 @@ static void service_notify_message(Unit *u, pid_t pid, 
char **tags) {
 log_warning_unit(u-id,
  Failed to parse notification message 
%s, e);
 else {
+int r;
+
 log_debug_unit(u-id,
%s: got %s, u-id, e);
 service_set_main_pid(s, pid);
+r = unit_watch_pid(u, pid);
+if (r  0)
+/* FIXME: we need to do something here */
+log_warning_unit(u-id,
+ Failed to watch PID %lu from 
service %s,
+ (unsigned long) pid, u-id);
 }
 }
 
-- 
1.8.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel