Skip to content

Commit

Permalink
Merge branch 'sverk/opt-inet-tcp-ctrl-proc'
Browse files Browse the repository at this point in the history
* sverk/opt-inet-tcp-ctrl-proc:
  Optimize inet:tcp_controlling_process
  erts: Update obsolete HARD_DEBUG code
  • Loading branch information
sverker committed Jul 5, 2012
2 parents 2d519dc + 4ce6c4d commit 13fb710
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 43 deletions.
48 changes: 7 additions & 41 deletions erts/emulator/beam/erl_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,7 @@ erts_move_msg_mbuf_to_heap(Eterm** hpp, ErlOffHeap* off_heap, ErlMessage *msg)
#endif

#ifdef HARD_DEBUG
ProcBin *dbg_mso_start = off_heap->mso;
ErlFunThing *dbg_fun_start = off_heap->funs;
ExternalThing *dbg_external_start = off_heap->externals;
struct erl_off_heap_header* dbg_oh_start = off_heap->first;
Eterm dbg_term, dbg_token;
ErlHeapFragment *dbg_bp;
Uint *dbg_hp, *dbg_thp_start;
Expand Down Expand Up @@ -772,48 +770,16 @@ erts_move_msg_mbuf_to_heap(Eterm** hpp, ErlOffHeap* off_heap, ErlMessage *msg)
int i, j;
ErlHeapFragment* frag;
{
ProcBin *mso = off_heap->mso;
struct erl_off_heap_header* dbg_oh = off_heap->first;
i = j = 0;
while (mso != dbg_mso_start) {
mso = mso->next;
while (dbg_oh != dbg_oh_start) {
dbg_oh = dbg_oh->next;
i++;
}
for (frag=bp; frag; frag=frag->next) {
mso = frag->off_heap.mso;
while (mso) {
mso = mso->next;
j++;
}
}
ASSERT(i == j);
}
{
ErlFunThing *fun = off_heap->funs;
i = j = 0;
while (fun != dbg_fun_start) {
fun = fun->next;
i++;
}
for (frag=bp; frag; frag=frag->next) {
fun = frag->off_heap.funs;
while (fun) {
fun = fun->next;
j++;
}
}
ASSERT(i == j);
}
{
ExternalThing *external = off_heap->externals;
i = j = 0;
while (external != dbg_external_start) {
external = external->next;
i++;
}
for (frag=bp; frag; frag=frag->next) {
external = frag->off_heap.externals;
while (external) {
external = external->next;
dbg_oh = frag->off_heap.first;
while (dbg_oh) {
dbg_oh = dbg_oh->next;
j++;
}
}
Expand Down
10 changes: 8 additions & 2 deletions lib/kernel/src/inet.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1255,15 +1255,21 @@ tcp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) ->
_ ->
case prim_inet:getopt(S, active) of
{ok, A0} ->
prim_inet:setopt(S, active, false),
case A0 of
false -> ok;
_ -> prim_inet:setopt(S, active, false)
end,
case tcp_sync_input(S, NewOwner, false) of
true -> %% socket already closed,
ok;
false ->
try erlang:port_connect(S, NewOwner) of
true ->
unlink(S), %% unlink from port
prim_inet:setopt(S, active, A0),
case A0 of
false -> ok;
_ -> prim_inet:setopt(S, active, A0)
end,
ok
catch
error:Reason ->
Expand Down

0 comments on commit 13fb710

Please sign in to comment.