OpenWrt/LEDE Project

  • Status Closed
  • Percent Complete
    100%
  • Task Type Bug Report
  • Category Base system
  • Assigned To No-one
  • Operating System All
  • Severity Medium
  • Priority Very Low
  • Reported Version Trunk
  • Due in Version Undecided
  • Due Date Undecided
  • Private
Attached to Project: OpenWrt/LEDE Project
Opened by antismap - 06.02.2019
Last edited by Hans Dedecker - 19.04.2019

FS#2103 - procd: respawn parameters lost when using /etc/init.d/<program>/restart

procd loses respawn parameters when using /etc/init.d/<program>/restart
This happens when the program takes too long time to stop.

Here is the reason why:
1. in instance.c, the respawn and restart bools are set to false.

//instance.c
void
instance_stop(struct service_instance *in, bool halt)
{
...
	in->restart = in->respawn = false; => restart and respawn bool set to false
	kill(in->proc.pid, SIGTERM);
...
}

2. in service_handle_set (called for starting the process anew), we have the following code:

	s = avl_find_element(&services, name, s, avl);
	if (s) {
		DEBUG(2, "Update service %s\n", name);
		return service_update(s, tb, add); => we are here, because the program didn't yet terminate ! avl_find_element doesn't return NULL
	}

	DEBUG(2, "Create service %s\n", name);
	s = service_alloc(name);
	if (!s)
		return UBUS_STATUS_UNKNOWN_ERROR;

	ret = service_update(s, tb, add);

In my case, avl_find_element returns the previous instance because the program didn’t close yet. service_update is called on the previous structure, without allocating a new one.

problem: in→restart and in→respawn are still false !
consequence: “respawn” parameters are lost. This is visible in the output of

ubus call service list '{"name":"program"}'

example:
before /etc/init.d/program/restart :

        "program": {
                "instances": {
                        "program": {
                                "running": true,
                                "pid": 4904,
                                "command": [
                                        "\/usr\/bin\/program",
                                ],
                                "term_timeout": 5,
                                "limits": {
                                        "core": "unlimited" 
                                },
                                "respawn": {
                                        "threshold": 3600,
                                        "timeout": 1,
                                        "retry": 0
                                },
                                "pidfile": "\/var\/run\/program.pid" 
                        }
                }
        },

after

        "program": {
                "instances": {
                        "program": {
                                "running": true,
                                "pid": 4904,
                                "command": [
                                        "\/usr\/bin\/program",
                                ],
                                "term_timeout": 5,
                                "limits": {
                                        "core": "unlimited" 
                                },
                                "pidfile": "\/var\/run\/program.pid" 
                        }
                }
        },
Closed by  Hans Dedecker
19.04.2019 06:59
Reason for closing:  Fixed
Additional comments about closing:  

Fixed in commit https://git.ope nwrt.org/?p=project/procd.git;a=commit;h =a30a8fdced45b79bae12662caf68ffb8597858b 3

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing