@@ -95,7 +95,10 @@ public function add($fd, $flag, $func, $args = [])
95
95
return $ timerId ;
96
96
case EventInterface::EV_READ :
97
97
if (\is_resource ($ fd )) {
98
- if ($ this ->_reads [$ key = (int ) $ fd ] ?? null ) {
98
+ if (
99
+ ($ this ->_reads [$ key = (int ) $ fd ] ?? null ) or
100
+ Event::isset ($ fd , SWOOLE_EVENT_READ )
101
+ ) {
99
102
$ this ->del ($ fd , EventInterface::EV_READ );
100
103
}
101
104
if ($ res = Event::add ($ fd , $ func , null , SWOOLE_EVENT_READ )) {
@@ -108,7 +111,10 @@ public function add($fd, $flag, $func, $args = [])
108
111
return false ;
109
112
case self ::EV_WRITE :
110
113
if (\is_resource ($ fd )) {
111
- if ($ this ->_writes [$ key = (int ) $ fd ] ?? null ) {
114
+ if (
115
+ ($ this ->_writes [$ key = (int ) $ fd ] ?? null ) or
116
+ Event::isset ($ fd , SWOOLE_EVENT_WRITE )
117
+ ) {
112
118
$ this ->del ($ fd , EventInterface::EV_WRITE );
113
119
}
114
120
if ($ res = Event::add ($ fd , null , $ func , SWOOLE_EVENT_WRITE )) {
@@ -150,30 +156,32 @@ public function del($fd, $flag)
150
156
151
157
return false ;
152
158
case self ::EV_READ :
153
- if (
154
- \is_resource ($ fd ) and
155
- isset ($ this ->_reads [$ key = (int ) $ fd ]) and
156
- Event::isset ($ fd , SWOOLE_EVENT_READ )
157
- ) {
158
- if (Event::del ($ fd )) {
159
- unset($ this ->_reads [$ key ]);
159
+ if (\is_resource ($ fd )) {
160
+ $ key = (int ) $ fd ;
161
+ if (Event::isset ($ fd , SWOOLE_EVENT_READ )){
162
+ if (Event::del ($ fd )) {
160
163
161
- return true ;
164
+ return false ;
165
+ }
162
166
}
167
+ unset($ this ->_reads [$ key ]);
168
+
169
+ return true ;
163
170
}
164
171
165
172
return false ;
166
173
case self ::EV_WRITE :
167
- if (
168
- \is_resource ($ fd ) and
169
- isset ($ this ->_writes [$ key = (int ) $ fd ]) and
170
- Event::isset ($ fd , SWOOLE_EVENT_WRITE )
171
- ) {
172
- if (Event::del ($ fd )) {
173
- unset($ this ->_writes [$ key ]);
174
+ if (\is_resource ($ fd )) {
175
+ $ key = (int ) $ fd ;
176
+ if (Event::isset ($ fd , SWOOLE_EVENT_WRITE )){
177
+ if (Event::del ($ fd )) {
174
178
175
- return true ;
179
+ return false ;
180
+ }
176
181
}
182
+ unset($ this ->_writes [$ key ]);
183
+
184
+ return true ;
177
185
}
178
186
179
187
return false ;
0 commit comments