[erlang-questions] Problem with io:fwrite/2 ?

Gardell, Steven <>
Fri May 28 11:23:22 CEST 2010


Thanks. Being somewhat new to Erlang, I maybe didn't provide quite
enough
info. I am using the standard file IO:

call_logger()->
    {ok,File} = file:open("loadlog.txt", [append]),
    call_logger(File).

call_logger(File)->
    call_collector(#'CallLog'{file=File}),
    call_logger(File).

Note that that this works just fine for fwrite/3.

-----Original Message-----
From: Gustav Simonsson [mailto:] 
Sent: Friday, May 28, 2010 4:47 AM
To: Gardell, Steven
Cc: 
Subject: Re: [erlang-questions] Problem with io:fwrite/2 ?

Hard to say without knowing how your CL#'CallLog'.file implements the
Erlang IO protocols, does it always reply on the form {io_reply,
ReplyAs, Reply}?
Thing is, the main receive clause in wait_io_mon_reply(From, Mref) in
stdlib/io.erl waits for either a io_reply or an exit/down message, so it
could potentially hang there if your CL#'CallLog'.file is not correctly
implemented.

BR,
Gustav Simonsson


----- Original Message -----
From: "Steven Gardell" <>
To: 
Sent: Thursday, 27 May, 2010 19:01:02 GMT +01:00 Amsterdam / Berlin /
Bern / Rome / Stockholm / Vienna
Subject: [erlang-questions] Problem with io:fwrite/2 ?

Running R13B04 under Linux RES 4. 
It seems that io:fwrite/2 is hanging "most of the time." With the
following code segment:
 
  io:format("BEFORE FULL WRITE~n"),
    io:fwrite(CL#'CallLog'.file,
        "Calls: ~w Rate: ~w Trans: ~w %SlowAdd: ~.1f %SlowMod: ~.1f
%SlowOther ~.1f %SlowTotal ~.1f %Slow2: ~.1f %Slow3: ~.1f Failed ~w
Unexpected: ~w~n",
        [CL#'CallLog'.callCount,
        Rate,
        CL#'CallLog'.transCount,
        SlowAdd1,
        SlowMod1,
        SlowOther1,
        SlowTotal1,
        SlowTotal2,
        SlowTotal3,
        CL#'CallLog'.failedCount,
        CL#'CallLog'.unexpectedMsg]),
 
    io:format("BEFORE EMPTY LINE~n"),
    io:fwrite(CL#'CallLog'.file,"~n"),
    io:format("AFTER EMPTY LINE~n").
 
I see:
 
1> LOADTEST: Ready
loadtest:onecall(twoterm4trans).
Test: 5/27/2010 12:47:36 Rate: 1 Hold: 1 Calls:1
{go,1,1,0,1,1,twoterm4trans} BEFORE FULL WRITE BEFORE EMPTY LINE
2>

The subsequent behavior of the program leads me to believe we never
returned from fwrite().


More information about the erlang-questions mailing list