7
7
// The AlliedModders I/O library is licensed under the GNU General Public
8
8
// License, version 3 or higher. For more information, see LICENSE.txt
9
9
//
10
- #include " posix/amio- posix-errors.h"
11
- #include " solaris/amio- solaris-port.h"
10
+ #include " posix/posix-errors.h"
11
+ #include " solaris/solaris-port.h"
12
12
#include < sys/types.h>
13
13
#include < sys/stat.h>
14
14
#include < fcntl.h>
@@ -50,7 +50,7 @@ PortImpl::Shutdown()
50
50
51
51
for (size_t i = 0 ; i < fds_.length (); i++) {
52
52
if (fds_[i].transport )
53
- fds_[i].transport -> detach ( );
53
+ detach_for_shutdown_locked ( fds_[i].transport );
54
54
}
55
55
56
56
AMIO_RETRY_IF_EINTR (close (port_));
@@ -75,14 +75,15 @@ PortImpl::attach_locked(PosixTransport *transport, StatusListener *listener, Tra
75
75
transport->setUserData (slot);
76
76
77
77
if (Ref<IOError> error = change_events_locked (transport, flags)) {
78
+ // Note: we're not fully attached, so no need to notify any proxies.
78
79
detach_locked (transport);
79
80
return error;
80
81
}
81
82
82
83
return nullptr ;
83
84
}
84
85
85
- void
86
+ PassRef<StatusListener>
86
87
PortImpl::detach_locked (PosixTransport *transport)
87
88
{
88
89
int fd = transport->fd ();
@@ -93,13 +94,10 @@ PortImpl::detach_locked(PosixTransport *transport)
93
94
if (transport->flags () & kTransportArmed )
94
95
port_dissociate (port_, PORT_SOURCE_FD, fd);
95
96
96
- // Just for safety, we detach here in case the assignment below drops the
97
- // last ref to the transport.
98
- transport->detach ();
99
-
100
97
fds_[slot].transport = nullptr ;
101
98
fds_[slot].modified = generation_;
102
99
free_slots_.append (slot);
100
+ return transport->detach ();
103
101
}
104
102
105
103
PassRef<IOError>
@@ -150,9 +148,9 @@ PortImpl::handleEvent(size_t slot)
150
148
AutoMaybeUnlock unlock (lock_);
151
149
152
150
if (outFlag == kTransportReading )
153
- listener->OnReadReady (transport );
151
+ listener->OnReadReady ();
154
152
else if (outFlag == kTransportWriting )
155
- listener->OnWriteReady (transport );
153
+ listener->OnWriteReady ();
156
154
}
157
155
158
156
// Don't re-arm if the fd changed or the port is already re-armed.
0 commit comments