diff options
author | sehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-06 19:45:08 +0000 |
---|---|---|
committer | sehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-06 19:45:08 +0000 |
commit | 1e1f1a7eb400cfd9094262315fc03d6a4e13fa1b (patch) | |
tree | 7dc8af2ae8f949cc9114cb04931b2898be201315 /base/sync_socket_posix.cc | |
parent | de23ed934a0ed25ed0c371256e1f8f0355d465d2 (diff) | |
download | chromium_src-1e1f1a7eb400cfd9094262315fc03d6a4e13fa1b.zip chromium_src-1e1f1a7eb400cfd9094262315fc03d6a4e13fa1b.tar.gz chromium_src-1e1f1a7eb400cfd9094262315fc03d6a4e13fa1b.tar.bz2 |
Add an implementation of base::SyncSocket::Peek for posix platforms. Also
update the unit test to test the result.
TEST=ipc_tests/sync_socket_unittest.cc
Review URL: http://codereview.chromium.org/468023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33944 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/sync_socket_posix.cc')
-rw-r--r-- | base/sync_socket_posix.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/base/sync_socket_posix.cc b/base/sync_socket_posix.cc index 5390c7d..194c0bc 100644 --- a/base/sync_socket_posix.cc +++ b/base/sync_socket_posix.cc @@ -8,6 +8,7 @@ #include <limits.h> #include <stdio.h> #include <sys/types.h> +#include <sys/ioctl.h> #include <sys/socket.h> #include "base/atomicops.h" @@ -98,10 +99,13 @@ size_t SyncSocket::Receive(void* buffer, size_t length) { } } -// TODO(port). Some kind of select? size_t SyncSocket::Peek() { - NOTIMPLEMENTED(); - return 0; + int number_chars; + if (-1 == ioctl(handle_, FIONREAD, &number_chars)) { + // If there is an error in ioctl, signal that the channel would block. + return 0; + } + return (size_t) number_chars; } } // namespace base |