Skip to content

Commit e830e9d

Browse files
committed
Merge onResolve callback into coroutine
1 parent e1b1558 commit e830e9d

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

lib/Internal/Processor.php

+10-11
Original file line numberDiff line numberDiff line change
@@ -1173,21 +1173,20 @@ private function sendHandshake($inSSL = false) {
11731173
$payload .= str_repeat("\0", 23); // reserved
11741174

11751175
if (!$inSSL && ($this->capabilities & self::CLIENT_SSL)) {
1176-
\Amp\call(function () use ($payload) {
1177-
yield $this->write($payload);
1176+
\Amp\asyncCall(function () use ($payload) {
1177+
try {
1178+
yield $this->write($payload);
11781179

1179-
$context = $this->config->ssl ?: new ClientTlsContext;
1180-
$context = $context->withPeerName($this->config->host);
1180+
$context = $this->config->ssl ?: new ClientTlsContext;
1181+
$context = $context->withPeerName($this->config->host);
11811182

1182-
return yield $this->socket->enableCrypto($context);
1183-
})->onResolve(function ($error) {
1184-
if ($error) {
1183+
yield $this->socket->enableCrypto($context);
1184+
1185+
$this->sendHandshake(true);
1186+
} catch (\Throwable $e) {
11851187
$this->closeSocket();
1186-
$this->getDeferred()->fail($error);
1187-
return;
1188+
$this->getDeferred()->fail($e);
11881189
}
1189-
1190-
$this->sendHandshake(true);
11911190
});
11921191

11931192
return;

0 commit comments

Comments
 (0)