Skip to content

Commit

Permalink
format fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
cybernetlab committed Sep 17, 2019
1 parent 98cf44b commit 292776b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/thrift/binary/framed/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ defmodule Thrift.Binary.Framed.Client do
:ok = transport.close(sock)

case info do
{:reconnect, _} = reconnect ->
{:reconnect, _} ->
{:connect, info, %{s | sock: nil}}

{:close, from} ->
Expand Down
24 changes: 15 additions & 9 deletions test/thrift/binary/framed/server_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,23 @@ defmodule Servers.Binary.Framed.IntegrationTest do
thrift_test "client can reconnect when connection closed by server", ctx do
{:ok, sock} = :gen_tcp.listen(0, [:binary, packet: 4, active: false])
{:ok, port} = :inet.port(sock)
first_conn = Task.async(fn ->
{:ok, conn} = :gen_tcp.accept(sock)
:ok = :gen_tcp.close(conn)
end)

first_conn =
Task.async(fn ->
{:ok, conn} = :gen_tcp.accept(sock)
:ok = :gen_tcp.close(conn)
end)

name = String.to_atom("#{ctx.client_name}_1")
{:ok, client} = Client.start_link("localhost", port, name: name, reconnect: true)
second_conn = Task.async(fn ->
{:ok, conn} = :gen_tcp.accept(sock)
{:ok, _} = :gen_tcp.recv(conn, 0)
:ok = :gen_tcp.send(conn, @ping_reply)
end)

second_conn =
Task.async(fn ->
{:ok, conn} = :gen_tcp.accept(sock)
{:ok, _} = :gen_tcp.recv(conn, 0)
:ok = :gen_tcp.send(conn, @ping_reply)
end)

assert {:ok, true} == Client.ping(client)
Task.await(first_conn)
Task.await(second_conn)
Expand Down

0 comments on commit 292776b

Please sign in to comment.