[PATCH pacrunner] client: Detach threads since they are never joined

2014-09-03 Thread Slava Monich
By default, a new thread is created in a joinable state.
---
 src/client.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/client.c b/src/client.c
index d354c2b..603f4a6 100644
--- a/src/client.c
+++ b/src/client.c
@@ -84,6 +84,8 @@ static DBusMessage *find_proxy_for_url(DBusConnection *conn,
DBusMessage *msg, void *user_data)
 {
struct jsrun_data *jsrun;
+   pthread_attr_t attrs;
+   int err;
 
jsrun = g_try_new0(struct jsrun_data, 1);
if (!jsrun)
@@ -94,7 +96,11 @@ static DBusMessage *find_proxy_for_url(DBusConnection *conn,
jsrun->conn = dbus_connection_ref(conn);
jsrun->msg = dbus_message_ref(msg);
 
-   if (pthread_create(&jsrun->thread, NULL, jsrun_thread, jsrun) != 0) {
+   pthread_attr_init(&attrs);
+   pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
+   err = pthread_create(&jsrun->thread, &attrs, jsrun_thread, jsrun);
+   pthread_attr_destroy(&attrs);
+   if (err != 0) {
jsrun_free(jsrun);
return g_dbus_create_error(msg,
PACRUNNER_ERROR_INTERFACE ".Failed",
-- 
1.8.3.2

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH pacrunner] client: Detach threads since they are never joined

2014-09-05 Thread Patrik Flykt
On Wed, 2014-09-03 at 11:31 +0300, Slava Monich wrote:
> By default, a new thread is created in a joinable state.

Applied with the following commit message:

Unless the threads are created as detached (or joined, which is not the
case here), not all resources will be released when the thread exits.
If not handled, this causes unlimited memory usage over time.


Patrik


___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman