Re-order include directories

:Release Notes:
Make upgrade build for luna-service2 (useful for desktop) possible by
preferring local includes over system/staging.

:Detailed Notes:
Re-order includes to use includes for system dependencies after
includes for project itself.

:Testing Performed:
Desktop build

:QA Notes:

:Issues Addressed:
[GF-38496] luna-service2 submissions/154 does not compile on the desktop

Open-webOS-DCO-1.0-Signed-off-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Change-Id: Iee07f62c6cc44f4707469cc94e98d93cdbb90cf2
Reviewed-on: https://g2g.palm.com/3641
Reviewed-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Tested-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Reviewed-by: Build Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Move ls-monitor ot /usr/sbin

:Release Notes:
Move ls-monitor binary to /usr/sbin

:Detailed Notes
Currently, it is safe to move ls-monitor from /usr/bin to /usr/sbin,
because it's used only by name. This will enhance the security.

:Testing Performed:
Tested on the device

:QA Notes:

:Issues Addressed:
[GF-42258] LS2: Move ls-monitor to /usr/sbin

Open-webOS-DCO-1.0-Signed-off-by: Alexandr Smoktal <alexandr.smoktal@lge.com>

Change-Id: I753ed317e2fb61ef572eb29690b757c591f318c5
Reviewed-on: https://g2g.palm.com/3649
Reviewed-by: Build Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Tested-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Enable asserts for testing builds

:Release Notes:
Enable assert for in luna-service2 if WEBOS_DISTRO_PRERELEASE == devel

:Detailed Notes:
Currently assert are disabled for all release builds.
Enabling for testing images will help to interpret unexpected crashes.

:Testing Performed:
On device and emulator.

:QA Notes:

:Issues Addressed:
[GF-39090] LS2: Enable asserts for testing builds

Open-webOS-DCO-1.0-Signed-off-by: Alexandr Smoktal <alexandr.smoktal@lge.com>

Change-Id: I1fb95abb76191802c467e2ecef087d924b9f17fb
Reviewed-on: https://g2g.palm.com/3658
Reviewed-by: Build Verification
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Tested-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Reviewed-by: Keith Derrick <keith.derrick@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Fix asserts in developer images

:Release Notes:
Asserts should be disabled only in Mass Production builds,
when WEBOS_DISTRO_PRERELEASE == "".

:Detailed Notes:
Previously asserts was enabled for "devel" phase of the project.
This was changed to enable release in all development images.
Now asserts are disable only in Mass Production builds
where WEBOS_DISTRO_PRERELEASE == "".

:Testing Performed:
Builds was tested with an appropriate values.

:QA Notes:

:Issues Addressed:
[GF-43805] LS2: Fix asserts in development images.

Open-webOS-DCO-1.0-Signed-off-by: Alexandr Smoktal <alexandr.smoktal@lge.com>

Change-Id: I6fd295e59875231fc6f3c4b48bddb0bc1f04bdbc
Reviewed-on: https://g2g.palm.com/3721
Reviewed-by: Keith Derrick <keith.derrick@lge.com>
Tested-by: Keith Derrick <keith.derrick@lge.com>
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Tested-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Remove umediaserver hacks

:Release Notes:
Remove umediaserver hacks in luna-service2.

:Detailed Notes:
All umediaserver related hacks can be removed from the LS2
due to new glob-stype patterns in LS2 roles files and new
umediaserver interface which allows clients to set own unique ids.

:Testing Performed:
All umediaserver related components was tested without hacks.

:QA Notes:

:Issues Addressed:
[GF-42575] LS2: Remove umediaserver hacks from the hub.c

Open-webOS-DCO-1.0-Signed-off-by: Alexandr Smoktal <alexandr.smoktal@lge.com>

Change-Id: I3ca64c5b8724f8492c2247689f64833dce205919
Reviewed-on: https://g2g.palm.com/3706
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Tested-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Reviewed-by: Build Verification
Reviewed-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Add PmTrace to control a flow of a call

:Release Notes:
Add PmTrace to control the main points that alone call passes

:Detailed Notes:
Add new PmTrace provider: pmtrace_lunaservice2.
Add 5 tracepoints to analyze performance of luna-service2:
- client is ready to send a call(client_prepare);
- client has sent the call (client_call);
- server has received the call and is ready to call a handler (service_receive);
- handler has been called, server is ready to send reply to the client (service_reply);
- client has recevied the reply and is ready to call a callback (client_callback).
CMake has to be run with an option -DWEBOS_LTTNG_ENABLED:BOOLEAN=True to enable traces.

:Testing Performed:
Traces were collected successfully.
Unit tests were passed.

:QA Notes:

:Issues Addressed:
[GF-39729] Add PmTrace tracepoints in LS2 service

Open-webOS-DCO-1.0-Signed-off-by: Alekseyev Oleksandr<alekseyev.oleksandr@lge.com>

Change-Id: I6e7079203c5fb13f88d0bd8b743888b0fbad88e8
Reviewed-on: https://g2g.palm.com/3722
Reviewed-by: Build Verification
Reviewed-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Tested-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Revert "Remove umediaserver hacks"

This reverts commit 6796be907764c5f7daa1d7807d0e685da8a672b7.

Open-webOS-DCO-1.0-Signed-off-by: Alexandr Smoktal <alexandr.smoktal@lge.com>

Change-Id: I306d401ae50f0eba7c3fb2df2e36845fdd955166
Reviewed-on: https://g2g.palm.com/3754
Reviewed-by: Build Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Tested-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Reviewed-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Fix memory cleanup in tests

:Release Notes:
Some memory cleanup in tests was fixed
'check' make target has been changed to run fast

:Detailed Notes:
There were a few missed cleanup functions and memory checker had
some complaints on this.
Test with deallocated mutex was removed from the incoming transport test.
test_clock and test_timersource were excluded from the `check` target
to speed up its execution.

:Testing Performed:
Tests have been run and checked for memory leaks.

:QA Notes:

:Issues Addressed:
[GF-45291] LS2: Investigate and fix potential memory leaks

Open-webOS-DCO-1.0-Signed-off-by: Alexandr Smoktal <alexandr.smoktal@lge.com>

Change-Id: I50d21de0f18fe19c00563f26c73bda77dffae690
Reviewed-on: https://g2g.palm.com/3853
Reviewed-by: Build Verification
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Tested-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Reviewed-by: Keith Derrick <keith.derrick@lge.com>
Fix potential file descriptor leak

:Release Notes:

:Detailed Notes:
Call to socket(2) can return non-negative file descriptor on success.
If consequent code fails, the descriptor 0 will not be closed.

:Testing Performed:
Trivial change. Build succeeded.

:QA Notes:

:Issues Addressed:
[CID-22564] 11. off_by_one: Testing whether handle "fd" is strictly greater than zero

Open-webOS-DCO-1.0-Signed-off-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>

Change-Id: Ic8c5c8b6973031ccfb6a4bab1a5812cbc9ec0441
Reviewed-on: https://g2g.palm.com/3889
Reviewed-by: Build Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Mykola Kryvonos <mykola.kryvonos@lge.com>
Reviewed-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Reviewed-by: Keith Derrick <keith.derrick@lge.com>
Implement wildcards in service files

:Release Notes:
Accept and correctly handle service files with glob-style wildcards
in service names.

:Detailed Notes:
Glob-style wildcards in service names are needed to remove hacks for
umedia-server from ls-hub. Names with wildcards are stored in a binary
search tree, which is sorted by wildcard prefixes. Then, if lookup for
exact service name is failed, the tree is searched to match against
a pattern.

:Testing Performed:
Build succeeded.
Unit tests (with memchecker).

:QA Notes:

:Issues Addressed:
[GF-45074] LS2: add support for patterns in service files

Open-webOS-DCO-1.0-Signed-off-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>

Change-Id: I5d0d03bd6446588b5947e1a7bdf4ff41f69cc8a3
Reviewed-on: https://g2g.palm.com/3854
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Add new ls-control command to rescan volatile dir

:Release Notes:
Split roles/services directories into steady and volatile.
Add a new command for ls-control to rescan volatile directories.

:Detailed Notes:

:Testing Performed:
A new test was added. All tests were passed successfully.
Checked on the real system.

:QA Notes:

:Issues Addressed:
[GF-40294] Add new api to LS2 to support scanning specific dir

Open-webOS-DCO-1.0-Signed-off-by: Alekseyev Oleksandr<alekseyev.oleksandr@lge.com>

Change-Id: Ic64d7b4df99df37e91b2131d5bdeea372ea0df6e
Reviewed-on: https://g2g.palm.com/3875
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Fix hub memory cleanup

:Release Notes:
Fixed hub memory cleanup for clients and roles.

:Detailed Notes:
All memory cleanups related to clients and roles were reviewed and fixed.

:Testing Performed:
Unit-tests were run. Hub was tested.

:QA Notes:

:Issues Addressed:
[GF-45291] LS2: Investigate and fix potential memory leaks

Open-webOS-DCO-1.0-Signed-off-by: Alexandr Smoktal <alexandr.smoktal@lge.com>

Change-Id: Id1a34526cc0018e40ec304acebc1caa17404b1a6
Reviewed-on: https://g2g.palm.com/3916
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Change library version to 3.5.2

:Release Notes:
Change library version to 3.5.2

:Detailed Notes:

:Testing Performed:

:QA Notes:

:Issues Addressed:

Open-webOS-DCO-1.0-Signed-off-by: Alekseyev Oleksandr<alekseyev.oleksandr@lge.com>

Change-Id: If6e18c4843bae46782c7583943ae7fb5af2786fc
Reviewed-on: https://g2g.palm.com/3934
Reviewed-by: DCO Verification
Reviewed-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Tested-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Tested-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Fix bugs detected by coverity

:Release Notes:
Close potentially leaked descriptors.
Fix incorrect sizeof.
Dereference after null check.
Logically dead code.

:Detailed Notes:

:Testing Performed:
Build succeeded. Unit tests.

:QA Notes:

:Issues Addressed:
[GF-51891] LS2: Fix bugs detected by coverity

Open-webOS-DCO-1.0-Signed-off-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>

Change-Id: Ia4e45824d8555b36442037a7989119e369b2cdf3
Reviewed-on: https://g2g.palm.com/3953
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Keith Derrick <keith.derrick@lge.com>
Tested-by: Keith Derrick <keith.derrick@lge.com>
Fix one more report

:Release Notes:
Fix dead logics.

:Detailed Notes:

:Testing Performed:
Trivial. Build succeeded. Unit tests.

:QA Notes:

:Issues Addressed:
[GF-51891] LS2: Fix bugs detected by coverity

Open-webOS-DCO-1.0-Signed-off-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>

Change-Id: I6e416547f5c71c09d19c0ab3c815855549181de2
Reviewed-on: https://g2g.palm.com/3982
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Reviewed-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Change library version to 3.5.3

:Release Notes:
Change library version to 3.5.3

:Detailed Notes:

:Testing Performed:

:QA Notes:

:Issues Addressed:

Open-webOS-DCO-1.0-Signed-off-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>

Change-Id: I011cfc0c7840f6742b8af124e3c4775c1e739b0c
Reviewed-on: https://g2g.palm.com/3983
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Mykola Kryvonos <mykola.kryvonos@lge.com>
Reviewed-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
ls-hubd*watchdogs are not working

:Release Notes:
Existing ls-hubd_p*_watchdog.conf jobs call reboot_ls-hubd_if.sh which
is missing in current versions.  The functions of that script have been
taken by crashd, so all the watchdog needs to do now is to leave a
cluse about who crashed and call reboot.

:Detailed Notes:
the two ls-hubd_private_watchdog.conf and ls-hubd_public_watchdog
have been combined into a single ls-hubd_watchdog.conf which simple
adds the name of the crashing program to the global environment
and then calls reboot.  The crash-logging functions formerly handled
by the init.d/reboot_ls-hubd_if.sh are now automatically handled
by crashd and rdxd.

:Testing Performed:
Other than a normal miniBAT, many kills of both ls-hubd_private and
ls-hubd_public using various signals. kill -INT causes the proc to
exit normally without causing a reboot (though you need to reboot
after that since the ls-hubs connections are built at boot-time),
kill -TRAP or kill -ABRT both reliably kill the hubs and cause
reboot - other signals likley will also, but I got tired of trying
them all.

:QA Notes:

:Issues Addressed:
[GF-45875] ls-hubd_p*_watchdog not working

Open-webOS-DCO-1.0-Signed-off-by: Ed Chejlava <ed.chejlava@lge.com>

Change-Id: I7ba5f4ebbf715ab9882b781d06b3d5c4291955f7
Reviewed-on: https://g2g.palm.com/3977
Reviewed-by: DCO Verification
Reviewed-by: Keith Derrick <keith.derrick@lge.com>
Tested-by: Keith Derrick <keith.derrick@lge.com>
ls-hubd_watchdog to reboot system on ls-hub crash

:Release Notes:
If ls-hubd_private or ls-hubd_public crash, the only known remedy is to
reboot. This watchdog triggers on stopping ls-hubd_* and if the stopping
is not a desired event, it will initiate a reboot.

:Detailed Notes:
If ls-hubd_* are stopped by a user or as part of a normal shutdown, the
env var RESULT presented by Upstart will be "ok", or if there is a
normal reboot or shutdown occurring (triggered by RUNLEVEL 0,1,6), then
a watchdog reboot is not needed.  If it is needed, watchdog will add
LD_HUBD_CRASH=<name of the stopping job> ("ls-hubd_public" or
"ls-hubd_private") to the global Upstart env so that reboot knows how to
handle the process.

:Testing Performed:
Many reboots were initated via the reboot and shutdown commands and also
by killing -ABRT ls-hubd_*
Also ran a miniBAT for good measure.

:QA Notes:

:Issues Addressed:
[GF-45875] ls-hubd_p*_watchdog not working

Open-webOS-DCO-1.0-Signed-off-by: Ed Chejlava <ed.chejlava@lge.com>
Change-Id: I8260e3462354ccbc5a7bcbce6ded1ee85635e2dc
Reviewed-on: https://g2g.palm.com/3978
Reviewed-by: DCO Verification
Reviewed-by: Keith Derrick <keith.derrick@lge.com>
Tested-by: Keith Derrick <keith.derrick@lge.com>
Instead of relying on existing service/role directories create them on startup

It makes the service start a lot easier when the hub daemon takes care about creating the
service/role directories on its own instead of doing this job as part of the init script
(which is very close to the daemon anyway).

Upstream-Status: pending (http://github.com/openwebos/luna-service2)

Open-webOS-DCO-1.0-Signed-off-by: Simon Busch <morphis@gravedo.de>
Add support for systemd

In order to synchronize our service launch on boot we need to add explicit support for
systemd to notify systemd when we're really set up and other depending services can be
launched. As ls-hubd is a critical component of the system it has to be really up before
anyone can use it in order not to fail.

Upstream-Status: pending (http://github.com/openwebos/luna-service2)

Open-webOS-DCO-1.0-Signed-off-by: Simon Busch <morphis@gravedo.de>