diff options
author | sbc <sbc@chromium.org> | 2015-07-21 12:36:30 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-21 19:48:17 +0000 |
commit | b1904c3552fd0a572426430462c912efee2e0a98 (patch) | |
tree | 55ecaf36b296f138cdb4302bb0ab6042a59b3cbe /native_client_sdk | |
parent | e1f6f228d129a7611e98ac399e19949a11c42580 (diff) | |
download | chromium_src-b1904c3552fd0a572426430462c912efee2e0a98.zip chromium_src-b1904c3552fd0a572426430462c912efee2e0a98.tar.gz chromium_src-b1904c3552fd0a572426430462c912efee2e0a98.tar.bz2 |
[NaCl SDK] Fix initialization of pthread_t in dlopen example
Initializing a pthread_t to NULL (or any value really)
is not valid. This causes a compiler warning with the new
arm glibc toolchain so needs to be fixed because we
enable the new toolchain.
Turns out the pid_ member was not even needed so this
change removes it and adds a pthread_detach call which
allows for freeing on the thread's resources
(in the absence of pthread_join).
CQ_EXTRA_TRYBOTS=tryserver.chromium.linux:linux_nacl_sdk;tryserver.chromium.mac:mac_nacl_sdk
BUG=505885
Review URL: https://codereview.chromium.org/1243123002
Cr-Commit-Position: refs/heads/master@{#339720}
Diffstat (limited to 'native_client_sdk')
-rw-r--r-- | native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc b/native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc index 81aa015..1c64314 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 { |