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

Unified Diff: base/sync_socket_posix.cc

Issue 468023: Add an implementation of base::SyncSocket::Peek for posix platforms. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 | ipc/sync_socket_unittest.cc » ('j') | ipc/sync_socket_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sync_socket_posix.cc
===================================================================
--- base/sync_socket_posix.cc (revision 33881)
+++ base/sync_socket_posix.cc (working copy)
@@ -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 @@
}
}
-// 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
« no previous file with comments | « no previous file | ipc/sync_socket_unittest.cc » ('j') | ipc/sync_socket_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698