Chromium Code Reviews| Index: net/udp/udp_socket_posix.cc |
| diff --git a/net/udp/udp_socket_posix.cc b/net/udp/udp_socket_posix.cc |
| index 401158289a7a730886f59ad5035f132b82114275..20c2a991f38a354a29126f483734d0d025a8a324 100644 |
| --- a/net/udp/udp_socket_posix.cc |
| +++ b/net/udp/udp_socket_posix.cc |
| @@ -4,6 +4,7 @@ |
| #include "net/udp/udp_socket_posix.h" |
| +#include <dlfcn.h> |
|
xunjieli
2016/06/29 13:35:09
Should this header be in the #if defined(OS_ANDROI
pauljensen
2016/06/29 13:45:49
Done.
|
| #include <errno.h> |
| #include <fcntl.h> |
| #include <net/if.h> |
| @@ -35,6 +36,8 @@ |
| #include "base/android/build_info.h" |
| #include "base/native_library.h" |
| #include "base/strings/utf_string_conversions.h" |
| +// This was added in Lollipop to dlfcn.h |
| +#define RTLD_NOLOAD 4 |
| #endif |
| namespace net { |
| @@ -351,11 +354,11 @@ int UDPSocketPosix::BindToNetwork( |
| // shouldn't matter. |
| if (!setNetworkForSocket) { |
| // Android's netd client library should always be loaded in our address |
| - // space as it shims libc functions like connect(). |
| + // space as it shims socket() which was used to create |socket_|. |
| base::FilePath file(base::GetNativeLibraryName("netd_client")); |
| - base::NativeLibrary lib = base::LoadNativeLibrary(file, nullptr); |
| - setNetworkForSocket = reinterpret_cast<SetNetworkForSocket>( |
| - base::GetFunctionPointerFromNativeLibrary(lib, "setNetworkForSocket")); |
| + void* dl = dlopen(file.value().c_str(), RTLD_NOW | RTLD_NOLOAD); |
|
xunjieli
2016/06/29 13:35:09
Could add a brief comment on the flags (RTLD_NOW |
pauljensen
2016/06/29 13:45:50
Done.
|
| + setNetworkForSocket = |
| + reinterpret_cast<SetNetworkForSocket>(dlsym(dl, "setNetworkForSocket")); |
| } |
| if (!setNetworkForSocket) |
| return ERR_NOT_IMPLEMENTED; |