Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc

Issue 1243123002: [NaCl SDK] Fix initialization of pthread_t in dlopen example (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698