match: kdbus_match_entry_free fixed

Signed-off-by: Radoslaw Pajak <r.pajak@samsung.com>
Correct linking flags: Use -pthread instead of -lpthread

(I am using Ubuntu 13.10, with self-compiled kernel)
Before this commit, I got the following error:
	$ make
make -C /lib/modules/3.13.3/build M=/home/sb/OSS/kdbus
make -C test KBUILD_MODNAME=kdbus
make[1]: Entering directory `/home/sb/OSS/kdbus/test'
  TARGET_CC kdbus-enum.o
  TARGET_CC kdbus-util.o
  TARGET_CC test-kdbus-sync.o
  TARGET_CC test-kdbus-prio.o
  TARGET_LD test-kdbus-sync
  TARGET_LD test-kdbus-prio
test-kdbus-sync.o: In function `main':
/home/sb/OSS/kdbus/test/test-kdbus-sync.c:101: undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[1]: *** [test-kdbus-sync] Error 1

The man page (such as here http://linux.die.net/man/3/pthread_create)
claims:
	Compile and link with -pthread.

So we need to remove the 'l', which is usually used for libraries on
linking.
This commit let's me compile this repository again.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
connection: update conn->flags before kdbus_notify_id_change uses them

Signed-off-by: Radoslaw Pajak <r.pajak@samsung.com>
kdbus.txt: grammatical fixes
match.c use div64_u64 to devide trough bloom.size

This fixes the build on 32bit systems which can't devide trough a 64 bit value.
include "linux/ioctl.h"
names: Acquiring name by activator connection logic fixed

This fix allows to register activator connection when
normal connection already exists for that name.
Also, when activator connection registers for a second name
(different than first one) name lookup will
result in no entry found and checking for multiple names
will not occur. So checking needs to be done earlier.

Signed-off-by: Michal Eljasiewicz <m.eljasiewic@samsung.com>
connection: cosmetics
connection, names: flush dcache after writing to pool
test/test-kdbus-monitor: fix PAYLOAD_OFF size alignment
test-kdbus-monitor: exit from main loop
test-kdbus-monitor: open output file with O_WRONLY|O_TRUNC
names: clear e->activator when activator has disconnected

As reported by Radoslaw Pajak.

On 02/24/2014 09:39 AM, Radoslaw Pajak wrote:
> If e->activator wasn't released when activator connection has
> disconnected, there was no possibility to open new activator
> connection for that name in the case when there was another
> owner of that name.
Revert "names: clear e->activator when activator has disconnected"

This reverts commit caefc83318261b91ce9f0077eafe4220e0db500f.
FW: [PATCH] names: clear e->activator when activator has disconnected

If e->activator wasn't released when activator connection has disconnected,
there was no possibility to open new activator connection for that name
in the case when there was another owner of that name.

Signed-off-by: Radoslaw Pajak <r.pajak@samsung.com>
names: return -EINVAL if an activator tries to request a second name
names: fix regressions in kdbus_name_remove_by_conn

1. unref the activator connection without the locks held, so we don't
run into ABBA locking situations.

2. dereference conn->activator_of before freeing all the name entry
items.
names: fix return codes and conditions

The conn->names is decreased once the implementor takes over a name from
the activator. Hence, we can't rely on it to check whether a connection
already is the holder of an activatable name.

Refactor the code so that the error codes match:

-EALREADY is returned when the connection already is the owner of the
name is has request to become (activator or implementor)

-EINVAL is returned if the connection is an activator but already owns
a different name entry
test: remove debug left-over
policy: factor out logic to free an item