Index: native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc |
diff --git a/native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc b/native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc |
index 81aa015342d6fcba33aae56891d6c851d97b1326..1c643142789f90e660116b751909c1fb686a1543 100644 |
--- a/native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc |
+++ b/native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc |
@@ -41,8 +41,7 @@ class DlOpenInstance : public pp::Instance { |
eightball_so_(NULL), |
reverse_so_(NULL), |
eightball_(NULL), |
- reverse_(NULL), |
- tid_(NULL) {} |
+ reverse_(NULL) {} |
virtual ~DlOpenInstance() {} |
@@ -61,11 +60,18 @@ class DlOpenInstance : public pp::Instance { |
// server. |
mount("", "/http", "httpfs", 0, ""); |
+ pthread_t thread; |
logmsg("Spawning thread to cache .so files..."); |
- if (pthread_create(&tid_, NULL, LoadLibrariesOnWorker, this)) { |
+ int rtn = pthread_create(&thread, NULL, LoadLibrariesOnWorker, this); |
+ if (rtn != 0) { |
logmsg("ERROR; pthread_create() failed."); |
return false; |
} |
+ rtn = pthread_detach(thread); |
+ if (rtn != 0) { |
+ logmsg("ERROR; pthread_detach() failed."); |
+ return false; |
+ } |
return true; |
} |
@@ -160,7 +166,6 @@ class DlOpenInstance : public pp::Instance { |
void* reverse_so_; |
TYPE_eightball eightball_; |
TYPE_reverse reverse_; |
- pthread_t tid_; |
}; |
class DlOpenModule : public pp::Module { |