| Index: net/base/listen_socket.cc
|
| ===================================================================
|
| --- net/base/listen_socket.cc (revision 6915)
|
| +++ net/base/listen_socket.cc (working copy)
|
| @@ -12,6 +12,7 @@
|
| #include <errno.h>
|
| #include <sys/socket.h>
|
| #include <arpa/inet.h>
|
| +#include "base/message_loop.h"
|
| #include "net/base/net_errors.h"
|
| #include "third_party/libevent/event.h"
|
| #endif
|
| @@ -29,7 +30,12 @@
|
| const int kReadBufSize = 200;
|
|
|
| ListenSocket::ListenSocket(SOCKET s, ListenSocketDelegate *del)
|
| +#if defined(OS_WIN)
|
| : socket_(s),
|
| +#elif defined(OS_POSIX)
|
| + : event_(new event),
|
| + socket_(s),
|
| +#endif
|
| socket_delegate_(del) {
|
| #if defined(OS_WIN)
|
| socket_event_ = WSACreateEvent();
|
| @@ -171,7 +177,8 @@
|
| #if defined(OS_WIN)
|
| watcher_.StopWatching();
|
| #elif defined(OS_POSIX)
|
| - watcher_.StopWatchingFileDescriptor();
|
| + MessageLoopForIO::current()->UnwatchSocket(event_.get());
|
| + wait_state_ = NOT_WAITING;
|
| #endif
|
| }
|
|
|
| @@ -180,9 +187,8 @@
|
| WSAEventSelect(socket_, socket_event_, FD_ACCEPT | FD_CLOSE | FD_READ);
|
| watcher_.StartWatching(socket_event_, this);
|
| #elif defined(OS_POSIX)
|
| - // Implicitly calls StartWatchingFileDescriptor().
|
| - MessageLoopForIO::current()->WatchFileDescriptor(
|
| - socket_, true, MessageLoopForIO::WATCH_READ, &watcher_, this);
|
| + MessageLoopForIO::current()->WatchSocket(
|
| + socket_, EV_READ|EV_PERSIST, event_.get(),this);
|
| wait_state_ = state;
|
| #endif
|
| }
|
| @@ -244,7 +250,7 @@
|
| }
|
| }
|
| #elif defined(OS_POSIX)
|
| -void ListenSocket::OnFileCanReadWithoutBlocking(int fd) {
|
| +void ListenSocket::OnSocketReady(short flags) {
|
| if (wait_state_ == WAITING_ACCEPT) {
|
| Accept();
|
| }
|
| @@ -256,11 +262,4 @@
|
| // TODO(erikkay): this seems to get hit multiple times after the close
|
| }
|
| }
|
| -
|
| -void ListenSocket::OnFileCanWriteWithoutBlocking(int fd) {
|
| - // MessagePumpLibevent callback, we don't listen for write events
|
| - // so we shouldn't ever reach here.
|
| - NOTREACHED();
|
| -}
|
| -
|
| #endif
|
|
|