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

Unified Diff: native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc

Issue 23456045: [NaCl SDK] nacl_io: Add initial support for getsockopt (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
Index: native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc
index abaf55ba1e9e48ae0a89fa16d08b65d87ce62962..87d6f484d3a33b5852fff6bfd09cbea7e1176386 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc
@@ -204,14 +204,27 @@ Error MountNodeSocket::GetSockOpt(int lvl,
int optname,
void* optval,
socklen_t* len) {
- return EINVAL;
+ if (lvl != SOL_SOCKET)
+ return ENOPROTOOPT;
+
+ switch (optname) {
+ case SO_ERROR: {
+ int copy_bytes = std::min(sizeof(int), *len);
+ memcpy(optval, &last_errno_, copy_bytes);
+ *len = sizeof(int);
+ last_errno_ = 0;
+ return 0;
+ }
+ }
+
+ return ENOPROTOOPT;
}
Error MountNodeSocket::SetSockOpt(int lvl,
int optname,
const void* optval,
socklen_t len) {
- return EINVAL;
+ return ENOPROTOOPT;
}
Error MountNodeSocket::Bind(const struct sockaddr* addr, socklen_t len) {
@@ -372,4 +385,4 @@ Error MountNodeSocket::GetSockName(struct sockaddr* addr, socklen_t* len) {
} // namespace nacl_io
-#endif // PROVIDES_SOCKET_API
+#endif // PROVIDES_SOCKET_API
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/mount_node_socket.h ('k') | native_client_sdk/src/libraries/nacl_io/mount_node_tcp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698