File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -592,7 +592,9 @@ public function isSingleton(string $name): bool
592592 */
593593 public function destroyRequest (string $ id ): void
594594 {
595- unset($ this ->requestPool [$ id ]);
595+ if (isset ($ this ->requestPool [$ id ])) {
596+ unset($ this ->requestPool [$ id ]);
597+ }
596598 }
597599
598600 /**
@@ -602,7 +604,9 @@ public function destroyRequest(string $id): void
602604 */
603605 public function destroySession (string $ sid ): void
604606 {
605- unset($ this ->sessionPool [$ sid ]);
607+ if (isset ($ this ->sessionPool [$ sid ])) {
608+ unset($ this ->sessionPool [$ sid ]);
609+ }
606610 }
607611
608612 /**
Original file line number Diff line number Diff line change @@ -22,11 +22,11 @@ class DestroyRequestListener implements EventHandlerInterface
2222 */
2323 public function handle (EventInterface $ event ): void
2424 {
25- $ id = ( string ) $ event ->getParam (0 , '' );
26- if (empty ( $ id) ) {
25+ $ id = $ event ->getParam (0 , '' );
26+ if (! $ id ) {
2727 return ;
2828 }
2929
30- BeanFactory::destroyRequest ($ id );
30+ BeanFactory::destroyRequest (( string ) $ id );
3131 }
3232}
Original file line number Diff line number Diff line change 1212use Swoft \Event \EventInterface ;
1313use Swoft \Log \Logger ;
1414use Swoft \SwoftEvent ;
15+ use Throwable ;
1516use function bean ;
1617use function sgo ;
1718
@@ -47,24 +48,28 @@ public function handle(EventInterface $event): void
4748 */
4849 private function coroutineComplete (): void
4950 {
50- // Wait
51- Context::getWaitGroup ()->wait ();
52-
5351 /* @var Logger $logger */
5452 $ logger = bean ('logger ' );
5553
56- // Add notice log
57- if ($ logger ->isEnable ()) {
58- $ logger ->appendNoticeLog ();
59- }
54+ try {
55+ // Wait coroutine
56+ Context::getWaitGroup ()->wait ();
6057
61- // Coroutine destroy
62- Swoft::trigger (SwoftEvent::COROUTINE_DESTROY );
58+ // Add notice log
59+ if ($ logger ->isEnable ()) {
60+ $ logger ->appendNoticeLog ();
61+ }
6362
64- // Destroy request bean
65- Swoft::trigger (BeanEvent::DESTROY_REQUEST , $ this , Co::tid ());
63+ // Coroutine destroy
64+ Swoft::trigger (SwoftEvent::COROUTINE_DESTROY );
65+ } catch (Throwable $ e ) {
66+ $ logger ->error ('run coroutine complete handle error: ' . $ e ->getMessage ());
67+ } finally { // Use finally ensure context destroy
68+ // Destroy request bean
69+ Swoft::trigger (BeanEvent::DESTROY_REQUEST , $ this , Co::tid ());
6670
67- // Destroy context
68- Context::destroy ();
71+ // Destroy context
72+ Context::destroy ();
73+ }
6974 }
7075}
You can’t perform that action at this time.
0 commit comments