Skip to content

Commit

Permalink
Update connect() and crypto enable
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Jul 31, 2017
1 parent 5cbbecb commit 6ae0e76
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,26 +152,22 @@ public function connect() {

$this->deferreds[] = $deferred = new Deferred;
\Amp\Socket\connect($this->config->resolvedHost)->onResolve(function ($error, $socket) use ($deferred) {
$socket = $socket->getResource();
if ($this->connectionState === self::CLOSED) {
$deferred->resolve(null);
if ($socket) {
fclose($socket);
$socket->close();
}
return;
}

if ($error) {
$deferred->fail($error);
if ($socket) {
fclose($socket);
}
return;
}

$this->processors = [$this->parseMysql()];

$this->socket = $socket;
$this->socket = $socket->getResource();
$this->readWatcher = Loop::onReadable($this->socket, [$this, "onInit"]);
});

Expand Down Expand Up @@ -1199,7 +1195,7 @@ private function sendHandshake($inSSL = false) {

Loop::cancel($watcherId);
Loop::disable($this->readWatcher); // temporarily disable, reenable after establishing tls
\Amp\Socket\cryptoEnable($socket, $this->config->ssl + ['peer_name' => $this->config->host])->onResolve(function ($error) {
\Amp\Socket\Internal\enableCrypto($socket, $this->config->ssl + ['peer_name' => $this->config->host])->onResolve(function ($error) {

This comment has been minimized.

Copy link
@kelunik

kelunik Aug 17, 2017

Member

Hmm... that really shouldn't be done. Internal functions aren't subject to the public API and might break in the future without a new major release.

This comment has been minimized.

Copy link
@trowski

trowski Aug 18, 2017

Author Member

Very much agree, at this point I just wanted to get the existing code working. I'd like to refactor this entire class to use Amp\Socket\ClientSocket.

if ($error) {
$this->getDeferred()->fail($error);
$this->closeSocket();
Expand Down

0 comments on commit 6ae0e76

Please sign in to comment.