Lines Matching refs:p

261         Path *p = PATH(u);  in path_init()  local
266 p->directory_mode = 0755; in path_init()
268 p->trigger_limit.interval = USEC_INFINITY; in path_init()
269 p->trigger_limit.burst = UINT_MAX; in path_init()
272 void path_free_specs(Path *p) { in path_free_specs() argument
275 assert(p); in path_free_specs()
277 while ((s = p->specs)) { in path_free_specs()
279 LIST_REMOVE(spec, p->specs, s); in path_free_specs()
286 Path *p = PATH(u); in path_done() local
288 assert(p); in path_done()
290 path_free_specs(p); in path_done()
293 static int path_add_mount_dependencies(Path *p) { in path_add_mount_dependencies() argument
296 assert(p); in path_add_mount_dependencies()
298 LIST_FOREACH(spec, s, p->specs) { in path_add_mount_dependencies()
299 r = unit_require_mounts_for(UNIT(p), s->path, UNIT_DEPENDENCY_FILE); in path_add_mount_dependencies()
307 static int path_verify(Path *p) { in path_verify() argument
308 assert(p); in path_verify()
309 assert(UNIT(p)->load_state == UNIT_LOADED); in path_verify()
311 if (!p->specs) in path_verify()
312 …return log_unit_error_errno(UNIT(p), SYNTHETIC_ERRNO(ENOEXEC), "Path unit lacks path setting. Refu… in path_verify()
317 static int path_add_default_dependencies(Path *p) { in path_add_default_dependencies() argument
320 assert(p); in path_add_default_dependencies()
322 if (!UNIT(p)->default_dependencies) in path_add_default_dependencies()
325 …r = unit_add_dependency_by_name(UNIT(p), UNIT_BEFORE, SPECIAL_PATHS_TARGET, true, UNIT_DEPENDENCY_… in path_add_default_dependencies()
329 if (MANAGER_IS_SYSTEM(UNIT(p)->manager)) { in path_add_default_dependencies()
330 …r = unit_add_two_dependencies_by_name(UNIT(p), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, … in path_add_default_dependencies()
335 …return unit_add_two_dependencies_by_name(UNIT(p), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TA… in path_add_default_dependencies()
338 static int path_add_trigger_dependencies(Path *p) { in path_add_trigger_dependencies() argument
342 assert(p); in path_add_trigger_dependencies()
344 if (UNIT_TRIGGER(UNIT(p))) in path_add_trigger_dependencies()
347 r = unit_load_related_unit(UNIT(p), ".service", &x); in path_add_trigger_dependencies()
351 …return unit_add_two_dependencies(UNIT(p), UNIT_BEFORE, UNIT_TRIGGERS, x, true, UNIT_DEPENDENCY_IMP… in path_add_trigger_dependencies()
354 static int path_add_extras(Path *p) { in path_add_extras() argument
357 assert(p); in path_add_extras()
361 if (p->trigger_limit.interval == USEC_INFINITY) in path_add_extras()
362 p->trigger_limit.interval = 2 * USEC_PER_SEC; in path_add_extras()
364 if (p->trigger_limit.burst == UINT_MAX) in path_add_extras()
365 p->trigger_limit.burst = 200; in path_add_extras()
367 r = path_add_trigger_dependencies(p); in path_add_extras()
371 r = path_add_mount_dependencies(p); in path_add_extras()
375 return path_add_default_dependencies(p); in path_add_extras()
379 Path *p = PATH(u); in path_load() local
392 r = path_add_extras(p); in path_load()
396 return path_verify(p); in path_load()
400 Path *p = PATH(u); in path_dump() local
403 assert(p); in path_dump()
416 prefix, path_state_to_string(p->state), in path_dump()
417 prefix, path_result_to_string(p->result), in path_dump()
419 prefix, yes_no(p->make_directory), in path_dump()
420 prefix, p->directory_mode, in path_dump()
421 prefix, FORMAT_TIMESPAN(p->trigger_limit.interval, USEC_PER_SEC), in path_dump()
422 prefix, p->trigger_limit.burst); in path_dump()
424 LIST_FOREACH(spec, s, p->specs) in path_dump()
428 static void path_unwatch(Path *p) { in path_unwatch() argument
429 assert(p); in path_unwatch()
431 LIST_FOREACH(spec, s, p->specs) in path_unwatch()
435 static int path_watch(Path *p) { in path_watch() argument
438 assert(p); in path_watch()
440 LIST_FOREACH(spec, s, p->specs) { in path_watch()
449 static void path_set_state(Path *p, PathState state) { in path_set_state() argument
451 assert(p); in path_set_state()
453 if (p->state != state) in path_set_state()
454 bus_unit_send_pending_change_signal(UNIT(p), false); in path_set_state()
456 old_state = p->state; in path_set_state()
457 p->state = state; in path_set_state()
460 path_unwatch(p); in path_set_state()
463 …log_unit_debug(UNIT(p), "Changed %s -> %s", path_state_to_string(old_state), path_state_to_string(… in path_set_state()
465 unit_notify(UNIT(p), state_translation_table[old_state], state_translation_table[state], 0); in path_set_state()
468 static void path_enter_waiting(Path *p, bool initial, bool from_trigger_notify);
471 Path *p = PATH(u); in path_coldplug() local
473 assert(p); in path_coldplug()
474 assert(p->state == PATH_DEAD); in path_coldplug()
476 if (p->deserialized_state != p->state) { in path_coldplug()
478 if (IN_SET(p->deserialized_state, PATH_WAITING, PATH_RUNNING)) in path_coldplug()
479 path_enter_waiting(p, true, false); in path_coldplug()
481 path_set_state(p, p->deserialized_state); in path_coldplug()
487 static void path_enter_dead(Path *p, PathResult f) { in path_enter_dead() argument
488 assert(p); in path_enter_dead()
490 if (p->result == PATH_SUCCESS) in path_enter_dead()
491 p->result = f; in path_enter_dead()
493 unit_log_result(UNIT(p), p->result == PATH_SUCCESS, path_result_to_string(p->result)); in path_enter_dead()
494 path_set_state(p, p->result != PATH_SUCCESS ? PATH_FAILED : PATH_DEAD); in path_enter_dead()
497 static void path_enter_running(Path *p) { in path_enter_running() argument
502 assert(p); in path_enter_running()
505 if (unit_stop_pending(UNIT(p))) in path_enter_running()
508 if (!ratelimit_below(&p->trigger_limit)) { in path_enter_running()
509 log_unit_warning(UNIT(p), "Trigger limit hit, refusing further activation."); in path_enter_running()
510 path_enter_dead(p, PATH_FAILURE_TRIGGER_LIMIT_HIT); in path_enter_running()
514 trigger = UNIT_TRIGGER(UNIT(p)); in path_enter_running()
516 log_unit_error(UNIT(p), "Unit to trigger vanished."); in path_enter_running()
517 path_enter_dead(p, PATH_FAILURE_RESOURCES); in path_enter_running()
521 r = manager_add_job(UNIT(p)->manager, JOB_START, trigger, JOB_REPLACE, NULL, &error, NULL); in path_enter_running()
525 path_set_state(p, PATH_RUNNING); in path_enter_running()
526 path_unwatch(p); in path_enter_running()
531 … log_unit_warning(UNIT(p), "Failed to queue unit startup job: %s", bus_error_message(&error, r)); in path_enter_running()
532 path_enter_dead(p, PATH_FAILURE_RESOURCES); in path_enter_running()
535 static bool path_check_good(Path *p, bool initial, bool from_trigger_notify) { in path_check_good() argument
536 assert(p); in path_check_good()
538 LIST_FOREACH(spec, s, p->specs) in path_check_good()
545 static void path_enter_waiting(Path *p, bool initial, bool from_trigger_notify) { in path_enter_waiting() argument
550 trigger = UNIT_TRIGGER(UNIT(p)); in path_enter_waiting()
552 path_set_state(p, PATH_RUNNING); in path_enter_waiting()
553 path_unwatch(p); in path_enter_waiting()
557 if (path_check_good(p, initial, from_trigger_notify)) { in path_enter_waiting()
558 log_unit_debug(UNIT(p), "Got triggered."); in path_enter_waiting()
559 path_enter_running(p); in path_enter_waiting()
563 r = path_watch(p); in path_enter_waiting()
571 if (path_check_good(p, false, from_trigger_notify)) { in path_enter_waiting()
572 log_unit_debug(UNIT(p), "Got triggered."); in path_enter_waiting()
573 path_enter_running(p); in path_enter_waiting()
577 path_set_state(p, PATH_WAITING); in path_enter_waiting()
581 log_unit_warning_errno(UNIT(p), r, "Failed to enter waiting state: %m"); in path_enter_waiting()
582 path_enter_dead(p, PATH_FAILURE_RESOURCES); in path_enter_waiting()
585 static void path_mkdir(Path *p) { in path_mkdir() argument
586 assert(p); in path_mkdir()
588 if (!p->make_directory) in path_mkdir()
591 LIST_FOREACH(spec, s, p->specs) in path_mkdir()
592 path_spec_mkdir(s, p->directory_mode); in path_mkdir()
596 Path *p = PATH(u); in path_start() local
599 assert(p); in path_start()
600 assert(IN_SET(p->state, PATH_DEAD, PATH_FAILED)); in path_start()
610 path_mkdir(p); in path_start()
612 p->result = PATH_SUCCESS; in path_start()
613 path_enter_waiting(p, true, false); in path_start()
619 Path *p = PATH(u); in path_stop() local
621 assert(p); in path_stop()
622 assert(IN_SET(p->state, PATH_WAITING, PATH_RUNNING)); in path_stop()
624 path_enter_dead(p, PATH_SUCCESS); in path_stop()
629 Path *p = PATH(u); in path_serialize() local
635 (void) serialize_item(f, "state", path_state_to_string(p->state)); in path_serialize()
636 (void) serialize_item(f, "result", path_result_to_string(p->result)); in path_serialize()
638 LIST_FOREACH(spec, s, p->specs) { in path_serialize()
657 Path *p = PATH(u); in path_deserialize_item() local
671 p->deserialized_state = state; in path_deserialize_item()
680 p->result = f; in path_deserialize_item()
705 LIST_FOREACH(spec, s, p->specs) in path_deserialize_item()
734 Path *p; in path_dispatch_io() local
741 p = PATH(s->unit); in path_dispatch_io()
743 if (!IN_SET(p->state, PATH_WAITING, PATH_RUNNING)) in path_dispatch_io()
746 LIST_FOREACH(spec, i, p->specs) in path_dispatch_io()
762 path_enter_running(p); in path_dispatch_io()
764 path_enter_waiting(p, false, false); in path_dispatch_io()
769 path_enter_dead(p, PATH_FAILURE_RESOURCES); in path_dispatch_io()
774 Path *p = PATH(u); in path_trigger_notify() local
785 if (!IN_SET(p->state, PATH_WAITING, PATH_RUNNING)) in path_trigger_notify()
790 path_enter_dead(p, PATH_FAILURE_UNIT_START_LIMIT_HIT); in path_trigger_notify()
798 if (p->state == PATH_RUNNING && in path_trigger_notify()
800 log_unit_debug(UNIT(p), "Got notified about unit deactivation."); in path_trigger_notify()
801 path_enter_waiting(p, false, true); in path_trigger_notify()
802 } else if (p->state == PATH_WAITING && in path_trigger_notify()
804 log_unit_debug(UNIT(p), "Got notified about unit activation."); in path_trigger_notify()
805 path_enter_waiting(p, false, true); in path_trigger_notify()
810 Path *p = PATH(u); in path_reset_failed() local
812 assert(p); in path_reset_failed()
814 if (p->state == PATH_FAILED) in path_reset_failed()
815 path_set_state(p, PATH_DEAD); in path_reset_failed()
817 p->result = PATH_SUCCESS; in path_reset_failed()
821 Path *p = PATH(u); in path_can_start() local
824 assert(p); in path_can_start()
828 path_enter_dead(p, PATH_FAILURE_START_LIMIT_HIT); in path_can_start()