From kagato@REDACTED Tue Jun 1 00:22:24 2010 From: kagato@REDACTED (Jayson Vantuyl) Date: Mon, 31 May 2010 15:22:24 -0700 Subject: ErlCtl 0.2 Released Message-ID: Just released ErlCtl 0.2. Read about it here: http://needlesslymessianic.com/2010/05/31/erlctl-0-2-released?utm_source=erlang-questions&utm_medium=email&utm_campaign=erlctl-0.2 Or just go to GitHub: http://github.com/jvantuyl/erlctl/tree/erlctl-0.2 Enjoy. -- Jayson Vantuyl kagato@REDACTED From agratton@REDACTED Tue Jun 1 00:41:03 2010 From: agratton@REDACTED (Angus Gratton) Date: Tue, 01 Jun 2010 08:41:03 +1000 Subject: [erlang-questions] ErlCtl 0.2 Released In-Reply-To: References: Message-ID: <4C043AFF.7030001@m5net.com> Jayson Vantuyl wrote: > Just released ErlCtl 0.2. Read about it here: > > http://needlesslymessianic.com/2010/05/31/erlctl-0-2-released?utm_source=erlang-questions&utm_medium=email&utm_campaign=erlctl-0.2 > > For anyone else wondering what ErlCtl actually is: "A framework for putting a sane and uniform command-line-interface on an Erlang application." Looks interesting. :-) Cheers, Angus From hd2010@REDACTED Tue Jun 1 02:07:46 2010 From: hd2010@REDACTED (Henning Diedrich) Date: Tue, 01 Jun 2010 02:07:46 +0200 Subject: [erlang-questions] generic replication bahaviour In-Reply-To: <39655.1275336659@snookles.snookles.com> References: <39655.1275336659@snookles.snookles.com> Message-ID: <4C044F52.90400@eonblast.com> > (*) Reading Brewer's writings about CAP and then the Gilbert & Lynch > proof, the formal definition of "P" is a tricky thing. > Did you read Stonebrakers latest take on the P? http://cacm.acm.org/blogs/blog-cacm/83396-errors-in-database-systems-eventual-consistency-and-the-cap-theorem/fulltext & Robinson's response http://www.cloudera.com/blog/2010/04/cap-confusion-problems-with-partition-tolerance/ In case you're interested, Stonebraker will lecture on that, too, at June 3 https://www1.gotomeeting.com/register/955469336 "Urban Myths" about SQL [...]"Myth #7: in CAP the theorem, choose AP over CA " From jacob.vorreuter@REDACTED Tue Jun 1 02:22:23 2010 From: jacob.vorreuter@REDACTED (Jacob Vorreuter) Date: Mon, 31 May 2010 17:22:23 -0700 Subject: preserving state in driver process between callbacks to emulator Message-ID: <5315394E-36FE-4D0A-99DE-03A1373B82F0@gmail.com> As my linked-in driver adventure continues, I'm at a point where I'm wondering if there's a way to maintain state between callbacks to the emulator. I'm writing an http proxy driver and I would like to be able to read the http headers from the client socket, return the host header to the Erlang emulator, receive back the ip and port of the backend server to connect to and then proxy the previously collected headers as well as the request body to the backend server. My question is how to store the header data so that it's available on subsequent calls to the driver. Is there a structure that persists between calls from the emulator? I started structuring my driver as follows: static void process(ErlDrvData handle, ErlIOVec *ev) { basic_drv_t* driver_data = (basic_drv_t*) handle; ErlDrvBinary* data = ev->binv[1]; int cmd = data->orig_bytes[0]; if(cmd == 1) { // read client fd from orig_bytes int clientfd = ... // read headers from client socket char *headers = ... // read host header char *host = ... // send host back to emulator to determine appropriate backend server ErlDrvTermData spec[] = { ERL_DRV_ATOM, driver_mk_atom("host"), ERL_DRV_STRING, (ErlDrvTermData)host, strlen(host), ERL_DRV_TUPLE, 2 }; driver_output_term(driver_data->port, spec, sizeof(spec) / sizeof(spec[0])); } else if(cmd == 2) { // read backend host and port from orig_bytes // connect to backend server // proxy *headers data from above to backend server ErlDrvTermData spec[] = {ERL_DRV_ATOM, driver_mk_atom("ok")}; driver_output_term(driver_data->port, spec, sizeof(spec) / sizeof(spec[0])); } } And the Erlang code is something like this: proxy_client_request(Fd) when is_integer(Fd) -> Port = open_port({spawn, 'basic_drv'}, [binary]), Cmd1 = 1, port_command(Port, <>), receive {host, Host} -> {ServerHost, ServerPort} = lookup_backend(Host), Cmd2 = 2, HostSize = size(ServerHost), port_command(Port, <>), receive ok -> ok end after 5000 -> {error, timeout} end, port_close(Port). Does is make sense what I'm trying to do? Any insight? Thanks, Jake From dmitriid@REDACTED Tue Jun 1 10:07:19 2010 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Tue, 1 Jun 2010 11:07:19 +0300 Subject: Erlang-related banners/badges for your site In-Reply-To: References: Message-ID: <6C751141-2131-41FC-927F-7684588018A9@gmail.com> Alternative site: http://b.erlanger.ru/ for those who fear AdBlock :) > Hi, all > > If you ever wanted an Erlang-related banner//badge for your site that would read something like "Erlang FTW!!!", you can now have one: > > http://banners.erlanger.ru/ > > Three sizes, two themes, customized labels. > > I'm open to suggestions (especially with regard to fonts, I have a problem rendering them correctly on Ubuntu 8.04 Server with Python's PIL) > > > P.S. Since many confuse erlanger with enlarger, Russian Erlang community now has a sort of meme: "erlang your code" :) From ivan@REDACTED Tue Jun 1 11:02:27 2010 From: ivan@REDACTED (Ivan Uemlianin) Date: Tue, 01 Jun 2010 10:02:27 +0100 Subject: ANN: wave.erl Message-ID: <4C04CCA3.2070205@llaisdy.com> Dear All Please find below wave.erl, an erlang script for reading and writing .wav audio files. I am releasing it under the ISC license. The script exports functions read/1, write/3 and write/2, and the wave record: -record(wave, {audio_format, sample_rate, data}). where: - audio_format is an unsigned integer (currently only 1, i.e. pcm encoding, is supported); - sample_rate is an unsigned integer (i.e., samples per second, in kHz); - data is a list of lists of signed integers, one list for each channel (e.g., stereo will have two lists of integers). read(FileName) reads a wav file and returns a wave record. write(WavRecord, FileName, BitsPerSample) writes the wave record WavRecord to the file FileName with the sample size BitsPerSample. write(WavRecord, FileName) just calls write/3 with BitsPerSample = 16. [identical announcement at http://llaisdy.wordpress.com/2010/06/01/wave-erl-an-erlang-script-to-read-and-write-wav-files/] With thanks and best wishes Ivan %% Copyright ? 2010 by Ivan Uemlianin (ivan@REDACTED) %% %% Permission to use, copy, modify, and/or distribute this software for any %% purpose with or without fee is hereby granted, provided that the above %% copyright notice and this permission notice appear in all copies. %% %% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS AND COPYRIGHT HOLDERS %% DISCLAIM ALL WARRANTIES WITH SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF %% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT %% HOLDERS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL %% DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR %% PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS %% ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF %% THIS SOFTWARE. %% * wave.erl --- Erlang functions to read and write .wav files. %% %% ** version 1.0: %% - does not support compression %% - only pcm encoding (AudioFormat = 1) %% %% ** todo %% - set debug flags to disable io:format in read/1 and write/3 %% - test wav file for well-formed-ness %% - function to parse and return header (ie without reading whole file) %% - pread(FileName, Offset, NFrames) %% %% ** refs %% %% [1] http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html %% [2] http://ccrma.stanford.edu/courses/422/projects/WaveFormat/ %% [3] http://chlorophil.blogspot.com/2007/06/erlang-binary-map.html -module(wave). -export([read/1, write/2, write/3]). % audio_format = integer (see wav docs for formats) % sample_rate in kHz % data is list of lists of integers (one list for each channel) -record(wave, {audio_format, sample_rate, data}). read(FileName) -> %% returns wave record {ok, Binary} = file:read_file(FileName), <> = Binary, % TODO: test file for well-formedness, e.g.: % ChunkID == "RIFF" % ChunkSize == SubChunk2Size + 36 % Format == "WAVE" % AudioFormat = 1 % no other encodings supported in v1.0 % SubChunk1ID == "fmt " % SubChunk1Size == 16 % SubChunk2ID == "data" % SubChunk2Size == NumSamples * NumChannels * BitsPerSample div 8 Channels = data2channels(Data, NumChannels, BitsPerSample), io:format("* ~p~n~n- ChunkID: ~p~n- ChunkSize: ~B~n- Format: ~p~n- SubChunk1ID: ~p~n- SubChunk1Size: ~B~n- AudioFormat: ~B~n- NumChannels: ~B~n- SampleRate: ~B~n- ByteRate: ~B~n- BlockAlign: ~B~n- BitsPerSample: ~B~n- SubChunk2ID: ~p~n- SubChunk2Size: ~B~n- Data: [...]~n~n", [FileName, binary_to_list(ChunkID), ChunkSize, binary_to_list(Format), binary_to_list(SubChunk1ID), SubChunk1Size, AudioFormat, NumChannels, SampleRate, ByteRate, BlockAlign, BitsPerSample, binary_to_list(SubChunk2ID), SubChunk2Size ]), #wave{sample_rate=SampleRate, audio_format=AudioFormat, data=Channels }. mono(Data, NBytes) -> [[ X || <> <= Data ]]. stereo(Data, NBytes) -> LP = [ [A,B] || << A:NBytes/little-signed-integer-unit:8, B:NBytes/little-signed-integer-unit:8 >> <= Data], lp2pl(LP, [], []). % list of pairs to pair of lists lp2pl([], Left, Right) -> [lists:reverse(Left), lists:reverse(Right)]; lp2pl([[L,R]|T], Left, Right) -> lp2pl(T, [L|Left], [R|Right]). data2channels(Data, NumChannels, BitsPerSample) -> NBytes = BitsPerSample div 8, case NumChannels of 1 -> mono(Data, NBytes); 2 -> stereo(Data, NBytes) end. lt2l([], Acc) -> lists:reverse(Acc); lt2l([H|T], Acc) -> lt2l(T, [element(2, H), element(1, H) | Acc]). pl2l(PL) -> X = lists:zip(lists:nth(1, PL), lists:nth(2, PL)), lt2l(X, []). channels2dataBin(Channels, BitsPerSample) -> case length(Channels) of 1 -> Data = lists:nth(1, Channels); 2 -> Data = pl2l(Channels) end, Size = length(Data) * (BitsPerSample div 8), DataBin = list_to_binary([ <> || X <- Data]), {Size, DataBin}. write(WavRecord, FileName) -> write(WavRecord, FileName, 16). write(WavRecord, FileName, BitsPerSample) -> {SubChunk2Size, Data} = channels2dataBin(WavRecord#wave.data, BitsPerSample), ChunkID = list_to_binary("RIFF"), Format = list_to_binary("WAVE"), SubChunk1ID = list_to_binary("fmt "), SubChunk1Size = 16, AudioFormat = 1, % only pcm encoding supported NumChannels = length(WavRecord#wave.data), SampleRate = WavRecord#wave.sample_rate, ByteRate = SampleRate * NumChannels * BitsPerSample div 8, BlockAlign = NumChannels * BitsPerSample div 8, SubChunk2ID = list_to_binary("data"), ChunkSize = SubChunk2Size + 36, io:format("* ~p~n~n- ChunkID: ~p~n- ChunkSize: ~B~n- Format: ~p~n- SubChunk1ID: ~p~n- SubChunk1Size: ~B~n- AudioFormat: ~B~n- NumChannels: ~B~n- SampleRate: ~B~n- ByteRate: ~B~n- BlockAlign: ~B~n- BitsPerSample: ~B~n- SubChunk2ID: ~p~n- SubChunk2Size: ~B~n- Data: [...]~n~n", [FileName, binary_to_list(ChunkID), ChunkSize, binary_to_list(Format), binary_to_list(SubChunk1ID), SubChunk1Size, AudioFormat, NumChannels, SampleRate, ByteRate, BlockAlign, BitsPerSample, binary_to_list(SubChunk2ID), SubChunk2Size ]), Binary = <>, file:write_file(FileName, Binary), {ok, FileName}. -- ============================================================ Ivan A. Uemlianin Speech Technology Research and Development ivan@REDACTED www.llaisdy.com llaisdy.wordpress.com www.linkedin.com/in/ivanuemlianin "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" (Schiller, Beethoven) ============================================================ From dmitriid@REDACTED Tue Jun 1 11:03:09 2010 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Tue, 1 Jun 2010 12:03:09 +0300 Subject: Erlang logo licensing Message-ID: There was a very short discussion here: http://www.trapexit.org/forum/viewtopic.php?p=50500&sid=58462aff01bb46b7684ae9515c3c7a0d with no conclusion. What are Erlang logo licensing terms? How freely can we use it and can we use it at all? :) From kostis@REDACTED Tue Jun 1 11:19:26 2010 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 01 Jun 2010 12:19:26 +0300 Subject: [erlang-questions] ANN: wave.erl In-Reply-To: <4C04CCA3.2070205@llaisdy.com> References: <4C04CCA3.2070205@llaisdy.com> Message-ID: <4C04D09E.6090208@cs.ntua.gr> Ivan Uemlianin wrote: > Dear All > > Please find below wave.erl, an erlang script for reading and writing > .wav audio files. I am releasing it under the ISC license. > > The script exports functions read/1, write/3 and write/2, and the wave > record: > > -record(wave, {audio_format, sample_rate, data}). > > where: > - audio_format is an unsigned integer (currently only 1, i.e. pcm > encoding, is supported); > - sample_rate is an unsigned integer (i.e., samples per second, in kHz); > - data is a list of lists of signed integers, one list for each channel > (e.g., stereo will have two lists of integers). > > read(FileName) reads a wav file and returns a wave record. > > write(WavRecord, FileName, BitsPerSample) writes the wave record > WavRecord to the file FileName with the sample size BitsPerSample. > > write(WavRecord, FileName) just calls write/3 with BitsPerSample = 16. Rather than writing all the above, which is just words in a mail, why don't you add the following to the file which is machine-checkable documentation which is now part of the code? ------------------------------------------------------------------------- -type audio_format() :: 1. % non_neg_integer() see wav docs for formats -type sample_rate() :: non_neg_integer(). -record(wave, {audio_format :: audio_format(), sample_rate :: sample_rate(), data :: [[integer()]]}). -type wave() :: #wave{}. -spec read(file:filename()) -> wave(). ... AND FURTHER DOWN -spec write(wave(), F) -> {'ok', F} when is_subtype(F, file:filename()). -spec write(wave(), F, sample_rate()) -> {'ok', F} when is_subtype(F, file:filename()). -------------------------------------------------------------------------- [although I do not see any compelling reason for the write functions to return {'ok', F} rather than just 'ok' at the moment.] Kostis From rvirding@REDACTED Tue Jun 1 11:27:57 2010 From: rvirding@REDACTED (Robert Virding) Date: Tue, 1 Jun 2010 11:27:57 +0200 Subject: [erlang-questions] Erlang logo licensing In-Reply-To: References: Message-ID: I don't know who owns the 'e' logo but I am certain that Erlang Solutions owns the curly writing Erlang. It's in their logo. Robert On 1 June 2010 11:03, Dmitrii Dimandt wrote: > There was a very short discussion here: http://www.trapexit.org/forum/viewtopic.php?p=50500&sid=58462aff01bb46b7684ae9515c3c7a0d with no conclusion. > > What are Erlang logo licensing terms? How freely can we use it and can we use it at all? :) From ivan@REDACTED Tue Jun 1 11:28:39 2010 From: ivan@REDACTED (Ivan Uemlianin) Date: Tue, 01 Jun 2010 10:28:39 +0100 Subject: [erlang-questions] ANN: wave.erl In-Reply-To: <4C04D09E.6090208@cs.ntua.gr> References: <4C04CCA3.2070205@llaisdy.com> <4C04D09E.6090208@cs.ntua.gr> Message-ID: <4C04D2C7.2090406@llaisdy.com> Dear Kostas Thank you for your comments. > why don't you add the following to the file ... The main reason I hadn't was that I haven't yet read Ch. 18 of Erlang Programming (Types and Programming). I shall go and do so immediately. I should like to start off with all this stuff in place. Best wishes Ivan On 01/06/2010 10:19, Kostis Sagonas wrote: > Ivan Uemlianin wrote: >> Dear All >> >> Please find below wave.erl, an erlang script for reading and writing >> .wav audio files. I am releasing it under the ISC license. >> >> The script exports functions read/1, write/3 and write/2, and the >> wave record: >> >> -record(wave, {audio_format, sample_rate, data}). >> >> where: >> - audio_format is an unsigned integer (currently only 1, i.e. pcm >> encoding, is supported); >> - sample_rate is an unsigned integer (i.e., samples per second, in kHz); >> - data is a list of lists of signed integers, one list for each >> channel (e.g., stereo will have two lists of integers). >> >> read(FileName) reads a wav file and returns a wave record. >> >> write(WavRecord, FileName, BitsPerSample) writes the wave record >> WavRecord to the file FileName with the sample size BitsPerSample. >> >> write(WavRecord, FileName) just calls write/3 with BitsPerSample = 16. > > Rather than writing all the above, which is just words in a mail, why > don't you add the following to the file which is machine-checkable > documentation which is now part of the code? > > ------------------------------------------------------------------------- > -type audio_format() :: 1. % non_neg_integer() see wav docs for formats > -type sample_rate() :: non_neg_integer(). > -record(wave, {audio_format :: audio_format(), > sample_rate :: sample_rate(), > data :: [[integer()]]}). > -type wave() :: #wave{}. > > -spec read(file:filename()) -> wave(). > > ... AND FURTHER DOWN > > -spec write(wave(), F) -> {'ok', F} when is_subtype(F, file:filename()). > > -spec write(wave(), F, sample_rate()) -> {'ok', F} when is_subtype(F, > file:filename()). > -------------------------------------------------------------------------- > > > [although I do not see any compelling reason for the write functions > to return {'ok', F} rather than just 'ok' at the moment.] > > Kostis -- ============================================================ Ivan A. Uemlianin Speech Technology Research and Development ivan@REDACTED www.llaisdy.com llaisdy.wordpress.com www.linkedin.com/in/ivanuemlianin "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" (Schiller, Beethoven) ============================================================ From mazen.harake@REDACTED Tue Jun 1 11:36:00 2010 From: mazen.harake@REDACTED (Mazen Harake) Date: Tue, 01 Jun 2010 10:36:00 +0100 Subject: [erlang-questions] ANN: wave.erl In-Reply-To: <4C04D09E.6090208@cs.ntua.gr> References: <4C04CCA3.2070205@llaisdy.com> <4C04D09E.6090208@cs.ntua.gr> Message-ID: <4C04D480.3030208@erlang-solutions.com> Tip: It is Open Source... Submit a patch ;) /Mazen On 01/06/2010 10:19, Kostis Sagonas wrote: > Ivan Uemlianin wrote: >> Dear All >> >> Please find below wave.erl, an erlang script for reading and writing >> .wav audio files. I am releasing it under the ISC license. >> >> The script exports functions read/1, write/3 and write/2, and the >> wave record: >> >> -record(wave, {audio_format, sample_rate, data}). >> >> where: >> - audio_format is an unsigned integer (currently only 1, i.e. pcm >> encoding, is supported); >> - sample_rate is an unsigned integer (i.e., samples per second, in kHz); >> - data is a list of lists of signed integers, one list for each >> channel (e.g., stereo will have two lists of integers). >> >> read(FileName) reads a wav file and returns a wave record. >> >> write(WavRecord, FileName, BitsPerSample) writes the wave record >> WavRecord to the file FileName with the sample size BitsPerSample. >> >> write(WavRecord, FileName) just calls write/3 with BitsPerSample = 16. > > Rather than writing all the above, which is just words in a mail, why > don't you add the following to the file which is machine-checkable > documentation which is now part of the code? > > ------------------------------------------------------------------------- > -type audio_format() :: 1. % non_neg_integer() see wav docs for formats > -type sample_rate() :: non_neg_integer(). > -record(wave, {audio_format :: audio_format(), > sample_rate :: sample_rate(), > data :: [[integer()]]}). > -type wave() :: #wave{}. > > -spec read(file:filename()) -> wave(). > > ... AND FURTHER DOWN > > -spec write(wave(), F) -> {'ok', F} when is_subtype(F, file:filename()). > > -spec write(wave(), F, sample_rate()) -> {'ok', F} when is_subtype(F, > file:filename()). > -------------------------------------------------------------------------- > > > [although I do not see any compelling reason for the write functions > to return {'ok', F} rather than just 'ok' at the moment.] > > Kostis > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From jesper.louis.andersen@REDACTED Tue Jun 1 11:54:31 2010 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Tue, 1 Jun 2010 11:54:31 +0200 Subject: [erlang-questions] ANN: wave.erl In-Reply-To: <4C04D09E.6090208@cs.ntua.gr> References: <4C04CCA3.2070205@llaisdy.com> <4C04D09E.6090208@cs.ntua.gr> Message-ID: On Tue, Jun 1, 2010 at 11:19 AM, Kostis Sagonas wrote: > Rather than writing all the above, which is just words in a mail, why don't > you add the following to the file which is machine-checkable documentation > which is now part of the code? What tools do currently make use of this information, and how? I guess the dialyzer does. If I write a spec such the function and spec are not matching, then what tool will report the discrepancy? Dialyzer? -- J. From ivan@REDACTED Tue Jun 1 12:12:12 2010 From: ivan@REDACTED (Ivan Uemlianin) Date: Tue, 01 Jun 2010 11:12:12 +0100 Subject: [erlang-questions] ANN: wave.erl In-Reply-To: References: <4C04CCA3.2070205@llaisdy.com> <4C04D09E.6090208@cs.ntua.gr> Message-ID: <4C04DCFC.4020605@llaisdy.com> On 01/06/2010 10:54, Jesper Louis Andersen wrote: > On Tue, Jun 1, 2010 at 11:19 AM, Kostis Sagonas wrote: > > >> Rather than writing all the above, which is just words in a mail, why don't >> you add the following to the file which is machine-checkable documentation >> which is now part of the code? >> > What tools do currently make use of this information, and how? I guess > the dialyzer does. If I write a spec such the function and spec are > not matching, then what tool will report the discrepancy? Dialyzer? > TypEr checks for type discrepancies; Dialyzer is more general. ;) Ivan -- ============================================================ Ivan A. Uemlianin Speech Technology Research and Development ivan@REDACTED www.llaisdy.com llaisdy.wordpress.com www.linkedin.com/in/ivanuemlianin "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" (Schiller, Beethoven) ============================================================ From ivan@REDACTED Tue Jun 1 12:16:03 2010 From: ivan@REDACTED (Ivan Uemlianin) Date: Tue, 01 Jun 2010 11:16:03 +0100 Subject: [erlang-questions] ANN: wave.erl In-Reply-To: <4C04D480.3030208@erlang-solutions.com> References: <4C04CCA3.2070205@llaisdy.com> <4C04D09E.6090208@cs.ntua.gr> <4C04D480.3030208@erlang-solutions.com> Message-ID: <4C04DDE3.7090802@llaisdy.com> Cool! I intend to write a small collection of scripts for audio (esp. speech) processing (reading and writing the files was an obvious first step). On my todo list is to set up a repos on github. Best Ivan On 01/06/2010 10:36, Mazen Harake wrote: > Tip: It is Open Source... Submit a patch ;) > > /Mazen > > On 01/06/2010 10:19, Kostis Sagonas wrote: >> Ivan Uemlianin wrote: >>> Dear All >>> >>> Please find below wave.erl, an erlang script for reading and writing >>> .wav audio files. I am releasing it under the ISC license. >>> >>> The script exports functions read/1, write/3 and write/2, and the >>> wave record: >>> >>> -record(wave, {audio_format, sample_rate, data}). >>> >>> where: >>> - audio_format is an unsigned integer (currently only 1, i.e. pcm >>> encoding, is supported); >>> - sample_rate is an unsigned integer (i.e., samples per second, in >>> kHz); >>> - data is a list of lists of signed integers, one list for each >>> channel (e.g., stereo will have two lists of integers). >>> >>> read(FileName) reads a wav file and returns a wave record. >>> >>> write(WavRecord, FileName, BitsPerSample) writes the wave record >>> WavRecord to the file FileName with the sample size BitsPerSample. >>> >>> write(WavRecord, FileName) just calls write/3 with BitsPerSample = 16. >> >> Rather than writing all the above, which is just words in a mail, why >> don't you add the following to the file which is machine-checkable >> documentation which is now part of the code? >> >> ------------------------------------------------------------------------- >> >> -type audio_format() :: 1. % non_neg_integer() see wav docs for formats >> -type sample_rate() :: non_neg_integer(). >> -record(wave, {audio_format :: audio_format(), >> sample_rate :: sample_rate(), >> data :: [[integer()]]}). >> -type wave() :: #wave{}. >> >> -spec read(file:filename()) -> wave(). >> >> ... AND FURTHER DOWN >> >> -spec write(wave(), F) -> {'ok', F} when is_subtype(F, file:filename()). >> >> -spec write(wave(), F, sample_rate()) -> {'ok', F} when is_subtype(F, >> file:filename()). >> -------------------------------------------------------------------------- >> >> >> [although I do not see any compelling reason for the write functions >> to return {'ok', F} rather than just 'ok' at the moment.] >> >> Kostis >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> > > --------------------------------------------------- > > --------------------------------------------------- > > WE'VE CHANGED NAMES! > > Since January 1st 2010 Erlang Training and Consulting Ltd. has become > ERLANG SOLUTIONS LTD. > > www.erlang-solutions.com > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > -- ============================================================ Ivan A. Uemlianin Speech Technology Research and Development ivan@REDACTED www.llaisdy.com llaisdy.wordpress.com www.linkedin.com/in/ivanuemlianin "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" (Schiller, Beethoven) ============================================================ From james.hague@REDACTED Tue Jun 1 15:31:08 2010 From: james.hague@REDACTED (James Hague) Date: Tue, 1 Jun 2010 08:31:08 -0500 Subject: interesting I/O bottleneck Message-ID: I've got an application which reads through directory trees, compares file dates, sorts lists of files, that sort of thing. I'm not loading files so much as calling file:list_dir and file:read_file_info. It's slower than I expected it to be, so I ran it through eprof. The result is that over 55% of the time is spent in file:file_name. Even functions I expected to be slightly expensive, like building a dict of all the filenames in a tree, are irrelevant in comparison. file:file_name looks like this: file_name(N) -> try file_name_1(N) catch Reason -> {error, Reason} end. file_name_1([C|T]) when is_integer(C), C > 0, C =< 255 -> [C|file_name_1(T)]; file_name_1([H|T]) -> file_name_1(H) ++ file_name_1(T); file_name_1([]) -> []; file_name_1(N) when is_atom(N) -> atom_to_list(N); file_name_1(_) -> throw(badarg). I didn't realize until looking at the source that a filename can be a deep list of characters and atoms. If it was an iolist, then the entire function could just go away, but that wouldn't handle atoms. As it stands, this function is surprisingly expensive. From kenrobinsonster@REDACTED Tue Jun 1 15:55:47 2010 From: kenrobinsonster@REDACTED (kenrobinson) Date: Tue, 1 Jun 2010 06:55:47 -0700 (PDT) Subject: gen_fsm crashes Message-ID: Hi All, This being my first post to this list, please feel free to correct any mistakes I make on the group etiquette on posts. I am running a supervisor which uses the standard restart strategy. Here is a snippet from my .app file covering the gen_fsm which crashes. {transport_tx_fsm, %% tag {transport_tx_fsm, start_link, []}, permanent, 10000, worker, [transport_tx_fsm]}, I start up using the following command line: erl -pa test ebin priv -sname ken1 -boot start_sasl I load using application:load(jaus) and application:start(jaus). It starts correctly. I also load some test code using l(transport_tx_fsm_test) and fire off a message to transport_tx_fsm. Test code is sent to it like so: gen_fsm:send_event(transport_tx_fsm, {send, SR}), After it crashes, it appears to restart and process the message (see below). My question is what does the bad timeout value signify where I haven't started the gen_fsm with a timeout value? regards, Ken =CRASH REPORT==== 30-May-2010::23:54:53 === crasher: initial call: transport_tx_fsm:init/1 pid: <0.103.0> registered_name: transport_tx_fsm exception error: bad receive timeout value in function gen_fsm:loop/7 ancestors: [jaus_supervisor,<0.53.0>] messages: [] links: [<0.61.0>] dictionary: [] trap_exit: false status: running heap_size: 377 stack_size: 24 reductions: 476 neighbours: =SUPERVISOR REPORT==== 30-May-2010::23:54:53 === Supervisor: {local,jaus_supervisor} Context: child_terminated Reason: timeout_value Offender: [{pid,<0.103.0>}, {name,transport_tx_fsm}, {mfa,{transport_tx_fsm,start_link,[]}}, {restart_type,permanent}, {shutdown,10000}, {child_type,worker}] 23:54:53.896740 2010-05-30 [info] Called init message in transport_tx_fsm 23:54:53.896821 2010-05-30 [info] handle_info udp args ClientSocket #Port<0.1353> Host {127,0,0,1} Port 47761 Data <<2,0,128,0,192,3,2,1,0,6,5,64,0,1,1,19,0>> State {state} =PROGRESS REPORT==== 30-May-2010::23:54:53 === supervisor: {local,jaus_supervisor} started: [{pid,<0.105.0>}, {name,transport_tx_fsm}, {mfa,{transport_tx_fsm,start_link,[]}}, {restart_type,permanent}, {shutdown,10000}, {child_type,worker}] 23:54:53.901490 2010-05-30 [info] unwrap arg <<2,0,128,0,192,3,2,1,0,6,5,64,0,1,1,19,0>> From zeno490@REDACTED Tue Jun 1 16:58:20 2010 From: zeno490@REDACTED (Nicholas Frechette) Date: Tue, 1 Jun 2010 10:58:20 -0400 Subject: [erlang-questions] interesting I/O bottleneck In-Reply-To: References: Message-ID: That function doesn't appear to be tail recursive and might contribute to the poor performance. You could probably rewrite it in <1min to make it tail recursive with a lists:reverse at the end. Chances are it might be faster. 2cents On Tue, Jun 1, 2010 at 9:31 AM, James Hague wrote: > I've got an application which reads through directory trees, compares file > dates, sorts lists of files, that sort of thing. I'm not loading files so > much as calling file:list_dir and file:read_file_info. It's slower than I > expected it to be, so I ran it through eprof. The result is that over 55% > of > the time is spent in file:file_name. Even functions I expected to be > slightly expensive, like building a dict of all the filenames in a tree, > are > irrelevant in comparison. > > file:file_name looks like this: > > file_name(N) -> > try > file_name_1(N) > catch Reason -> > {error, Reason} > end. > > file_name_1([C|T]) when is_integer(C), C > 0, C =< 255 -> > [C|file_name_1(T)]; > file_name_1([H|T]) -> > file_name_1(H) ++ file_name_1(T); > file_name_1([]) -> > []; > file_name_1(N) when is_atom(N) -> > atom_to_list(N); > file_name_1(_) -> > throw(badarg). > > I didn't realize until looking at the source that a filename can be a deep > list of characters and atoms. If it was an iolist, then the entire function > could just go away, but that wouldn't handle atoms. As it stands, this > function is surprisingly expensive. > From rvirding@REDACTED Tue Jun 1 17:07:39 2010 From: rvirding@REDACTED (Robert Virding) Date: Tue, 1 Jun 2010 17:07:39 +0200 Subject: [erlang-questions] interesting I/O bottleneck In-Reply-To: References: Message-ID: I wonder how much that would help. Unless you have long file names I don't think it would. It is essentially doing a flattening version of lists:concat, it could quite easily be optimised to minimize the append. Do you know if the input file names to the function contain atoms or are deep? Robert On 1 June 2010 16:58, Nicholas Frechette wrote: > That function doesn't appear to be tail recursive and might contribute to > the poor performance. You could probably rewrite it in <1min to make it tail > recursive with a lists:reverse at the end. Chances are it might be faster. > > 2cents > > On Tue, Jun 1, 2010 at 9:31 AM, James Hague wrote: > >> I've got an application which reads through directory trees, compares file >> dates, sorts lists of files, that sort of thing. I'm not loading files so >> much as calling file:list_dir and file:read_file_info. It's slower than I >> expected it to be, so I ran it through eprof. The result is that over 55% >> of >> the time is spent in file:file_name. Even functions I expected to be >> slightly expensive, like building a dict of all the filenames in a tree, >> are >> irrelevant in comparison. >> >> file:file_name looks like this: >> >> file_name(N) -> >> ? ?try >> ? ? ? ?file_name_1(N) >> ? ?catch Reason -> >> ? ? ? ?{error, Reason} >> ? ?end. >> >> file_name_1([C|T]) when is_integer(C), C > 0, C =< 255 -> >> ? ?[C|file_name_1(T)]; >> file_name_1([H|T]) -> >> ? ?file_name_1(H) ++ file_name_1(T); >> file_name_1([]) -> >> ? ?[]; >> file_name_1(N) when is_atom(N) -> >> ? ?atom_to_list(N); >> file_name_1(_) -> >> ? ?throw(badarg). >> >> I didn't realize until looking at the source that a filename can be a deep >> list of characters and atoms. If it was an iolist, then the entire function >> could just go away, but that wouldn't handle atoms. As it stands, this >> function is surprisingly expensive. >> > From james.hague@REDACTED Tue Jun 1 17:17:04 2010 From: james.hague@REDACTED (James Hague) Date: Tue, 1 Jun 2010 10:17:04 -0500 Subject: [erlang-questions] interesting I/O bottleneck In-Reply-To: References: Message-ID: >Do you know if the input file names to the function contain >atoms or are deep? In my code the filenames are flat strings (no atoms, no nested lists). If I had known that filenames could be deep lists I would have taken advantage of that, but I'm not currently. Is there a reason that atoms are allowed in filenames? Why not just go with iolists? From tony@REDACTED Tue Jun 1 16:59:27 2010 From: tony@REDACTED (Tony Rogvall) Date: Tue, 1 Jun 2010 16:59:27 +0200 Subject: [erlang-questions] interesting I/O bottleneck In-Reply-To: References: Message-ID: Interesting stuff ;-) I tried some tricks, and I was a bit surprised. Replace "when is_integer(C), C > 0, C =< 255" with "when (C band -256) =:= 0, C =/= 0" This will speed up the function a bit more than 50% ! Without the check for zero, the code is even a bit faster. The code check that the characters is in range 1-255, avoid to pass zeros to the C driver layer. side note: One problem with this code is that it accepts atoms on form 'hello\0world'. Either the code must be updated to check the atoms or the code may be speed up a bit further ;-) Test this: file:write_file("hello\0world", <<1,2,3,4>>). and then: file:write_file('hello\0world', <<1,2,3,4>>). The first case generates a badarg while the second case generates a file "hello" with the content <<1,2,3,4>>. An other approach to speed it up is to check for the common case without building a new string: file_name(N) -> try case is_flat_file_name(N) of true -> N; false -> file_name_1(N) end catch Reason -> {error, Reason} end. This will speed up the case when flat strings are passed to the file_name function more than 150%. The reason without peek in the code is that "C band -256" generates code that will be executed without any functions calls inside the vm. Maybe something for the compiler writer to think about ? /Tony On 1 jun 2010, at 15.31, James Hague wrote: > I've got an application which reads through directory trees, compares file > dates, sorts lists of files, that sort of thing. I'm not loading files so > much as calling file:list_dir and file:read_file_info. It's slower than I > expected it to be, so I ran it through eprof. The result is that over 55% of > the time is spent in file:file_name. Even functions I expected to be > slightly expensive, like building a dict of all the filenames in a tree, are > irrelevant in comparison. > > file:file_name looks like this: > > file_name(N) -> > try > file_name_1(N) > catch Reason -> > {error, Reason} > end. > > file_name_1([C|T]) when is_integer(C), C > 0, C =< 255 -> > [C|file_name_1(T)]; > file_name_1([H|T]) -> > file_name_1(H) ++ file_name_1(T); > file_name_1([]) -> > []; > file_name_1(N) when is_atom(N) -> > atom_to_list(N); > file_name_1(_) -> > throw(badarg). > > I didn't realize until looking at the source that a filename can be a deep > list of characters and atoms. If it was an iolist, then the entire function > could just go away, but that wouldn't handle atoms. As it stands, this > function is surprisingly expensive. From johanmon@REDACTED Tue Jun 1 20:54:49 2010 From: johanmon@REDACTED (Johan Montelius) Date: Tue, 01 Jun 2010 20:54:49 +0200 Subject: [erlang-questions] generic replication bahaviour In-Reply-To: <39655.1275336659@snookles.snookles.com> References: <39655.1275336659@snookles.snookles.com> Message-ID: Yes, I well aware of the CAP theorem and that a generic replication scheme will not fit all purposes but we could give it a try. Since replication per se is not a goal we need to decide what the aim is. Assume the goal is to increase the throughput for a server and be able to handle more request per second. We could possibly achieve this by replicating the server. If the ratio of read to write operations is high enough and we can handle read operations locally (meaning that you might not see your writes immediately) we have a good chance of doing this. In this case we would go for Consistency. The replicated service should of course be Available but not necessarily more than a non-replicated service. Should we handle Partitions, well we should not loose Consistency and if we have partitions we play it safe and in the worst case stop responding. So who would use a replication scheme that would stop if there is a partition? Someone that knows that a partition will not occur? What happens if we run all replicas in the same Erlang node using a multicore host? Partitions will not happen and we will be able to implement a Consistent and also more Available service. If we move to a multi Erlang node (possibly distributed) then there might be partitions (and node crashes that the system will not be able to tell from a partition) so we will have to sacrifice either A o C. Since Consistency is waht we aim for we will simply sacrifice A and in some cases stop responding. How often will this happen? Not more often than the non-replicated service would crash (me think). The system that I'm playing around with now is quite simple and works similar to gen_leader but it is more focused on only providing consistent replication. The question is of course if I've already made to many decisions and therefore land in the "Won't work for my app" slot. The Dynomite, Scalari etc approach is to move the state of a server to a separate replicated store. The server it self is then stateless and uses the replicated store so that multiple servers can run in parallel. This is of course a very good solution but sometimes it might be over-kill or simple problematic to extract the state from an existing server implementation. If one already has a gen_server implemented an alternative approach would then be to simply (well we'll se) turn it in to a gen_replicated server. Johan On Mon, 31 May 2010 22:10:59 +0200, Scott Lystig Fritchie wrote: > Replying to a thead from last week.... > > Johan Montelius wrote: > > jm> has anyone played around with a generic replication behaviour in the > jm> style of gen_server? > > No, sorry. But before doing such a thing, I think you need to put some > thought into what "replication" means vis a vis Brewer's CAP theorem. > Or more perhaps more usefully(*), the spectrum of consistency > vs. availability. > > Then (perhaps?) deciding on an implementation that's based on a state > machine replication technique or a quorum-based technique. The choice > of technique may help drive what kind of metadata you're going to > require for each thingie stored. Are the thingie's key-value pairs, or > something else? Do you require monotonically-increasing timestamps or > vector clocks or something else? Does the behavior always resolve > consistency ambiguity or push those decisions to the client, and how the > client app inform the behavior of its choice? > > If you're dealing with disk-based persistence, then any Erlang process > that's doing disk I/O can block at very inconvenient times for very > inconvenient lengths of time. Syncronous replication across a network > (even a fast LAN) can result in similiar inconveniences, at least in > terms of Murphy's Law. The sum of these inconveniences can easily tip > an implementation into the "Won't work for my app" category. > > Just things off the top of the cuff of my head. :-) I'll make a blind > guess and say that this is why key-value stores such as Dynomite, > Scalaris, Riak, Ringo, Scalien, and others are already "out there"(**) > and useful: they choose a path through the maze of choices above and > then do it well. > > -Scott > > (*) Reading Brewer's writings about CAP and then the Gilbert & Lynch > proof, the formal definition of "P" is a tricky thing. > > (**) Sorry, Hibari hasn't been released yet, contrary to what my Erlang > Factory 2010 San Francisco talk had predicted. Mid-July 2010 is my best > guess right now. > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ From comptekki@REDACTED Tue Jun 1 22:31:35 2010 From: comptekki@REDACTED (Wes James) Date: Tue, 1 Jun 2010 14:31:35 -0600 Subject: obsolete messages Message-ID: I have some code that I got from an example: a2l(A) when atom(A) -> atom_to_list(A); a2l(L) when list(L) -> L. l2a(L) when list(L) -> list_to_atom(L); l2a(A) when atom(A) -> A. when compiled it says atom/1 and list/1 are obsolete. What are the replacements for atom/1 and list/1 in the context above? thx, -wes From tuncer.ayaz@REDACTED Tue Jun 1 22:34:50 2010 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Tue, 1 Jun 2010 22:34:50 +0200 Subject: [erlang-questions] obsolete messages In-Reply-To: References: Message-ID: On Tue, Jun 1, 2010 at 10:31 PM, Wes James wrote: > I have some code that I got from an example: > > a2l(A) when atom(A) -> atom_to_list(A); > a2l(L) when list(L) -> L. > > l2a(L) when list(L) -> list_to_atom(L); > l2a(A) when atom(A) -> A. > > when compiled it says atom/1 and list/1 are obsolete. What are the > replacements for atom/1 and list/1 in the context above? is_atom/1, is_list/1. From gleber.p@REDACTED Tue Jun 1 22:35:33 2010 From: gleber.p@REDACTED (Gleb Peregud) Date: Tue, 1 Jun 2010 22:35:33 +0200 Subject: [erlang-questions] obsolete messages In-Reply-To: References: Message-ID: is_atom/1 and is_list/1 On Tue, Jun 1, 2010 at 22:31, Wes James wrote: > I have some code that I got from an example: > > a2l(A) when atom(A) -> atom_to_list(A); > a2l(L) when list(L) -> L. > > l2a(L) when list(L) -> list_to_atom(L); > l2a(A) when atom(A) -> A. > > when compiled it says atom/1 and list/1 are obsolete. What are the > replacements for atom/1 and list/1 in the context above? > > thx, > > -wes > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From ivan@REDACTED Tue Jun 1 22:36:24 2010 From: ivan@REDACTED (Ivan Uemlianin) Date: Tue, 01 Jun 2010 21:36:24 +0100 Subject: [erlang-questions] obsolete messages In-Reply-To: References: Message-ID: <4C056F48.7050701@llaisdy.com> I think the new guards are is_atom/1 and is_list/1 Best Ivan On 01/06/2010 21:31, Wes James wrote: > I have some code that I got from an example: > > a2l(A) when atom(A) -> atom_to_list(A); > a2l(L) when list(L) -> L. > > l2a(L) when list(L) -> list_to_atom(L); > l2a(A) when atom(A) -> A. > > when compiled it says atom/1 and list/1 are obsolete. What are the > replacements for atom/1 and list/1 in the context above? > > thx, > > -wes > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > -- ============================================================ Ivan A. Uemlianin Speech Technology Research and Development ivan@REDACTED www.llaisdy.com llaisdy.wordpress.com www.linkedin.com/in/ivanuemlianin "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" (Schiller, Beethoven) ============================================================ From comptekki@REDACTED Tue Jun 1 22:41:12 2010 From: comptekki@REDACTED (Wes James) Date: Tue, 1 Jun 2010 14:41:12 -0600 Subject: obsolete messages In-Reply-To: References: Message-ID: > is_atom/1, is_list/1 Tuncer and Gleb thx! -wes From a.zhuravlev@REDACTED Tue Jun 1 23:22:29 2010 From: a.zhuravlev@REDACTED (Alexander Zhuravlev) Date: Wed, 2 Jun 2010 01:22:29 +0400 Subject: Too strict HTTP Status Line parsing Message-ID: <20100601212229.GA58321@zaa.local> Hello, I've tried to use lhttpc library (http://bitbucket.org/etc/lhttpc) to fetch a resource (http://www.qype.com/review/1376848) and got the following error: {{http_error,"HTTP/1.1 200\r\n"}, [{lhttpc_client,read_response,5}, {lhttpc_client,execute,8}, {lhttpc_client,request,9}]} I've checked lhttpc source code and found out that to receive and parse an HTTP response it uses _standard_ erlang module gen_tcp on a socket in {packet, http} mode. So it looks like the {http_error,"HTTP/1.1 200\r\n"} error was in fact generated by erlang's http packet parsing code. I found the following code in packet_parse_http function from erts/emulator/beam/packet_parser.c file: ... p0 = ptr; while (n && SP(ptr)) { ptr++; n--; } if (ptr==p0) return -1; ... As far as I understand "HTTP/1.1 200\r\n" line does not have any spaces after the status code "200", and the function strips \r\n as a first step of its operation. So the "while" cycle does not run and we get into the "if (ptr==p0) branch" this basically leads to returning of {http_error, "HTTP/1.1 200\r\n"} atom up to the call stack. Strictly speaking this is not a bug in erlang, but I suppose it should take a more relaxed approach to HTTP Status Line parsing and not return http_error if an HTTP response Status Line does not have a Reason-phrase part. From james.hague@REDACTED Tue Jun 1 23:34:59 2010 From: james.hague@REDACTED (James Hague) Date: Tue, 1 Jun 2010 16:34:59 -0500 Subject: [erlang-questions] interesting I/O bottleneck In-Reply-To: References: Message-ID: I'm convinced that file:file_name shouldn't be that expensive. It's ugly, yes, and I wish it was unnecessary, but it's not horribly inefficient. Maybe because it's so heavily recursive (and not tail recursive) it's showing skewed results in eprof? On Tue, Jun 1, 2010 at 10:17 AM, James Hague wrote: > >Do you know if the input file names to the function contain > >atoms or are deep? > > In my code the filenames are flat strings (no atoms, no nested lists). If > I had known that filenames could be deep lists I would have taken advantage > of that, but I'm not currently. > > Is there a reason that atoms are allowed in filenames? Why not just go with > iolists? > From a.zhuravlev@REDACTED Tue Jun 1 23:48:35 2010 From: a.zhuravlev@REDACTED (Alexander Zhuravlev) Date: Wed, 2 Jun 2010 01:48:35 +0400 Subject: Too strict HTTP Status Line parsing In-Reply-To: <20100601212229.GA58321@zaa.local> References: <20100601212229.GA58321@zaa.local> Message-ID: <20100601214835.GA58602@zaa.local> On Wed, Jun 02, 2010 at 01:22:29AM +0400, Alexander Zhuravlev wrote: > Hello, > > I've tried to use lhttpc library (http://bitbucket.org/etc/lhttpc) to fetch > a resource (http://www.qype.com/review/1376848) and got the following > error: > > {{http_error,"HTTP/1.1 200\r\n"}, > [{lhttpc_client,read_response,5}, > {lhttpc_client,execute,8}, > {lhttpc_client,request,9}]} Almost forgot, the error was reproduced with erlang R13B04: Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] lhttpc version 1.2.4 > I've checked lhttpc source code and found out that to receive and parse an HTTP > response it uses _standard_ erlang module gen_tcp on a socket in > {packet, http} mode. So it looks like the {http_error,"HTTP/1.1 200\r\n"} error was > in fact generated by erlang's http packet parsing code. > > I found the following code in packet_parse_http function from > erts/emulator/beam/packet_parser.c file: > > ... > p0 = ptr; > while (n && SP(ptr)) { > ptr++; n--; > } > if (ptr==p0) return -1; > ... > > As far as I understand "HTTP/1.1 200\r\n" line does not have any spaces > after the status code "200", and the function strips \r\n as a first step of > its operation. So the "while" cycle does not run and we get into the > "if (ptr==p0) branch" this basically leads to returning of > {http_error, "HTTP/1.1 200\r\n"} atom up to the call stack. > > Strictly speaking this is not a bug in erlang, but I suppose it > should take a more relaxed approach to HTTP Status Line parsing > and not return http_error if an HTTP response Status Line does not have > a Reason-phrase part. -- Alexander Zhuravlev From comptekki@REDACTED Wed Jun 2 00:25:03 2010 From: comptekki@REDACTED (Wes James) Date: Tue, 1 Jun 2010 16:25:03 -0600 Subject: [erlang-questions] Re: erl startup In-Reply-To: <4BF3658A.7070208@m5net.com> References: <4BF356DF.7040804@m5net.com> <4BF35C66.2040505@m5net.com> <4BF3658A.7070208@m5net.com> Message-ID: On Tue, May 18, 2010 at 10:14 PM, Bernard Duggan wrote: > On 19/05/10 13:46, Wes James wrote: >> >> I'm trying run my_mod which i'm running in conjunction with yaws so >> that the my_mod will every 5 minutes go and check a printer for home >> and grab the pages printed and stick it in a mnesia table. ?I then use >> a .yaws page to look at the mnesia page count values. ?This is why I'm >> trying to get the timer to work as I start yaws and keep going after >> yaws is started. >> > > Okay, so it seems like this issue here is the notion of "running a module". > ?I don't think it means what you think it means (actually I don't think it > means anything at all, really). ?What it sounds like you want to do is spawn > a process that does some startup stuff and then basically sits idle to allow > its ets table and timer to continue to work. > There's a couple of ways to approach this - the "OTP way(s)" would be to > either wrap the whole thing in an application or gen_server behaviour. ?That > gives you all sorts of nice extras (easy supervision, appearing in appmon > etc) but does require a bit of scaffold code and has something of a learning > curve before you figure out how to do it "right" (hell, I'm /still/ figuring > the details of that out). > The much easier (though less flexible and powerful) way is to modify your > code to something like this: > > start() -> > ? ? ? ?spawn_link(?MODULE, run, []). > > run() -> > ? ? ? ?Id_Table=ets:new(start_id_table, []), > ? ? ? ?io:format("~w~n", ?[Id_Table]), > ? ? ? ?{ok, TRef}=timer:apply_interval(1000*60*5, prt, getc, []), % 1000 > milliseconds * 60 * 5 = 5 minutes > ? ? ? ?ets:insert(Id_Table, {id, TRef}), > ? ? ? ?wait_for_exit(). > > wait_for_exit() -> > ? ? ? ?receive > ? ? ? ? ? ? ? ?some_exit_signal -> ?ok; > ? ? ? ? ? ? ? ?_ -> ?wait_for_exit() > ? ? ? ?end. > > > (Haven't compile or tested this - there's probably a syntax error or two). > ?Note the tail-recursive receive loop at the end which keeps the process > alive and keeps its message queue empty but does nothing else. > > Also, just as a tip: I recently discovered the timer:minutes/1 function and > its friends - much easier to read and code than "1000*60*5" :) > > Cheers, > > Bernard > > Bernard, I tried this and didn't get it to work at first, but then I came back to tested it again and it does work. Thx for your input! -wes From comptekki@REDACTED Wed Jun 2 00:43:48 2010 From: comptekki@REDACTED (Wes James) Date: Tue, 1 Jun 2010 16:43:48 -0600 Subject: [erlang-questions] Re: erl startup In-Reply-To: <4BF3658A.7070208@m5net.com> References: <4BF356DF.7040804@m5net.com> <4BF35C66.2040505@m5net.com> <4BF3658A.7070208@m5net.com> Message-ID: On Tue, May 18, 2010 at 10:14 PM, Bernard Duggan wrote: > start() -> > ? ? ? ?spawn_link(?MODULE, run, []). > > run() -> > ? ? ? ?Id_Table=ets:new(start_id_table, []), > ? ? ? ?io:format("~w~n", ?[Id_Table]), > ? ? ? ?{ok, TRef}=timer:apply_interval(1000*60*5, prt, getc, []), % 1000 > milliseconds * 60 * 5 = 5 minutes > ? ? ? ?ets:insert(Id_Table, {id, TRef}), > ? ? ? ?wait_for_exit(). > > wait_for_exit() -> > ? ? ? ?receive > ? ? ? ? ? ? ? ?some_exit_signal -> ?ok; > ? ? ? ? ? ? ? ?_ -> ?wait_for_exit() > ? ? ? ?end. > If I do this module:wait_for_exit() ! some_exit_signal. It just hangs. I have to hit ctrl-c to kill it. Isn't it supposed to exit wait_for_exit() after that? thx, -wes From bernie@REDACTED Wed Jun 2 02:37:36 2010 From: bernie@REDACTED (Bernard Duggan) Date: Wed, 02 Jun 2010 10:37:36 +1000 Subject: [erlang-questions] Re: erl startup In-Reply-To: References: <4BF356DF.7040804@m5net.com> <4BF35C66.2040505@m5net.com> <4BF3658A.7070208@m5net.com> Message-ID: <4C05A7D0.2050806@m5net.com> On 02/06/10 08:43, Wes James wrote: > [snip] >> wait_for_exit() -> >> receive >> some_exit_signal -> ok; >> _ -> wait_for_exit() >> end. >> >> > If I do this > > module:wait_for_exit() ! some_exit_signal. > > It just hangs. I have to hit ctrl-c to kill it. Isn't it supposed to > exit wait_for_exit() after that? > ...No? What you're asking it to do there is to send the message 'some_exit_signal' to the process returned by the call module:wait_for_exit(). That function doesn't return a process - indeed, its whole point is to /not return at all/ until it receives that message. You need to get the PID of the process that's running (the value returned by start()) and send the signal to that. ie: 1> Pid = module:start(). 2> Pid ! some_exit_signal. B From comptekki@REDACTED Wed Jun 2 03:26:09 2010 From: comptekki@REDACTED (Wes James) Date: Tue, 1 Jun 2010 19:26:09 -0600 Subject: [erlang-questions] Re: erl startup In-Reply-To: <4C05A7D0.2050806@m5net.com> References: <4BF356DF.7040804@m5net.com> <4BF35C66.2040505@m5net.com> <4BF3658A.7070208@m5net.com> <4C05A7D0.2050806@m5net.com> Message-ID: On Tue, Jun 1, 2010 at 6:37 PM, Bernard Duggan wrote: > On 02/06/10 08:43, Wes James wrote: >> >> [snip] >>> >>> wait_for_exit() -> >>> ? ? ? ?receive >>> ? ? ? ? ? ? ? ?some_exit_signal -> ? ?ok; >>> ? ? ? ? ? ? ? ?_ -> ? ?wait_for_exit() >>> ? ? ? ?end. >>> >>> >> >> If I do this >> >> ?module:wait_for_exit() ! some_exit_signal. >> >> It just hangs. ?I have to hit ctrl-c to kill it. ?Isn't it supposed to >> exit wait_for_exit() after that? >> > > ...No? ?What you're asking it to do there is to send the message > 'some_exit_signal' to the process returned by the call > module:wait_for_exit(). ?That function doesn't return a process - indeed, > its whole point is to /not return at all/ until it receives that message. > You need to get the PID of the process that's running (the value returned by > start()) and send the signal to that. ?ie: > > 1> Pid = module:start(). > > 2> Pid ! some_exit_signal. > > B > Thx again. That worked. -wes From kostis@REDACTED Wed Jun 2 09:07:50 2010 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 02 Jun 2010 10:07:50 +0300 Subject: [erlang-questions] ANN: wave.erl In-Reply-To: References: <4C04CCA3.2070205@llaisdy.com> <4C04D09E.6090208@cs.ntua.gr> Message-ID: <4C060346.3070402@cs.ntua.gr> Jesper Louis Andersen wrote: > On Tue, Jun 1, 2010 at 11:19 AM, Kostis Sagonas wrote: > >> Rather than writing all the above, which is just words in a mail, why don't >> you add the following to the file which is machine-checkable documentation >> which is now part of the code? > > What tools do currently make use of this information, and how? I guess > the dialyzer does. Mainly dialyzer uses this information. Pretty soon (quite possibly in R14) edoc will also be in a position to use this information for generating documentation for the code. > If I write a spec such the function and spec are > not matching, then what tool will report the discrepancy? Dialyzer? Yes. But it is better to see it with your own eyes. Try it! Kostis From kostis@REDACTED Wed Jun 2 09:10:36 2010 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 02 Jun 2010 10:10:36 +0300 Subject: [erlang-questions] ANN: wave.erl In-Reply-To: <4C04DCFC.4020605@llaisdy.com> References: <4C04CCA3.2070205@llaisdy.com> <4C04D09E.6090208@cs.ntua.gr> <4C04DCFC.4020605@llaisdy.com> Message-ID: <4C0603EC.8060400@cs.ntua.gr> Ivan Uemlianin wrote: > On 01/06/2010 10:54, Jesper Louis Andersen wrote: >> On Tue, Jun 1, 2010 at 11:19 AM, Kostis Sagonas >> wrote: >> >> >>> Rather than writing all the above, which is just words in a mail, why >>> don't >>> you add the following to the file which is machine-checkable >>> documentation >>> which is now part of the code? >>> >> What tools do currently make use of this information, and how? I guess >> the dialyzer does. If I write a spec such the function and spec are >> not matching, then what tool will report the discrepancy? Dialyzer? >> > TypEr checks for type discrepancies; Dialyzer is more general. Actually, it's dialyzer that uses this info. TypEr is just a front end that takes the type information which appears in the file and/or is computed by dialyzer and either prints it on the screen or annotates the file with it. Kostis From mhishami@REDACTED Wed Jun 2 11:29:28 2010 From: mhishami@REDACTED (Hisham) Date: Wed, 2 Jun 2010 02:29:28 -0700 (PDT) Subject: SOAP Call Message-ID: <11599093-2d42-478d-b0b6-12e47be9699e@p5g2000pri.googlegroups.com> Hi, I have below operation: 1> Wsdl = yaws_soap_lib:initModel("SDPServices.wsdl"). {wsdl,[], {model,[{type,'_document',sequence, [{el,[{alt,'soap:Header','soap:Header',[], 1,1,true, undefined}, {alt,'soap:Fault','soap:Fault',[], 1,1,true,undefined}, {alt,'soap:Envelope','soap:Envelope',[], 1,1,true,undefined}, {alt,'soap:Body','soap:Body',[], 1,1,true,undefined}, {...}|...], 3> yaws_soap_lib:wsdl_operations(Wsdl). [] 4> My concern is, I have "zero" operations after parsing the WSDL as shown in 3> above. I browse through the web, and some says I have to trim the "nillable=true" out, and it should be fine. That was done, but still the operations are zero. Anybody can pin point to the right direction? TIA. From max.lapshin@REDACTED Wed Jun 2 12:13:20 2010 From: max.lapshin@REDACTED (Max Lapshin) Date: Wed, 2 Jun 2010 14:13:20 +0400 Subject: log4erl as system logger Message-ID: Hi. I want to use log4erl as a default error logger for all system (to log all process failures), but I don't understand how. What part of erlang documentation have I missed? Where should I read to understand, how to change logger. From w.a.de.jong@REDACTED Wed Jun 2 12:16:51 2010 From: w.a.de.jong@REDACTED (Willem de Jong) Date: Wed, 2 Jun 2010 12:16:51 +0200 Subject: [erlang-questions] SOAP Call In-Reply-To: <11599093-2d42-478d-b0b6-12e47be9699e@p5g2000pri.googlegroups.com> References: <11599093-2d42-478d-b0b6-12e47be9699e@p5g2000pri.googlegroups.com> Message-ID: Hello, Can you show us the WSDL? Regards, Willem On Wed, Jun 2, 2010 at 11:29 AM, Hisham wrote: > Hi, > > > I have below operation: > > 1> Wsdl = yaws_soap_lib:initModel("SDPServices.wsdl"). > {wsdl,[], > {model,[{type,'_document',sequence, > [{el,[{alt,'soap:Header','soap:Header',[], > 1,1,true, > undefined}, > {alt,'soap:Fault','soap:Fault',[], > 1,1,true,undefined}, > {alt,'soap:Envelope','soap:Envelope',[], > 1,1,true,undefined}, > {alt,'soap:Body','soap:Body',[], > 1,1,true,undefined}, > {...}|...], > 3> yaws_soap_lib:wsdl_operations(Wsdl). > [] > 4> > > My concern is, I have "zero" operations after parsing the WSDL as > shown in 3> above. > I browse through the web, and some says I have to trim the > "nillable=true" out, and it should be fine. > That was done, but still the operations are zero. > > Anybody can pin point to the right direction? > > TIA. > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From mhishami@REDACTED Wed Jun 2 12:26:32 2010 From: mhishami@REDACTED (Hisham) Date: Wed, 2 Jun 2010 18:26:32 +0800 Subject: [erlang-questions] SOAP Call In-Reply-To: References: <11599093-2d42-478d-b0b6-12e47be9699e@p5g2000pri.googlegroups.com> Message-ID: Hi Willem, Appreciate your reply (as always :D) Please find the attached file. Not sure if attachment is allowed, but I put the main email to you. On Wed, Jun 2, 2010 at 6:16 PM, Willem de Jong wrote: > Hello, > > Can you show us the WSDL? > > Regards, > Willem > > On Wed, Jun 2, 2010 at 11:29 AM, Hisham wrote: > >> Hi, >> >> >> I have below operation: >> >> 1> Wsdl = yaws_soap_lib:initModel("SDPServices.wsdl"). >> {wsdl,[], >> {model,[{type,'_document',sequence, >> [{el,[{alt,'soap:Header','soap:Header',[], >> 1,1,true, >> undefined}, >> {alt,'soap:Fault','soap:Fault',[], >> 1,1,true,undefined}, >> {alt,'soap:Envelope','soap:Envelope',[], >> 1,1,true,undefined}, >> {alt,'soap:Body','soap:Body',[], >> 1,1,true,undefined}, >> {...}|...], >> 3> yaws_soap_lib:wsdl_operations(Wsdl). >> [] >> 4> >> >> My concern is, I have "zero" operations after parsing the WSDL as >> shown in 3> above. >> I browse through the web, and some says I have to trim the >> "nillable=true" out, and it should be fine. >> That was done, but still the operations are zero. >> >> Anybody can pin point to the right direction? >> >> TIA. >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: SDPServices.wsdl Type: text/xml Size: 52362 bytes Desc: not available URL: From gleber.p@REDACTED Wed Jun 2 12:51:11 2010 From: gleber.p@REDACTED (Gleb Peregud) Date: Wed, 2 Jun 2010 12:51:11 +0200 Subject: [erlang-questions] log4erl as system logger In-Reply-To: References: Message-ID: Hi Max I've been peeking into this because of curiosity too some time ago, but never get to any working code. Here's a logger module does which more-or-less the same thing you want to do: http://jungerl.cvs.sourceforge.net/viewvc/jungerl/jungerl/lib/msc/src/logger.erl?revision=1.2&view=markup Best, Gleb Peregud On Wed, Jun 2, 2010 at 12:13, Max Lapshin wrote: > Hi. I want to use log4erl as a default error logger for all system (to > log all process failures), > but I don't understand how. > > What part of erlang documentation have I missed? Where should I read > to understand, how to change logger. > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From maruthavanan_s@REDACTED Wed Jun 2 13:05:52 2010 From: maruthavanan_s@REDACTED (maruthavanan s) Date: Wed, 2 Jun 2010 07:05:52 -0400 Subject: OTP Efficiency Message-ID: Hi All, I could understand that OTP gives us a fault tolerant solutions like restarting on crashing, supervisors, FSM behaviours etc. I am curious on the efficiency of a application. Say for e.g. I develop a solution with both OTP and without OTP (handling 100% errors may be not possible :) ) which one would be efficient? Thanks, Marutha From qoocku@REDACTED Wed Jun 2 14:14:29 2010 From: qoocku@REDACTED (=?UTF-8?B?RGFtaWFuIERvYnJvY3p5xYRza2k=?=) Date: Wed, 02 Jun 2010 14:14:29 +0200 Subject: [erlang-questions] log4erl as system logger In-Reply-To: References: Message-ID: <4C064B25.4070104@gmail.com> W dniu 02.06.2010 12:13, Max Lapshin pisze: > Hi. I want to use log4erl as a default error logger for all system (to > log all process failures), > but I don't understand how. > > What part of erlang documentation have I missed? Where should I read > to understand, how to change logger. > error_logger is "gen_event" process registered locally under the name "error_logger". The process start is hard-coded in the "kernel" application (kernel.erl module implements "kernel_sup" supervisor behavior - this supervisor launches the "error_logger" process) which is loaded as the very first. What you can do is to kill this process as soon as possible (risking that some logging messages would not reach the logger) and replace it with another "gen_event" process registering it under the name "error_logger". You may obtain this by launching special application that starts only the specialized gen_event process (if you want to use it in a boot script) or by passing a command line options "-s " which fires :start/0 function. The latter is launched after all primary application has been loaded, so the initial logs would go through the standard error_logger. I think you should write a special "launcher" module to replace the standard logger. Besides log4erl must implements error_logger message protocol. I do not know it is so. Hope this helps, Damian > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: From alex.arnon@REDACTED Wed Jun 2 14:22:01 2010 From: alex.arnon@REDACTED (Alex Arnon) Date: Wed, 2 Jun 2010 15:22:01 +0300 Subject: [erlang-questions] log4erl as system logger In-Reply-To: <4C064B25.4070104@gmail.com> References: <4C064B25.4070104@gmail.com> Message-ID: Could one possibly simply add an error_logger appender? Maybe make it the default? 2010/6/2 Damian Dobroczy?ski > W dniu 02.06.2010 12:13, Max Lapshin pisze: > > Hi. I want to use log4erl as a default error logger for all system (to > > log all process failures), > > but I don't understand how. > > > > What part of erlang documentation have I missed? Where should I read > > to understand, how to change logger. > > > > error_logger is "gen_event" process registered locally under the name > "error_logger". The process start is hard-coded in the "kernel" > application (kernel.erl module implements "kernel_sup" supervisor > behavior - this supervisor launches the "error_logger" process) which is > loaded as the very first. What you can do is to kill this process as > soon as possible (risking that some logging messages would not reach the > logger) and replace it with another "gen_event" process registering it > under the name "error_logger". You may obtain this by launching special > application that starts only the specialized gen_event process (if you > want to use it in a boot script) or by passing a command line options > "-s " which fires :start/0 function. The > latter is launched after all primary application has been loaded, so the > initial logs would go through the standard error_logger. I think you > should write a special "launcher" module to replace the standard logger. > Besides log4erl must implements error_logger message protocol. I do not > know it is so. > > Hope this helps, > Damian > > > ________________________________________________________________ > > erlang-questions (at) erlang.org mailing list. > > See http://www.erlang.org/faq.html > > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > > > From qoocku@REDACTED Wed Jun 2 14:30:11 2010 From: qoocku@REDACTED (=?UTF-8?B?RGFtaWFuIERvYnJvY3p5xYRza2k=?=) Date: Wed, 02 Jun 2010 14:30:11 +0200 Subject: [erlang-questions] log4erl as system logger In-Reply-To: References: Message-ID: <4C064ED3.60008@gmail.com> W dniu 02.06.2010 12:13, Max Lapshin pisze: > Hi. I want to use log4erl as a default error logger for all system (to > log all process failures), > but I don't understand how. > > What part of erlang documentation have I missed? Where should I read > to understand, how to change logger. > I've looked at the log4erl code and there is a module called "error_logger_log4erl_h" which implements gen_event behavior and acts as a "bridge" between error_logger protocol and log4erl protocol. Apparently, you have to add this handler to the standard event_logger process so that all other processes using error_logger calls may be logged by log4erl logger. I think you cannot replace standard error_logger because log4erl do not implement error_logger protocol. Both must co-exists within the system. D. > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: From qoocku@REDACTED Wed Jun 2 14:30:34 2010 From: qoocku@REDACTED (=?UTF-8?B?RGFtaWFuIERvYnJvY3p5xYRza2k=?=) Date: Wed, 02 Jun 2010 14:30:34 +0200 Subject: [erlang-questions] log4erl as system logger In-Reply-To: References: <4C064B25.4070104@gmail.com> Message-ID: <4C064EEA.6020001@gmail.com> W dniu 02.06.2010 14:22, Alex Arnon pisze: > Could one possibly simply add an error_logger appender? > Maybe make it the default? Sorry, I do not know log4erl application ; but what I've seen in the source code there's nothing like error_logger appender (unless you create it) but only error_logger events handler which acts like a "bridge" between error_logger protocol and log4erl protocol (as I've written in the previous post). B.r. D. > > > 2010/6/2 Damian Dobroczy?ski > >> W dniu 02.06.2010 12:13, Max Lapshin pisze: >>> Hi. I want to use log4erl as a default error logger for all system (to >>> log all process failures), >>> but I don't understand how. >>> >>> What part of erlang documentation have I missed? Where should I read >>> to understand, how to change logger. >>> >> >> error_logger is "gen_event" process registered locally under the name >> "error_logger". The process start is hard-coded in the "kernel" >> application (kernel.erl module implements "kernel_sup" supervisor >> behavior - this supervisor launches the "error_logger" process) which is >> loaded as the very first. What you can do is to kill this process as >> soon as possible (risking that some logging messages would not reach the >> logger) and replace it with another "gen_event" process registering it >> under the name "error_logger". You may obtain this by launching special >> application that starts only the specialized gen_event process (if you >> want to use it in a boot script) or by passing a command line options >> "-s " which fires :start/0 function. The >> latter is launched after all primary application has been loaded, so the >> initial logs would go through the standard error_logger. I think you >> should write a special "launcher" module to replace the standard logger. >> Besides log4erl must implements error_logger message protocol. I do not >> know it is so. >> >> Hope this helps, >> Damian >> >>> ________________________________________________________________ >>> erlang-questions (at) erlang.org mailing list. >>> See http://www.erlang.org/faq.html >>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>> >> >> >> > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: From alessandro.sivieri@REDACTED Wed Jun 2 14:37:59 2010 From: alessandro.sivieri@REDACTED (Alessandro Sivieri) Date: Wed, 2 Jun 2010 14:37:59 +0200 Subject: [erlang-questions] log4erl as system logger In-Reply-To: <4C064EEA.6020001@gmail.com> References: <4C064B25.4070104@gmail.com> <4C064EEA.6020001@gmail.com> Message-ID: For what I have seen, too, there is no way to replace the default logger with a different one (as in Java, for example); maybe we can suggest this modification to the OTP maintainers, or they can tell us if there is some reason in not allowing this. -- Sivieri Alessandro alessandro.sivieri@REDACTED http://www.chimera-bellerofonte.eu/ http://www.poul.org/ From serge@REDACTED Wed Jun 2 14:50:15 2010 From: serge@REDACTED (Serge Aleynikov) Date: Wed, 02 Jun 2010 08:50:15 -0400 Subject: [erlang-questions] log4erl as system logger In-Reply-To: References: <4C064B25.4070104@gmail.com> <4C064EEA.6020001@gmail.com> Message-ID: <4C065387.4030008@aleynikov.org> Default error_logger implements gen_event behavior that allows swapping handlers. You can take a look at how LAMA application does it in the start_link() function by changing default logger to format and send log events to a syslog daemon: http://jungerl.cvs.sourceforge.net/viewvc/jungerl/jungerl/lib/lama/src/lama_syslog_h.erl?revision=1.4&view=markup Serge On 6/2/2010 8:37 AM, Alessandro Sivieri wrote: > For what I have seen, too, there is no way to replace the default logger > with a different one (as in Java, for example); maybe we can suggest this > modification to the OTP maintainers, or they can tell us if there is some > reason in not allowing this. > From mihai@REDACTED Wed Jun 2 17:34:20 2010 From: mihai@REDACTED (Mihai Balea) Date: Wed, 2 Jun 2010 11:34:20 -0400 Subject: [erlang-questions] log4erl as system logger In-Reply-To: References: <4C064B25.4070104@gmail.com> <4C064EEA.6020001@gmail.com> Message-ID: <70642D9E-5D92-473D-87EF-B8394E10A31B@hates.ms> On Jun 2, 2010, at 8:37 AM, Alessandro Sivieri wrote: > For what I have seen, too, there is no way to replace the default logger > with a different one (as in Java, for example); maybe we can suggest this > modification to the OTP maintainers, or they can tell us if there is some > reason in not allowing this. I don't see why you couldn't just replace the error_logger module with a custom one. You'd just need to be sure it has the same API. Otherwise stuff will break in nasty ways, since the error_logger module is used by all sorts of system code. As others have mentioned, another (better) alternative would be to replace the default handlers with custom ones. After all, error_logger is just a gen_event process, so this is quite easy to do and can change the logging behavior completely. You'd have to handle the default OTP protocol, but that's not such a big deal. Mihai From mevans@REDACTED Wed Jun 2 17:43:38 2010 From: mevans@REDACTED (Evans, Matthew) Date: Wed, 2 Jun 2010 11:43:38 -0400 Subject: [erlang-questions] OTP Efficiency In-Reply-To: References: Message-ID: Well OTP will add some extra load on your system. The gen_server:call / gen_server:cast adds a bit of extra load such as monitoring of the destination process, timers, some extra pattern matching. However, trust me, as someone who used to think that such overheads would be unacceptable and started to develop an application that wasn't OTP I soon regretted it. My application soon became a mess that was hard to debug and extend, and I soon ended up spending a day making it OTP. The advantages that OTP provides to make your application structure easier to understand and more extendable soon pays for any performance loss you may see. I would also add that if you need reliability in your service you will just need to reinvent what OTP has already provided for you anyway. If performance is really a high priority you can always use the handle_info callback to receive messages. The only time I don't use OTP are for processes that never receive any (or perhaps a single) messages, and perform a unique task (such as process a batch of data, wait for a resource etc). Matt -----Original Message----- From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On Behalf Of maruthavanan s Sent: Wednesday, June 02, 2010 7:06 AM To: erlang-questions@REDACTED Subject: [erlang-questions] OTP Efficiency Hi All, I could understand that OTP gives us a fault tolerant solutions like restarting on crashing, supervisors, FSM behaviours etc. I am curious on the efficiency of a application. Say for e.g. I develop a solution with both OTP and without OTP (handling 100% errors may be not possible :) ) which one would be efficient? Thanks, Marutha From alessandro.sivieri@REDACTED Wed Jun 2 17:46:18 2010 From: alessandro.sivieri@REDACTED (Alessandro Sivieri) Date: Wed, 2 Jun 2010 17:46:18 +0200 Subject: [erlang-questions] log4erl as system logger In-Reply-To: <70642D9E-5D92-473D-87EF-B8394E10A31B@hates.ms> References: <4C064B25.4070104@gmail.com> <4C064EEA.6020001@gmail.com> <70642D9E-5D92-473D-87EF-B8394E10A31B@hates.ms> Message-ID: Well, then it was not so clear how to do it... -- Sivieri Alessandro alessandro.sivieri@REDACTED http://www.chimera-bellerofonte.eu/ http://www.poul.org/ From anthonym@REDACTED Wed Jun 2 18:16:52 2010 From: anthonym@REDACTED (Anthony Molinaro) Date: Wed, 2 Jun 2010 09:16:52 -0700 Subject: [erlang-questions] Good practice for binary distributing In-Reply-To: References: <60482D9E-777C-4A03-9C8B-C22DA386CB55@mindspring.com> Message-ID: <20100602161652.GA3306@alumni.caltech.edu> Try framewerk, its autotools based and will build debs and rpms http://code.google.com/p/fwtemplates/ You may have to muck around with it to encrypt your source, also it won't package up erlang itself (it relies on the system supplied erlang). But if you want to integrate erlang packages with the natie package manager it'll do it for you. -Anthony On Sun, May 30, 2010 at 10:50:44AM +0400, Max Lapshin wrote: > On Sun, May 30, 2010 at 6:57 AM, Matt Stancliff wrote: > > Same with an erlang redis library: > > ?Before (Emakefile, Makefile, Rakefile, rebar): > > http://github.com/mattsta/er/tree/20bcb6 > > ?After (rebar-only): http://github.com/mattsta/er/ > > > > It is nice, but I don't understand, how will it help me to build > debian packages. > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > -- ------------------------------------------------------------------------ Anthony Molinaro From pablo.platt@REDACTED Wed Jun 2 17:27:40 2010 From: pablo.platt@REDACTED (Pablo Platt) Date: Wed, 2 Jun 2010 08:27:40 -0700 (PDT) Subject: my socket can't handle the load Message-ID: <235670.22465.qm@web112613.mail.gq1.yahoo.com> Hi, I'm writing a driver to a database that is using a tcp socket. There are two types of messages, "send and forget" and "send and receive". I have a gen_server that is responsible for opening the socket, receive a message from a process and sending it to the socket and receive responses and pass them to the caller. The gen_server saves a list of {request_id, CallerPid} in the state to know who to respond to when a packet is received from the db. Everything works when the rate of messages is low but when increasing it I'm starting to get gen_server timeout error on the requestor. Do I need to add/change parameters when opening the socket? Should I queue requests and wait for a response before sending the next request or is it ok to send several requests one after the other? Thanks The client sends a request using either: Resp = gen_server:call(Conn, {request, Request}) or gen_server:cast(Conn, {request, Request}) The relevant gen_server code: init([Host, Port]) -> Socket = open_socket(Host, Port), {ok, #state{socket=Socket, req_id=1}}. open_socket(Host, Port) -> case gen_tcp:connect(Host, Port, [binary, {active, true}]) of {ok, Sock} -> Sock; {error, Reason} -> exit({open_socket_failed, Reason}) end. handle_call({request, Packet}, From, State) -> ReqID = State#state.req_id + 1, gen_tcp:send(State#state.socket, Packet), {noreply, State#state{req_id=ReqID, requests=[{ReqID, From}|State#state.requests]}}; handle_cast({request, Packet}, State) -> ReqID = State#state.req_id + 1, gen_tcp:send(State#state.socket, Packet), {noreply, State#state{req_id=ReqID}}. handle_info({tcp, _Socket, Data}, State) -> RawResp = <<(State#state.resp)/binary, Data/binary>>, case check_packet:decode_response(RawResp) of undefined -> {noreply, State#state{resp = RawResp}}; {Resp, Tail} -> ResponseTo = get_requestor(Resp), {value, {ResponseTo, Client}, NewRequests} = lists:keytake(ResponseTo, 1, State#state.requests), gen_server:reply(Client, Resp), {noreply, State#state{resp = Tail, requests=NewRequests}} end; % the following never been called, even when I'm getting the error. handle_info({tcp_closed, _Socket}, State) -> {noreply, State}; handle_info({tcp_error, _Socket, _Reason}, State) -> {noreply, State}. terminate(_Reason, _State) -> ok. From max.lapshin@REDACTED Wed Jun 2 18:31:35 2010 From: max.lapshin@REDACTED (Max Lapshin) Date: Wed, 2 Jun 2010 20:31:35 +0400 Subject: [erlang-questions] Good practice for binary distributing In-Reply-To: <20100602161652.GA3306@alumni.caltech.edu> References: <60482D9E-777C-4A03-9C8B-C22DA386CB55@mindspring.com> <20100602161652.GA3306@alumni.caltech.edu> Message-ID: It is interesting. Clients make me tired with CentOS (I really don't want to make packages for it) and this infrastructure may help me. From max.lapshin@REDACTED Wed Jun 2 18:59:55 2010 From: max.lapshin@REDACTED (Max Lapshin) Date: Wed, 2 Jun 2010 20:59:55 +0400 Subject: fixed 80 columns in io:format Message-ID: I've found several places in otp: http://github.com/erlang/otp/blob/dev/lib/stdlib/src/io_lib.erl#L166 http://github.com/erlang/otp/blob/dev/lib/stdlib/src/io_lib_pretty.erl#L37 Am I right, thinking that these places hardcode width of terminal and insert newline, where it is not required for me? From ulf.wiger@REDACTED Wed Jun 2 20:10:56 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 02 Jun 2010 20:10:56 +0200 Subject: [erlang-questions] fixed 80 columns in io:format In-Reply-To: References: Message-ID: <4C069EB0.8050908@erlang-solutions.com> Max Lapshin wrote: > I've found several places in otp: > > http://github.com/erlang/otp/blob/dev/lib/stdlib/src/io_lib.erl#L166 > http://github.com/erlang/otp/blob/dev/lib/stdlib/src/io_lib_pretty.erl#L37 > > Am I right, thinking that these places hardcode width of terminal and > insert newline, where it is not required for me? No, those places set common defaults for cases when nothing else has been specified. The shell asks the group server for the column width, which in its turn asks the tty driver (tty_drv). However, if you want the shell to make use of a wider tty, the culprit is this: http://github.com/erlang/otp/blob/dev/lib/stdlib/src/shell.erl#L1424 pp(V, I, RT) -> io_lib_pretty:print(V, I, columns(), ?LINEMAX, ?CHAR_MAX, record_print_fun(RT)). The ?CHAR_MAX macro expands to 60, which sets the actual limit for the column depth. If this were -1 instead, the pretty printer would make use of the full width of the window. Someone wiser than I will have to explain why CHAR_MAX is hard-coded to 60, and not (if hard-coded at all) -1. BR, Ulf W -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From bernie@REDACTED Wed Jun 2 23:35:58 2010 From: bernie@REDACTED (Bernard Duggan) Date: Thu, 03 Jun 2010 07:35:58 +1000 Subject: [erlang-questions] my socket can't handle the load In-Reply-To: <235670.22465.qm@web112613.mail.gq1.yahoo.com> References: <235670.22465.qm@web112613.mail.gq1.yahoo.com> Message-ID: <4C06CEBE.50507@m5net.com> Hi Pablo, One thing you may want to try is to wherever possible, avoid letting the queue on your gen_server grow beyond a couple of messages. Allowing the queue to grow unchecked can cause serious performance degradation on selective receives (which, to be fair, I can't see any of in your code, but they can crop up in non-obvious library calls at times). Off the top of my head, you'd do this by: a) changing the handle_cast operation to a handle_call (to keep clients using that operation from flooding you with requests) and b) changing {active, true} to {active, once} in your connect call (and making the corresponding change in handle_info to reactivate the socket. It may or may not be your problem, but it's a fairly easy change and worth a try. Another possibility is that you have the same issue, but in the calling process (I'm guessing now, since you haven't provided that code). A gen_server call does a selective receive while it waits for a response - if your message queue is very large when you make the call, there's a good chance you'll get a timeout regardless of how quickly the gen_server serves the request. Cheers, Bernard On 3/06/2010 1:27 AM, Pablo Platt wrote: > Hi, > > I'm writing a driver to a database that is using a tcp socket. > There are two types of messages, "send and forget" and "send and receive". > I have a gen_server that is responsible for opening the socket, receive a message from a process and sending it to the socket and receive responses and pass them to the caller. > The gen_server saves a list of {request_id, CallerPid} in the state to know who to respond to when a packet is received from the db. > > Everything works when the rate of messages is low but when increasing it I'm starting to get gen_server timeout error on the requestor. > Do I need to add/change parameters when opening the socket? > Should I queue requests and wait for a response before sending the next request or is it ok to send several requests one after the other? > > Thanks > > The client sends a request using either: > Resp = gen_server:call(Conn, {request, Request}) > or > gen_server:cast(Conn, {request, Request}) > > > The relevant gen_server code: > > init([Host, Port]) -> > Socket = open_socket(Host, Port), > {ok, #state{socket=Socket, req_id=1}}. > > open_socket(Host, Port) -> > case gen_tcp:connect(Host, Port, [binary, {active, true}]) of > {ok, Sock} -> > Sock; > {error, Reason} -> > exit({open_socket_failed, Reason}) > end. > > handle_call({request, Packet}, From, State) -> > ReqID = State#state.req_id + 1, > gen_tcp:send(State#state.socket, Packet), > {noreply, State#state{req_id=ReqID, requests=[{ReqID, From}|State#state.requests]}}; > > handle_cast({request, Packet}, State) -> > ReqID = State#state.req_id + 1, > gen_tcp:send(State#state.socket, Packet), > {noreply, State#state{req_id=ReqID}}. > > handle_info({tcp, _Socket, Data}, State) -> > RawResp = <<(State#state.resp)/binary, Data/binary>>, > case check_packet:decode_response(RawResp) of > undefined -> > {noreply, State#state{resp = RawResp}}; > {Resp, Tail} -> > ResponseTo = get_requestor(Resp), > {value, {ResponseTo, Client}, NewRequests} = lists:keytake(ResponseTo, 1, State#state.requests), > gen_server:reply(Client, Resp), > {noreply, State#state{resp = Tail, requests=NewRequests}} > end; > > % the following never been called, even when I'm getting the error. > handle_info({tcp_closed, _Socket}, State) -> > {noreply, State}; > > handle_info({tcp_error, _Socket, _Reason}, State) -> > {noreply, State}. > > terminate(_Reason, _State) -> > ok. > > > > From kaiduanx@REDACTED Thu Jun 3 02:59:02 2010 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Wed, 2 Jun 2010 20:59:02 -0400 Subject: [erlang-questions] my socket can't handle the load In-Reply-To: <4C06CEBE.50507@m5net.com> References: <235670.22465.qm@web112613.mail.gq1.yahoo.com> <4C06CEBE.50507@m5net.com> Message-ID: Pablo, Have you considered any chance the call of gen_tcp:send(State#state.socket, Packet) getting blocked? For example, a slow receiver. If gen_tcp:send() is getting blocked, hand_call() will get blocked, and gen_server will slow down. Please look the example listed in gen_tcp, http://www.erlang.org/doc/man/gen_tcp.html#examples Kaiduan On Wed, Jun 2, 2010 at 5:35 PM, Bernard Duggan wrote: > Hi Pablo, > ? ?One thing you may want to try is to wherever possible, avoid letting > the queue on your gen_server grow beyond a couple of messages. ?Allowing > the queue to grow unchecked can cause serious performance degradation on > selective receives (which, to be fair, I can't see any of in your code, > but they can crop up in non-obvious library calls at times). > Off the top of my head, you'd do this by: > a) changing the handle_cast operation to a handle_call (to keep clients > using that operation from flooding you with requests) and > b) changing {active, true} to {active, once} in your connect call (and > making the corresponding change in handle_info to reactivate the socket. > > It may or may not be your problem, but it's a fairly easy change and > worth a try. > > Another possibility is that you have the same issue, but in the calling > process (I'm guessing now, since you haven't provided that code). ?A > gen_server call does a selective receive while it waits for a response - > if your message queue is very large when you make the call, there's a > good chance you'll get a timeout regardless of how quickly the > gen_server serves the request. > > Cheers, > > Bernard > > On 3/06/2010 1:27 AM, Pablo Platt wrote: >> Hi, >> >> I'm writing a driver to a database that is using a tcp socket. >> There are two types of messages, "send and forget" and "send and receive". >> I have a gen_server that is responsible for opening the socket, receive a message from a process and sending it to the socket and receive responses and pass them to the caller. >> The gen_server saves a list of {request_id, CallerPid} in the state to know who to respond to when a packet is received from the db. >> >> Everything works when the rate of messages is low but when increasing it I'm starting to get gen_server timeout error on the requestor. >> Do I need to add/change parameters when opening the socket? >> Should I queue requests and wait for a response before sending the next request or is it ok to send several requests one after the other? >> >> Thanks >> >> The client sends a request using either: >> Resp = gen_server:call(Conn, {request, Request}) >> or >> gen_server:cast(Conn, {request, Request}) >> >> >> The relevant gen_server code: >> >> init([Host, Port]) -> >> ? ? Socket = open_socket(Host, Port), >> ? ? {ok, #state{socket=Socket, req_id=1}}. >> >> open_socket(Host, Port) -> >> ? ? case gen_tcp:connect(Host, Port, [binary, {active, true}]) of >> ? ? ? ? {ok, Sock} -> >> ? ? ? ? ? ? Sock; >> ? ? ? ? {error, Reason} -> >> ? ? ? ? ? ? exit({open_socket_failed, Reason}) >> ? ? end. >> >> handle_call({request, Packet}, From, State) -> >> ? ? ReqID = State#state.req_id + 1, >> ? ? gen_tcp:send(State#state.socket, Packet), >> ? ? {noreply, State#state{req_id=ReqID, requests=[{ReqID, From}|State#state.requests]}}; >> >> handle_cast({request, Packet}, State) -> >> ? ? ReqID = State#state.req_id + 1, >> ? ? gen_tcp:send(State#state.socket, Packet), >> ? ? {noreply, State#state{req_id=ReqID}}. >> >> handle_info({tcp, _Socket, Data}, State) -> >> ? ? RawResp = <<(State#state.resp)/binary, Data/binary>>, >> ? ? case check_packet:decode_response(RawResp) of >> ? ? ? ? undefined -> >> ? ? ? ? ? ? {noreply, State#state{resp = RawResp}}; >> ? ? ? ? {Resp, Tail} -> >> ? ? ? ? ? ? ResponseTo = get_requestor(Resp), >> ? ? ? ? ? ? {value, {ResponseTo, Client}, NewRequests} = lists:keytake(ResponseTo, 1, State#state.requests), >> ? ? ? ? ? ? gen_server:reply(Client, Resp), >> ? ? ? ? ? ? {noreply, State#state{resp = Tail, requests=NewRequests}} >> ? ? end; >> >> % the following never been called, even when I'm getting the error. >> handle_info({tcp_closed, _Socket}, State) -> >> ? ? {noreply, State}; >> >> handle_info({tcp_error, _Socket, _Reason}, State) -> >> ? ? {noreply, State}. >> >> terminate(_Reason, _State) -> >> ? ? ok. >> >> >> >> > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From comptekki@REDACTED Thu Jun 3 06:37:17 2010 From: comptekki@REDACTED (Wes James) Date: Wed, 2 Jun 2010 22:37:17 -0600 Subject: grab a value in list for later use in map Message-ID: With a map such as this: map(fun(Row) -> {tr, [], [{td, [], massage(W)} || W <- Row] } end, Rows) It outputs values like this: 4 6183 2010-05-20 0 6193 2010-05-21 6 6209 2010-05-24 But if there is a 0 in the first column, I want to instead of outputting the 0, subtract the column to the right value - previous column value, i.e subtract 6193-6183. How do I keep a second column value around if I need it like this with map? thx, -wes From bengt.kleberg@REDACTED Thu Jun 3 06:49:44 2010 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 03 Jun 2010 06:49:44 +0200 Subject: [erlang-questions] grab a value in list for later use in map In-Reply-To: References: Message-ID: <1275540584.5087.2.camel@seasc1137> Greetings, In general it is a good idea to use lists:foldl/3 when you are (potentially) accumulating things. bengt On Thu, 2010-06-03 at 06:37 +0200, Wes James wrote: > With a map such as this: > > map(fun(Row) -> > {tr, [], > [{td, [], massage(W)} || W <- Row] > } > end, Rows) > > It outputs values like this: > > 4 6183 2010-05-20 > 0 6193 2010-05-21 > 6 6209 2010-05-24 > > But if there is a 0 in the first column, I want to instead of > outputting the 0, subtract the column to the right value - previous > column value, i.e subtract 6193-6183. How do I keep a second column > value around if I need it like this with map? > > thx, > > -wes > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > From pablo.platt@REDACTED Thu Jun 3 08:49:17 2010 From: pablo.platt@REDACTED (Pablo Platt) Date: Wed, 2 Jun 2010 23:49:17 -0700 (PDT) Subject: [erlang-questions] my socket can't handle the load In-Reply-To: References: <235670.22465.qm@web112613.mail.gq1.yahoo.com> <4C06CEBE.50507@m5net.com> Message-ID: <314178.89312.qm@web112601.mail.gq1.yahoo.com> @Bernard, Kaiduan When I'm testing with a pool of 20 connections instead of 1, the driver and socket works fine. I think that means that both the receiver (database) and the sender can handle the load. When sending one request at a time from the same socket it also works fine but don't think this is the correct design. I don't think {active, once} is relevant here because responses from the db will only arrive when I make requests so I don't need to protect myself against DOS from untrusted third party. When getting a timeout on gen_server:call to the socket gen_server, how can I print useful info about the socket gen_server and the process calling it so I can see the mailbox queue of them and maybe other useful stuff that help me find the problem? Thanks ________________________________ From: Kaiduan Xie To: Bernard Duggan Cc: Pablo Platt ; Erlang Sent: Thu, June 3, 2010 3:59:02 AM Subject: Re: [erlang-questions] my socket can't handle the load Pablo, Have you considered any chance the call of gen_tcp:send(State#state.socket, Packet) getting blocked? For example, a slow receiver. If gen_tcp:send() is getting blocked, hand_call() will get blocked, and gen_server will slow down. Please look the example listed in gen_tcp, http://www.erlang.org/doc/man/gen_tcp.html#examples Kaiduan On Wed, Jun 2, 2010 at 5:35 PM, Bernard Duggan wrote: > Hi Pablo, > One thing you may want to try is to wherever possible, avoid letting > the queue on your gen_server grow beyond a couple of messages. Allowing > the queue to grow unchecked can cause serious performance degradation on > selective receives (which, to be fair, I can't see any of in your code, > but they can crop up in non-obvious library calls at times). > Off the top of my head, you'd do this by: > a) changing the handle_cast operation to a handle_call (to keep clients > using that operation from flooding you with requests) and > b) changing {active, true} to {active, once} in your connect call (and > making the corresponding change in handle_info to reactivate the socket. > > It may or may not be your problem, but it's a fairly easy change and > worth a try. > > Another possibility is that you have the same issue, but in the calling > process (I'm guessing now, since you haven't provided that code). A > gen_server call does a selective receive while it waits for a response - > if your message queue is very large when you make the call, there's a > good chance you'll get a timeout regardless of how quickly the > gen_server serves the request. > > Cheers, > > Bernard > > On 3/06/2010 1:27 AM, Pablo Platt wrote: >> Hi, >> >> I'm writing a driver to a database that is using a tcp socket. >> There are two types of messages, "send and forget" and "send and receive". >> I have a gen_server that is responsible for opening the socket, receive a message from a process and sending it to the socket and receive responses and pass them to the caller. >> The gen_server saves a list of {request_id, CallerPid} in the state to know who to respond to when a packet is received from the db. >> >> Everything works when the rate of messages is low but when increasing it I'm starting to get gen_server timeout error on the requestor. >> Do I need to add/change parameters when opening the socket? >> Should I queue requests and wait for a response before sending the next request or is it ok to send several requests one after the other? >> >> Thanks >> >> The client sends a request using either: >> Resp = gen_server:call(Conn, {request, Request}) >> or >> gen_server:cast(Conn, {request, Request}) >> >> >> The relevant gen_server code: >> >> init([Host, Port]) -> >> Socket = open_socket(Host, Port), >> {ok, #state{socket=Socket, req_id=1}}. >> >> open_socket(Host, Port) -> >> case gen_tcp:connect(Host, Port, [binary, {active, true}]) of >> {ok, Sock} -> >> Sock; >> {error, Reason} -> >> exit({open_socket_failed, Reason}) >> end. >> >> handle_call({request, Packet}, From, State) -> >> ReqID = State#state.req_id + 1, >> gen_tcp:send(State#state.socket, Packet), >> {noreply, State#state{req_id=ReqID, requests=[{ReqID, From}|State#state.requests]}}; >> >> handle_cast({request, Packet}, State) -> >> ReqID = State#state.req_id + 1, >> gen_tcp:send(State#state.socket, Packet), >> {noreply, State#state{req_id=ReqID}}. >> >> handle_info({tcp, _Socket, Data}, State) -> >> RawResp = <<(State#state.resp)/binary, Data/binary>>, >> case check_packet:decode_response(RawResp) of >> undefined -> >> {noreply, State#state{resp = RawResp}}; >> {Resp, Tail} -> >> ResponseTo = get_requestor(Resp), >> {value, {ResponseTo, Client}, NewRequests} = lists:keytake(ResponseTo, 1, State#state.requests), >> gen_server:reply(Client, Resp), >> {noreply, State#state{resp = Tail, requests=NewRequests}} >> end; >> >> % the following never been called, even when I'm getting the error. >> handle_info({tcp_closed, _Socket}, State) -> >> {noreply, State}; >> >> handle_info({tcp_error, _Socket, _Reason}, State) -> >> {noreply, State}. >> >> terminate(_Reason, _State) -> >> ok. >> >> >> >> > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From pablo.platt@REDACTED Thu Jun 3 08:52:08 2010 From: pablo.platt@REDACTED (Pablo Platt) Date: Wed, 2 Jun 2010 23:52:08 -0700 (PDT) Subject: [erlang-questions] my socket can't handle the load Message-ID: <576214.89312.qm@web112601.mail.gq1.yahoo.com> p.s. when getting a gen_server:call timeout the debug message of the requester(not the socket gen_server) says: heap_size: 1597 stack_size: 24 reductions: 1996 ________________________________ From: Pablo Platt To: Kaiduan Xie ; Bernard Duggan Cc: Erlang Sent: Thu, June 3, 2010 9:49:17 AM Subject: Re: [erlang-questions] my socket can't handle the load @Bernard, Kaiduan When I'm testing with a pool of 20 connections instead of 1, the driver and socket works fine. I think that means that both the receiver (database) and the sender can handle the load. When sending one request at a time from the same socket it also works fine but don't think this is the correct design. I don't think {active, once} is relevant here because responses from the db will only arrive when I make requests so I don't need to protect myself against DOS from untrusted third party. When getting a timeout on gen_server:call to the socket gen_server, how can I print useful info about the socket gen_server and the process calling it so I can see the mailbox queue of them and maybe other useful stuff that help me find the problem? Thanks ________________________________ From: Kaiduan Xie To: Bernard Duggan Cc: Pablo Platt ; Erlang Sent: Thu, June 3, 2010 3:59:02 AM Subject: Re: [erlang-questions] my socket can't handle the load Pablo, Have you considered any chance the call of gen_tcp:send(State#state.socket, Packet) getting blocked? For example, a slow receiver. If gen_tcp:send() is getting blocked, hand_call() will get blocked, and gen_server will slow down. Please look the example listed in gen_tcp, http://www.erlang.org/doc/man/gen_tcp.html#examples Kaiduan On Wed, Jun 2, 2010 at 5:35 PM, Bernard Duggan wrote: > Hi Pablo, > One thing you may want to try is to wherever possible, avoid letting > the queue on your gen_server grow beyond a couple of messages. Allowing > the queue to grow unchecked can cause serious performance degradation on > selective receives (which, to be fair, I can't see any of in your code, > but they can crop up in non-obvious library calls at times). > Off the top of my head, you'd do this by: > a) changing the handle_cast operation to a handle_call (to keep clients > using that operation from flooding you with requests) and > b) changing {active, true} to {active, once} in your connect call (and > making the corresponding change in handle_info to reactivate the socket. > > It may or may not be your problem, but it's a fairly easy change and > worth a try. > > Another possibility is that you have the same issue, but in the calling > process (I'm guessing now, since you haven't provided that code). A > gen_server call does a selective receive while it waits for a response - > if your message queue is very large when you make the call, there's a > good chance you'll get a timeout regardless of how quickly the > gen_server serves the request. > > Cheers, > > Bernard > > On 3/06/2010 1:27 AM, Pablo Platt wrote: >> Hi, >> >> I'm writing a driver to a database that is using a tcp socket. >> There are two types of messages, "send and forget" and "send and receive". >> I have a gen_server that is responsible for opening the socket, receive a message from a process and sending it to the socket and receive responses and pass them to the caller. >> The gen_server saves a list of {request_id, CallerPid} in the state to know who to respond to when a packet is received from the db. >> >> Everything works when the rate of messages is low but when increasing it I'm starting to get gen_server timeout error on the requestor. >> Do I need to add/change parameters when opening the socket? >> Should I queue requests and wait for a response before sending the next request or is it ok to send several requests one after the other? >> >> Thanks >> >> The client sends a request using either: >> Resp = gen_server:call(Conn, {request, Request}) >> or >> gen_server:cast(Conn, {request, Request}) >> >> >> The relevant gen_server code: >> >> init([Host, Port]) -> >> Socket = open_socket(Host, Port), >> {ok, #state{socket=Socket, req_id=1}}. >> >> open_socket(Host, Port) -> >> case gen_tcp:connect(Host, Port, [binary, {active, true}]) of >> {ok, Sock} -> >> Sock; >> {error, Reason} -> >> exit({open_socket_failed, Reason}) >> end. >> >> handle_call({request, Packet}, From, State) -> >> ReqID = State#state.req_id + 1, >> gen_tcp:send(State#state.socket, Packet), >> {noreply, State#state{req_id=ReqID, requests=[{ReqID, From}|State#state.requests]}}; >> >> handle_cast({request, Packet}, State) -> >> ReqID = State#state.req_id + 1, >> gen_tcp:send(State#state.socket, Packet), >> {noreply, State#state{req_id=ReqID}}. >> >> handle_info({tcp, _Socket, Data}, State) -> >> RawResp = <<(State#state.resp)/binary, Data/binary>>, >> case check_packet:decode_response(RawResp) of >> undefined -> >> {noreply, State#state{resp = RawResp}}; >> {Resp, Tail} -> >> ResponseTo = get_requestor(Resp), >> {value, {ResponseTo, Client}, NewRequests} = lists:keytake(ResponseTo, 1, State#state.requests), >> gen_server:reply(Client, Resp), >> {noreply, State#state{resp = Tail, requests=NewRequests}} >> end; >> >> % the following never been called, even when I'm getting the error. >> handle_info({tcp_closed, _Socket}, State) -> >> {noreply, State}; >> >> handle_info({tcp_error, _Socket, _Reason}, State) -> >> {noreply, State}. >> >> terminate(_Reason, _State) -> >> ok. >> >> >> >> > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From johanmon@REDACTED Thu Jun 3 10:08:45 2010 From: johanmon@REDACTED (Johan Montelius) Date: Thu, 03 Jun 2010 10:08:45 +0200 Subject: monitor and failure detectors In-Reply-To: <1275540584.5087.2.camel@seasc1137> References: <1275540584.5087.2.camel@seasc1137> Message-ID: Some question on monitors: Is there a way to change the timeout of monitors to configure how eager they will be to deliver a DOWN/noconnection message? Can this be changed on a per monitor basis so one could monitor one process with a 0.1s timeout and another with a 20s timeout? I guess it is the empd daemon that is responsible for tracking the state of nodes on a host. If a node crashes a monitor will report DOWN/noconnection. Could it be possible to have monitor generate a DOWN/down or similar when/if it can be determined that the node (and thus the process that we monitor) is actually down. The DOWN/noconnection message leaves us in a state where we don't know it is down or simply disconnected. Johan -- Associate Professor Johan Montelius Royal Institute of Technology - KTH School of Information and Communication Technology - ICT From torben.lehoff@REDACTED Thu Jun 3 10:09:21 2010 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Thu, 3 Jun 2010 10:09:21 +0200 Subject: [erlang-questions] OTP Efficiency In-Reply-To: References: Message-ID: I have similar experiences - see http://groups.google.com/group/erlang-programming/browse_thread/thread/93ed9747126fd30d?pli=1 for my war story. Cheers, Torben On Wed, Jun 2, 2010 at 17:43, Evans, Matthew wrote: > Well OTP will add some extra load on your system. > > The gen_server:call / gen_server:cast adds a bit of extra load such as > monitoring of the destination process, timers, some extra pattern matching. > > However, trust me, as someone who used to think that such overheads would > be unacceptable and started to develop an application that wasn't OTP I soon > regretted it. My application soon became a mess that was hard to debug and > extend, and I soon ended up spending a day making it OTP. > > The advantages that OTP provides to make your application structure easier > to understand and more extendable soon pays for any performance loss you may > see. I would also add that if you need reliability in your service you will > just need to reinvent what OTP has already provided for you anyway. > > If performance is really a high priority you can always use the handle_info > callback to receive messages. > > The only time I don't use OTP are for processes that never receive any (or > perhaps a single) messages, and perform a unique task (such as process a > batch of data, wait for a resource etc). > > Matt > > -----Original Message----- > From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On > Behalf Of maruthavanan s > Sent: Wednesday, June 02, 2010 7:06 AM > To: erlang-questions@REDACTED > Subject: [erlang-questions] OTP Efficiency > > > Hi All, > > > > I could understand that OTP gives us a fault tolerant solutions like > restarting on crashing, supervisors, FSM behaviours etc. > > > > I am curious on the efficiency of a application. > > > > Say for e.g. I develop a solution with both OTP and without OTP (handling > 100% errors may be not possible :) ) which one would be efficient? > > > > Thanks, > > Marutha > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > -- http://www.linkedin.com/in/torbenhoffmann From max.lapshin@REDACTED Thu Jun 3 10:18:56 2010 From: max.lapshin@REDACTED (Max Lapshin) Date: Thu, 3 Jun 2010 12:18:56 +0400 Subject: [erlang-questions] OTP Efficiency In-Reply-To: References: Message-ID: I've also tried to work without OTP and there have been left only two places in my code, which are not OTP: 1) gen_server:call changed to implementation without additional erlang:monitor, because caller already has monitor. It reduced load. 2) media_ticker is a process, that retrieves frame by frame and sleeps for the timestamp difference. It happened to be easier to make it very small without otp From ssyeoh@REDACTED Thu Jun 3 10:19:15 2010 From: ssyeoh@REDACTED (ssyeoh) Date: Thu, 3 Jun 2010 01:19:15 -0700 (PDT) Subject: common test test specification Message-ID: Hi, Need some hints about how to to write the common test test specification. My need is to setup test to run suites for several OTP apps but only do code coverage once covering all source codes from all tested apps. thanks /ssyeoh From ulf.wiger@REDACTED Thu Jun 3 10:24:58 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 03 Jun 2010 10:24:58 +0200 Subject: [erlang-questions] monitor and failure detectors In-Reply-To: References: <1275540584.5087.2.camel@seasc1137> Message-ID: <4C0766DA.3030100@erlang-solutions.com> Monitors have no timeout. They trigger immediately when either the process dies or the node of the process is disconnected. Is it the latter event that you are referring to? This can be configured using -kernel net_ticktime T, where T is 60 seconds by default. See http://www.erlang.org/doc/man/kernel_app.html "net_ticktime = TickTime Specifies the net_kernel tick time. TickTime is given in seconds. Once every TickTime/4 second, all connected nodes are ticked (if anything else has been written to a node) and if nothing has been received from another node within the last four (4) tick times that node is considered to be down. This ensures that nodes which are not responding, for reasons such as hardware errors, are considered to be down. The time T, in which a node that is not responding is detected, is calculated as: MinT < T < MaxT where: MinT = TickTime - TickTime / 4 MaxT = TickTime + TickTime / 4 TickTime is by default 60 (seconds). Thus, 45 < T < 75 seconds. Note: All communicating nodes should have the same TickTime value specified. Note: Normally, a terminating node is detected immediately." BR, Ulf W Johan Montelius wrote: > > Some question on monitors: > > Is there a way to change the timeout of monitors to configure how eager > they will be to deliver a DOWN/noconnection message? Can this be changed > on a per monitor basis so one could monitor one process with a 0.1s > timeout and another with a 20s timeout? > > > I guess it is the empd daemon that is responsible for tracking the state > of nodes on a host. If a node crashes a monitor will report > DOWN/noconnection. Could it be possible to have monitor generate a > DOWN/down or similar when/if it can be determined that the node (and > thus the process that we monitor) is actually down. The > DOWN/noconnection message leaves us in a state where we don't know it is > down or simply disconnected. > > Johan -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From ulf.wiger@REDACTED Thu Jun 3 10:41:18 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 03 Jun 2010 10:41:18 +0200 Subject: [erlang-questions] OTP Efficiency In-Reply-To: References: Message-ID: <4C076AAE.2020800@erlang-solutions.com> Max Lapshin wrote: > I've also tried to work without OTP and there have been left only two > places in my code, which are not OTP: > > 1) gen_server:call changed to implementation without additional > erlang:monitor, because caller already has monitor. > It reduced load. Note, however, that a new optimization in the OTP "dev" branch makes selective message reception O(1), i.e. insensitive to the length of the message queue - given that it can be determined at compile-time that the receive patterns can not match any message received before a certain time. The way to achieve this is to create a unique reference (make_ref/1 or monitor/2), and then use that reference in each receive clause, e.g. call(P, Req, T) -> Ref = erlang:monitor(process, P), P ! {'$req', {self(), Ref}, Req}, receive {Ref, Reply} -> Reply; {'DOWN', Ref, _, _, Reason} -> erlang:error(Reason, [P, Req, T]) after T -> erlang:error(timeout, [P, Req, T]) end. My guess (not having dug into the code to verify) is that you can substitute a call to make_ref() for the monitor call, but a pre-existing monitor ref would not suffice. What the compiler does is basically transform it into this: call(P, Req, T) -> Ref = erlang:monitor(process, P), P ! {'$req', {self(), Ref}, Req}, receive {Ref, Reply} -> Reply; {'DOWN', Ref, _, _, Reason} -> erlang:error(Reason, [P, Req, T]) after T -> erlang:error(timeout, [P, Req, T]) end. ...but at the BEAM ASM level, where and are new instructions, marking the end of the message queue, and then jumping to that mark and doing the receive processing from there. In other words, removing the monitor may not in all cases result in faster code. It could well be the other way around. The gen:call() function has been refactored to make this compiler optimization possible (i.e. await_reply() has been inlined.) This is in some sense indicative of how the OTP team approaches optimizations. They tend to focus on changes that make "textbook" Erlang run faster, rather than going for impressive benchmark performance. They are a bit boring that way, but it is a very good reason to stick to the "mainstream" way of coding. BR, Ulf W -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From johanmon@REDACTED Thu Jun 3 10:46:46 2010 From: johanmon@REDACTED (Johan Montelius) Date: Thu, 03 Jun 2010 10:46:46 +0200 Subject: [erlang-questions] monitor and failure detectors In-Reply-To: <4C0766DA.3030100@erlang-solutions.com> References: <1275540584.5087.2.camel@seasc1137> <4C0766DA.3030100@erlang-solutions.com> Message-ID: Ok, so it's a global parameter for all monitors. From a application level point of view it could be an advantage to have this as a per monitor value. When a node does terminate in a controlled way, does it not inform other nodes that it is terminating? Does it only close the connections to other nodes and let them trigger on the closed connection. A smother way woudl be to send a last "bye" message and let them report that the node and all processes of that node are down. -- Is the description in the manual ok? "if nothing has been received from another node within the last four (4) tick times" should it not read "if nothing has been received from another node within the last four (4) ticks" It's confusing that "tick times" is not "ticktime". "TickTime is by default 60 (seconds). Thus, 45 < T < 75 seconds." How can T be smaller than 60? If a node dies then we have to wait for at least 4 ticks (60 s) before we detect it. If we are unlucky it could take 60+15 but how could it be 45? Johan On Thu, 03 Jun 2010 10:24:58 +0200, Ulf Wiger wrote: > > Monitors have no timeout. They trigger immediately when either > the process dies or the node of the process is disconnected. > > Is it the latter event that you are referring to? > This can be configured using -kernel net_ticktime T, where > T is 60 seconds by default. > > See http://www.erlang.org/doc/man/kernel_app.html > > "net_ticktime = TickTime > > Specifies the net_kernel tick time. > TickTime is given in seconds. Once every TickTime/4 second, > all connected nodes are ticked (if anything else has been > written to a node) and if nothing has been received from > another node within the last four (4) tick times that node > is considered to be down. This ensures that nodes which are > not responding, for reasons such as hardware errors, are > considered to be down. > > The time T, in which a node that is not responding is > detected, is calculated as: MinT < T < MaxT where: > > MinT = TickTime - TickTime / 4 > MaxT = TickTime + TickTime / 4 > > TickTime is by default 60 (seconds). Thus, 45 < T < 75 seconds. > > Note: All communicating nodes should have the same TickTime value > specified. > > Note: Normally, a terminating node is detected immediately." > > BR, > Ulf W > > Johan Montelius wrote: >> >> Some question on monitors: >> >> Is there a way to change the timeout of monitors to configure how eager >> they will be to deliver a DOWN/noconnection message? Can this be changed >> on a per monitor basis so one could monitor one process with a 0.1s >> timeout and another with a 20s timeout? >> >> >> I guess it is the empd daemon that is responsible for tracking the state >> of nodes on a host. If a node crashes a monitor will report >> DOWN/noconnection. Could it be possible to have monitor generate a >> DOWN/down or similar when/if it can be determined that the node (and >> thus the process that we monitor) is actually down. The >> DOWN/noconnection message leaves us in a state where we don't know it is >> down or simply disconnected. >> >> Johan > > -- Associate Professor Johan Montelius Royal Institute of Technology - KTH School of Information and Communication Technology - ICT From alex.arnon@REDACTED Thu Jun 3 10:50:54 2010 From: alex.arnon@REDACTED (Alex Arnon) Date: Thu, 3 Jun 2010 11:50:54 +0300 Subject: [erlang-questions] EUnit Help In-Reply-To: <4A36B10B.6080209@it.uu.se> References: <007170FE7206414489341A0BC625CF1F@SSI.CORP> <4A36B10B.6080209@it.uu.se> Message-ID: Hi, I am also running into a similar issue with my tests. I am running unit tests that spawn-link a gen_server (tests are defined in same module), then send it a shut down request. The tests work on R12B5, but fail with the following on R13B1 and R13B4. Note that the final error is different from David's: (emacs@REDACTED)2> eunit:test(dbr_status_server). dbr_status_server: server_stop_0_test...*skipped* undefined *unexpected termination of test process* ::shutdown ======================================================= Failed: 0. Skipped: 0. Passed: 1. One or more tests were cancelled. error A unit test that does not invoke the gen_server passes with no problem (see 'Passed: 1' above). Please help! :) On Mon, Jun 15, 2009 at 11:37 PM, Richard Carlsson wrote: > David Mercer wrote: > >> *unexpected termination of test process* >> >> ::{badarg,[{io,put_chars,[<0.133.0>,unicode,<<>>]}, >> {eunit_proc,handle_test,2}, >> {eunit_proc,tests_inorder,3}, >> {eunit_proc,with_timeout,3}, >> {eunit_proc,run_group,2}, >> {eunit_proc,child_process,2}]} >> > > Are you running R13B (not R13B01) with an unpatched EUnit? In that case, > either install the fixed 2.1.1 version that can be found on the download > page (http://www.erlang.org/download.html), or upgrade to R13B01. Sorry > for the inconvenience. > > /Richard > > > ________________________________________________________________ > erlang-questions mailing list. See http://www.erlang.org/faq.html > erlang-questions (at) erlang.org > > From max.lapshin@REDACTED Thu Jun 3 10:50:55 2010 From: max.lapshin@REDACTED (Max Lapshin) Date: Thu, 3 Jun 2010 12:50:55 +0400 Subject: [erlang-questions] OTP Efficiency In-Reply-To: <4C076AAE.2020800@erlang-solutions.com> References: <4C076AAE.2020800@erlang-solutions.com> Message-ID: > This is in some sense indicative of how the OTP team approaches > optimizations. They tend to focus on changes that make "textbook" > Erlang run faster, rather than going for impressive benchmark > performance. They are a bit boring that way, but it is a very > good reason to stick to the "mainstream" way of coding. > Thank you for such wide explanation. I will repeat my tests right after release. From info@REDACTED Thu Jun 3 12:52:09 2010 From: info@REDACTED (info) Date: Thu, 3 Jun 2010 12:52:09 +0200 Subject: how to interface a mysql database ? Message-ID: <201006031252091525836@its3.ch> For the time beeing, what is at disposal to interface a mysql database ? - the ODBC driver - the Yariv's driver What else ? John From kaiduanx@REDACTED Thu Jun 3 14:14:33 2010 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Thu, 3 Jun 2010 08:14:33 -0400 Subject: [erlang-questions] my socket can't handle the load In-Reply-To: <576214.89312.qm@web112601.mail.gq1.yahoo.com> References: <576214.89312.qm@web112601.mail.gq1.yahoo.com> Message-ID: Pablo, you can use erlang:process_info(Pid, message_queue_len) to find the mail box size of gen_server. On Thu, Jun 3, 2010 at 2:52 AM, Pablo Platt wrote: > p.s. > when getting a gen_server:call timeout the debug message of the > requester(not the socket gen_server) says: > heap_size: 1597 > stack_size: 24 > reductions: 1996 > > > ________________________________ > From: Pablo Platt > To: Kaiduan Xie ; Bernard Duggan > Cc: Erlang > Sent: Thu, June 3, 2010 9:49:17 AM > Subject: Re: [erlang-questions] my socket can't handle the load > > @Bernard, Kaiduan > When I'm testing with a pool of 20 connections instead of 1, the driver and > socket works fine. > I think that means that both the receiver (database) and the sender can > handle the load. > When sending one request at a time from the same socket it also works fine > but don't think this is the correct design. > > I don't think {active, once} is relevant here because responses from the db > will only arrive when I make requests > so I don't need to protect myself against DOS from untrusted third party. > > When getting a timeout on gen_server:call to the socket gen_server, how can > I print useful info > about the socket gen_server and the process calling it so I can see the > mailbox queue of them and maybe other useful > stuff that help me find the problem? > > Thanks > > ________________________________ > From: Kaiduan Xie > To: Bernard Duggan > Cc: Pablo Platt ; Erlang > > Sent: Thu, June 3, 2010 3:59:02 AM > Subject: Re: [erlang-questions] my socket can't handle the load > > Pablo, > > Have you considered any chance the call of > gen_tcp:send(State#state.socket, Packet) getting blocked? For example, > a slow receiver. If gen_tcp:send() is getting blocked, hand_call() > will get blocked, and gen_server will slow down. Please look the > example listed in gen_tcp, > > http://www.erlang.org/doc/man/gen_tcp.html#examples > > Kaiduan > > On Wed, Jun 2, 2010 at 5:35 PM, Bernard Duggan wrote: >> Hi Pablo, >> ? ?One thing you may want to try is to wherever possible, avoid letting >> the queue on your gen_server grow beyond a couple of messages. ?Allowing >> the queue to grow unchecked can cause serious performance degradation on >> selective receives (which, to be fair, I can't see any of in your code, >> but they can crop up in non-obvious library calls at times). >> Off the top of my head, you'd do this by: >> a) changing the handle_cast operation to a handle_call (to keep clients >> using that operation from flooding you with requests) and >> b) changing {active, true} to {active, once} in your connect call (and >> making the corresponding change in handle_info to reactivate the socket. >> >> It may or may not be your problem, but it's a fairly easy change and >> worth a try. >> >> Another possibility is that you have the same issue, but in the calling >> process (I'm guessing now, since you haven't provided that code). ?A >> gen_server call does a selective receive while it waits for a response - >> if your message queue is very large when you make the call, there's a >> good chance you'll get a timeout regardless of how quickly the >> gen_server serves the request. >> >> Cheers, >> >> Bernard >> >> On 3/06/2010 1:27 AM, Pablo Platt wrote: >>> Hi, >>> >>> I'm writing a driver to a database that is using a tcp socket. >>> There are two types of messages, "send and forget" and "send and >>> receive". >>> I have a gen_server that is responsible for opening the socket, receive a >>> message from a process and sending it to the socket and receive responses >>> and pass them to the caller. >>> The gen_server saves a list of {request_id, CallerPid} in the state to >>> know who to respond to when a packet is received from the db. >>> >>> Everything works when the rate of messages is low but when increasing it >>> I'm starting to get gen_server timeout error on the requestor. >>> Do I need to add/change parameters when opening the socket? >>> Should I queue requests and wait for a response before sending the next >>> request or is it ok to send several requests one after the other? >>> >>> Thanks >>> >>> The client sends a request using either: >>> Resp = gen_server:call(Conn, {request, Request}) >>> or >>> gen_server:cast(Conn, {request, Request}) >>> >>> >>> The relevant gen_server code: >>> >>> init([Host, Port]) -> >>> ? ? Socket = open_socket(Host, Port), >>> ? ? {ok, #state{socket=Socket, req_id=1}}. >>> >>> open_socket(Host, Port) -> >>> ? ? case gen_tcp:connect(Host, Port, [binary, {active, true}]) of >>> ? ? ? ? {ok, Sock} -> >>> ? ? ? ? ? ? Sock; >>> ? ? ? ? {error, Reason} -> >>> ? ? ? ? ? ? exit({open_socket_failed, Reason}) >>> ? ? end. >>> >>> handle_call({request, Packet}, From, State) -> >>> ? ? ReqID = State#state.req_id + 1, >>> ? ? gen_tcp:send(State#state.socket, Packet), >>> ? ? {noreply, State#state{req_id=ReqID, requests=[{ReqID, >>> From}|State#state.requests]}}; >>> >>> handle_cast({request, Packet}, State) -> >>> ? ? ReqID = State#state.req_id + 1, >>> ? ? gen_tcp:send(State#state.socket, Packet), >>> ? ? {noreply, State#state{req_id=ReqID}}. >>> >>> handle_info({tcp, _Socket, Data}, State) -> >>> ? ? RawResp = <<(State#state.resp)/binary, Data/binary>>, >>> ? ? case check_packet:decode_response(RawResp) of >>> ? ? ? ? undefined -> >>> ? ? ? ? ? ? {noreply, State#state{resp = RawResp}}; >>> ? ? ? ? {Resp, Tail} -> >>> ? ? ? ? ? ? ResponseTo = get_requestor(Resp), >>> ? ? ? ? ? ? {value, {ResponseTo, Client}, NewRequests} = >>> lists:keytake(ResponseTo, 1, State#state.requests), >>> ? ? ? ? ? ? gen_server:reply(Client, Resp), >>> ? ? ? ? ? ? {noreply, State#state{resp = Tail, requests=NewRequests}} >>> ? ? end; >>> >>> % the following never been called, even when I'm getting the error. >>> handle_info({tcp_closed, _Socket}, State) -> >>> ? ? {noreply, State}; >>> >>> handle_info({tcp_error, _Socket, _Reason}, State) -> >>> ? ? {noreply, State}. >>> >>> terminate(_Reason, _State) -> >>> ? ? ok. >>> >>> >>> >>> >> >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> > > > From thomasl_erlang@REDACTED Thu Jun 3 14:57:19 2010 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 3 Jun 2010 05:57:19 -0700 (PDT) Subject: Syslog-ng clients? Message-ID: <578320.13769.qm@web111404.mail.gq1.yahoo.com> Hi all, I'd like to log my erlang stuff to syslog-ng but haven't found any well-known code for doing this. Any recommendations? Thanks in advance. Best, Thomas From max.lapshin@REDACTED Thu Jun 3 16:01:55 2010 From: max.lapshin@REDACTED (Max Lapshin) Date: Thu, 3 Jun 2010 18:01:55 +0400 Subject: [erlang-questions] Syslog-ng clients? In-Reply-To: <578320.13769.qm@web111404.mail.gq1.yahoo.com> References: <578320.13769.qm@web111404.mail.gq1.yahoo.com> Message-ID: On Thu, Jun 3, 2010 at 4:57 PM, Thomas Lindgren wrote: > Hi all, > > I'd like to log my erlang stuff to syslog-ng but haven't found any well-known code for doing this. Any recommendations? Thanks in advance. > log4erl syslog_appender ? From info@REDACTED Thu Jun 3 16:34:48 2010 From: info@REDACTED (info) Date: Thu, 3 Jun 2010 16:34:48 +0200 Subject: odbc and mysql Message-ID: <201006031634479215349@its3.ch> Hi all, Do you see why these lines are correct: SQL1="select Id_Zone from zones where ( Id_ref= '10' )", {selected,Cols1,Rows1}=odbc:sql_query(Ref,SQL1), But this one ... {selected,["Id_Zone"],[{Idz}]=odbc:sql_query(Ref,SQL1), ... returns the following message: Exception error: no match of right hand side value {selected,["Id_Zone"],[{101}] Are there restrictions with odbc ? columns syntax ? types of data ? From attila.r.nohl@REDACTED Thu Jun 3 16:45:55 2010 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Thu, 3 Jun 2010 16:45:55 +0200 Subject: [erlang-questions] odbc and mysql In-Reply-To: <201006031634479215349@its3.ch> References: <201006031634479215349@its3.ch> Message-ID: There's obviously a syntax error in the second example, but probably it's not the one that you're interested in :-) Could you print the values of Cols1 and Rows1? 2010/6/3, info : > Hi all, > Do you see why these lines are correct: > > SQL1="select Id_Zone from zones where ( Id_ref= '10' )", > {selected,Cols1,Rows1}=odbc:sql_query(Ref,SQL1), > > But this one ... > {selected,["Id_Zone"],[{Idz}]=odbc:sql_query(Ref,SQL1), > ... returns the following message: > Exception error: no match of right hand side value > {selected,["Id_Zone"],[{101}] > > Are there restrictions with odbc ? columns syntax ? types of data ? > From reachsaurabhnarula@REDACTED Thu Jun 3 19:02:45 2010 From: reachsaurabhnarula@REDACTED (Saurabh Narula) Date: Thu, 3 Jun 2010 22:32:45 +0530 Subject: =?UTF-8?Q?Sending_String_with_Unicode_Currency_Symbols_=28like_?= =?UTF-8?Q?=E2=82=A1=29_from_erlang_to_C_language_NIF_=28Native_Implemented_funct?= =?UTF-8?Q?ions=29?= Message-ID: Hello Everyone, i am trying to send erlang string from erlang program to the NIF (Native Implemented functions) written in C language. While sending the string from erlang I have an option of specifying the encoding. The functions that help me achieve this are ERL_NIF_TERM enif_make_string(ErlNifEnv* env, const char* string, ErlNifCharEncoding encoding) int enif_get_string(ErlNifEnv* env, ERL_NIF_TERM list, char* buf, unsigned size, ErlNifCharEncoding encode) The only supported encoding is currently ERL_NIF_LATIN1 for iso-latin-1 (8-bit ascii), and while sending it back to the erlang I can specify the encoding as ERL_NIF_LATIN1, which is the only option right now. My issue is that my string contains Unicode currency symbols like ?, as the encoding currently only supports ERL_NIF_LATIN1, there is no way the NIF library can understand unicode currency symbols. Does anybody has any workaround for this? I want to thank you in advance, and would really appreciate any help from the members. Regards, Saurabh From bob@REDACTED Thu Jun 3 19:15:29 2010 From: bob@REDACTED (Bob Ippolito) Date: Thu, 3 Jun 2010 10:15:29 -0700 Subject: =?UTF-8?Q?Re=3A_=5Berlang=2Dquestions=5D_Sending_String_with_Unicode_C?= =?UTF-8?Q?urrency_Symbols_=28like_=E2=82=A1=29_from_erlang_to_C_language_NIF_=28Na?= =?UTF-8?Q?tive_Implemented_functions=29?= In-Reply-To: References: Message-ID: On Thu, Jun 3, 2010 at 10:02 AM, Saurabh Narula wrote: > Hello Everyone, > > i am trying to send erlang string from erlang program to the NIF > (Native Implemented functions) written in C language. > > While sending the string from erlang I have an option of specifying > the encoding. The functions that help me achieve this are > > ERL_NIF_TERM enif_make_string(ErlNifEnv* env, const char* string, > ErlNifCharEncoding encoding) > int enif_get_string(ErlNifEnv* env, ERL_NIF_TERM list, char* buf, > unsigned size, ErlNifCharEncoding encode) > > The only supported encoding is currently ERL_NIF_LATIN1 for > iso-latin-1 (8-bit ascii), and while sending it back to the erlang I > can specify the encoding as ERL_NIF_LATIN1, which is the only option > right now. > > My issue is that my string contains Unicode currency symbols like ?, > as the encoding currently only supports ERL_NIF_LATIN1, there is no > way the NIF library can understand unicode currency symbols. Does > anybody has any workaround for this? You could use a UTF-8 encoded binary instead of a list. -bob From info@REDACTED Thu Jun 3 19:08:43 2010 From: info@REDACTED (info) Date: Thu, 3 Jun 2010 19:08:43 +0200 Subject: [erlang-questions] odbc and mysql References: <201006031634479215349@its3.ch>, Message-ID: <201006031908424198072@its3.ch> Cols1= ["Id_Zone"] Rows1= [{101}] There's obviously a syntax error in the second example, but probably it's not the one that you're interested in :-) Could you print the values of Cols1 and Rows1? 2010/6/3, info : > Hi all, > Do you see why these lines are correct: > > SQL1="select Id_Zone from zones where ( Id_ref= '10' )", > {selected,Cols1,Rows1}=odbc:sql_query(Ref,SQL1), > > But this one ... > {selected,["Id_Zone"],[{Idz}]=odbc:sql_query(Ref,SQL1), > ... returns the following message: > Exception error: no match of right hand side value > {selected,["Id_Zone"],[{101}] > > Are there restrictions with odbc ? columns syntax ? types of data ? > ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED From w.a.de.jong@REDACTED Thu Jun 3 19:31:41 2010 From: w.a.de.jong@REDACTED (Willem de Jong) Date: Thu, 3 Jun 2010 19:31:41 +0200 Subject: [erlang-questions] SOAP Call In-Reply-To: References: <11599093-2d42-478d-b0b6-12e47be9699e@p5g2000pri.googlegroups.com> Message-ID: Hi, The problem is that this uses SOAP 1.2 binding. This isn't supported. Do you have the option to use version 1.1? Regards, Willem On Wed, Jun 2, 2010 at 12:26 PM, Hisham wrote: > Hi Willem, > > Appreciate your reply (as always :D) > Please find the attached file. Not sure if attachment is allowed, but I put > the main email to you. > > > On Wed, Jun 2, 2010 at 6:16 PM, Willem de Jong wrote: > >> Hello, >> >> Can you show us the WSDL? >> >> Regards, >> Willem >> >> On Wed, Jun 2, 2010 at 11:29 AM, Hisham wrote: >> >>> Hi, >>> >>> >>> I have below operation: >>> >>> 1> Wsdl = yaws_soap_lib:initModel("SDPServices.wsdl"). >>> {wsdl,[], >>> {model,[{type,'_document',sequence, >>> [{el,[{alt,'soap:Header','soap:Header',[], >>> 1,1,true, >>> undefined}, >>> {alt,'soap:Fault','soap:Fault',[], >>> 1,1,true,undefined}, >>> {alt,'soap:Envelope','soap:Envelope',[], >>> 1,1,true,undefined}, >>> {alt,'soap:Body','soap:Body',[], >>> 1,1,true,undefined}, >>> {...}|...], >>> 3> yaws_soap_lib:wsdl_operations(Wsdl). >>> [] >>> 4> >>> >>> My concern is, I have "zero" operations after parsing the WSDL as >>> shown in 3> above. >>> I browse through the web, and some says I have to trim the >>> "nillable=true" out, and it should be fine. >>> That was done, but still the operations are zero. >>> >>> Anybody can pin point to the right direction? >>> >>> TIA. >>> >>> ________________________________________________________________ >>> erlang-questions (at) erlang.org mailing list. >>> See http://www.erlang.org/faq.html >>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>> >>> >> > From maruthavanan_s@REDACTED Thu Jun 3 19:29:31 2010 From: maruthavanan_s@REDACTED (maruthavanan s) Date: Thu, 3 Jun 2010 13:29:31 -0400 Subject: [erlang-questions] SQLite ODBC In-Reply-To: References: ,, Message-ID: Hi, Thanks a lot for the info. I could not get this get work for windows. I could not build the priv directory. Where can I find this exe? Regards, Marutha > Date: Mon, 26 Apr 2010 21:57:57 +0200 > From: ingela.andin@REDACTED > To: rtrlists@REDACTED > CC: maruthavanan_s@REDACTED; erlang-questions@REDACTED > Subject: Re: [erlang-questions] SQLite ODBC > > 2010/4/26 Robert Raschke : > > On Mon, Apr 26, 2010 at 12:44 PM, maruthavanan s >> wrote: > > > >> > >> Hi, > >> > >> I want to connect SQLite to ODBC drivers. Is this possible with latest > >> version? > >> > >> I was able to successfully connection but when I try to get the columns I > >> fail with "no column supported" error. > >> > >> Thanks, > >> Marutha > >> > > > > > > The Erlang ODBC lib does not currently support Unicode. You will need to > > convert Unicode columns as part of your query. For example, by using ODBC > > conversion functions: > > SELECT {fn CONVERT(unicode_column, SQL_VARCHAR)} "char_column" FROM table > > There will be some unicode support in the upcoming release, now > available in github if you are interested. > > Regards Ingela, Erlang OTP team, Ericsson AB > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > From ovidiudeac@REDACTED Thu Jun 3 20:00:29 2010 From: ovidiudeac@REDACTED (Ovidiu Deac) Date: Thu, 3 Jun 2010 21:00:29 +0300 Subject: How to make the Erlang VM predictible when spawning processes? Message-ID: Hello everybody, I'm doing some research in order to figure out if Erlang is suitable for an application that we need to implement. In a few words it's about a server which has a requirement saying "no request should take more then 10ms"', measured on the client's computer. So I started a couple of tests for various erlang components to figure out how much some operations would take. Partly because I wanted to get some figures and partly to exercise my Erlang skills. First I wrote a profiler module which can measure the execution time for various modules which implement set_up,tear_down and test_main. Also this profiler can repeat a test a number of times and returns a list with all the execution times, the minimum, the maximum and the average time. Nothing fancy. See the attachment for the profiler code and I post below some results for a test that I ran on a machine with Intel Core2 Duo/Win7/erlang v5.7.5. One test consists in 1000 spawns and is repeated 100 times. The times displayed are microseconds. $ make -C .. && erl +P 200000 -noshell -s profiler run spawn_test 100 silent 0 1000 -s init stop make: Entering directory `/cygdrive/d/work/erlang/finn' make: Leaving directory `/cygdrive/d/work/erlang/finn' Module to test:spawn_test, Repeats:100, Params=[silent,'0','1000'] Times elapsed = [1,15998,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1,15991,1,1,1,1, 14991,1,1,1,1,15991,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1, 15991,1,1,1,1,1,14989,1,1,1,1,15991,1,1,1,1,15991,1,1,1, 14993,1,1,1,15993,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1,15991, 1,1,1,1,14991,1,1,1,15993,1,1,1,1,15991,1,1,1,1,14991] Max us/execution=15998 Min us/execution=1 Variation=15997 Average us/execution=3279.01 The average time for spawning a process is around 3us which is very good. It's interesting to see that spawning 1000 processes took 1microsecond (!!!) Looks like some bug it the profiler. Also my main concern is that from time to time spawning a process takes around 15ms which is way too much. I tried to run erl +P 200000 but the behaviour is the same as without this parameter. Do you have any idea how to make the VM predictible in order to satisfy the 10ms requirement? Thanks in advance, Ovidiu -------------- next part -------------- A non-text attachment was scrubbed... Name: profiler.erl Type: application/octet-stream Size: 1420 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: spawn_test.erl Type: application/octet-stream Size: 1236 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: tools.erl Type: application/octet-stream Size: 236 bytes Desc: not available URL: From maruthavanan_s@REDACTED Thu Jun 3 20:29:16 2010 From: maruthavanan_s@REDACTED (maruthavanan s) Date: Thu, 3 Jun 2010 14:29:16 -0400 Subject: [erlang-questions] SQLite ODBC In-Reply-To: References: ,,, Message-ID: Hi, I somehow succedded by doing something to get the sqlite_port.exe but I get a run time error. What I did is created a library file using sqlite3.def and sqlite3.dll. Then linked the priv directory so that all ei and erl_interface libraries are included. But finally I could not succeed. Can any one help me to find this where I am doing wrong? I have attached the file as exe1 instead of exe for security reasons. Thanks, Marutha > From: maruthavanan_s@REDACTED > To: ingela.andin@REDACTED; rtrlists@REDACTED > CC: erlang-questions@REDACTED > Date: Thu, 3 Jun 2010 13:29:31 -0400 > Subject: RE: [erlang-questions] SQLite ODBC > > > Hi, > > Thanks a lot for the info. I could not get this get work for windows. I could not build the priv directory. Where can I find this exe? > > Regards, > Marutha > > > Date: Mon, 26 Apr 2010 21:57:57 +0200 > > From: ingela.andin@REDACTED > > To: rtrlists@REDACTED > > CC: maruthavanan_s@REDACTED; erlang-questions@REDACTED > > Subject: Re: [erlang-questions] SQLite ODBC > > > > 2010/4/26 Robert Raschke : > > > On Mon, Apr 26, 2010 at 12:44 PM, maruthavanan s > >> wrote: > > > > > >> > > >> Hi, > > >> > > >> I want to connect SQLite to ODBC drivers. Is this possible with latest > > >> version? > > >> > > >> I was able to successfully connection but when I try to get the columns I > > >> fail with "no column supported" error. > > >> > > >> Thanks, > > >> Marutha > > >> > > > > > > > > > The Erlang ODBC lib does not currently support Unicode. You will need to > > > convert Unicode columns as part of your query. For example, by using ODBC > > > conversion functions: > > > SELECT {fn CONVERT(unicode_column, SQL_VARCHAR)} "char_column" FROM table > > > > There will be some unicode support in the upcoming release, now > > available in github if you are interested. > > > > Regards Ingela, Erlang OTP team, Ericsson AB > > > > ________________________________________________________________ > > erlang-questions (at) erlang.org mailing list. > > See http://www.erlang.org/faq.html > > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: sqlite_port.exe1 Type: application/octet-stream Size: 64000 bytes Desc: not available URL: From info@REDACTED Thu Jun 3 23:57:48 2010 From: info@REDACTED (info) Date: Thu, 3 Jun 2010 23:57:48 +0200 Subject: [erlang-questions] odbc and mysql References: <201006031634479215349@its3.ch>, , <201006031908424198072@its3.ch>, Message-ID: <201006032357483177267@its3.ch> No. Impossible. Is it possible that the Idz variable was already bound? 2010/6/3, info : > Cols1= ["Id_Zone"] > Rows1= [{101}] > > There's obviously a syntax error in the second example, but probably > it's not the one that you're interested in :-) Could you print the > values of Cols1 and Rows1? > > 2010/6/3, info : > > Hi all, > > Do you see why these lines are correct: > > > > SQL1="select Id_Zone from zones where ( Id_ref= '10' )", > > {selected,Cols1,Rows1}=odbc:sql_query(Ref,SQL1), > > > > But this one ... > > {selected,["Id_Zone"],[{Idz}]=odbc:sql_query(Ref,SQL1), > > ... returns the following message: > > Exception error: no match of right hand side value > > {selected,["Id_Zone"],[{101}] > > > > Are there restrictions with odbc ? columns syntax ? types of data ? > > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > From thomasl_erlang@REDACTED Thu Jun 3 23:12:04 2010 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 3 Jun 2010 14:12:04 -0700 (PDT) Subject: [erlang-questions] Syslog-ng clients? In-Reply-To: References: <578320.13769.qm@web111404.mail.gq1.yahoo.com> Message-ID: <985641.16367.qm@web111402.mail.gq1.yahoo.com> ----- Original Message ---- > From: Max Lapshin > I'd like to log my erlang stuff to > syslog-ng but haven't found any well-known code for doing this. Any > recommendations? Thanks in advance. > log4erl syslog_appender > ? Thanks Max, I'll take a look at that. Best, Thomas From hd2010@REDACTED Fri Jun 4 00:12:56 2010 From: hd2010@REDACTED (Henning Diedrich) Date: Fri, 04 Jun 2010 00:12:56 +0200 Subject: Missing SQL Message-ID: <4C0828E8.2020107@eonblast.com> Harald Weppner and I got into a brief exchange about his experience using key-value-stores. One central theme ran like this: "The main issue with key-value stores and dropping SQL is that relationships don't magically go away and that you constantly juggle the question of whether it's better to represent relationships in the value or in the key." More here: http://www.eonblast.com/blog/missing-sql/ Disclaimer: I am currently working on Erlvolt, which is an Erlang API to VoltDB, which promises scaling, ACID and SQL. Obviously I like that promise a lot. Before anyone get's sad, let me just say that there are different tools best suited for different applications. Henning From ovidiudeac@REDACTED Fri Jun 4 00:45:26 2010 From: ovidiudeac@REDACTED (Ovidiu Deac) Date: Fri, 4 Jun 2010 01:45:26 +0300 Subject: How to make the Erlang VM predictible when spawning processes? In-Reply-To: References: Message-ID: I'm back with some tests that I've just ran on an Intel Core i5/Linux 2.6.32/erts v5.7.4. The results look more credible since 1000 processes are no longer spawned in 1microsecond. Also the variance between separate test executions is much smaller. But the problem remains if I spawn 1 milion processes I come across spawns which take up to 18milliseconds. So again, any idea about how I could make the VM to be predictible? I assume that I should find the level of load that it can take. Reusing processes as I would have done in other languages sounds like a bad idea from start. Also I'm thinking I could increase the work done by one process such that it's not too small but still it fits inside the initial heap size so garbage collection is not needed. Also another thing that I observed is that during the test only about 50% out of each processor seems to be used. At least this is what the system monitor says. Any VM flags that would help with this? I tried +P and +S but without results. Ovidiu On Thu, Jun 3, 2010 at 9:00 PM, Ovidiu Deac wrote: > Hello everybody, > > I'm doing some research in order to figure out if Erlang is suitable > for an application that we need to implement. > > In a few words it's about a server which has a requirement saying "no > request should take more then 10ms"', measured on the client's > computer. > > So I started a couple of tests for various erlang components to figure > out how much some operations would take. Partly because I wanted to > get some figures and partly to exercise my Erlang skills. > > First I wrote a profiler module which can measure the execution time > for various modules which implement set_up,tear_down and test_main. > Also this profiler can repeat a test a number of times and returns a > list with all the execution times, the minimum, the maximum and the > average time. Nothing fancy. > > See the attachment for the profiler code and I post below some results > for a test that I ran on a machine with Intel Core2 Duo/Win7/erlang > v5.7.5. One test consists in 1000 spawns and is repeated 100 times. > The times displayed are microseconds. > > $ make -C .. && erl +P 200000 -noshell -s profiler run spawn_test 100 > silent 0 1000 -s init stop > make: Entering directory `/cygdrive/d/work/erlang/finn' > make: Leaving directory `/cygdrive/d/work/erlang/finn' > Module to test:spawn_test, Repeats:100, Params=[silent,'0','1000'] > Times elapsed = [1,15998,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1,15991,1,1,1,1, > ? ? ? ? ? ? ? ? 14991,1,1,1,1,15991,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1, > ? ? ? ? ? ? ? ? 15991,1,1,1,1,1,14989,1,1,1,1,15991,1,1,1,1,15991,1,1,1, > ? ? ? ? ? ? ? ? 14993,1,1,1,15993,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1,15991, > ? ? ? ? ? ? ? ? 1,1,1,1,14991,1,1,1,15993,1,1,1,1,15991,1,1,1,1,14991] > Max us/execution=15998 > Min us/execution=1 > Variation=15997 > Average us/execution=3279.01 > > The average time for spawning a process is around 3us which is very > good. It's interesting to see that spawning 1000 processes took > 1microsecond (!!!) Looks like some bug it the profiler. Also my main > concern is that from time to time spawning a process takes around 15ms > which is way too much. > > I tried to run erl +P 200000 but the behaviour is the same as without > this parameter. > > Do you have any idea how to make the VM predictible in order to > satisfy the 10ms requirement? > > Thanks in advance, > Ovidiu > From ok@REDACTED Fri Jun 4 03:00:06 2010 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 4 Jun 2010 13:00:06 +1200 Subject: Overriding built-in functions in a module Message-ID: There is currently a discussion going on in the SWI Prolog mailing list about the way user code can break when a new operation is added to the system. Alan Baljeu takes the reasonable position that What's needed for stability ... is ... Whatever I define within a module is the definition used within [that] module. The local [operations] supersede imported [ones]. Warn if something is shadowed, but allow it. I was about to gloat about Erlang getting this right, and then I thought I had better try it. Consider the following module. 1 -module(foo). 2 -export([bar/0]). 3 4 bar() -> spawn(fun (X) -> X+1 end). 5 6 spawn(F) -> F(41). where we're expecting foo:bar() to return 42. erlc reports /foo.erl:4: Warning: call to spawn/1 will call erlang:spawn/1; not spawn/1 in this module (add an explicit module name to the call to avoid this warning) ./foo.erl:6: Warning: defining BIF spawn/1 ./foo.erl:6: Warning: function spawn/1 is unused The second message is clearly WRONG: this _can't_ be defining the built-in function erlang:spawn/1 because this isn't the erlang: module. What's more, it clearly DIDN'T define erlang:spawn/1; the last message complains that there *is* a function spawn/1 in this module which is not used. So let's do what the first error message says: * 4 bar() -> ?MODULE:spawn(fun (X) -> X+1 end). m% erlc foo.erl ./foo.erl:6: Warning: defining BIF spawn/1 ./foo.erl:6: Warning: function spawn/1 is unused There's an explicit call there, how can it not be used? Change it again, so that now it reads * 1 -module(foo). 2 -export([bar/0,spawn/1]). 3 * 4 bar() -> ?MODULE:spawn(fun (X) -> X+1 end). 5 6 spawn(F) -> F(41). Erlc is now silent, and foo:bar() gives the expected answer. The price is that a function which was never meant to be exported (and because of the clash with a built in function never _should_ be exported, to avoid confusion) *has* to be exported, and a call to a purely local function has to be a remote call. This is silly. I chose spawn/1 as an example of a function that *was* added as a pervasive export from erlang: long after people had been using Erlang, and rightly so. There's no reason to believe that this is the last such function to be *rightly* added. We need the following things: (1) If a function f/n is defined in a module, then any calls to f/n without a module prefix refer to THAT definition. (2) The warning message for a definition of such a function should not say that it is defining a BIF but that it is defining a function with the same NAME as a BIF, e.g., ./foo.erl:6: Warning: there is a BIF called spawn/1; to use the BIF you will need an erlang: prefix. (3) Such warnings are useful, but sometimes it is intentional, so a directive such as -private([spawn/1]). would be useful to silence the warning while giving human readers (and the compiler!) adequate notice. (Amongst other things, in a code review, it is easier to grep for -private than to gather compiler warnings.) I'm sure I've seen a proposal like this before, so I haven't written up an EEP for it yet. From rvirding@REDACTED Fri Jun 4 03:27:07 2010 From: rvirding@REDACTED (Robert Virding) Date: Fri, 4 Jun 2010 03:27:07 +0200 Subject: =?UTF-8?Q?Re=3A_=5Berlang=2Dquestions=5D_Sending_String_with_Unicode_C?= =?UTF-8?Q?urrency_Symbols_=28like_=E2=82=A1=29_from_erlang_to_C_language_NIF_=28Na?= =?UTF-8?Q?tive_Implemented_functions=29?= In-Reply-To: References: Message-ID: What do you intend to do with the string when you have it in C? In what format would you like it? Robert On 3 June 2010 19:02, Saurabh Narula wrote: > Hello Everyone, > > i am trying to send erlang string from erlang program to the NIF > (Native Implemented functions) written in C language. > > While sending the string from erlang I have an option of specifying > the encoding. The functions that help me achieve this are > > ERL_NIF_TERM enif_make_string(ErlNifEnv* env, const char* string, > ErlNifCharEncoding encoding) > int enif_get_string(ErlNifEnv* env, ERL_NIF_TERM list, char* buf, > unsigned size, ErlNifCharEncoding encode) > > The only supported encoding is currently ERL_NIF_LATIN1 for > iso-latin-1 (8-bit ascii), and while sending it back to the erlang I > can specify the encoding as ERL_NIF_LATIN1, which is the only option > right now. > > My issue is that my string contains Unicode currency symbols like ?, > as the encoding currently only supports ERL_NIF_LATIN1, there is no > way the NIF library can understand unicode currency symbols. Does > anybody has any workaround for this? > > I want to thank you in advance, and would really appreciate any help > from the members. > > Regards, > Saurabh > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From igorrs@REDACTED Fri Jun 4 05:39:19 2010 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Fri, 4 Jun 2010 00:39:19 -0300 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: References: Message-ID: On Thu, Jun 3, 2010 at 10:00 PM, Richard O'Keefe wrote: > > So let's do what the first error message says: > > * ? ?4 ?bar() -> ?MODULE:spawn(fun (X) -> X+1 end). > > m% erlc foo.erl > ./foo.erl:6: Warning: defining BIF spawn/1 > ./foo.erl:6: Warning: function spawn/1 is unused > > There's an explicit call there, how can it not be used? This was a little bit unrelated to the topic. Given that you can't call a non-exported function with that syntax, that code is certainly not calling the local fun spawn/1, since it's not exported. Considering it's not called anywhere in the module, it's then unused. That's another characteristic of Erlang you're questioning (the reason why you can't call a non-exported LOCAL function with module syntax). As for the other characteristic (local functions not overriding built-ins in local calls), I totally agree with you and share your worries. I have Erlang code in production and would be happy if upgrades to newer version of Erlang would require as few changes as possible. Best regards. Igor. > Change it again, so that now it reads > > * ? ?1 ?-module(foo). > ? ? 2 ?-export([bar/0,spawn/1]). > ? ? 3 > * ? ?4 ?bar() -> ?MODULE:spawn(fun (X) -> X+1 end). > ? ? 5 > ? ? 6 ?spawn(F) -> F(41). > > Erlc is now silent, and foo:bar() gives the expected answer. > The price is that a function which was never meant to be exported > (and because of the clash with a built in function never _should_ > be exported, to avoid confusion) *has* to be exported, and a call > to a purely local function has to be a remote call. > > This is silly. From ok@REDACTED Fri Jun 4 07:18:58 2010 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 4 Jun 2010 17:18:58 +1200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: References: Message-ID: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> On Jun 4, 2010, at 3:39 PM, Igor Ribeiro Sucupira wrote: > On Thu, Jun 3, 2010 at 10:00 PM, Richard O'Keefe wrote: >> >> So let's do what the first error message says: >> >> * 4 bar() -> ?MODULE:spawn(fun (X) -> X+1 end). >> >> m% erlc foo.erl >> ./foo.erl:6: Warning: defining BIF spawn/1 >> ./foo.erl:6: Warning: function spawn/1 is unused >> >> There's an explicit call there, how can it not be used? > > > This was a little bit unrelated to the topic. Given that you can't > call a non-exported function with that syntax, that code is certainly > not calling the local fun spawn/1, since it's not exported. Note that I wasn't suggesting that the call should be *allowed*, only that it is *there*. There's a big difference between "there are NO calls to this function" and "the calls to this function won't be allowed at run time because the function is not exported." In short, I am not quarreling with the decision to report an error here, only commenting that the error message is extremely misleading. From igorrs@REDACTED Fri Jun 4 07:53:13 2010 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Fri, 4 Jun 2010 02:53:13 -0300 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> Message-ID: On Fri, Jun 4, 2010 at 2:18 AM, Richard O'Keefe wrote: > > On Jun 4, 2010, at 3:39 PM, Igor Ribeiro Sucupira wrote: > >> On Thu, Jun 3, 2010 at 10:00 PM, Richard O'Keefe wrote: >>> >>> So let's do what the first error message says: >>> >>> * ? ?4 ?bar() -> ?MODULE:spawn(fun (X) -> X+1 end). >>> >>> m% erlc foo.erl >>> ./foo.erl:6: Warning: defining BIF spawn/1 >>> ./foo.erl:6: Warning: function spawn/1 is unused >>> >>> There's an explicit call there, how can it not be used? >> >> >> This was a little bit unrelated to the topic. Given that you can't >> call a non-exported function with that syntax, that code is certainly >> not calling the local fun spawn/1, since it's not exported. > > Note that I wasn't suggesting that the call should be *allowed*, > only that it is *there*. ?There's a big difference between > "there are NO calls to this function" and > "the calls to this function won't be allowed at run time because > ?the function is not exported." Although I disagree with this opinion, I recognize that deciding if "the call is there" depends on how far one thinks the compiler should go. I believe the compiler has a coherent behavior in that case: function calls with module syntax are only "resolved" at run time, so deciding the call is there in that example would require the compiler to treat as a special case the calls that happen to be to a module with the same name as the one being compiled. The compiler opts to not do that extra analysis of function calls, since it doesn't absolutely need to. Maybe this is not as "clever" as it could be, but I think it is a coherent behavior. Best regards. Igor. > In short, I am not quarreling with the decision to report an > error here, only commenting that the error message is extremely > misleading. -- "The secret of joy in work is contained in one word - excellence. To know how to do something well is to enjoy it." - Pearl S. Buck. From raimo+erlang-questions@REDACTED Fri Jun 4 08:04:13 2010 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 4 Jun 2010 08:04:13 +0200 Subject: [erlang-questions] Re: How to make the Erlang VM predictible when spawning processes? In-Reply-To: References: Message-ID: <20100604060413.GA11662@erix.ericsson.se> Just a naive thought. On any contemporary OS (Windows, Linux, MacOS X, BSD...) you should expect that the OS scheduler might throw you out about 10..20 ms for some arbitrary OS reason... Unless you run some OS with a more real-timeish scheduler, i think there are e.g Linux flavours for this. On Fri, Jun 04, 2010 at 01:45:26AM +0300, Ovidiu Deac wrote: > I'm back with some tests that I've just ran on an Intel Core i5/Linux > 2.6.32/erts v5.7.4. > > The results look more credible since 1000 processes are no longer > spawned in 1microsecond. Also the variance between separate test > executions is much smaller. > > But the problem remains if I spawn 1 milion processes I come across > spawns which take up to 18milliseconds. So again, any idea about how I > could make the VM to be predictible? > > I assume that I should find the level of load that it can take. > Reusing processes as I would have done in other languages sounds like > a bad idea from start. Also I'm thinking I could increase the work > done by one process such that it's not too small but still it fits > inside the initial heap size so garbage collection is not needed. > > Also another thing that I observed is that during the test only about > 50% out of each processor seems to be used. At least this is what the > system monitor says. Any VM flags that would help with this? I tried > +P and +S but without results. > > Ovidiu > > > > On Thu, Jun 3, 2010 at 9:00 PM, Ovidiu Deac wrote: > > Hello everybody, > > > > I'm doing some research in order to figure out if Erlang is suitable > > for an application that we need to implement. > > > > In a few words it's about a server which has a requirement saying "no > > request should take more then 10ms"', measured on the client's > > computer. > > > > So I started a couple of tests for various erlang components to figure > > out how much some operations would take. Partly because I wanted to > > get some figures and partly to exercise my Erlang skills. > > > > First I wrote a profiler module which can measure the execution time > > for various modules which implement set_up,tear_down and test_main. > > Also this profiler can repeat a test a number of times and returns a > > list with all the execution times, the minimum, the maximum and the > > average time. Nothing fancy. > > > > See the attachment for the profiler code and I post below some results > > for a test that I ran on a machine with Intel Core2 Duo/Win7/erlang > > v5.7.5. One test consists in 1000 spawns and is repeated 100 times. > > The times displayed are microseconds. > > > > $ make -C .. && erl +P 200000 -noshell -s profiler run spawn_test 100 > > silent 0 1000 -s init stop > > make: Entering directory `/cygdrive/d/work/erlang/finn' > > make: Leaving directory `/cygdrive/d/work/erlang/finn' > > Module to test:spawn_test, Repeats:100, Params=[silent,'0','1000'] > > Times elapsed = [1,15998,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1,15991,1,1,1,1, > > ? ? ? ? ? ? ? ? 14991,1,1,1,1,15991,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1, > > ? ? ? ? ? ? ? ? 15991,1,1,1,1,1,14989,1,1,1,1,15991,1,1,1,1,15991,1,1,1, > > ? ? ? ? ? ? ? ? 14993,1,1,1,15993,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1,15991, > > ? ? ? ? ? ? ? ? 1,1,1,1,14991,1,1,1,15993,1,1,1,1,15991,1,1,1,1,14991] > > Max us/execution=15998 > > Min us/execution=1 > > Variation=15997 > > Average us/execution=3279.01 > > > > The average time for spawning a process is around 3us which is very > > good. It's interesting to see that spawning 1000 processes took > > 1microsecond (!!!) Looks like some bug it the profiler. Also my main > > concern is that from time to time spawning a process takes around 15ms > > which is way too much. > > > > I tried to run erl +P 200000 but the behaviour is the same as without > > this parameter. > > > > Do you have any idea how to make the VM predictible in order to > > satisfy the 10ms requirement? > > > > Thanks in advance, > > Ovidiu > > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From raimo+erlang-questions@REDACTED Fri Jun 4 08:25:38 2010 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 4 Jun 2010 08:25:38 +0200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> Message-ID: <20100604062538.GB11662@erix.ericsson.se> On Fri, Jun 04, 2010 at 05:18:58PM +1200, Richard O'Keefe wrote: > > On Jun 4, 2010, at 3:39 PM, Igor Ribeiro Sucupira wrote: > > > On Thu, Jun 3, 2010 at 10:00 PM, Richard O'Keefe wrote: > >> > >> So let's do what the first error message says: > >> > >> * 4 bar() -> ?MODULE:spawn(fun (X) -> X+1 end). > >> > >> m% erlc foo.erl > >> ./foo.erl:6: Warning: defining BIF spawn/1 You are right about the "defining BIF" warning being misleading! > >> ./foo.erl:6: Warning: function spawn/1 is unused > >> > >> There's an explicit call there, how can it not be used? > > > > > > This was a little bit unrelated to the topic. Given that you can't > > call a non-exported function with that syntax, that code is certainly > > not calling the local fun spawn/1, since it's not exported. > > Note that I wasn't suggesting that the call should be *allowed*, > only that it is *there*. There's a big difference between > "there are NO calls to this function" and But there *are* no calls to the local function spawn/1. The local function spawn/1 will never be used and that is what that warning says. One might argue that any other module might call foo:spawn/1 so therefore any local function might actually be used (the programmers intention was to use it) from another module so a warning about a local function not being used is never certain to be right... > "the calls to this function won't be allowed at run time because > the function is not exported." The call to ?MODULE:spawn/1 will be *allowed* at run time but will probably fail. Not certainly, however. A newer version of ?MODULE might export it so it *could* be part of a code upgrade (silly name for that, though :-). > > In short, I am not quarreling with the decision to report an > error here, only commenting that the error message is extremely > misleading. #1 is. #2 not really. > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From icfp.publicity@REDACTED Fri Jun 4 08:36:42 2010 From: icfp.publicity@REDACTED (Wouter Swierstra) Date: Fri, 4 Jun 2010 08:36:42 +0200 Subject: ICFP Programming Contest Message-ID: This year's ICFP Programming Contest will begin on June 18th (12:00 Noon GMT) and will run till June 21st (12:00 Noon GMT). As in the previous editions, this is your chance to show that your favorite programming language is better than all others! The problem statement and further information will become available at: http://icfpcontest.org/2010/ Feel free to contact ifcpcont at imn dot htwk-leipzig dot de for further questions. Good luck! Wouter From ovidiudeac@REDACTED Fri Jun 4 10:43:46 2010 From: ovidiudeac@REDACTED (Ovidiu Deac) Date: Fri, 4 Jun 2010 11:43:46 +0300 Subject: [erlang-questions] Re: How to make the Erlang VM predictible when spawning processes? In-Reply-To: <20100604060413.GA11662@erix.ericsson.se> References: <20100604060413.GA11662@erix.ericsson.se> Message-ID: I was hoping that the latency introduced by the OS would be lower and we would have enough time to satisfy the 10ms requirement. If you are right then I guess 10ms response time is not realistic on a standard system. Anyway we will do some tests first and then try to see what is doable and what would be acceptable. On Fri, Jun 4, 2010 at 9:04 AM, Raimo Niskanen wrote: > Just a naive thought. > > On any contemporary OS (Windows, Linux, MacOS X, BSD...) you should > expect that the OS scheduler might throw you out about 10..20 ms > for some arbitrary OS reason... > > Unless you run some OS with a more real-timeish scheduler, > i think there are e.g Linux flavours for this. > > On Fri, Jun 04, 2010 at 01:45:26AM +0300, Ovidiu Deac wrote: >> I'm back with some tests that I've just ran on an Intel Core i5/Linux >> 2.6.32/erts v5.7.4. >> >> The results look more credible since 1000 processes are no longer >> spawned in 1microsecond. Also the variance between separate test >> executions is much smaller. >> >> But the problem remains if I spawn 1 milion processes I come across >> spawns which take up to 18milliseconds. So again, any idea about how I >> could make the VM to be predictible? >> >> I assume that I should find the level of load that it can take. >> Reusing processes as I would have done in other languages sounds like >> a bad idea from start. Also I'm thinking I could increase the work >> done by one process such that it's not too small but still it fits >> inside the initial heap size so garbage collection is not needed. >> >> Also another thing that I observed is that during the test only about >> 50% out of each processor seems to be used. At least this is what the >> system monitor says. Any VM flags that would help with this? I tried >> +P and +S but without results. >> >> Ovidiu >> >> >> >> On Thu, Jun 3, 2010 at 9:00 PM, Ovidiu Deac wrote: >> > Hello everybody, >> > >> > I'm doing some research in order to figure out if Erlang is suitable >> > for an application that we need to implement. >> > >> > In a few words it's about a server which has a requirement saying "no >> > request should take more then 10ms"', measured on the client's >> > computer. >> > >> > So I started a couple of tests for various erlang components to figure >> > out how much some operations would take. Partly because I wanted to >> > get some figures and partly to exercise my Erlang skills. >> > >> > First I wrote a profiler module which can measure the execution time >> > for various modules which implement set_up,tear_down and test_main. >> > Also this profiler can repeat a test a number of times and returns a >> > list with all the execution times, the minimum, the maximum and the >> > average time. Nothing fancy. >> > >> > See the attachment for the profiler code and I post below some results >> > for a test that I ran on a machine with Intel Core2 Duo/Win7/erlang >> > v5.7.5. One test consists in 1000 spawns and is repeated 100 times. >> > The times displayed are microseconds. >> > >> > $ make -C .. && erl +P 200000 -noshell -s profiler run spawn_test 100 >> > silent 0 1000 -s init stop >> > make: Entering directory `/cygdrive/d/work/erlang/finn' >> > make: Leaving directory `/cygdrive/d/work/erlang/finn' >> > Module to test:spawn_test, Repeats:100, Params=[silent,'0','1000'] >> > Times elapsed = [1,15998,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1,15991,1,1,1,1, >> > ? ? ? ? ? ? ? ? 14991,1,1,1,1,15991,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1, >> > ? ? ? ? ? ? ? ? 15991,1,1,1,1,1,14989,1,1,1,1,15991,1,1,1,1,15991,1,1,1, >> > ? ? ? ? ? ? ? ? 14993,1,1,1,15993,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1,15991, >> > ? ? ? ? ? ? ? ? 1,1,1,1,14991,1,1,1,15993,1,1,1,1,15991,1,1,1,1,14991] >> > Max us/execution=15998 >> > Min us/execution=1 >> > Variation=15997 >> > Average us/execution=3279.01 >> > >> > The average time for spawning a process is around 3us which is very >> > good. It's interesting to see that spawning 1000 processes took >> > 1microsecond (!!!) Looks like some bug it the profiler. Also my main >> > concern is that from time to time spawning a process takes around 15ms >> > which is way too much. >> > >> > I tried to run erl +P 200000 but the behaviour is the same as without >> > this parameter. >> > >> > Do you have any idea how to make the VM predictible in order to >> > satisfy the 10ms requirement? >> > >> > Thanks in advance, >> > Ovidiu >> > >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > From bgustavsson@REDACTED Fri Jun 4 11:26:57 2010 From: bgustavsson@REDACTED (=?UTF-8?Q?Bj=C3=B6rn_Gustavsson?=) Date: Fri, 4 Jun 2010 11:26:57 +0200 Subject: [erlang-questions] interesting I/O bottleneck In-Reply-To: References: Message-ID: On Tue, Jun 1, 2010 at 5:17 PM, James Hague wrote: > > Is there a reason that atoms are allowed in filenames? Why not just go with > iolists? > Backward compatibility. -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From attila.r.nohl@REDACTED Fri Jun 4 11:29:11 2010 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Fri, 4 Jun 2010 11:29:11 +0200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: References: Message-ID: 2010/6/4, Richard O'Keefe : > There is currently a discussion going on in the SWI Prolog mailing > list about the way user code can break when a new operation is > added to the system. Alan Baljeu takes the reasonable position that > > What's needed for stability ... is ... > Whatever I define within a module > is the definition used within [that] module. > The local [operations] supersede imported [ones]. > Warn if something is shadowed, but allow it. > > I was about to gloat about Erlang getting this right, and then I > thought I had better try it. > > Consider the following module. > > 1 -module(foo). > 2 -export([bar/0]). > 3 > 4 bar() -> spawn(fun (X) -> X+1 end). > 5 > 6 spawn(F) -> F(41). > > where we're expecting foo:bar() to return 42. > erlc reports > > /foo.erl:4: Warning: call to spawn/1 will call erlang:spawn/1; not > spawn/1 in this module > (add an explicit module name to the call to avoid this warning) > ./foo.erl:6: Warning: defining BIF spawn/1 > ./foo.erl:6: Warning: function spawn/1 is unused > > The second message is clearly WRONG: this _can't_ be defining the > built-in function erlang:spawn/1 because this isn't the erlang: > module. I think that second message is right. The message is not about erlang:spawn, but a function that could be accessed simply by the name "spawn" (and it happens to be a BIF). The root cause of the problem is that many functions from the erlang module are "auto-imported", but if my memory serves correctly, this is being addressed by the OTP team. From jesper.louis.andersen@REDACTED Fri Jun 4 11:31:57 2010 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Fri, 4 Jun 2010 11:31:57 +0200 Subject: [erlang-questions] Re: How to make the Erlang VM predictible when spawning processes? In-Reply-To: References: <20100604060413.GA11662@erix.ericsson.se> Message-ID: On Fri, Jun 4, 2010 at 10:43 AM, Ovidiu Deac wrote: > I was hoping that the latency introduced by the OS would be lower and > we would have enough time to satisfy the 10ms requirement. If you are > right then I guess 10ms response time is not realistic on a standard > system. Shooting partially in the dark here. But what if you had a small set of already spawned processes able to do the work when required? I would guess you can eliminate some of the spawn-time with that solution. It is not much different from minimizing the time spent under a lock by preallocation. -- J. From reachsaurabhnarula@REDACTED Fri Jun 4 11:39:22 2010 From: reachsaurabhnarula@REDACTED (Saurabh Narula) Date: Fri, 4 Jun 2010 15:09:22 +0530 Subject: =?UTF-8?Q?Re=3A_=5Berlang=2Dquestions=5D_Sending_String_with_Unicode_C?= =?UTF-8?Q?urrency_Symbols_=28like_=E2=82=A1=29_from_erlang_to_C_language_NIF_=28Na?= =?UTF-8?Q?tive_Implemented_functions=29?= In-Reply-To: References: Message-ID: thank you bob for your reply, is there any other alternative than sending Binary to NIF? Robert, My string has an xml which I intent to parse in C NIF and give it back to erlang program. I make ERL_NIF_TERMS in C function and give them back to erlang, I would like to have the format as string only. Or do u have suggestions for any other format for the kind of operation I am doing? Thank you. Saurabh On Thu, Jun 3, 2010 at 10:45 PM, Bob Ippolito wrote: > On Thu, Jun 3, 2010 at 10:02 AM, Saurabh Narula > wrote: >> Hello Everyone, >> >> i am trying to send erlang string from erlang program to the NIF >> (Native Implemented functions) written in C language. >> >> While sending the string from erlang I have an option of specifying >> the encoding. The functions that help me achieve this are >> >> ERL_NIF_TERM enif_make_string(ErlNifEnv* env, const char* string, >> ErlNifCharEncoding encoding) >> int enif_get_string(ErlNifEnv* env, ERL_NIF_TERM list, char* buf, >> unsigned size, ErlNifCharEncoding encode) >> >> The only supported encoding is currently ERL_NIF_LATIN1 for >> iso-latin-1 (8-bit ascii), and while sending it back to the erlang I >> can specify the encoding as ERL_NIF_LATIN1, which is the only option >> right now. >> >> My issue is that my string contains Unicode currency symbols like ?, >> as the encoding currently only supports ERL_NIF_LATIN1, there is no >> way the NIF library can understand unicode currency symbols. Does >> anybody has any workaround for this? > > You could use a UTF-8 encoded binary instead of a list. > > -bob > From mikpe@REDACTED Fri Jun 4 11:43:39 2010 From: mikpe@REDACTED (Mikael Pettersson) Date: Fri, 4 Jun 2010 11:43:39 +0200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: References: Message-ID: <19464.51915.702107.984415@pilspetsen.it.uu.se> Richard O'Keefe writes: > We need the following things: > > (1) If a function f/n is defined in a module, > then any calls to f/n without a module prefix > refer to THAT definition. > > (2) The warning message for a definition of such > a function should not say that it is defining > a BIF but that it is defining a function with > the same NAME as a BIF, e.g., > > ./foo.erl:6: Warning: there is a BIF called spawn/1; > to use the BIF you will need an erlang: prefix. > > (3) Such warnings are useful, but sometimes it is > intentional, so a directive such as > > -private([spawn/1]). > > would be useful to silence the warning while giving > human readers (and the compiler!) adequate notice. > (Amongst other things, in a code review, it is easier > to grep for -private than to gather compiler warnings.) > > I'm sure I've seen a proposal like this before, so I haven't written > up an EEP for it yet. FWIW, I agree with all 3 points. It would bring Erlang one step closer to a saner set of scoping rules. Having auto-imports override local definitions is just plain wrong. From tuncer.ayaz@REDACTED Fri Jun 4 12:07:02 2010 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Fri, 4 Jun 2010 12:07:02 +0200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <19464.51915.702107.984415@pilspetsen.it.uu.se> References: <19464.51915.702107.984415@pilspetsen.it.uu.se> Message-ID: Yesterday OTP-8579 landed on the dev branch. It might solve the issue discussed here. Tests: http://github.com/erlang/otp/commit/b72cac2 Docs: http://github.com/erlang/otp/commit/dcd4d82 Merge commit message from http://github.com/erlang/otp/commit/09f146a: ----8<---- OTP-8579 Local functions should override auto-imported Local and imported functions now override the autoimported BIFs when the names clash. The pre R14 behaviour was that autoimported BIFs would override local functions. To avoid that old programs change behaviour, the following will generate an error: Doing a call without explicit module name to a local function having a name clashing with the name of an autoimported BIF that was present (and autoimported) before OTP R14A Explicitly importing a function having a name clashing with the name of an autoimported BIF that was present (and autoimported) before OTP R14A Using any form of the old compiler directive nowarn_bif_clash If the BIF was added or autoimported in OTP R14A or later, overriding it with an import or a local function will only result in a warning, To resolve clashes, you can either use the explicit module name erlang to call the BIF, or you can remove the autoimport of that specific BIF by using the new compiler directive -compile({no_auto_import,[F/A]})., which makes all calls to the local or imported function without explicit module name pass without warnings or errors. The change makes it possible to add autoimported BIFs without breaking or silently changing old code in the future. However some current code ingeniously utilizing the old behaviour or the nowarn_bif_clash compiler directive, might need changing to be accepted by the compiler. ---->8---- From sverker@REDACTED Fri Jun 4 12:07:00 2010 From: sverker@REDACTED (Sverker Eriksson) Date: Fri, 04 Jun 2010 12:07:00 +0200 Subject: =?UTF-8?B?UmU6IFtlcmxhbmctcXVlc3Rpb25zXSBTZW5kaW5nIFN0cmluZyB3aXQ=?= =?UTF-8?B?aCBVbmljb2RlIEN1cnJlbmN5IFN5bWJvbHMgKGxpa2Ug4oKhKSBmcm9tIGVybGE=?= =?UTF-8?B?bmcgdG8gQyBsYW5ndWFnZSBOSUYgKE5hdGl2ZSBJbXBsZW1lbnRlZCBmdW5jdGk=?= =?UTF-8?B?b25zKQ==?= In-Reply-To: References: Message-ID: <4C08D044.3000602@erix.ericsson.se> Saurabh Narula wrote: > thank you bob for your reply, is there any other alternative than > sending Binary to NIF? > > You can always use enif_get_list_cell() and parse the string (list) yourself character by character. /Sverker, Erlang/OTP From bengt.kleberg@REDACTED Fri Jun 4 12:11:50 2010 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 04 Jun 2010 12:11:50 +0200 Subject: [erlang-questions] interesting I/O bottleneck In-Reply-To: References: Message-ID: <1275646310.5058.10.camel@seasc1137> Greetings, Would it be possible to have faster code for iolists and still be backwards compatible? I am thinking along the lines of a function with a try/catch that assumes an iolist. If it fails the old, slower, code is tried too. Without a catch, of course. bengt On Fri, 2010-06-04 at 11:26 +0200, Bj?rn Gustavsson wrote: > On Tue, Jun 1, 2010 at 5:17 PM, James Hague wrote: > > > > Is there a reason that atoms are allowed in filenames? Why not just go with > > iolists? > > > > Backward compatibility. > From bgustavsson@REDACTED Fri Jun 4 12:21:54 2010 From: bgustavsson@REDACTED (=?UTF-8?Q?Bj=C3=B6rn_Gustavsson?=) Date: Fri, 4 Jun 2010 12:21:54 +0200 Subject: [erlang-questions] interesting I/O bottleneck In-Reply-To: <1275646310.5058.10.camel@seasc1137> References: <1275646310.5058.10.camel@seasc1137> Message-ID: On Fri, Jun 4, 2010 at 12:11 PM, Bengt Kleberg wrote: > Would it be possible to have faster code for iolists and still be > backwards compatible? Yes. > I am thinking along the lines of a function with a try/catch that > assumes an iolist. If it fails the old, slower, code is tried too. > Without a catch, of course. A good patch (following our submission guidelines) doing that will very likely be accepted (but not for R14A). -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From bartlomiej@REDACTED Fri Jun 4 12:23:33 2010 From: bartlomiej@REDACTED (=?utf-8?Q?Bart=C5=82omiej_Puzo=C5=84?=) Date: Fri, 4 Jun 2010 10:23:33 +0000 (GMT) Subject: Eastrisk library released Message-ID: <677965251.433341275647013287.JavaMail.root@zimbra> Hi all, We have released our Asterisk interface. Feel free to fork from: http://github.com/esl/eastrisk Saludos, -- Bart?omiej Puzo? Erlang Solutions --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From rvirding@REDACTED Fri Jun 4 12:47:45 2010 From: rvirding@REDACTED (Robert Virding) Date: Fri, 4 Jun 2010 12:47:45 +0200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: References: <19464.51915.702107.984415@pilspetsen.it.uu.se> Message-ID: LFE already has this function scoping: Local functions (to a function) Functions defined in the module Explicit imports Implicit imports from module erln Seeing it doesn't have the backwards compatibility issues it can do it without extra compiler options. I definitely think it is the right way to go. Robert On 4 June 2010 12:07, Tuncer Ayaz wrote: > Yesterday OTP-8579 landed on the dev branch. > It might solve the issue discussed here. > > Tests: http://github.com/erlang/otp/commit/b72cac2 > Docs: ?http://github.com/erlang/otp/commit/dcd4d82 > > Merge commit message from > http://github.com/erlang/otp/commit/09f146a: > ----8<---- > OTP-8579 ?Local functions should override auto-imported > > Local and imported functions now override the autoimported > BIFs when the names clash. The pre R14 behaviour was that > autoimported BIFs would override local functions. To avoid > that old programs change behaviour, the following will > generate an error: > > Doing a call without explicit module name to a local function > having a name clashing with the name of an autoimported BIF > that was present (and autoimported) before OTP R14A > Explicitly importing a function having a name clashing with > the name of an autoimported BIF that was present (and > autoimported) before OTP R14A Using any form of the old > compiler directive nowarn_bif_clash > > If the BIF was added or autoimported in OTP R14A or later, > overriding it with an import or a local function will only > result in a warning, > > To resolve clashes, you can either use the explicit module > name erlang to call the BIF, or you can remove the autoimport > of that specific BIF by using the new compiler directive > -compile({no_auto_import,[F/A]})., which makes all calls to > the local or imported function without explicit module name > pass without warnings or errors. > > The change makes it possible to add autoimported BIFs without > breaking or silently changing old code in the future. However > some current code ingeniously utilizing the old behaviour or > the nowarn_bif_clash compiler directive, might need changing > to be accepted by the compiler. > ---->8---- > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From pascalchapier@REDACTED Fri Jun 4 15:06:49 2010 From: pascalchapier@REDACTED (Pascal Chapier) Date: Fri, 4 Jun 2010 15:06:49 +0200 Subject: [erlang-questions] Speedy unsort:shuffle/1,2 ? Message-ID: Hello, I have tried a solution which is quite efficient, and I got good results in distribution. But I have trouble with the performance results, particularly the 2 last values in the table bellow (is there a known bug in erlang:statistics function?). My intent was to evaluate the relationship between length and shuffle time. I did a new test, and got extravagant results again, but for other list length - the time for 1 list cannot be 4293323265?s since the program did the 14 * 1000 loops of test/0 in less than 6 hours -. My configuration is R13B04 on windows XP. The risk of this method is to get two identical numbers in the tupple_list. I can't evaluate the impact on randomless, in this case, keysort simply left the elements in original order. The quality of the method depends on the random:uniform function, maybe some other function could be faster and/or better. Here is the code I used: shuffle(P) -> Max = length(P)*10000, {_,R}= lists:unzip(lists:keysort(1,[{random:uniform(Max),X} || X <- P])), R. test() -> test:perfshuffle(shuffle,125,1000), test:perfshuffle(shuffle,250,1000), test:perfshuffle(shuffle,500,1000), test:perfshuffle(shuffle,1000,1000), test:perfshuffle(shuffle,2000,1000), test:perfshuffle(shuffle,4000,1000), test:perfshuffle(shuffle,8000,1000), test:perfshuffle(shuffle,16000,1000), test:perfshuffle(shuffle,32000,1000), test:perfshuffle(shuffle,64000,1000), test:perfshuffle(shuffle,128000,1000), test:perfshuffle(shuffle,256000,1000), test:perfshuffle(shuffle,512000,1000), test:perfshuffle(shuffle,1024000,1000), test:testshuffle(shuffle,10,1000000). testshuffle() -> io:format("Usage: testshuffle(ShuffleFunctionName,SizOfList,NumberOfTrial)~n"). testshuffle(F,L,T) -> S = lists:seq(0,L), Nul = [X-X || X <- S], {Res,Car} = testshuffle(F,Nul,Nul,S,L,T), Moy = [X/T || X <- Res], Sig = [math:sqrt(X/T) || X <- Car], Tm = L/2, Td = math:sqrt((L*(L+2))/12), io:format("Theoritical results: average = ~p, deviation = ~p~n", [Tm,Td]), io:format("Average :~p~n",[Moy]), io:format("Deviation :~p~n",[Sig]). testshuffle(_,Am,Ac,_S,_L,0) -> {Am,Ac}; testshuffle(F,Am,Ac,S,L,I) -> Ns = ?MODULE:F(S), Am1 = [X+Y || {X,Y} <- lists:zip(Am,Ns)], Ac1 = [X+math:pow(Y-L/2,2) || {X,Y} <- lists:zip(Ac,Ns)], testshuffle(F,Am1,Ac1,S,L,I-1). perfshuffle() -> io:format("Usage: perfshuffle(ShuffleFunctionName,SizOfList,NumberOfTrial)~n"). perfshuffle(F,L,T) -> S = lists:seq(0,L), statistics(runtime), statistics(wall_clock), perfshuffle1(F,S,T), {_, Time1} = statistics(runtime), {_, Time2} = statistics(wall_clock), T1 = 1000 * Time1/T, T2 = 1000 * Time2/T, io:format("Average Shuffle Time for a list of ~p elements~nRuntime -> ~p~nWallclock -> ~p~n", [L,T1,T2]). perfshuffle1(_F,_S,0) -> ok; perfshuffle1(F,S,N) -> _ = ?MODULE:F(S), perfshuffle1(F,S,N-1). And the results (performance in ?s): Average Shuffle Time for a list of 125 elements Runtime -> 281.0 Wallclock -> 281.0 Average Shuffle Time for a list of 250 elements Runtime -> 422.0 Wallclock -> 422.0 Average Shuffle Time for a list of 500 elements Runtime -> 891.0 Wallclock -> 906.0 Average Shuffle Time for a list of 1000 elements Runtime -> 2109.0 Wallclock -> 2110.0 Average Shuffle Time for a list of 2000 elements Runtime -> 4328.0 Wallclock -> 4328.0 Average Shuffle Time for a list of 4000 elements Runtime -> 8438.0 Wallclock -> 8515.0 Average Shuffle Time for a list of 8000 elements Runtime -> 16828.0 Wallclock -> 17172.0 Average Shuffle Time for a list of 16000 elements Runtime -> 38234.0 Wallclock -> 40141.0 Average Shuffle Time for a list of 32000 elements Runtime -> 85750.0 Wallclock -> 90125.0 Average Shuffle Time for a list of 64000 elements Runtime -> 183688.0 Wallclock -> 192891.0 Average Shuffle Time for a list of 128000 elements Runtime -> 442297.0 Wallclock -> 4.735e5 Average Shuffle Time for a list of 256000 elements Runtime -> 990390.0 Wallclock -> 1058078.0 Average Shuffle Time for a list of 512000 elements Runtime -> 4293323265.0 Wallclock -> 2907109.0 Average Shuffle Time for a list of 1024000 elements Runtime -> 1630126.0 Wallclock -> 6554031.0 Theoritical results: average = 5.0, deviation = 3.1622776601683795 Average :[4.996671,4.996889,4.997597,5.003431,5.000648,4.997709,5.005808, 4.999759,4.996688,5.003346,5.001454] Deviation :[3.164504542578506,3.161651941627984,3.1614915783534836, 3.1614669063585024,3.162072737936305,3.1621861109049227, 3.160950173602868,3.165070457351621,3.1611447293662467, 3.160723651317843,3.1637879195673024] Pascal _________________________________________________________________ Hotmail : Simple et Efficace qui vous facilite la vie? D?couvrez la NOW g?n?ration ! http://www.windowslive.fr/hotmail/nowgeneration/ From ahmed.nawras@REDACTED Fri Jun 4 15:31:19 2010 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Fri, 4 Jun 2010 17:31:19 +0400 Subject: [erlang-questions] log4erl as system logger In-Reply-To: References: <4C064B25.4070104@gmail.com> <4C064EEA.6020001@gmail.com> <70642D9E-5D92-473D-87EF-B8394E10A31B@hates.ms> Message-ID: Hi All, It's funny that I've just responded to a query of a user few days ago about the exact subject. Please find my copy-and-pasted response below. You can forward all error_logger requests to log4erl. You can do that using: error_logger:delete_report_handler(error_logger), %% to disable error_logger file output error_logger:tty(false), %% to disable console output log4erl:error_logger_handler(). %% to get all error_logger You can check that log4erl is handling error_logger logs using: > gen_event:which_handlers(error_logger). I hope this answers your question. If not, please let me know. Best regards, Ahmed On Wed, Jun 2, 2010 at 7:46 PM, Alessandro Sivieri wrote: > Well, then it was not so clear how to do it... > > -- > Sivieri Alessandro > alessandro.sivieri@REDACTED > http://www.chimera-bellerofonte.eu/ > http://www.poul.org/ > From ovidiudeac@REDACTED Fri Jun 4 15:22:40 2010 From: ovidiudeac@REDACTED (Ovidiu Deac) Date: Fri, 4 Jun 2010 16:22:40 +0300 Subject: [erlang-questions] Re: How to make the Erlang VM predictible when spawning processes? In-Reply-To: References: <20100604060413.GA11662@erix.ericsson.se> Message-ID: If I only have transient processes I can avoid the garbage collection by setting the initial heap to a value which is big enough for the process. If I reuse the processes I can't make this optimization. This is why I was thinking that reusing processes is not good. On Fri, Jun 4, 2010 at 12:31 PM, Jesper Louis Andersen wrote: > On Fri, Jun 4, 2010 at 10:43 AM, Ovidiu Deac wrote: >> I was hoping that the latency introduced by the OS would be lower and >> we would have enough time to satisfy the 10ms requirement. If you are >> right then I guess 10ms response time is not realistic on a standard >> system. > > Shooting partially in the dark here. But what if you had a small set > of already spawned processes able to do the work when required? I > would guess you can eliminate some of the spawn-time with that > solution. It is not much different from minimizing the time spent > under a lock by preallocation. > > -- > J. > From maruthavanan_s@REDACTED Fri Jun 4 16:41:49 2010 From: maruthavanan_s@REDACTED (maruthavanan s) Date: Fri, 4 Jun 2010 10:41:49 -0400 Subject: [erlang-questions] Eastrisk library released In-Reply-To: <677965251.433341275647013287.JavaMail.root@zimbra> References: <677965251.433341275647013287.JavaMail.root@zimbra> Message-ID: Hi, I was waiting for this for a long time. Let me have a look into it. Thanks, Marutha ------------------------------------------------ Hi all, We have released our Asterisk interface. Feel free to fork from: http://github.com/esl/eastrisk Saludos, -- Bart?omiej Puzo? Erlang Solutions --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From zeno490@REDACTED Fri Jun 4 17:21:52 2010 From: zeno490@REDACTED (Nicholas Frechette) Date: Fri, 4 Jun 2010 11:21:52 -0400 Subject: [erlang-questions] Re: How to make the Erlang VM predictible when spawning processes? In-Reply-To: References: <20100604060413.GA11662@erix.ericsson.se> Message-ID: Having pre-spawned processes doesn't mean you have to reuse them. You could just spawn them ahead of time, say 1000 of them, let them terminate as normal. Once you request a process to give it a task and you notice that you've passed a threshold, say, < 500 free processes left, you can spawn a process that forks 1000 more and adds them to the pool of waiting ones. Example numbers of course but with a setup like this, it might work good enough. Or, alternatively, once a process has done it's job, instead of simply terminating, spawn a new one and add it to the free pool. That way the number of pre-spawned processes should be more constant and the performance hit of spawning shouldn't matter that much as you are done with your (main) work. Nicholas On Fri, Jun 4, 2010 at 9:22 AM, Ovidiu Deac wrote: > If I only have transient processes I can avoid the garbage collection > by setting the initial heap to a value which is big enough for the > process. If I reuse the processes I can't make this optimization. > > This is why I was thinking that reusing processes is not good. > > On Fri, Jun 4, 2010 at 12:31 PM, Jesper Louis Andersen > wrote: > > On Fri, Jun 4, 2010 at 10:43 AM, Ovidiu Deac > wrote: > >> I was hoping that the latency introduced by the OS would be lower and > >> we would have enough time to satisfy the 10ms requirement. If you are > >> right then I guess 10ms response time is not realistic on a standard > >> system. > > > > Shooting partially in the dark here. But what if you had a small set > > of already spawned processes able to do the work when required? I > > would guess you can eliminate some of the spawn-time with that > > solution. It is not much different from minimizing the time spent > > under a lock by preallocation. > > > > -- > > J. > > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From anders.nygren@REDACTED Fri Jun 4 17:57:42 2010 From: anders.nygren@REDACTED (Anders Nygren) Date: Fri, 4 Jun 2010 10:57:42 -0500 Subject: [erlang-questions] Eastrisk library released In-Reply-To: <677965251.433341275647013287.JavaMail.root@zimbra> References: <677965251.433341275647013287.JavaMail.root@zimbra> Message-ID: On Fri, Jun 4, 2010 at 5:23 AM, Bart?omiej Puzo? wrote: > Hi all, > > We have released our Asterisk interface. Feel free to fork from: > http://github.com/esl/eastrisk > It is missing license information. /Anders > Saludos, > -- > Bart?omiej Puzo? > Erlang Solutions > > --------------------------------------------------- > > --------------------------------------------------- > > WE'VE CHANGED NAMES! > > Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. > > www.erlang-solutions.com > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From steven.charles.davis@REDACTED Sat Jun 5 02:18:02 2010 From: steven.charles.davis@REDACTED (Steve Davis) Date: Fri, 4 Jun 2010 17:18:02 -0700 (PDT) Subject: log4erl as system logger In-Reply-To: References: <4C064B25.4070104@gmail.com> <4C064EEA.6020001@gmail.com> <70642D9E-5D92-473D-87EF-B8394E10A31B@hates.ms> Message-ID: <876902b6-427e-44f2-a556-a82132f1b30d@d8g2000yqf.googlegroups.com> Similar but different --- this was my solution to the logging issue (though not log4erl based). It replaces the default error_logger but allows it to swap back on termination. I also needed multiple log files/log levels and a "default" log. The key parts are in the start_link and handle_info for 'EXIT'. http://github.com/komone/ewok/blob/master/src/ewok_logging_srv.erl There could be some inspiration buried in it for the issue at hand. regs, /s From pablo.platt@REDACTED Sat Jun 5 11:13:19 2010 From: pablo.platt@REDACTED (Pablo Platt) Date: Sat, 5 Jun 2010 02:13:19 -0700 (PDT) Subject: [erlang-questions] my socket can't handle the load In-Reply-To: References: <576214.89312.qm@web112601.mail.gq1.yahoo.com> Message-ID: <798646.58019.qm@web112601.mail.gq1.yahoo.com> I was able to identify exactly when the issue happens. As long as only one request at a time is sent to the driver it works fine: request1, response1, request2, response2... If the client sends several requests as fast as it can without waiting for a response it breaks. debug messages show the following: request1, request2, response1, request3, response2, Error timeout for request3, response3 This failure is reproducible. The timeout occurs after 5000ms compared to ~10ms for a normal query. It can't be related to too many messages in a process mail box because we are only talking about 3 requests. I don't know if this issue is related to my driver or the db. Is there something related to sockets, or TCP that breaks when you send and receive data in a non-blocking way? Is there an erlang driver that sends messages to a socket in a non-blocking way and handle responses according to a unique id tag that I can use as a reference to see if any special configuration is needed? ________________________________ From: Kaiduan Xie To: Pablo Platt Cc: Bernard Duggan ; Erlang Sent: Thu, June 3, 2010 3:14:33 PM Subject: Re: [erlang-questions] my socket can't handle the load Pablo, you can use erlang:process_info(Pid, message_queue_len) to find the mail box size of gen_server. On Thu, Jun 3, 2010 at 2:52 AM, Pablo Platt wrote: > p.s. > when getting a gen_server:call timeout the debug message of the > requester(not the socket gen_server) says: > heap_size: 1597 > stack_size: 24 > reductions: 1996 > > > ________________________________ > From: Pablo Platt > To: Kaiduan Xie ; Bernard Duggan > Cc: Erlang > Sent: Thu, June 3, 2010 9:49:17 AM > Subject: Re: [erlang-questions] my socket can't handle the load > > @Bernard, Kaiduan > When I'm testing with a pool of 20 connections instead of 1, the driver and > socket works fine. > I think that means that both the receiver (database) and the sender can > handle the load. > When sending one request at a time from the same socket it also works fine > but don't think this is the correct design. > > I don't think {active, once} is relevant here because responses from the db > will only arrive when I make requests > so I don't need to protect myself against DOS from untrusted third party. > > When getting a timeout on gen_server:call to the socket gen_server, how can > I print useful info > about the socket gen_server and the process calling it so I can see the > mailbox queue of them and maybe other useful > stuff that help me find the problem? > > Thanks > > ________________________________ > From: Kaiduan Xie > To: Bernard Duggan > Cc: Pablo Platt ; Erlang > > Sent: Thu, June 3, 2010 3:59:02 AM > Subject: Re: [erlang-questions] my socket can't handle the load > > Pablo, > > Have you considered any chance the call of > gen_tcp:send(State#state.socket, Packet) getting blocked? For example, > a slow receiver. If gen_tcp:send() is getting blocked, hand_call() > will get blocked, and gen_server will slow down. Please look the > example listed in gen_tcp, > > http://www.erlang.org/doc/man/gen_tcp.html#examples > > Kaiduan > > On Wed, Jun 2, 2010 at 5:35 PM, Bernard Duggan wrote: >> Hi Pablo, >> One thing you may want to try is to wherever possible, avoid letting >> the queue on your gen_server grow beyond a couple of messages. Allowing >> the queue to grow unchecked can cause serious performance degradation on >> selective receives (which, to be fair, I can't see any of in your code, >> but they can crop up in non-obvious library calls at times). >> Off the top of my head, you'd do this by: >> a) changing the handle_cast operation to a handle_call (to keep clients >> using that operation from flooding you with requests) and >> b) changing {active, true} to {active, once} in your connect call (and >> making the corresponding change in handle_info to reactivate the socket. >> >> It may or may not be your problem, but it's a fairly easy change and >> worth a try. >> >> Another possibility is that you have the same issue, but in the calling >> process (I'm guessing now, since you haven't provided that code). A >> gen_server call does a selective receive while it waits for a response - >> if your message queue is very large when you make the call, there's a >> good chance you'll get a timeout regardless of how quickly the >> gen_server serves the request. >> >> Cheers, >> >> Bernard >> >> On 3/06/2010 1:27 AM, Pablo Platt wrote: >>> Hi, >>> >>> I'm writing a driver to a database that is using a tcp socket. >>> There are two types of messages, "send and forget" and "send and >>> receive". >>> I have a gen_server that is responsible for opening the socket, receive a >>> message from a process and sending it to the socket and receive responses >>> and pass them to the caller. >>> The gen_server saves a list of {request_id, CallerPid} in the state to >>> know who to respond to when a packet is received from the db. >>> >>> Everything works when the rate of messages is low but when increasing it >>> I'm starting to get gen_server timeout error on the requestor. >>> Do I need to add/change parameters when opening the socket? >>> Should I queue requests and wait for a response before sending the next >>> request or is it ok to send several requests one after the other? >>> >>> Thanks >>> >>> The client sends a request using either: >>> Resp = gen_server:call(Conn, {request, Request}) >>> or >>> gen_server:cast(Conn, {request, Request}) >>> >>> >>> The relevant gen_server code: >>> >>> init([Host, Port]) -> >>> Socket = open_socket(Host, Port), >>> {ok, #state{socket=Socket, req_id=1}}. >>> >>> open_socket(Host, Port) -> >>> case gen_tcp:connect(Host, Port, [binary, {active, true}]) of >>> {ok, Sock} -> >>> Sock; >>> {error, Reason} -> >>> exit({open_socket_failed, Reason}) >>> end. >>> >>> handle_call({request, Packet}, From, State) -> >>> ReqID = State#state.req_id + 1, >>> gen_tcp:send(State#state.socket, Packet), >>> {noreply, State#state{req_id=ReqID, requests=[{ReqID, >>> From}|State#state.requests]}}; >>> >>> handle_cast({request, Packet}, State) -> >>> ReqID = State#state.req_id + 1, >>> gen_tcp:send(State#state.socket, Packet), >>> {noreply, State#state{req_id=ReqID}}. >>> >>> handle_info({tcp, _Socket, Data}, State) -> >>> RawResp = <<(State#state.resp)/binary, Data/binary>>, >>> case check_packet:decode_response(RawResp) of >>> undefined -> >>> {noreply, State#state{resp = RawResp}}; >>> {Resp, Tail} -> >>> ResponseTo = get_requestor(Resp), >>> {value, {ResponseTo, Client}, NewRequests} = >>> lists:keytake(ResponseTo, 1, State#state.requests), >>> gen_server:reply(Client, Resp), >>> {noreply, State#state{resp = Tail, requests=NewRequests}} >>> end; >>> >>> % the following never been called, even when I'm getting the error. >>> handle_info({tcp_closed, _Socket}, State) -> >>> {noreply, State}; >>> >>> handle_info({tcp_error, _Socket, _Reason}, State) -> >>> {noreply, State}. >>> >>> terminate(_Reason, _State) -> >>> ok. >>> >>> >>> >>> >> >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> > > > From eric.l.2046@REDACTED Sat Jun 5 11:39:17 2010 From: eric.l.2046@REDACTED (Eric Liang) Date: Sat, 05 Jun 2010 17:39:17 +0800 Subject: [erlang-questions] beam[8449]: segfault at 0 ip 0000000000437e10 sp 00007fffce250948 error 4 in beam[400000+174000] In-Reply-To: <19453.25855.346911.194353@pilspetsen.it.uu.se> References: <4BFA2DEC.50707@gmail.com> <19450.17437.149260.11204@pilspetsen.it.uu.se> <4BFA71AE.5060708@gmail.com> <19450.31693.774522.332905@pilspetsen.it.uu.se> <4BFB4309.1060507@gmail.com> <19451.44811.595873.338827@pilspetsen.it.uu.se> <4BFD250F.6020202@gmail.com> <19453.25855.346911.194353@pilspetsen.it.uu.se> Message-ID: <4C0A1B45.1070304@gmail.com> On 05/27/2010 02:14 AM, Mikael Pettersson wrote: > Eric Liang wrote: > >> I've done a build of the source, but it just can't match the object. How >> do you make it? I use the command: apt-get source to get the source, so >> it does have the same version with the object. >> > I did: > > >> tar zxvf otp_src_R13B03.tar.gz >> cd otp_src_R13B03 >> ./configure; make >> > The binary files of interest are bin/x86_64-unknown-linux-gnu/beam and > erts/emulator/obj/x86_64-unknown-linux-gnu/opt/plain/erl_goodfit_alloc.o. > > Thanks Mikael, and sorry for replying you too late as the seg-fault is not occured every time. I get the debug symbols by this: http://forum.nginx.org/read.php?26,93440,94735 >>> You can get a stack dump from the crash by attaching gdb to the >>> soon-to-crash beam process. Now instead of being terminated gdb will >>> get control of the process and you should be able to print a stack >>> trace with bt or where. (This does require that there's a sufficient >>> time window from the start of the application to the crash.) >>> =20 >>> >> I've make a core dump 4 seconds before it crash, as mentioned above,=20 >> because don't get the right symbols, it just with some quesion-marks: >> >> Core was generated by `/usr/lib/erlang/erts-5.7.2/bin/beam'. >> #0 0x00007f0a28ecd5a9 in ?? () >> (gdb) whe >> #0 0x00007f0a28ecd5a9 in ?? () >> #1 0x0000000000000000 in ?? () >> (gdb) >> > A core dump from a time point before the crash is useless. Either get a > core dump from the crash itself (execute `ulimit -c unlimited' in bash > before running the test), or attach gdb, continue the process, and wait > for gdb to receive control when the crash occurs. > I do set the ulimit -c in /etc/profile and after I reboot it: sunny@REDACTED:~$ ulimit -c unlimited sunny@REDACTED:~/commands$ cat /proc/sys/kernel/core_pattern /tmp/core.%t.%e.%p And I the test is ok: sunny@REDACTED:~$ kill -s SIGSEGV $$ Connection to dev-2 closed. sunny@REDACTED:~$ ls /tmp/ core.1275730620.bash.12566 But still no core file generated,when the error occurs. Anyway, I attatched the running process by gdb, and here is the result: Program received signal SIGSEGV, Segmentation fault. unlink_free_block (allctr=0x7ad480, block=0x0) at beam/erl_goodfit_alloc.c:453 453 Uint sz = BLK_SZ(blk); (gdb) whe #0 unlink_free_block (allctr=0x7ad480, block=0x0) at beam/erl_goodfit_alloc.c:453 #1 0x0000000000437fd6 in get_free_block (allctr=0x7ad480, size=, cand_blk=0x0, cand_size=0) at beam/erl_goodfit_alloc.c:421 #2 0x00000000004322c6 in mbc_alloc_block (allctr=0x7ad480, size=72) at beam/erl_alloc_util.c:631 #3 mbc_alloc (allctr=0x7ad480, size=72) at beam/erl_alloc_util.c:758 #4 0x00000000004b1697 in erts_alloc () at beam/erl_alloc.h:179 #5 exit_async () at beam/erl_async.c:132 #6 0x000000000043c13d in system_cleanup (exit_code=) at beam/erl_init.c:1306 #7 0x000000000043c443 in erl_exit (n=0, fmt=0x54649c "") at beam/erl_init.c:1380 #8 0x000000000045d042 in halt_0 (A__p=) at beam/bif.c:3319 #9 0x00000000004d081f in process_main () at beam/beam_emu.c:2008 #10 0x000000000043d56c in erl_start (argc=34, argv=) at beam/erl_init.c:1233 #11 0x00000000004269b9 in main (argc=8049792, argv=0x0) at sys/unix/erl_main.c:29 (gdb) f 1 #1 0x0000000000437fd6 in get_free_block (allctr=0x7ad480, size=, cand_blk=0x0, cand_size=0) at beam/erl_goodfit_alloc.c:421 421 unlink_free_block(allctr, blk); (gdb) l 421 416 /* We are guaranteed to find a block that fits in this bucket */ 417 blk = search_bucket(allctr, min_bi, size); 418 ASSERT(blk); 419 if (cand_blk && cand_size <= BLK_SZ(blk)) 420 return NULL; /* cand_blk was better */ 421 unlink_free_block(allctr, blk); 422 return blk; 423 } 424 425 (gdb) As the running process use the no-debug symbol version beam, I guess the ASSERT in line:418 does not work. So I dig in (gdb) p allctr $1 = (Allctr_t *) 0x7ad480 (gdb) p min_bi $2 = (gdb) p size $3 = (gdb) p *allctr $4 = {name_prefix = 0x534227 "sl_", alloc_no = 3, name = {alloc = 0, realloc = 0, free = 0}, vsn_str = 0x53602f "2.1", t = 0, ramv = 0, sbc_threshold = 524288, sbc_move_threshold = 80, mbc_move_threshold = 50, main_carrier_size = 131072, max_mseg_sbcs = 256, max_mseg_mbcs = 5, largest_mbc_size = 10485760, smallest_mbc_size = 1048576, mbc_growth_stages = 10, mseg_opt = {cache = 1, preserv = 1, abs_shrink_th = 4145152, rel_shrink_th = 80}, mbc_header_size = 32, sbc_header_size = 32, min_mbc_size = 16384, min_mbc_first_free_size = 4096, min_block_size = 32, mbc_list = {first = 0x7f4f93a5d010, last = 0x7f4f93a5d010}, sbc_list = {first = 0x0, last = 0x0}, main_carrier = 0x7f4f93a5d010, get_free_block = 0x437f40 , link_free_block = 0x437d00 , unlink_free_block = 0x437e10 , info_options = 0x438480 , get_next_mbc_size = 0x430e40 , creating_mbc = 0x438100 , destroying_mbc = 0x438100 , init_atoms = 0x4385c0 , mutex = {mtx = {pt_mtx = { __data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = { __prev = 0x0, __next = 0x0}}, __size = '\000' , __align = 0}, is_rec_mtx = 0, prev = 0x0, next = 0x0}}, thread_safe = 0, ts_list = {prev = 0x0, next = 0x0}, atoms_initialized = 0, stopped = 0, calls = {this_alloc = {giga_no = 0, no = 2460}, this_free = {giga_no = 0, no = 2458}, this_realloc = {giga_no = 0, no = 0}, mseg_alloc = {giga_no = 0, no = 0}, mseg_dealloc = {giga_no = 0, no = 0}, mseg_realloc = {giga_no = 0, no = 0}, sys_alloc = {giga_no = 0, no = 1}, sys_free = {giga_no = 0, no = 0}, sys_realloc = {giga_no = 0, no = 0}}, sbcs = {curr_mseg = {no = 0, size = 0}, curr_sys_alloc = {no = 0, size = 0}, max = {no = 0, size = 0}, max_ever = {no = 0, size = 0}, blocks = {curr = {no = 0, size = 0}, max = {no = 0, size = 0}, max_ever = {no = 0, size = 0}}}, mbcs = {curr_mseg = {no = 0, size = 0}, curr_sys_alloc = {no = 1, size = 131112}, max = {no = 1, size = 131112}, max_ever = {no = 0, size = 0}, blocks = {curr = {no = 4, size = 384}, max = {no = 144, size = 13848}, max_ever = {no = 0, size = 0}}}} (gdb) And stalled here, do you have any advices? and also, any other suggestions would be appreciated. TIA. > >> Look back the initial error: >> >> segfault at 0 ip 0000000000437e10 sp 00007fffce250948 error 4 in >> beam[400000+174000] >> >> Would you mind tell me what's the meaning of -ip-/-sp-, and what does >> -error 4- means? >> > IP is the Instruction Pointer aka Program Counter. SP is the stack pointer. > The 'error 4' is a low-level error code which is irrelevant for us. > Got it, thank you. Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 261 bytes Desc: OpenPGP digital signature URL: From bartlomiej@REDACTED Sat Jun 5 11:54:40 2010 From: bartlomiej@REDACTED (=?utf-8?Q?Bart=C5=82omiej_Puzo=C5=84?=) Date: Sat, 5 Jun 2010 09:54:40 +0000 (GMT) Subject: [erlang-questions] Eastrisk library released In-Reply-To: Message-ID: <561320062.436261275731680894.JavaMail.root@zimbra> Thanks for spotting, updated. > > We have released our Asterisk interface. Feel free to fork from: > > http://github.com/esl/eastrisk > > > > It is missing license information. -- Bart?omiej Puzo? Erlang Solutions bartlomiej.puzon@REDACTED --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From rumata-estor@REDACTED Sat Jun 5 12:25:01 2010 From: rumata-estor@REDACTED (Dmitry Belyaev) Date: Sat, 05 Jun 2010 14:25:01 +0400 Subject: [erlang-questions] my socket can't handle the load In-Reply-To: <798646.58019.qm@web112601.mail.gq1.yahoo.com> References: <576214.89312.qm@web112601.mail.gq1.yahoo.com> <798646.58019.qm@web112601.mail.gq1.yahoo.com> Message-ID: <1275733501.2196.4.camel@rumbuntu> I've had the same problems with my emongo driver. Finally, I found that under heavy load received packet could consist of *two* responses but my code did process only first. Maybe this is your case too. On Sat, 2010-06-05 at 02:13 -0700, Pablo Platt wrote: > I was able to identify exactly when the issue happens. > As long as only one request at a time is sent to the driver it works fine: > request1, response1, request2, response2... > > If the client sends several requests as fast as it can without waiting for a response it breaks. > debug messages show the following: > request1, request2, response1, request3, response2, Error timeout for request3, response3 > > This failure is reproducible. The timeout occurs after 5000ms compared to ~10ms for a normal query. > It can't be related to too many messages in a process mail box because we are only talking about 3 requests. > I don't know if this issue is related to my driver or the db. > > Is there something related to sockets, or TCP that breaks when you send and receive data in a non-blocking way? > Is there an erlang driver that sends messages to a socket in a non-blocking way and handle responses according to a unique id tag > that I can use as a reference to see if any special configuration is needed? > > > > > > > ________________________________ > From: Kaiduan Xie > To: Pablo Platt > Cc: Bernard Duggan ; Erlang > Sent: Thu, June 3, 2010 3:14:33 PM > Subject: Re: [erlang-questions] my socket can't handle the load > > Pablo, you can use erlang:process_info(Pid, message_queue_len) to find > the mail box size of gen_server. > > On Thu, Jun 3, 2010 at 2:52 AM, Pablo Platt wrote: > > p.s. > > when getting a gen_server:call timeout the debug message of the > > requester(not the socket gen_server) says: > > heap_size: 1597 > > stack_size: 24 > > reductions: 1996 > > > > > > ________________________________ > > From: Pablo Platt > > To: Kaiduan Xie ; Bernard Duggan > > Cc: Erlang > > Sent: Thu, June 3, 2010 9:49:17 AM > > Subject: Re: [erlang-questions] my socket can't handle the load > > > > @Bernard, Kaiduan > > When I'm testing with a pool of 20 connections instead of 1, the driver and > > socket works fine. > > I think that means that both the receiver (database) and the sender can > > handle the load. > > When sending one request at a time from the same socket it also works fine > > but don't think this is the correct design. > > > > I don't think {active, once} is relevant here because responses from the db > > will only arrive when I make requests > > so I don't need to protect myself against DOS from untrusted third party. > > > > When getting a timeout on gen_server:call to the socket gen_server, how can > > I print useful info > > about the socket gen_server and the process calling it so I can see the > > mailbox queue of them and maybe other useful > > stuff that help me find the problem? > > > > Thanks > > > > ________________________________ > > From: Kaiduan Xie > > To: Bernard Duggan > > Cc: Pablo Platt ; Erlang > > > > Sent: Thu, June 3, 2010 3:59:02 AM > > Subject: Re: [erlang-questions] my socket can't handle the load > > > > Pablo, > > > > Have you considered any chance the call of > > gen_tcp:send(State#state.socket, Packet) getting blocked? For example, > > a slow receiver. If gen_tcp:send() is getting blocked, hand_call() > > will get blocked, and gen_server will slow down. Please look the > > example listed in gen_tcp, > > > > http://www.erlang.org/doc/man/gen_tcp.html#examples > > > > Kaiduan > > > > On Wed, Jun 2, 2010 at 5:35 PM, Bernard Duggan wrote: > >> Hi Pablo, > >> One thing you may want to try is to wherever possible, avoid letting > >> the queue on your gen_server grow beyond a couple of messages. Allowing > >> the queue to grow unchecked can cause serious performance degradation on > >> selective receives (which, to be fair, I can't see any of in your code, > >> but they can crop up in non-obvious library calls at times). > >> Off the top of my head, you'd do this by: > >> a) changing the handle_cast operation to a handle_call (to keep clients > >> using that operation from flooding you with requests) and > >> b) changing {active, true} to {active, once} in your connect call (and > >> making the corresponding change in handle_info to reactivate the socket. > >> > >> It may or may not be your problem, but it's a fairly easy change and > >> worth a try. > >> > >> Another possibility is that you have the same issue, but in the calling > >> process (I'm guessing now, since you haven't provided that code). A > >> gen_server call does a selective receive while it waits for a response - > >> if your message queue is very large when you make the call, there's a > >> good chance you'll get a timeout regardless of how quickly the > >> gen_server serves the request. > >> > >> Cheers, > >> > >> Bernard > >> > >> On 3/06/2010 1:27 AM, Pablo Platt wrote: > >>> Hi, > >>> > >>> I'm writing a driver to a database that is using a tcp socket. > >>> There are two types of messages, "send and forget" and "send and > >>> receive". > >>> I have a gen_server that is responsible for opening the socket, receive a > >>> message from a process and sending it to the socket and receive responses > >>> and pass them to the caller. > >>> The gen_server saves a list of {request_id, CallerPid} in the state to > >>> know who to respond to when a packet is received from the db. > >>> > >>> Everything works when the rate of messages is low but when increasing it > >>> I'm starting to get gen_server timeout error on the requestor. > >>> Do I need to add/change parameters when opening the socket? > >>> Should I queue requests and wait for a response before sending the next > >>> request or is it ok to send several requests one after the other? > >>> > >>> Thanks > >>> > >>> The client sends a request using either: > >>> Resp = gen_server:call(Conn, {request, Request}) > >>> or > >>> gen_server:cast(Conn, {request, Request}) > >>> > >>> > >>> The relevant gen_server code: > >>> > >>> init([Host, Port]) -> > >>> Socket = open_socket(Host, Port), > >>> {ok, #state{socket=Socket, req_id=1}}. > >>> > >>> open_socket(Host, Port) -> > >>> case gen_tcp:connect(Host, Port, [binary, {active, true}]) of > >>> {ok, Sock} -> > >>> Sock; > >>> {error, Reason} -> > >>> exit({open_socket_failed, Reason}) > >>> end. > >>> > >>> handle_call({request, Packet}, From, State) -> > >>> ReqID = State#state.req_id + 1, > >>> gen_tcp:send(State#state.socket, Packet), > >>> {noreply, State#state{req_id=ReqID, requests=[{ReqID, > >>> From}|State#state.requests]}}; > >>> > >>> handle_cast({request, Packet}, State) -> > >>> ReqID = State#state.req_id + 1, > >>> gen_tcp:send(State#state.socket, Packet), > >>> {noreply, State#state{req_id=ReqID}}. > >>> > >>> handle_info({tcp, _Socket, Data}, State) -> > >>> RawResp = <<(State#state.resp)/binary, Data/binary>>, > >>> case check_packet:decode_response(RawResp) of > >>> undefined -> > >>> {noreply, State#state{resp = RawResp}}; > >>> {Resp, Tail} -> > >>> ResponseTo = get_requestor(Resp), > >>> {value, {ResponseTo, Client}, NewRequests} = > >>> lists:keytake(ResponseTo, 1, State#state.requests), > >>> gen_server:reply(Client, Resp), > >>> {noreply, State#state{resp = Tail, requests=NewRequests}} > >>> end; > >>> > >>> % the following never been called, even when I'm getting the error. > >>> handle_info({tcp_closed, _Socket}, State) -> > >>> {noreply, State}; > >>> > >>> handle_info({tcp_error, _Socket, _Reason}, State) -> > >>> {noreply, State}. > >>> > >>> terminate(_Reason, _State) -> > >>> ok. > >>> > >>> > >>> > >>> > >> > >> > >> ________________________________________________________________ > >> erlang-questions (at) erlang.org mailing list. > >> See http://www.erlang.org/faq.html > >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > >> > >> > > > > > > > > > > From per@REDACTED Sat Jun 5 12:31:58 2010 From: per@REDACTED (Per Hedeland) Date: Sat, 5 Jun 2010 12:31:58 +0200 (CEST) Subject: [erlang-questions] my socket can't handle the load In-Reply-To: <798646.58019.qm@web112601.mail.gq1.yahoo.com> Message-ID: <201006051031.o55AVwQC092621@pluto.hedeland.org> Pablo Platt wrote: > >I was able to identify exactly when the issue happens. >As long as only one request at a time is sent to the driver it works fine: >request1, response1, request2, response2... > >If the client sends several requests as fast as it can without waiting for a response it breaks. >debug messages show the following: >request1, request2, response1, request3, response2, Error timeout for request3, response3 I think the problem is just that while your handle_info() callback tries to handle incomplete responses and additional data (and presumably you have some framing to allow you to do that), you never process more than one response per handle_info() invocation. I.e. what is happening here is most likely that the complete response3 arrives concatenated onto response2, but you don't process it - I believe you will find response3 sitting in State#state.resp. The fix is then (of course) to keep processing the data you received until there are no more complete responses. (I'm assuming that you can't make use of some variant of the nice 'packet' option, see inet:setopts/2.) --Per Hedeland From hvjunk@REDACTED Sat Jun 5 15:43:36 2010 From: hvjunk@REDACTED (Hendrik Visage) Date: Sat, 5 Jun 2010 15:43:36 +0200 Subject: [erlang-questions] Re: How to make the Erlang VM predictible when spawning processes? In-Reply-To: References: <20100604060413.GA11662@erix.ericsson.se> Message-ID: On 6/4/10, Ovidiu Deac wrote: > I was hoping that the latency introduced by the OS would be lower and > we would have enough time to satisfy the 10ms requirement. If you are > right then I guess 10ms response time is not realistic on a standard > system. Especially not on Windows ;) > Anyway we will do some tests first and then try to see what is doable > and what would be acceptable. You might be able to handle bursts, but as been mentioned before, you will have to also look at specialized OSs for real time needs like that. Which brings us to the question: Is it for things that somebody's life depends on, or is it for production/etc. where you will have damages if the 10ms is missed. In either of those two cases, you are better of with proper real time OS and software. However, if you have something that could handle a mis or three every so often (like webserver/OLTP/ATM/etc.) then these spikes should not worry you ;) > > On Fri, Jun 4, 2010 at 9:04 AM, Raimo Niskanen > wrote: >> Just a naive thought. >> >> On any contemporary OS (Windows, Linux, MacOS X, BSD...) you should >> expect that the OS scheduler might throw you out about 10..20 ms >> for some arbitrary OS reason... >> >> Unless you run some OS with a more real-timeish scheduler, >> i think there are e.g Linux flavours for this. >> >> On Fri, Jun 04, 2010 at 01:45:26AM +0300, Ovidiu Deac wrote: >>> I'm back with some tests that I've just ran on an Intel Core i5/Linux >>> 2.6.32/erts v5.7.4. >>> >>> The results look more credible since 1000 processes are no longer >>> spawned in 1microsecond. Also the variance between separate test >>> executions is much smaller. >>> >>> But the problem remains if I spawn 1 milion processes I come across >>> spawns which take up to 18milliseconds. So again, any idea about how I >>> could make the VM to be predictible? >>> >>> I assume that I should find the level of load that it can take. >>> Reusing processes as I would have done in other languages sounds like >>> a bad idea from start. Also I'm thinking I could increase the work >>> done by one process such that it's not too small but still it fits >>> inside the initial heap size so garbage collection is not needed. >>> >>> Also another thing that I observed is that during the test only about >>> 50% out of each processor seems to be used. At least this is what the >>> system monitor says. Any VM flags that would help with this? I tried >>> +P and +S but without results. >>> >>> Ovidiu >>> >>> >>> >>> On Thu, Jun 3, 2010 at 9:00 PM, Ovidiu Deac wrote: >>> > Hello everybody, >>> > >>> > I'm doing some research in order to figure out if Erlang is suitable >>> > for an application that we need to implement. >>> > >>> > In a few words it's about a server which has a requirement saying "no >>> > request should take more then 10ms"', measured on the client's >>> > computer. >>> > >>> > So I started a couple of tests for various erlang components to figure >>> > out how much some operations would take. Partly because I wanted to >>> > get some figures and partly to exercise my Erlang skills. >>> > >>> > First I wrote a profiler module which can measure the execution time >>> > for various modules which implement set_up,tear_down and test_main. >>> > Also this profiler can repeat a test a number of times and returns a >>> > list with all the execution times, the minimum, the maximum and the >>> > average time. Nothing fancy. >>> > >>> > See the attachment for the profiler code and I post below some results >>> > for a test that I ran on a machine with Intel Core2 Duo/Win7/erlang >>> > v5.7.5. One test consists in 1000 spawns and is repeated 100 times. >>> > The times displayed are microseconds. >>> > >>> > $ make -C .. && erl +P 200000 -noshell -s profiler run spawn_test 100 >>> > silent 0 1000 -s init stop >>> > make: Entering directory `/cygdrive/d/work/erlang/finn' >>> > make: Leaving directory `/cygdrive/d/work/erlang/finn' >>> > Module to test:spawn_test, Repeats:100, Params=[silent,'0','1000'] >>> > Times elapsed = >>> > [1,15998,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1,15991,1,1,1,1, >>> > >>> > 14991,1,1,1,1,15991,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1, >>> > >>> > 15991,1,1,1,1,1,14989,1,1,1,1,15991,1,1,1,1,15991,1,1,1, >>> > >>> > 14993,1,1,1,15993,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1,15991, >>> > 1,1,1,1,14991,1,1,1,15993,1,1,1,1,15991,1,1,1,1,14991] >>> > Max us/execution=15998 >>> > Min us/execution=1 >>> > Variation=15997 >>> > Average us/execution=3279.01 >>> > >>> > The average time for spawning a process is around 3us which is very >>> > good. It's interesting to see that spawning 1000 processes took >>> > 1microsecond (!!!) Looks like some bug it the profiler. Also my main >>> > concern is that from time to time spawning a process takes around 15ms >>> > which is way too much. >>> > >>> > I tried to run erl +P 200000 but the behaviour is the same as without >>> > this parameter. >>> > >>> > Do you have any idea how to make the VM predictible in order to >>> > satisfy the 10ms requirement? >>> > >>> > Thanks in advance, >>> > Ovidiu >>> > >>> >>> ________________________________________________________________ >>> erlang-questions (at) erlang.org mailing list. >>> See http://www.erlang.org/faq.html >>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>> >> >> -- >> >> / Raimo Niskanen, Erlang/OTP, Ericsson AB >> > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From pablo.platt@REDACTED Sat Jun 5 17:36:32 2010 From: pablo.platt@REDACTED (Pablo Platt) Date: Sat, 5 Jun 2010 08:36:32 -0700 (PDT) Subject: [erlang-questions] my socket can't handle the load In-Reply-To: <201006051031.o55AVwQC092621@pluto.hedeland.org> References: <201006051031.o55AVwQC092621@pluto.hedeland.org> Message-ID: <37029.59792.qm@web112619.mail.gq1.yahoo.com> That was the problem. Dmitry and Per you were both right. Thanks ________________________________ From: Per Hedeland To: pablo.platt@REDACTED Cc: erlang-questions@REDACTED Sent: Sat, June 5, 2010 1:31:58 PM Subject: Re: [erlang-questions] my socket can't handle the load Pablo Platt wrote: > >I was able to identify exactly when the issue happens. >As long as only one request at a time is sent to the driver it works fine: >request1, response1, request2, response2... > >If the client sends several requests as fast as it can without waiting for a response it breaks. >debug messages show the following: >request1, request2, response1, request3, response2, Error timeout for request3, response3 I think the problem is just that while your handle_info() callback tries to handle incomplete responses and additional data (and presumably you have some framing to allow you to do that), you never process more than one response per handle_info() invocation. I.e. what is happening here is most likely that the complete response3 arrives concatenated onto response2, but you don't process it - I believe you will find response3 sitting in State#state.resp. The fix is then (of course) to keep processing the data you received until there are no more complete responses. (I'm assuming that you can't make use of some variant of the nice 'packet' option, see inet:setopts/2.) --Per Hedeland ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED From pablo.platt@REDACTED Sat Jun 5 17:39:03 2010 From: pablo.platt@REDACTED (Pablo Platt) Date: Sat, 5 Jun 2010 08:39:03 -0700 (PDT) Subject: {packet, PacketType} for little-signed packets Message-ID: <385661.80040.qm@web112604.mail.gq1.yahoo.com> Hi Is there a way I can handle {packet, PacketType} for little-endian where Packet = <> Length=4+byte_size(Message) I currently handle it manually but it'll be nice if gen_tcp could handle it for me the way {packet, PacketType} works for big-endian byte order. Thanks From mhishami@REDACTED Sat Jun 5 18:54:05 2010 From: mhishami@REDACTED (Hisham) Date: Sun, 6 Jun 2010 00:54:05 +0800 Subject: [erlang-questions] SOAP Call In-Reply-To: References: <11599093-2d42-478d-b0b6-12e47be9699e@p5g2000pri.googlegroups.com> Message-ID: Hi Willem, Thanks for your note. I was afraid you might say this :-) No problem, as we just have to do this via template like ErlyDTL with mochiweb for preparing the message to be sent. Another way is to just hardcode the message structure into a string. We'll see which one works the best. As for receiving request, a normal erlsom:simple_form/1 can do the work just fine. Thanks for your tips Willem. Have a good weekend guys. On Fri, Jun 4, 2010 at 1:31 AM, Willem de Jong wrote: > Hi, > > The problem is that this uses SOAP 1.2 binding. This isn't supported. Do > you have the option to use version 1.1? > > Regards, > Willem > > On Wed, Jun 2, 2010 at 12:26 PM, Hisham wrote: > >> Hi Willem, >> >> Appreciate your reply (as always :D) >> Please find the attached file. Not sure if attachment is allowed, but I >> put the main email to you. >> >> >> On Wed, Jun 2, 2010 at 6:16 PM, Willem de Jong wrote: >> >>> Hello, >>> >>> Can you show us the WSDL? >>> >>> Regards, >>> Willem >>> >>> On Wed, Jun 2, 2010 at 11:29 AM, Hisham wrote: >>> >>>> Hi, >>>> >>>> >>>> I have below operation: >>>> >>>> 1> Wsdl = yaws_soap_lib:initModel("SDPServices.wsdl"). >>>> {wsdl,[], >>>> {model,[{type,'_document',sequence, >>>> [{el,[{alt,'soap:Header','soap:Header',[], >>>> 1,1,true, >>>> undefined}, >>>> {alt,'soap:Fault','soap:Fault',[], >>>> 1,1,true,undefined}, >>>> {alt,'soap:Envelope','soap:Envelope',[], >>>> 1,1,true,undefined}, >>>> {alt,'soap:Body','soap:Body',[], >>>> 1,1,true,undefined}, >>>> {...}|...], >>>> 3> yaws_soap_lib:wsdl_operations(Wsdl). >>>> [] >>>> 4> >>>> >>>> My concern is, I have "zero" operations after parsing the WSDL as >>>> shown in 3> above. >>>> I browse through the web, and some says I have to trim the >>>> "nillable=true" out, and it should be fine. >>>> That was done, but still the operations are zero. >>>> >>>> Anybody can pin point to the right direction? >>>> >>>> TIA. >>>> >>>> ________________________________________________________________ >>>> erlang-questions (at) erlang.org mailing list. >>>> See http://www.erlang.org/faq.html >>>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>>> >>>> >>> >> > From luismarianoguerra@REDACTED Sat Jun 5 19:45:16 2010 From: luismarianoguerra@REDACTED (Mariano Guerra) Date: Sat, 5 Jun 2010 14:45:16 -0300 Subject: sending extra information to leex or yecc? (or how to know the name of the file I'm parsing in them) Message-ID: the subject is rather long but that's what I need. I need to get the name of the file I'm parsing in leex or yecc it doesn't matter in which. If there isn't a way to get that, then is there a way to pass extra information to leex or yecc when I start running them with a file? From luismarianoguerra@REDACTED Sat Jun 5 20:52:53 2010 From: luismarianoguerra@REDACTED (Mariano Guerra) Date: Sat, 5 Jun 2010 15:52:53 -0300 Subject: sending extra information to leex or yecc? (or how to know the name of the file I'm parsing in them) In-Reply-To: References: Message-ID: On Sat, Jun 5, 2010 at 2:45 PM, Mariano Guerra wrote: > the subject is rather long but that's what I need. > > I need to get the name of the file I'm parsing in leex or yecc it > doesn't matter in which. > > If there isn't a way to get that, then is there a way to pass extra > information to leex or yecc when I start running them with a file? I reply myself, correct me if I'm wrong. erlang starts a server[1] that holds the information and the functions that want to know the values for the predefined macros send a message to that process right? [1] http://github.com/erlang/otp/blob/dev/lib/stdlib/src/epp.erl#L232 From torben.lehoff@REDACTED Sat Jun 5 23:35:58 2010 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Sat, 5 Jun 2010 23:35:58 +0200 Subject: [erlang-questions] {packet, PacketType} for little-signed packets In-Reply-To: <385661.80040.qm@web112604.mail.gq1.yahoo.com> References: <385661.80040.qm@web112604.mail.gq1.yahoo.com> Message-ID: Hi Pablo, I don't quite understand what your issue is, but it might be due to my lack of understanding of the gen_tcp details. If not I think you should rephrase your question. Anyway, I have a piece of advice based on your code sniplet. If you are defining the protocol yourself I would strongly suggest that you make Length equal to the size of the Message since it makes decoding a lot easier. I have dealt with Q.SIG and there the length in the PDU also depends on the size of the header which forces one to do the decoding in two steps instead of having the option to do it in one step in the function clause pattern match. Cheers, Torben On Sat, Jun 5, 2010 at 17:39, Pablo Platt wrote: > Hi > > Is there a way I can handle {packet, PacketType} for little-endian where > Packet = <> > Length=4+byte_size(Message) > > I currently handle it manually but it'll be nice if gen_tcp could handle it > for me the way {packet, PacketType} > works for big-endian byte order. > > Thanks > > > > -- http://www.linkedin.com/in/torbenhoffmann From pablo.platt@REDACTED Sun Jun 6 00:17:44 2010 From: pablo.platt@REDACTED (Pablo Platt) Date: Sat, 5 Jun 2010 15:17:44 -0700 (PDT) Subject: [erlang-questions] {packet, PacketType} for little-signed packets In-Reply-To: References: <385661.80040.qm@web112604.mail.gq1.yahoo.com> Message-ID: <272371.21887.qm@web112620.mail.gq1.yahoo.com> Hi Torben I'm implementing mongodbwire protocol http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol The first 4 bytes in each message are int32 of the "total message size, including the 4 bytes of length" and all data is little-endian: "Note that like BSON documents, all data in the mongo wire protocol is little-endian." Is it possible to patch gen_tcp to support BSON? Is there a simpler solution? ________________________________ From: Torben Hoffmann To: Pablo Platt ; erlang-questions Sent: Sun, June 6, 2010 12:35:58 AM Subject: Re: [erlang-questions] {packet, PacketType} for little-signed packets Hi Pablo, I don't quite understand what your issue is, but it might be due to my lack of understanding of the gen_tcp details. If not I think you should rephrase your question. Anyway, I have a piece of advice based on your code sniplet. If you are defining the protocol yourself I would strongly suggest that you make Length equal to the size of the Message since it makes decoding a lot easier. I have dealt with Q.SIG and there the length in the PDU also depends on the size of the header which forces one to do the decoding in two steps instead of having the option to do it in one step in the function clause pattern match. Cheers, Torben On Sat, Jun 5, 2010 at 17:39, Pablo Platt wrote: > Hi > > Is there a way I can handle {packet, PacketType} for little-endian where > Packet = <> > Length=4+byte_size(Message) > > I currently handle it manually but it'll be nice if gen_tcp could handle it > for me the way {packet, PacketType} > works for big-endian byte order. > > Thanks > > > > -- http://www.linkedin.com/in/torbenhoffmann From luismarianoguerra@REDACTED Sun Jun 6 03:17:53 2010 From: luismarianoguerra@REDACTED (Mariano Guerra) Date: Sat, 5 Jun 2010 22:17:53 -0300 Subject: [ANN] efene 0.7 - a language for the erlang VM - released Message-ID: For the complete release notes with details on each item and examples see the release notes here: http://marianoguerra.com.ar/efene/docs/releases/oseven.html About efene efene is a programming language that runs on the erlang virtual machine. The idea is to provide an alternative syntax to erlang that is most suitable for people coming from languages like Java, C, C++, C#, Javascript. The language is almost 100% compatible with erlang (and will be), the compiler allows to translate an efene source file into a readable erlang one or compile it directly to bytecode. It also adds some syntactic sugar in some places to make some tasks easier. Changes * if expression now allows calling functions in the condition, old and Erlang compatible if expression is now called when. No syntax changed. * for expression added as another way of writing list comprehensions with multiple statement body. * macro variables $module, $module_string, $file and $line replaced to it?s values at compile time. * scientific notation for floats. * improved error messages in objects. * improved documentation, tutorial and syntax highlighter. Resources * Download the latest snapshot: http://github.com/marianoguerra/efene/tarball/master * Website: http://marianoguerra.com.ar/efene * Documentation: http://marianoguerra.com.ar/efene/docs * Tutorial: http://marianoguerra.com.ar/efene/tutorial * Blog: http://efene.tumblr.com/ * Central repo: http://github.com/marianoguerra/efene * Issue Tracker: http://github.com/marianoguerra/efene/issues From torben.lehoff@REDACTED Sun Jun 6 11:50:17 2010 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Sun, 6 Jun 2010 11:50:17 +0200 Subject: [erlang-questions] {packet, PacketType} for little-signed packets In-Reply-To: <272371.21887.qm@web112620.mail.gq1.yahoo.com> References: <385661.80040.qm@web112604.mail.gq1.yahoo.com> <272371.21887.qm@web112620.mail.gq1.yahoo.com> Message-ID: Hi Pablo, No clue on the patching of gen_tcp. The mongodb wire protocol is not Erlang pattern matching friendly, since you have to record the Length, then peel off the message inside your function instead of doing the pattern matching directly in the function clause. Not a major issue, just annoying. Cheers, Torben On Sun, Jun 6, 2010 at 00:17, Pablo Platt wrote: > Hi Torben > > I'm implementing mongodb wire protocol > http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol > The first 4 bytes in each message are int32 of the "total message size, > including the 4 bytes of length" > and all data is little-endian: "Note that like BSON documents, all data in > the mongo wire protocol is little-endian." > > Is it possible to patch gen_tcp to support BSON? > Is there a simpler solution? > > ------------------------------ > *From:* Torben Hoffmann > *To:* Pablo Platt ; erlang-questions < > erlang-questions@REDACTED> > *Sent:* Sun, June 6, 2010 12:35:58 AM > *Subject:* Re: [erlang-questions] {packet, PacketType} for little-signed > packets > > Hi Pablo, > > I don't quite understand what your issue is, but it might be due to my lack > of understanding of the gen_tcp details. If not I think you should rephrase > your question. > > Anyway, I have a piece of advice based on your code sniplet. > > If you are defining the protocol yourself I would strongly suggest that you > make Length equal to the size of the Message since it makes decoding a lot > easier. I have dealt with Q.SIG and there the length in the PDU also > depends > on the size of the header which forces one to do the decoding in two steps > instead of having the option to do it in one step in the function clause > pattern match. > > Cheers, > Torben > > On Sat, Jun 5, 2010 at 17:39, Pablo Platt wrote: > > > Hi > > > > Is there a way I can handle {packet, PacketType} for little-endian where > > Packet = <> > > Length=4+byte_size(Message) > > > > I currently handle it manually but it'll be nice if gen_tcp could handle > it > > for me the way {packet, PacketType} > > works for big-endian byte order. > > > > Thanks > > > > > > > > > > > > > -- > http://www.linkedin.com/in/torbenhoffmann > > -- http://www.linkedin.com/in/torbenhoffmann From w.a.de.jong@REDACTED Sun Jun 6 12:10:13 2010 From: w.a.de.jong@REDACTED (Willem de Jong) Date: Sun, 6 Jun 2010 12:10:13 +0200 Subject: [erlang-questions] SOAP Call In-Reply-To: References: <11599093-2d42-478d-b0b6-12e47be9699e@p5g2000pri.googlegroups.com> Message-ID: Hi, Considering that you have the XSD, you might try an alternative approach: 1. extract the XSD from the WSDL (the bit between and ) 2. create a "model" out of this using erlsom:compile_xsd_file() 3. create a "model" for the soap envelope (of the right version...), again using erlsom:compile_xsd_file() 4. create a combined model using erlsom:add_model() (have a look at initModel2() in yaws_soap_lib.erl for an example). 5. create a set of record definitions using erlsom:write_hrl() The resulting model (and records) can be used to parse and generate the soap messages you need, using erlsom:scan() and erlsom:write(). Have a look at the erlsom documentation ! Regards, Willem Regards, Willem On Sat, Jun 5, 2010 at 6:54 PM, Hisham wrote: > Hi Willem, > > Thanks for your note. I was afraid you might say this :-) > > No problem, as we just have to do this via template like ErlyDTL with > mochiweb for preparing the message to be sent. > Another way is to just hardcode the message structure into a string. We'll > see which one works the best. > As for receiving request, a normal erlsom:simple_form/1 can do the work > just fine. > > Thanks for your tips Willem. > > Have a good weekend guys. > > > On Fri, Jun 4, 2010 at 1:31 AM, Willem de Jong wrote: > >> Hi, >> >> The problem is that this uses SOAP 1.2 binding. This isn't supported. Do >> you have the option to use version 1.1? >> >> Regards, >> Willem >> >> On Wed, Jun 2, 2010 at 12:26 PM, Hisham wrote: >> >>> Hi Willem, >>> >>> Appreciate your reply (as always :D) >>> Please find the attached file. Not sure if attachment is allowed, but I >>> put the main email to you. >>> >>> >>> On Wed, Jun 2, 2010 at 6:16 PM, Willem de Jong wrote: >>> >>>> Hello, >>>> >>>> Can you show us the WSDL? >>>> >>>> Regards, >>>> Willem >>>> >>>> On Wed, Jun 2, 2010 at 11:29 AM, Hisham wrote: >>>> >>>>> Hi, >>>>> >>>>> >>>>> I have below operation: >>>>> >>>>> 1> Wsdl = yaws_soap_lib:initModel("SDPServices.wsdl"). >>>>> {wsdl,[], >>>>> {model,[{type,'_document',sequence, >>>>> [{el,[{alt,'soap:Header','soap:Header',[], >>>>> 1,1,true, >>>>> undefined}, >>>>> {alt,'soap:Fault','soap:Fault',[], >>>>> 1,1,true,undefined}, >>>>> {alt,'soap:Envelope','soap:Envelope',[], >>>>> 1,1,true,undefined}, >>>>> {alt,'soap:Body','soap:Body',[], >>>>> 1,1,true,undefined}, >>>>> {...}|...], >>>>> 3> yaws_soap_lib:wsdl_operations(Wsdl). >>>>> [] >>>>> 4> >>>>> >>>>> My concern is, I have "zero" operations after parsing the WSDL as >>>>> shown in 3> above. >>>>> I browse through the web, and some says I have to trim the >>>>> "nillable=true" out, and it should be fine. >>>>> That was done, but still the operations are zero. >>>>> >>>>> Anybody can pin point to the right direction? >>>>> >>>>> TIA. >>>>> >>>>> ________________________________________________________________ >>>>> erlang-questions (at) erlang.org mailing list. >>>>> See http://www.erlang.org/faq.html >>>>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>>>> >>>>> >>>> >>> >> > From rvirding@REDACTED Sun Jun 6 16:54:42 2010 From: rvirding@REDACTED (Robert Virding) Date: Sun, 6 Jun 2010 16:54:42 +0200 Subject: [erlang-questions] Re: sending extra information to leex or yecc? (or how to know the name of the file I'm parsing in them) In-Reply-To: References: Message-ID: Do you mean the name of the source files used to generate a leex scanner or a yecc parser? Or do you mean the name of a file scanned by a leex scanner or parsed by a yecc parser? For a description of how a scanner/parser is integrated into the i/o system check out the i/o part of the Erlang Rationale found at: http://forum.trapexit.org/viewtopic.php?t=15022 In short neither know who calls them. When generating a scanner/parser there is no direct way to get the source file names, indirectly the source name is used to generate the module and file name of the resultant scanner/parser. What is that you want to do? Robert On 5 June 2010 20:52, Mariano Guerra wrote: > On Sat, Jun 5, 2010 at 2:45 PM, Mariano Guerra > wrote: >> the subject is rather long but that's what I need. >> >> I need to get the name of the file I'm parsing in leex or yecc it >> doesn't matter in which. >> >> If there isn't a way to get that, then is there a way to pass extra >> information to leex or yecc when I start running them with a file? > > I reply myself, correct me if I'm wrong. > > erlang starts a server[1] that holds the information and the functions > that want to know the values for the predefined macros send a message > to that process right? > > [1] http://github.com/erlang/otp/blob/dev/lib/stdlib/src/epp.erl#L232 > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From luismarianoguerra@REDACTED Sun Jun 6 19:42:34 2010 From: luismarianoguerra@REDACTED (Mariano Guerra) Date: Sun, 6 Jun 2010 14:42:34 -0300 Subject: [erlang-questions] Re: sending extra information to leex or yecc? (or how to know the name of the file I'm parsing in them) In-Reply-To: References: Message-ID: On Sun, Jun 6, 2010 at 11:54 AM, Robert Virding wrote: > Do you mean the name of the source files used to generate a leex > scanner or a yecc parser? Or do you mean the name of a file scanned by > a leex scanner or parsed by a yecc parser? > > For a description of how a scanner/parser is integrated into the i/o > system check out the i/o part of the Erlang Rationale found at: > > http://forum.trapexit.org/viewtopic.php?t=15022 > > In short neither know who calls them. When generating a scanner/parser > there is no direct way to get the source file names, indirectly the > source name is used to generate the module and file name of the > resultant scanner/parser. > > What is that you want to do? I had to replace some macro variables in my language[1] and needed to know the name of the file that I was parsing to replace $module $module_string and $file, what I did whas to spawn a process, register it with a name[2] and before starting the parsing I stored the information in the process[3], then from yecc I request the information sending a message[4] if there is a better way to do it I would like to know how, if there is some observations on how I did it it would be nice too :) [1] http://github.com/marianoguerra/efene [2] http://github.com/marianoguerra/efene/blob/0181fcecb2f0e430b2c5ac13b2652070ddb5476f/src/fn_server.erl#L4 [3] http://github.com/marianoguerra/efene/blob/0181fcecb2f0e430b2c5ac13b2652070ddb5476f/src/fn.erl#L287 [4] http://github.com/marianoguerra/efene/blob/0181fcecb2f0e430b2c5ac13b2652070ddb5476f/src/fn_parser.yrl#L266 From reachsaurabhnarula@REDACTED Sun Jun 6 23:01:37 2010 From: reachsaurabhnarula@REDACTED (Saurabh Narula) Date: Mon, 7 Jun 2010 02:31:37 +0530 Subject: size_object: bad tag for 0x600 Message-ID: Hello everyone, I am getting this error when i try to pattern match the result of C language NIF function with the erlang term. Even though the Eterm returned from the C Language NIF and erlang Term are same in format, the pattern match operation fails with the error "size_object: bad tag for 0x600". Overview of what i am doing - 1. send string with binary format from erlang to NIF. 2. inside NIF do operations. 3. parse string character by character inside NiF, make head | tail List/String 4. make eterms with these string with some atom etc. 5. pass it back to erlang. 6. do a pattern match of the string in erlang and string/list received from C NIF. Thank you in advance for your help. Saurabh From tuncer.ayaz@REDACTED Sun Jun 6 23:33:17 2010 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Sun, 6 Jun 2010 23:33:17 +0200 Subject: [erlang-questions] size_object: bad tag for 0x600 In-Reply-To: References: Message-ID: On Sun, Jun 6, 2010 at 11:01 PM, Saurabh Narula wrote: > Hello everyone, > > I am getting this error when i try to pattern match the result of C > language NIF function with the erlang term. > > Even though the Eterm returned from the C Language NIF and erlang > Term are same in format, the pattern match operation fails with the > error "size_object: bad tag for 0x600". The term you create seems to be of invalid type (tag) as size_object() bails out with that error. This might happen if the term is tagged as a binary but contains invalid data not matching the type. > Overview of what i am doing - > > 1. send string with binary format from erlang to NIF. > 2. inside NIF do operations. > 3. parse string character by character inside NiF, make head | tail > List/String > 4. make eterms with these string with some atom etc. > 5. pass it back to erlang. > 6. do a pattern match of the string in erlang and string/list > received from C NIF. Can you share the code on- or off-list? From tuncer.ayaz@REDACTED Sun Jun 6 23:44:14 2010 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Sun, 6 Jun 2010 23:44:14 +0200 Subject: [erlang-questions] size_object: bad tag for 0x600 In-Reply-To: References: Message-ID: On Sun, Jun 6, 2010 at 11:33 PM, Tuncer Ayaz wrote: > On Sun, Jun 6, 2010 at 11:01 PM, Saurabh Narula wrote: >> Hello everyone, >> >> I am getting this error when i try to pattern match the result of C >> language NIF function with the erlang term. >> >> Even though the Eterm returned from the C Language NIF and erlang >> Term are same in format, the pattern match operation fails with the >> error "size_object: bad tag for 0x600". > > The term you create seems to be of invalid type (tag) as size_object() > bails out with that error. This might happen if the term is tagged as > a binary but contains invalid data not matching the type. One way to trigger that error is calling enif_make_list_from_array() with an array where some elements are uninitialized. From mikpe@REDACTED Mon Jun 7 00:02:17 2010 From: mikpe@REDACTED (Mikael Pettersson) Date: Mon, 7 Jun 2010 00:02:17 +0200 Subject: [erlang-questions] size_object: bad tag for 0x600 In-Reply-To: References: Message-ID: <19468.6889.314426.180955@pilspetsen.it.uu.se> Saurabh Narula writes: > Hello everyone, > > I am getting this error when i try to pattern match the result of C > language NIF function with the erlang term. > > Even though the Eterm returned from the C Language NIF and erlang Term > are same in format, the pattern match operation fails with the error > "size_object: bad tag for 0x600". > > Overview of what i am doing - > > 1. send string with binary format from erlang to NIF. > 2. inside NIF do operations. > 3. parse string character by character inside NiF, make head | tail List/String > 4. make eterms with these string with some atom etc. > 5. pass it back to erlang. > 6. do a pattern match of the string in erlang and string/list received > from C NIF. > > > Thank you in advance for your help. size_object() operates on Erlang terms, but 0x600 is not a valid representation for any Erlang term, that's why it complains. Somewhere in your code where you construct Erlang terms you do so incorrectly. Perhaps you're inserting a C integer into a term somewhere and forgot to call make_small()? From ovidiudeac@REDACTED Mon Jun 7 00:13:16 2010 From: ovidiudeac@REDACTED (Ovidiu Deac) Date: Mon, 7 Jun 2010 01:13:16 +0300 Subject: [erlang-questions] Re: How to make the Erlang VM predictible when spawning processes? In-Reply-To: References: <20100604060413.GA11662@erix.ericsson.se> Message-ID: After the tests we did we have two options. Either to reconsider the requirements and accept something like <10ms in 99% of the calls or to do some tests with a more RT-capable os. We'll think about it next week. Thanks for your answers. On Sat, Jun 5, 2010 at 4:43 PM, Hendrik Visage wrote: > On 6/4/10, Ovidiu Deac wrote: >> I was hoping that the latency introduced by the OS would be lower and >> we would have enough time to satisfy the 10ms requirement. If you are >> right then I guess 10ms response time is not realistic on a standard >> system. > > Especially not on Windows ;) > >> Anyway we will do some tests first and then try to see what is doable >> and what would be acceptable. > > You might be able to handle bursts, but as been mentioned before, you > will have to also look at specialized OSs for real time needs like > that. Which brings us to the question: Is it for things that > somebody's life depends on, or is it for production/etc. where you > will have damages if the 10ms is missed. > > In either of those two cases, you are better of with proper real time > OS and software. > > However, if you have something that could handle a mis or three every > so often (like ?webserver/OLTP/ATM/etc.) then these spikes should not > worry you ;) > > >> >> On Fri, Jun 4, 2010 at 9:04 AM, Raimo Niskanen >> wrote: >>> Just a naive thought. >>> >>> On any contemporary OS (Windows, Linux, MacOS X, BSD...) you should >>> expect that the OS scheduler might throw you out about 10..20 ms >>> for some arbitrary OS reason... >>> >>> Unless you run some OS with a more real-timeish scheduler, >>> i think there are e.g Linux flavours for this. >>> >>> On Fri, Jun 04, 2010 at 01:45:26AM +0300, Ovidiu Deac wrote: >>>> I'm back with some tests that I've just ran on an Intel Core i5/Linux >>>> 2.6.32/erts v5.7.4. >>>> >>>> The results look more credible since 1000 processes are no longer >>>> spawned in 1microsecond. Also the variance between separate test >>>> executions is much smaller. >>>> >>>> But the problem remains if I spawn 1 milion processes I come across >>>> spawns which take up to 18milliseconds. So again, any idea about how I >>>> could make the VM to be predictible? >>>> >>>> I assume that I should find the level of load that it can take. >>>> Reusing processes as I would have done in other languages sounds like >>>> a bad idea from start. Also I'm thinking I could increase the work >>>> done by one process such that it's not too small but still it fits >>>> inside the initial heap size so garbage collection is not needed. >>>> >>>> Also another thing that I observed is that during the test only about >>>> 50% out of each processor seems to be used. At least this is what the >>>> system monitor says. Any VM flags that would help with this? I tried >>>> +P and +S but without results. >>>> >>>> Ovidiu >>>> >>>> >>>> >>>> On Thu, Jun 3, 2010 at 9:00 PM, Ovidiu Deac wrote: >>>> > Hello everybody, >>>> > >>>> > I'm doing some research in order to figure out if Erlang is suitable >>>> > for an application that we need to implement. >>>> > >>>> > In a few words it's about a server which has a requirement saying "no >>>> > request should take more then 10ms"', measured on the client's >>>> > computer. >>>> > >>>> > So I started a couple of tests for various erlang components to figure >>>> > out how much some operations would take. Partly because I wanted to >>>> > get some figures and partly to exercise my Erlang skills. >>>> > >>>> > First I wrote a profiler module which can measure the execution time >>>> > for various modules which implement set_up,tear_down and test_main. >>>> > Also this profiler can repeat a test a number of times and returns a >>>> > list with all the execution times, the minimum, the maximum and the >>>> > average time. Nothing fancy. >>>> > >>>> > See the attachment for the profiler code and I post below some results >>>> > for a test that I ran on a machine with Intel Core2 Duo/Win7/erlang >>>> > v5.7.5. One test consists in 1000 spawns and is repeated 100 times. >>>> > The times displayed are microseconds. >>>> > >>>> > $ make -C .. && erl +P 200000 -noshell -s profiler run spawn_test 100 >>>> > silent 0 1000 -s init stop >>>> > make: Entering directory `/cygdrive/d/work/erlang/finn' >>>> > make: Leaving directory `/cygdrive/d/work/erlang/finn' >>>> > Module to test:spawn_test, Repeats:100, Params=[silent,'0','1000'] >>>> > Times elapsed = >>>> > [1,15998,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1,15991,1,1,1,1, >>>> > >>>> > 14991,1,1,1,1,15991,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1, >>>> > >>>> > 15991,1,1,1,1,1,14989,1,1,1,1,15991,1,1,1,1,15991,1,1,1, >>>> > >>>> > 14993,1,1,1,15993,1,1,1,1,14991,1,1,1,1,15991,1,1,1,1,15991, >>>> > ? ? ? ? ? ? ? ? 1,1,1,1,14991,1,1,1,15993,1,1,1,1,15991,1,1,1,1,14991] >>>> > Max us/execution=15998 >>>> > Min us/execution=1 >>>> > Variation=15997 >>>> > Average us/execution=3279.01 >>>> > >>>> > The average time for spawning a process is around 3us which is very >>>> > good. It's interesting to see that spawning 1000 processes took >>>> > 1microsecond (!!!) Looks like some bug it the profiler. Also my main >>>> > concern is that from time to time spawning a process takes around 15ms >>>> > which is way too much. >>>> > >>>> > I tried to run erl +P 200000 but the behaviour is the same as without >>>> > this parameter. >>>> > >>>> > Do you have any idea how to make the VM predictible in order to >>>> > satisfy the 10ms requirement? >>>> > >>>> > Thanks in advance, >>>> > Ovidiu >>>> > >>>> >>>> ________________________________________________________________ >>>> erlang-questions (at) erlang.org mailing list. >>>> See http://www.erlang.org/faq.html >>>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>>> >>> >>> -- >>> >>> / Raimo Niskanen, Erlang/OTP, Ericsson AB >>> >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> > From fritchie@REDACTED Mon Jun 7 07:23:15 2010 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Mon, 07 Jun 2010 00:23:15 -0500 Subject: [erlang-questions] monitor and failure detectors In-Reply-To: Message of "Thu, 03 Jun 2010 10:46:46 +0200." Message-ID: <3365.1275888195@snookles.snookles.com> Johan Montelius wrote: jw> Ok, so it's a global parameter for all monitors. From a application jw> level point of view it could be an advantage to have this as a per jw> monitor value. Hrm, I don't know if that's really feasible. It's the net_kernel's job to keep track of inter-node timeouts. The timeout used is the same for all connections to all other nodes. (You can have lots of "fun" with asymmetric timeout behavior by using different kernel net_ticktime values for different nodes, for very small values of "fun".) Assuming that you could have different timeout values between nodes, once a net_kernel connection between two nodes is interrupted, the net kernel (with help from the VM, IIRC) will immediately deliver all monitor DOWN events. Delaying the delivery of those {'DOWN', ...} events doesn't seem to me to have much useful value. If the TCP(*) connection between node A & B is broken, but you delay {'DOWN', ...} events from being delivered on A ... then some process on node A could happily assume that it could send messages to B when it almost certainly cannot. If "delay of DOWN event delivery" means being more cautious about whether or not a network partition has happened or if the remote node really did crash, you can't get that distinction from the net_kernel. You have to roll your own ... and prompt delivery of DOWN events is likely your best choice in that case, also. -Scott (*) Unless you're using a custom distribution protocol such as SCTP (I've never used it but it's alleged to exist?), it's either an unencrypted TCP connection or an SSL-encrypted TCP connection. From shehan@REDACTED Mon Jun 7 08:38:24 2010 From: shehan@REDACTED (shehan) Date: Mon, 7 Jun 2010 12:08:24 +0530 Subject: Mnesia DB problem Message-ID: <20100607063854.4BF8D19DC1C2@mail.wavenet.lk> Hi, I run db system which is related to heavy read/write operations. I mainly used transaction mode for data writing & dirty operation for data reading. However time to time db operations become stuck & when I run mnesia: info() in db nodes, following can be seen. Pls help to resolve my problem. Lock: {{test_frag13,'______WHOLETABLE_____'}, read, {tid,5075530493,<3214.15349.12>}} Note: I use following parameters for db nodes start script. ERL_MAX_ETS_TABLES=40000 MAX_PROCESSES=1024000 Br, Shehan From kagato@REDACTED Mon Jun 7 09:10:56 2010 From: kagato@REDACTED (Jayson Vantuyl) Date: Mon, 7 Jun 2010 00:10:56 -0700 Subject: [erlang-questions] monitor and failure detectors In-Reply-To: <3365.1275888195@snookles.snookles.com> References: <3365.1275888195@snookles.snookles.com> Message-ID: <1068364F-02C2-4F86-9FBD-F5D9D69F45CA@souja.net> In any case, there is a race condition between when the connection dies and the message is handled. Reading too much into the message is trouble. It's what I like to call a "volatile" message. It means only that a failure detector kicked in, and it doesn't actually contribute much information other than that a delay of a certain time existed at some point. As such, it doesn't really mean that the node is 'down' or not. It conveys no solid information about the node being down unless the node explicitly said that it went down (which I don't believe that it does anyways). I'm not sure what difference a 'DOWN' message would make if it were to come after a timeout. It certainly wouldn't have much more of an effect than just increasing the tick time via net_kernel by the same amount. On Jun 6, 2010, at 10:23 PM, Scott Lystig Fritchie wrote: > Johan Montelius wrote: > > jw> Ok, so it's a global parameter for all monitors. From a application > jw> level point of view it could be an advantage to have this as a per > jw> monitor value. > > Hrm, I don't know if that's really feasible. It's the net_kernel's job > to keep track of inter-node timeouts. The timeout used is the same for > all connections to all other nodes. (You can have lots of "fun" with > asymmetric timeout behavior by using different kernel net_ticktime > values for different nodes, for very small values of "fun".) > > Assuming that you could have different timeout values between nodes, > once a net_kernel connection between two nodes is interrupted, the net > kernel (with help from the VM, IIRC) will immediately deliver all > monitor DOWN events. > > Delaying the delivery of those {'DOWN', ...} events doesn't seem to me to > have much useful value. If the TCP(*) connection between node A & B is > broken, but you delay {'DOWN', ...} events from being delivered on A > ... then some process on node A could happily assume that it could send > messages to B when it almost certainly cannot. > > If "delay of DOWN event delivery" means being more cautious about > whether or not a network partition has happened or if the remote node > really did crash, you can't get that distinction from the net_kernel. > You have to roll your own ... and prompt delivery of DOWN events is > likely your best choice in that case, also. > > -Scott > > (*) Unless you're using a custom distribution protocol such as SCTP > (I've never used it but it's alleged to exist?), it's either an > unencrypted TCP connection or an SSL-encrypted TCP connection. > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > -- Jayson Vantuyl 417-207-6962 (mobile) kagato@REDACTED From johanmon@REDACTED Mon Jun 7 09:55:34 2010 From: johanmon@REDACTED (Johan Montelius) Date: Mon, 07 Jun 2010 09:55:34 +0200 Subject: [erlang-questions] monitor and failure detectors In-Reply-To: <3365.1275888195@snookles.snookles.com> References: <3365.1275888195@snookles.snookles.com> Message-ID: Agree, there is no point in delaying information but if I have a distributed system with plenty of nodes and I want five processes (on different nodes) to monitor each other more closely, then I could let them have a monitor timeout of two seconds while all other nodes monitor each other as usual with a 60s timeout. If one had this approach one could of course also ask the question - if we don't have any nodes monitoring each other (or links between them) then why query the status of another node at all? Setting up heartbeats between nodes could be a on demand service. Johan On Mon, 07 Jun 2010 07:23:15 +0200, Scott Lystig Fritchie wrote: > Delaying the delivery of those {'DOWN', ...} events doesn't seem to me to > have much useful value. -- Associate Professor Johan Montelius Royal Institute of Technology - KTH School of Information and Communication Technology - ICT From johanmon@REDACTED Mon Jun 7 10:09:14 2010 From: johanmon@REDACTED (Johan Montelius) Date: Mon, 07 Jun 2010 10:09:14 +0200 Subject: [erlang-questions] monitor and failure detectors In-Reply-To: <1068364F-02C2-4F86-9FBD-F5D9D69F45CA@souja.net> References: <3365.1275888195@snookles.snookles.com> <1068364F-02C2-4F86-9FBD-F5D9D69F45CA@souja.net> Message-ID: A DOWN message does not give you very much information about what happened but it might be that no DOWN message does give you a lot of information. I would like if the semantics of Erlang where such that: If a sequence of messages is potentially lost from A to B and B is monitoring A the B will receive a DOWN-noconnection message. The DOWN message is delivered to B after the last message that was reliably delivered and before any message sent after the potentially lost sequence of messages. If this is the case then it does mean a lot. As long as B does not receive DOWN-noconnection message it can live in a world where messages are reliably delivered from A to B. Is this the semantics of Erlang today? Johan On Mon, 07 Jun 2010 09:10:56 +0200, Jayson Vantuyl wrote: > In any case, there is a race condition between when the connection dies > and the message is handled. Reading too much into the message is > trouble. > > It's what I like to call a "volatile" message. It means only that a > failure detector kicked in, and it doesn't actually contribute much > information other than that a delay of a certain time existed at some > point. As such, it doesn't really mean that the node is 'down' or not. > It conveys no solid information about the node being down unless the > node explicitly said that it went down (which I don't believe that it > does anyways). > > I'm not sure what difference a 'DOWN' message would make if it were to > come after a timeout. It certainly wouldn't have much more of an effect > than just increasing the tick time via net_kernel by the same amount. > > On Jun 6, 2010, at 10:23 PM, Scott Lystig Fritchie wrote: > >> Johan Montelius wrote: >> >> jw> Ok, so it's a global parameter for all monitors. From a application >> jw> level point of view it could be an advantage to have this as a per >> jw> monitor value. >> >> Hrm, I don't know if that's really feasible. It's the net_kernel's job >> to keep track of inter-node timeouts. The timeout used is the same for >> all connections to all other nodes. (You can have lots of "fun" with >> asymmetric timeout behavior by using different kernel net_ticktime >> values for different nodes, for very small values of "fun".) >> >> Assuming that you could have different timeout values between nodes, >> once a net_kernel connection between two nodes is interrupted, the net >> kernel (with help from the VM, IIRC) will immediately deliver all >> monitor DOWN events. >> >> Delaying the delivery of those {'DOWN', ...} events doesn't seem to me >> to >> have much useful value. If the TCP(*) connection between node A & B is >> broken, but you delay {'DOWN', ...} events from being delivered on A >> ... then some process on node A could happily assume that it could send >> messages to B when it almost certainly cannot. >> >> If "delay of DOWN event delivery" means being more cautious about >> whether or not a network partition has happened or if the remote node >> really did crash, you can't get that distinction from the net_kernel. >> You have to roll your own ... and prompt delivery of DOWN events is >> likely your best choice in that case, also. >> >> -Scott >> >> (*) Unless you're using a custom distribution protocol such as SCTP >> (I've never used it but it's alleged to exist?), it's either an >> unencrypted TCP connection or an SSL-encrypted TCP connection. >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> > -- Associate Professor Johan Montelius Royal Institute of Technology - KTH School of Information and Communication Technology - ICT From michal.ptaszek@REDACTED Mon Jun 7 10:45:17 2010 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Mon, 7 Jun 2010 08:45:17 +0000 (GMT) Subject: Restarting registered processes Message-ID: <664092650.437491275900317862.JavaMail.root@zimbra> Hi, I was wondering what is the best way to handle the following situation. There is an application with main app's supervisor, under which we have additional sup (let's call it SUP), that has ~100 children, each one of them is a registered process (for now assume it is necessary to have them all registered). In the test scenario, we kill SUP and expect the main app supervisor to restart it. Of course, when SUP dies it sends exit signals to all its children which should die as well (they do not have trap_exit flag set). As soon as they exit, their references should be removed from the registered processes table. Unfortunately it turns out that SUP is restarted before all the children from previous epoch manage to shut down (process the exit signal). Because of that new children get badarg when they try to register themselves, SUP restarts again and again, until it reaches the max_restart_intensity: then whole application collapses. Do you have any idea how to solve this problem? I will be grateful for any hint. Best regards, Michal Ptaszek --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From rumata-estor@REDACTED Mon Jun 7 10:48:35 2010 From: rumata-estor@REDACTED (Dmitry Belyaev) Date: Mon, 07 Jun 2010 12:48:35 +0400 Subject: [erlang-questions] {packet, PacketType} for little-signed packets In-Reply-To: <272371.21887.qm@web112620.mail.gq1.yahoo.com> References: <385661.80040.qm@web112604.mail.gq1.yahoo.com> <272371.21887.qm@web112620.mail.gq1.yahoo.com> Message-ID: <4C0CB263.4090204@nm.ru> There is implementation on BSON in emongo. You can look at http://bitbucket.org/rumataestor/emongo It is not necessary to use {packet, ...} at all. Dmitry Belyaev On 06/06/2010 02:17 AM, Pablo Platt wrote: > Hi Torben > > I'm implementing mongodbwire protocol http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol > The first 4 bytes in each message are int32 of the "total message size, including the 4 bytes of length" > and all data is little-endian: "Note that like BSON documents, all data in the mongo wire protocol is little-endian." > > Is it possible to patch gen_tcp to support BSON? > Is there a simpler solution? > > > > > ________________________________ > From: Torben Hoffmann > To: Pablo Platt; erlang-questions > Sent: Sun, June 6, 2010 12:35:58 AM > Subject: Re: [erlang-questions] {packet, PacketType} for little-signed packets > > Hi Pablo, > > I don't quite understand what your issue is, but it might be due to my lack > of understanding of the gen_tcp details. If not I think you should rephrase > your question. > > Anyway, I have a piece of advice based on your code sniplet. > > If you are defining the protocol yourself I would strongly suggest that you > make Length equal to the size of the Message since it makes decoding a lot > easier. I have dealt with Q.SIG and there the length in the PDU also depends > on the size of the header which forces one to do the decoding in two steps > instead of having the option to do it in one step in the function clause > pattern match. > > Cheers, > Torben > > On Sat, Jun 5, 2010 at 17:39, Pablo Platt wrote: > > >> Hi >> >> Is there a way I can handle {packet, PacketType} for little-endian where >> Packet =<> >> Length=4+byte_size(Message) >> >> I currently handle it manually but it'll be nice if gen_tcp could handle it >> for me the way {packet, PacketType} >> works for big-endian byte order. >> >> Thanks >> >> >> >> >> > > > > From ulf.wiger@REDACTED Mon Jun 7 11:26:48 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Mon, 07 Jun 2010 11:26:48 +0200 Subject: [erlang-questions] Restarting registered processes In-Reply-To: <664092650.437491275900317862.JavaMail.root@zimbra> References: <664092650.437491275900317862.JavaMail.root@zimbra> Message-ID: <4C0CBB58.4030103@erlang-solutions.com> Hi Michal, I'm not entirely sure that this is a realistic case. What you are simulating is a bug in the supervisor, as far as I can tell (by killing it - with exit(SUP,kill)?). Normally, when a supervisor terminates, it will verify that all children are in fact dead before terminating itself. BR, Ulf W Michal Ptaszek wrote: > Hi, > > I was wondering what is the best way to handle the following > situation. > > There is an application with main app's supervisor, under which > we have additional sup (let's call it SUP), that has ~100 children, > each one of them is a registered process (for now assume it is > necessary to have them all registered). > > In the test scenario, we kill SUP and expect the main app supervisor > to restart it. Of course, when SUP dies it sends exit signals to > all its children which should die as well (they do not have > trap_exit flag set). As soon as they exit, their references should > be removed from the registered processes table. > > Unfortunately it turns out that SUP is restarted before all the > children from previous epoch manage to shut down (process the exit > signal). Because of that new children get badarg when they try to > register themselves, SUP restarts again and again, until it reaches > the max_restart_intensity: then whole application collapses. > > Do you have any idea how to solve this problem? > > I will be grateful for any hint. > > Best regards, > Michal Ptaszek -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From erik@REDACTED Mon Jun 7 15:45:17 2010 From: erik@REDACTED (Erik Bogghed) Date: Mon, 7 Jun 2010 15:45:17 +0200 Subject: Unicode Normalization Message-ID: Hi, I have been trying to get my head around this one for a few days. Is there any way to get UTF8 to normalized form C in Erlang? I have found a discussion about this in the CouchDB mailing list but I have not seen anything in the erlang documentation or any library for it. Most other languages have libraries for it, like Normalizer for PHP (http://php.net/manual/en/class.normalizer.php). Erik From francesco@REDACTED Tue Jun 8 00:58:42 2010 From: francesco@REDACTED (Francesco Cesarini (Erlang Solutions)) Date: Mon, 07 Jun 2010 23:58:42 +0100 Subject: Erlang @ CUFP in Baltimore 2/10 Talk Submission Deadline Message-ID: <4C0D79A2.10108@erlang-solutions.com> Hi All, a note to say that the deadline to submit a talk at the Commercial Users of Functional programming workshop in Baltimore is the 15th of June. While I would love to see Erlang strongly represented at the workshop, it is up to you to submit a talk proposal. There will be no published proceedings, as the meeting is intended to be more a discussion forum than a technical interchange. We're looking for two kinds of talks: *Experience reports* are typically 25 minutes long, and aim to inform participants about how functional programming plays out in real-world applications, focusing especially on lessons learned and insights gained. Experience reports don't need to be highly technical; reflections on the commercial, management, or software engineering aspects are, if anything, more important. You do not need to submit a paper! *Technical talks* are expected to be 30-45 minutes long, and should focus on teaching the audience something about a technical technique or methodology, from the point of view of someone who has seen it play out in practice. These talks could cover anything from techniques for building functional concurrent applications, to managing dynamic reconfigurations, to design recipes for using types effectively in large-scale applications. While these talks will often be based on a particular language, they should be accessible to a broad range of functional programmers. For more information and submission details, visit the CUFP website at http://cufp.org/2010-call-presentations See you there! Francesco --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From fritchie@REDACTED Tue Jun 8 03:00:26 2010 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Mon, 07 Jun 2010 20:00:26 -0500 Subject: [erlang-questions] monitor and failure detectors In-Reply-To: Message of "Mon\, 07 Jun 2010 10\:09\:14 +0200." Message-ID: <65314.1275958826@snookles.snookles.com> Johan Montelius wrote: jw> If a sequence of messages is potentially lost from A to B and B is jw> monitoring A the B will receive a DOWN-noconnection message. The jw> DOWN message is delivered to B after the last message that was jw> reliably delivered and before any message sent after the potentially jw> lost sequence of messages. IIRC, that's the current behavior, described in "Programming Distributed Erlang Applications: Pitfalls and Recipes" by H. Nilsson & L-?. Fredlund, ACM Erlang Workshop, 2007. -Scott From johanmon@REDACTED Tue Jun 8 09:58:28 2010 From: johanmon@REDACTED (Johan Montelius) Date: Tue, 08 Jun 2010 09:58:28 +0200 Subject: [erlang-questions] monitor and failure detectors In-Reply-To: <65314.1275958826@snookles.snookles.com> References: <65314.1275958826@snookles.snookles.com> Message-ID: One might want it to be more than the "current behaviour" :-) To exemplify how this question lacks a precise answer one can read this in the Reference Manual: "Message sending is asynchronous and safe, the message is guaranteed to eventually reach the recipient, provided that the recipient exists." In the manual for erlang:monitor/2 we are only told that down messages will be sent: "A 'DOWN' message will be sent to the monitoring process if Item dies, if Item does not exist, or if the connection is lost to the node which Item resides on." In the description by Barklund and Virdning it is stated that: "It is ensured that whenever possible, a signal dispatched to a process should eventually arrive at it." In the "Pitfalls and Recipes" we have: "If two messages m1 and m2 are sent, in order, from a process Q to a process P, and Q is linked (or monitors) to P, and no exit message from P is received at Q, then it is guaranteed that the message have been delivered, in order, at P." Which is the opposit of what I propose. It could well be that it is the "current behaviour" but is it defined by the language? Johan On Tue, 08 Jun 2010 03:00:26 +0200, Scott Lystig Fritchie wrote: > Johan Montelius wrote: > > jw> If a sequence of messages is potentially lost from A to B and B is > jw> monitoring A the B will receive a DOWN-noconnection message. The > jw> DOWN message is delivered to B after the last message that was > jw> reliably delivered and before any message sent after the potentially > jw> lost sequence of messages. > > IIRC, that's the current behavior, described in "Programming Distributed > Erlang Applications: Pitfalls and Recipes" by H. Nilsson & > L-?. Fredlund, ACM Erlang Workshop, 2007. > > -Scott -- Associate Professor Johan Montelius Royal Institute of Technology - KTH School of Information and Communication Technology - ICT From ulf.wiger@REDACTED Tue Jun 8 10:01:26 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 08 Jun 2010 10:01:26 +0200 Subject: [erlang-questions] monitor and failure detectors In-Reply-To: <65314.1275958826@snookles.snookles.com> References: <65314.1275958826@snookles.snookles.com> Message-ID: <4C0DF8D6.7000106@erlang-solutions.com> Scott Lystig Fritchie wrote: > > IIRC, that's the current behavior, described in "Programming Distributed > Erlang Applications: Pitfalls and Recipes" by H. Nilsson & > L-?. Fredlund, ACM Erlang Workshop, 2007. > > -Scott That was H. Svensson, not H. Nilsson. :) In both cases, H stands for Hans, BTW, and they both have a pretty firm grasp of Erlang (not to mention the fact that both presented at the workshop in Freiburg), so the error is forgivable. :) BR, Ulf W -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From johanmon@REDACTED Tue Jun 8 10:13:24 2010 From: johanmon@REDACTED (Johan Montelius) Date: Tue, 08 Jun 2010 10:13:24 +0200 Subject: [erlang-questions] Process Monitoring In-Reply-To: References: Message-ID: Hi, I don't know the answer but since your question relates to mine in the tread "monitor and failure detectors" I could provide my understanding of how this. I don't think you will have a measurable difference between monitoring each individual process on the remote card compared to monitoring the node they are running on. Individual monitors do not send their own heartbeats to see if a process is alive, it is simply being passively registered as interested when the process terminates. Locally they have also been registered as being interested in the state of the node. The local node then monitors the remote node using heartbeats. For your previous questions: 1) Are we guaranteed to get the {'DOWN', MonitorRef, Type, Object, Info} if the remote node crashes? See my other thread, I guess that the current behavior is - yes. 2) Is there a cost in doing many erlang:monitor calls (especially over remote nodes)? I don't think so. 3) Would a better option (WRT node crash) to maintain a table of node id's and interested pids on that node, and do erlang:monitor_node/2 instead? Don't think so. Johan On Thu, 27 May 2010 15:48:45 +0200, Evans, Matthew wrote: > Hi > > I asked this question a while ago, but no takers. > > I wish to monitor multiple processes on a remote card. Would the best > approach be to do erlang:monitor/2, or do erlang:monitor_node/2 and > write a simple (local) mechanism to alert interested parties locally? > > I guess the bigger question is: Is there any overhead of doing remote > erlang:monitor/2 calls? Since gen_server uses it my guess is no. > > Thanks > > Matt -- Associate Professor Johan Montelius Royal Institute of Technology - KTH School of Information and Communication Technology - ICT From ulf.wiger@REDACTED Tue Jun 8 10:18:44 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 08 Jun 2010 10:18:44 +0200 Subject: ttb:stop() doesn't fetch - bug or feature? Message-ID: <4C0DFCE4.6030008@erlang-solutions.com> Playing around with ttb, I have repeatedly been annoyed by the default behaviour of ttb:stop(). Even if you have set up a trace with a file handler (i.e. saying that you want to log to disk), ttb:stop() will not actually fetch the data and store to disk unless you explicitly call either stop([fetch]) or stop([format]). There is no recovery if you forget; you simply have to start over. I would like the default behaviour to be the logical one depending on how I started the trace. It is not obvious to me as a naive user that ttb does not in fact store the data on disk until I fetch. In fact, I have to 'fetch' even if I set up a "diskless" trace, using the {file,{local,F}} option, even though the traced nodes are pushing the trace data to the tracer node in real-time via the trace port. I would like to change ttb:stop() so that it automatically fetches if logging to disk has been specified, but this would of course break BW compatibility. Perhaps a new function, ttb:stop_trace(), which has the right defaults? Or maybe rather a ttb:fetch()? The question then would be if it should stop the tracing by default, or simply flush trace data to disk and continue tracing? Comments welcome. To make matters worse, fetch on a "diskless trace" doesn't actually work, so a test case on this might be in order. It is a rather minor bug fix, which I could submit later. This made me wonder how many actually rely on the current behaviour, though... A final gripe in this area: after fetching, ttb prints to the tty the name of the directory it just created to store the trace files. I think it would be much better if the name were returned to the caller, so that one doesn't have to search the current working directory to deduce the location of the files, or parse stdout. This would be an API change, or at least an addition to the API. Any voices against? BR, Ulf W -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From piotrek.kaleta@REDACTED Tue Jun 8 12:17:11 2010 From: piotrek.kaleta@REDACTED (Piotr Kaleta) Date: Tue, 08 Jun 2010 12:17:11 +0200 Subject: lists:seq/3 strange behaviour Message-ID: <4C0E18A7.1040507@gmail.com> What was the reason for lists:seq function to be implemented in a way that if you call: lists:seq(2, 1, 10) it works as expected returning an an empty list, while when beeing called like: lists:seq(20, 1, 10) it throws an exception? From pablo.platt@REDACTED Tue Jun 8 13:55:45 2010 From: pablo.platt@REDACTED (Pablo Platt) Date: Tue, 8 Jun 2010 04:55:45 -0700 (PDT) Subject: [erlang-questions] {packet, PacketType} for little-signed packets In-Reply-To: <4C0CB263.4090204@nm.ru> References: <385661.80040.qm@web112604.mail.gq1.yahoo.com> <272371.21887.qm@web112620.mail.gq1.yahoo.com> <4C0CB263.4090204@nm.ru> Message-ID: <377540.97897.qm@web112613.mail.gq1.yahoo.com> {packet, ...} will be much faster, reduce the code and possible errors. If someone can point me to what file need to be patched I can try to do it myself. ________________________________ From: Dmitry Belyaev To: erlang-questions@REDACTED Sent: Mon, June 7, 2010 11:48:35 AM Subject: Re: [erlang-questions] {packet, PacketType} for little-signed packets There is implementation on BSON in emongo. You can look at http://bitbucket.org/rumataestor/emongo It is not necessary to use {packet, ...} at all. Dmitry Belyaev On 06/06/2010 02:17 AM, Pablo Platt wrote: > Hi Torben > > I'm implementing mongodbwire protocol http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol > The first 4 bytes in each message are int32 of the "total message size, including the 4 bytes of length" > and all data is little-endian: "Note that like BSON documents, all data in the mongo wire protocol is little-endian." > > Is it possible to patch gen_tcp to support BSON? > Is there a simpler solution? > > > > > ________________________________ > From: Torben Hoffmann > To: Pablo Platt; erlang-questions > Sent: Sun, June 6, 2010 12:35:58 AM > Subject: Re: [erlang-questions] {packet, PacketType} for little-signed packets > > Hi Pablo, > > I don't quite understand what your issue is, but it might be due to my lack > of understanding of the gen_tcp details. If not I think you should rephrase > your question. > > Anyway, I have a piece of advice based on your code sniplet. > > If you are defining the protocol yourself I would strongly suggest that you > make Length equal to the size of the Message since it makes decoding a lot > easier. I have dealt with Q.SIG and there the length in the PDU also depends > on the size of the header which forces one to do the decoding in two steps > instead of having the option to do it in one step in the function clause > pattern match. > > Cheers, > Torben > > On Sat, Jun 5, 2010 at 17:39, Pablo Platt wrote: > > >> Hi >> >> Is there a way I can handle {packet, PacketType} for little-endian where >> Packet =<> >> Length=4+byte_size(Message) >> >> I currently handle it manually but it'll be nice if gen_tcp could handle it >> for me the way {packet, PacketType} >> works for big-endian byte order. >> >> Thanks >> >> >> >> >> > > > > ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED From pascalchapier@REDACTED Tue Jun 8 14:08:51 2010 From: pascalchapier@REDACTED (Pascal Chapier) Date: Tue, 8 Jun 2010 14:08:51 +0200 Subject: lists:seq/3 strange behaviour Message-ID: In fact it does exactly what it is written in the documentation: seq(From, To, Incr) -> Seq Types: >From = To = Incr = int() Seq = [int()] Returns a sequence of integers which starts with From and contains the successive results of adding Incr to the previous element, until To has been reached or passed (in the latter case, To is not an element of the sequence). Incr defaults to 1. Failure: If ToFrom-Incr and Incr is negative, or if Incr==0 and From/=To. and implemented in the code: seq(First, Last, Inc) when is_integer(First), is_integer(Last), is_integer(Inc) -> if Inc > 0, First - Inc =< Last; Inc < 0, First - Inc >= Last -> N = (Last - First + Inc) div Inc, seq_loop(N, Inc*(N-1)+First, Inc, []); Inc =:= 0, First =:= Last -> seq_loop(1, First, Inc, []) end. But you are right, the purpose of the If test is to evaluate the length of the list, and as there is no default contition which could produce an empty list, I guess that the intent was to generate an exception when parameters cannot produce finite non empty list. So I think it is a bug and tha the code should be seq(First, Last, Inc) when is_integer(First), is_integer(Last), is_integer(Inc) -> if Inc > 0, First + Inc =< Last; Inc < 0, First - Inc >= Last -> N = (Last - First + Inc) div Inc, seq_loop(N, Inc*(N-1)+First, Inc, []); Inc =:= 0, First =:= Last -> seq_loop(1, First, Inc, []) end. and the doc: Failure: If ToFrom-Incr and Incr is negative, or if Incr==0 and From/=To. Or, a solution that I prefer, add a default condition which return an empty list as you suggest. Pascal. _________________________________________________________________ La bo?te mail NOW G?n?ration vous permet de r?unir toutes vos bo?tes mail dans Hotmail ! http://www.windowslive.fr/hotmail/nowgeneration/ From jesper.pettersson@REDACTED Tue Jun 8 15:58:07 2010 From: jesper.pettersson@REDACTED (Jesper Pettersson) Date: Tue, 8 Jun 2010 15:58:07 +0200 Subject: [erlang-questions] lists:seq/3 strange behaviour In-Reply-To: References: Message-ID: Piotr wrote: > What was the reason for lists:seq function to be implemented in a way that if you call: > lists:seq(2, 1, 10) > it works as expected returning an an empty list, while when beeing called like: > lists:seq(20, 1, 10) > it throws an exception? Pascal wrote: > Or, a solution that I prefer, add a default condition which return an empty list as you suggest. In earlier versions (for example R12B-5) lists:seq/3 on the examples above throws a function-clause exception which makes more sense than a missing true-branch in an if-clause. I would prefer stronger guards and a function-clause exception over a solution which returns an empty list simply because the function is undefined for those cases. /Jesper Pettersson From kenrobinsonster@REDACTED Tue Jun 8 16:12:55 2010 From: kenrobinsonster@REDACTED (Ken Robinson) Date: Wed, 9 Jun 2010 00:12:55 +1000 Subject: [erlang-questions] gen_fsm crashes In-Reply-To: References: Message-ID: Hi All, Inspecting the gen_fsm.erl code from std_lib, it has a main loop(Parent, Name, StateName, StateData, Mod, Timeout, Debug) method. Appears one can have a bad receive timeout value. Need to now see what is a good way to track down that value. I see that Debug has options like trace and log. I am now trying to start up the application so these Debug options are active. Ken. On Tue, Jun 1, 2010 at 11:55 PM, kenrobinson wrote: > Hi All, > This being my first post to this list, please feel free to correct any > mistakes I make on the group ?etiquette on posts. > > I am running a supervisor which uses the standard restart strategy. > Here is a snippet from my .app file covering the gen_fsm which > crashes. > > ?{transport_tx_fsm, %% tag > ? {transport_tx_fsm, start_link, []}, > ? permanent, > ? 10000, > ? worker, > ? [transport_tx_fsm]}, > > > I start up using the following command line: > erl -pa test ebin priv -sname ken1 -boot start_sasl > > I load using application:load(jaus) and application:start(jaus). It > starts correctly. > > I also load some test code using l(transport_tx_fsm_test) and fire off > a message to transport_tx_fsm. Test code is sent to it like so: > ? ?gen_fsm:send_event(transport_tx_fsm, {send, SR}), > > After it crashes, it appears to restart and process the message (see > below). > > My question is what does the bad timeout value signify where I haven't > started the gen_fsm with a timeout value? > regards, > Ken > > =CRASH REPORT==== 30-May-2010::23:54:53 === > ?crasher: > ? ?initial call: transport_tx_fsm:init/1 > ? ?pid: <0.103.0> > ? ?registered_name: transport_tx_fsm > ? ?exception error: bad receive timeout value > ? ? ?in function ?gen_fsm:loop/7 > ? ?ancestors: [jaus_supervisor,<0.53.0>] > ? ?messages: [] > ? ?links: [<0.61.0>] > ? ?dictionary: [] > ? ?trap_exit: false > ? ?status: running > ? ?heap_size: 377 > ? ?stack_size: 24 > ? ?reductions: 476 > ?neighbours: > > =SUPERVISOR REPORT==== 30-May-2010::23:54:53 === > ? ? Supervisor: {local,jaus_supervisor} > ? ? Context: ? ?child_terminated > ? ? Reason: ? ? timeout_value > ? ? Offender: ? [{pid,<0.103.0>}, > ? ? ? ? ? ? ? ? ?{name,transport_tx_fsm}, > ? ? ? ? ? ? ? ? ?{mfa,{transport_tx_fsm,start_link,[]}}, > ? ? ? ? ? ? ? ? ?{restart_type,permanent}, > ? ? ? ? ? ? ? ? ?{shutdown,10000}, > ? ? ? ? ? ? ? ? ?{child_type,worker}] > > 23:54:53.896740 2010-05-30 [info] Called init message in > transport_tx_fsm > > 23:54:53.896821 2010-05-30 [info] handle_info udp args > ClientSocket #Port<0.1353> > ?Host ? ? ? ? {127,0,0,1} > Port ? ? ? ? 47761 > Data ? ? ? ? <<2,0,128,0,192,3,2,1,0,6,5,64,0,1,1,19,0>> > State ? ? ? ?{state} > > > =PROGRESS REPORT==== 30-May-2010::23:54:53 === > ? ? ? ? ?supervisor: {local,jaus_supervisor} > ? ? ? ? ? ? started: [{pid,<0.105.0>}, > ? ? ? ? ? ? ? ? ? ? ? {name,transport_tx_fsm}, > ? ? ? ? ? ? ? ? ? ? ? {mfa,{transport_tx_fsm,start_link,[]}}, > ? ? ? ? ? ? ? ? ? ? ? {restart_type,permanent}, > ? ? ? ? ? ? ? ? ? ? ? {shutdown,10000}, > ? ? ? ? ? ? ? ? ? ? ? {child_type,worker}] > 23:54:53.901490 2010-05-30 [info] unwrap arg > <<2,0,128,0,192,3,2,1,0,6,5,64,0,1,1,19,0>> > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From pascalchapier@REDACTED Tue Jun 8 17:53:30 2010 From: pascalchapier@REDACTED (Pascal Chapier) Date: Tue, 8 Jun 2010 17:53:30 +0200 Subject: [erlang-questions] lists:seq/3 strange behaviour Message-ID: OOps, I answer too fast, I think the the code should be seq(First, Last, Inc) when is_integer(First), is_integer(Last), is_integer(Inc) -> if Inc > 0, First =< Last; Inc < 0, First >= Last -> N = (Last - First + Inc) div Inc, seq_loop(N, Inc*(N-1)+First, Inc, []); Inc =:= 0, First =:= Last -> seq_loop(1, First, Inc, []) end. In this case we get: an exeption for both for lists:seq(2, 1, 10) and lists:seq(20, 1, 10). a list of one element if inc > (last-first) positive case at least the behavior is symetric for positive and negative increment. I know, the "let it crash" is more in conformance with the Erlang usage :o) As the good behavior depends on the the application use case, may be you are right, and the application will have to include a try/catch if the case is likely to appear. Pascal > Date: Tue, 8 Jun 2010 15:58:07 +0200 > From: jesper.pettersson@REDACTED > To: pascalchapier@REDACTED > CC: erlang-questions@REDACTED > Subject: Re: [erlang-questions] lists:seq/3 strange behaviour > > Piotr wrote: > > What was the reason for lists:seq function to be implemented in a way that > if you call: > > lists:seq(2, 1, 10) > > it works as expected returning an an empty list, while when beeing called > like: > > lists:seq(20, 1, 10) > > it throws an exception? > > Pascal wrote: > > Or, a solution that I prefer, add a default condition which return an > empty list as you suggest. > > In earlier versions (for example R12B-5) lists:seq/3 on the examples above > throws a function-clause exception which makes more sense than a missing > true-branch in an if-clause. I would prefer stronger guards and a > function-clause exception over a solution which returns an empty list simply > because the function is undefined for those cases. > > /Jesper Pettersson _________________________________________________________________ La bo?te mail NOW G?n?ration vous permet de r?unir toutes vos bo?tes mail dans Hotmail ! http://www.windowslive.fr/hotmail/nowgeneration/ From jvliwanag@REDACTED Wed Jun 9 02:21:45 2010 From: jvliwanag@REDACTED (Jan Vincent) Date: Wed, 9 Jun 2010 08:21:45 +0800 Subject: [erlang-questions] how to interface a mysql database ? In-Reply-To: <201006031252091525836@its3.ch> References: <201006031252091525836@its3.ch> Message-ID: There's also Amnesia http://amnesia.sourceforge.net/ . It's an erlang abstraction layer to SQL. On Jun 3, 2010, at 6:52 PM, info wrote: > For the time beeing, what is at disposal to interface a mysql database ? > - the ODBC driver > - the Yariv's driver > > What else ? > John Jan Vincent Liwanag jvliwanag@REDACTED From ok@REDACTED Wed Jun 9 03:26:02 2010 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 9 Jun 2010 13:26:02 +1200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> Message-ID: On Jun 4, 2010, at 5:53 PM, Igor Ribeiro Sucupira wrote: > Although I disagree with this opinion, I recognize that deciding if > "the call is there" depends on how far one thinks the compiler should > go. The issue wasn't "how far the compiler should go" but "what the compiler should SAY". It is simply that error messages should not be misleading. In the case at hand, when there IS a call to ?MODULE:f/n a compiler that says ?MODULE:f/n is unused is *WRONG*. Period. If on the other hand the compiler says there is no *LOCAL* call to f/n, then it is saying something true. > I believe the compiler has a coherent behavior in that case: function > calls with module syntax are only "resolved" at run time, so deciding > the call is there in that example would require the compiler to treat > as a special case the calls that happen to be to a module with the > same name as the one being compiled. > The compiler opts to not do that extra analysis of function calls, > since it doesn't absolutely need to. Maybe this is not as "clever" as > it could be, but I think it is a coherent behavior. No, because what the compiler *says* (this function is not used) is not consistent with what the compiler has *done* (checked whether there are any local calls). In fact I have found error messages from the compiler about functions not being used to be wrong vastly more often than they are right, simply because other errors in a module often calls to be overlooked. So instead of saying something about f/n not being *used* ("anywhere" being Griceanly implied) the compiler should say that ** no local calls to f/n were detected > >> In short, I am not quarreling with the decision to report an >> error here, only commenting that the error message is extremely >> misleading. This is a general principle about error messages. A compiler has checked whether some condition C holds or not. The error message should relate to condition C, not to some other C'. As a general rule, compilers should not try to guess *why* condition C was violated; I've found such guesses to be wrong more often than right. But they should be clear, truthful, not misleading about why they are complaining. From ok@REDACTED Wed Jun 9 03:53:29 2010 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 9 Jun 2010 13:53:29 +1200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <20100604062538.GB11662@erix.ericsson.se> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> <20100604062538.GB11662@erix.ericsson.se> Message-ID: <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> On Jun 4, 2010, at 6:25 PM, Raimo Niskanen wrote: >>> This was a little bit unrelated to the topic. Given that you can't >>> call a non-exported function with that syntax, that code is >>> certainly >>> not calling the local fun spawn/1, since it's not exported. >> >> Note that I wasn't suggesting that the call should be *allowed*, >> only that it is *there*. There's a big difference between >> "there are NO calls to this function" and > > But there *are* no calls to the local function spawn/1. Yes there is, it's just not a *local* call. > > The local function spawn/1 will never be used and > that is what that warning says. No it isn't, really. If the error message said There is a remote call to local function spawn/1 but it is not exported so it can never be used that way. I might agree with you. Just to repeat the context, imagine -module(foo). -export([bah/1]). bar(X) -> [X]. ./foo.erl:2: function bah/1 undefined ./foo.erl:3: Warning: function bar/1 is unused The mistake here isn't that bar/1 isn't used, but that it's not *exported*. We can see this even more clearly if we change the example: 1 -module(foo). 2 -export([bah/1]). 3 bar(X) when X < 0 -> ugh(-X); 4 bar(X) -> X+1. 5 ugh(X) when X < 0 -> bar(-X); 6 ugh(X) -> X-1. ./foo.erl:2: function bah/1 undefined ./foo.erl:3: Warning: function bar/1 is unused ./foo.erl:5: Warning: function ugh/1 is unused This time there *is* a local function call to bar/1 and there *is* a local function call to ugh/1. They are both *used*. What they aren't is *reachable*. Now let's change the example one more time. 1 -module(foo). 2 -export([zoo/0]). 3 bar(X) when X < 0 -> ugh(-X); 4 bar(X) -> X+1. 5 ugh(X) when X < 0 -> bar(-X); 6 ugh(X) -> X-1. 7 zoo() -> is_function(fun bar/1), is_function(fun ugh/1). ./foo.erl:7: Warning: the call to is_function/1 has no effect The functions bar/1 and ugh/1 are no more reachable than before. There is no possible call from the outside that will ever result in either function being invoked. But suddenly they are "used". Judging from the outside, what we have is a function is reachable iff (1) it is exported or (2) there is a local call to it from a reachable function or (3) a 'fun f/n' term referring to it occurs in a reachable function. A function can be *USED* fifty million times without being reachable, and as a test case like the one above proved, a function can be reachable without being used. This means that the wording of the error message is misleading. >> In short, I am not quarreling with the decision to report an >> error here, only commenting that the error message is extremely >> misleading. > > #1 is. #2 not really. No, really. Whether the error message in question occurs or not has nothing to do with whether the function is used, only with whether it is reachable. If you get the error message, no amount of adding *uses* will remove it, unless they happen to be reachable ones. The message "no exported function directly or indirectly mentions f/n" would not be misleading. Even better, it would draw the programmer's attention to the probable cause: a missing -export. From ok@REDACTED Wed Jun 9 04:05:55 2010 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 9 Jun 2010 14:05:55 +1200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: References: Message-ID: On Jun 4, 2010, at 9:29 PM, Attila Rajmund Nohl wrote: > 2010/6/4, Richard O'Keefe : >> 6 spawn(F) -> F(41). >> >> where we're expecting foo:bar() to return 42. >> erlc reports >> >> /foo.erl:4: Warning: call to spawn/1 will call erlang:spawn/1; not >> spawn/1 in this module >> (add an explicit module name to the call to avoid this warning) >> ./foo.erl:6: Warning: defining BIF spawn/1 >> ./foo.erl:6: Warning: function spawn/1 is unused >> >> The second message is clearly WRONG: this _can't_ be defining the >> built-in function erlang:spawn/1 because this isn't the erlang: >> module. > > I think that second message is right. It is right that there is a message. What the message literally says is completely untrue. > The message is not about > erlang:spawn, Maybe not, BUT IT SAYS THAT IT IS! It doesn't mention 'erlang:', true. But it does say "BIF", and this function definition, whatever else it is, is NOT a BIF definition. The error message should say something like 'local definition clashes with pre-R14A auto-imported function.' Just at the moment, with a small class of students who've just met Erlang, I have become very sensitive to the question of when error messages do more harm than good. From igorrs@REDACTED Wed Jun 9 07:06:33 2010 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Wed, 9 Jun 2010 02:06:33 -0300 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> <20100604062538.GB11662@erix.ericsson.se> <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> Message-ID: On Tue, Jun 8, 2010 at 10:53 PM, Richard O'Keefe wrote: > > On Jun 4, 2010, at 6:25 PM, Raimo Niskanen wrote: >>>> >>>> This was a little bit unrelated to the topic. Given that you can't >>>> call a non-exported function with that syntax, that code is certainly >>>> not calling the local fun spawn/1, since it's not exported. >>> >>> Note that I wasn't suggesting that the call should be *allowed*, >>> only that it is *there*. ?There's a big difference between >>> "there are NO calls to this function" and >> >> But there *are* no calls to the local function spawn/1. > > Yes there is, it's just not a *local* call. >> >> The local function spawn/1 will never be used and >> that is what that warning says. > > No it isn't, really. This is quite clearly what Raimo said: ./foo.erl:6: Warning: function spawn/1 is unused Also, I think it was a crucial point: the compiler's analysis decided (it wasn't a guess) that the function you're compiling will never be executed. You may argue that "usage" and "call" are more synonyms than "usage" and "execution", but then we could argue forever. As I can argue that the function you're are compiling will never be called (and this is actually my point of view). You disagree, but what I see in the code foo:spawn(...) is a call to an exported function, called spawn, with arity 1, on module foo. Maybe my mind is affected by the times I had to plan and perform code upgrades, but I really don't see a call in that code to the function you are compiling. Anyway, you can throw this last paragraph away, because what I wanted to stress is above it. Best regards. Igor. > If the error message said > ? ? ? ?There is a remote call to local function spawn/1 > ? ? ? ?but it is not exported so it can never be used > ? ? ? ?that way. > I might agree with you. From igorrs@REDACTED Wed Jun 9 07:42:58 2010 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Wed, 9 Jun 2010 02:42:58 -0300 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> <20100604062538.GB11662@erix.ericsson.se> <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> Message-ID: On Tue, Jun 8, 2010 at 10:53 PM, Richard O'Keefe wrote: > > The mistake here isn't that bar/1 isn't used, but that > it's not *exported*. ?We can see this even more clearly > if we change the example: > > ? ? 1 ?-module(foo). > ? ? 2 ?-export([bah/1]). > ? ? 3 ?bar(X) when X < 0 -> ugh(-X); > ? ? 4 ?bar(X) -> X+1. > ? ? 5 ?ugh(X) when X < 0 -> bar(-X); > ? ? 6 ?ugh(X) -> X-1. > > ? ? ./foo.erl:2: function bah/1 undefined > ? ? ./foo.erl:3: Warning: function bar/1 is unused > ? ? ./foo.erl:5: Warning: function ugh/1 is unused > > This time there *is* a local function call to bar/1 > and there *is* a local function call to ugh/1. ?They > are both *used*. ?What they aren't is *reachable*. > > Now let's change the example one more time. > > ? ? 1 ?-module(foo). > ? ? 2 ?-export([zoo/0]). > ? ? 3 ?bar(X) when X < 0 -> ugh(-X); > ? ? 4 ?bar(X) -> X+1. > ? ? 5 ?ugh(X) when X < 0 -> bar(-X); > ? ? 6 ?ugh(X) -> X-1. > ? ? 7 ?zoo() -> is_function(fun bar/1), is_function(fun ugh/1). > > ? ? ./foo.erl:7: Warning: the call to is_function/1 has no effect > > The functions bar/1 and ugh/1 are no more reachable than before. > There is no possible call from the outside that will ever result in > either function being invoked. ?But suddenly they are "used". What I see here is that the function bar/1 will never be executed and will never be called (consider code execution), but its value is used in code that can be executed and that's something that I call "usage". For example: if you remove the function, reachable code breaks. So maybe this is one of the main sources of disagreement in this thread: the strength one thinks there is in the relation between "reachable code" and the concept of "usage". Best regards. Igor. From hasan.veldstra@REDACTED Wed Jun 9 13:21:07 2010 From: hasan.veldstra@REDACTED (Hasan Veldstra) Date: Wed, 9 Jun 2010 12:21:07 +0100 Subject: [erlang-questions] Unicode Normalization In-Reply-To: References: Message-ID: On 7 June 2010 14:45, Erik Bogghed wrote: > I have been trying to get my head around this one for a few days. Is there any way to get UTF8 to normalized form C in Erlang? You can use the ICU library to do this. You could do it with erl_nif, or use this code - http://code.google.com/p/starling/ --Hasan http://veldstra.org http://vidiowiki.com From pablo.platt@REDACTED Wed Jun 9 14:44:58 2010 From: pablo.platt@REDACTED (Pablo Platt) Date: Wed, 9 Jun 2010 05:44:58 -0700 (PDT) Subject: [erlang-questions] {packet, PacketType} for little-signed packets In-Reply-To: <20100608214812.GA2246@hanele> References: <385661.80040.qm@web112604.mail.gq1.yahoo.com> <272371.21887.qm@web112620.mail.gq1.yahoo.com> <4C0CB263.4090204@nm.ru> <377540.97897.qm@web112613.mail.gq1.yahoo.com> <20100608214812.GA2246@hanele> Message-ID: <555310.52170.qm@web112604.mail.gq1.yahoo.com> I think I somehow need to add BSON to the {packet, PacketType} options and then add a case similar to asn1 http://github.com/erlang/otp/blob/dev/erts/emulator/beam/packet_parser.c#L326 Any ideas how to add BSON to the list of options and what code should be in the case TCP_PB_BSON ? case TCP_PB_ASN1: { /* TCP_PB_ASN1: handles long (4 bytes) or short length format */ const char* tptr = ptr; int length; int nn = n; if (n < 2) goto more; nn--; if ((*tptr++ & 0x1f) == 0x1f) { /* Long tag format */ while (nn && ((*tptr & 0x80) == 0x80)) { tptr++; nn--; } if (nn < 2) goto more; tptr++; nn--; } /* tptr now point to length field and nn characters remain */ length = *tptr & 0x7f; if ((*tptr & 0x80) == 0x80) { /* Long length format */ tptr++; nn--; if (nn < length) goto more; switch (length) { case 0: plen = 0; break; case 1: plen = get_int8(tptr); tptr += 1; break; case 2: plen = get_int16(tptr); tptr += 2; break; case 3: plen = get_int24(tptr); tptr += 3; break; case 4: plen = get_int32(tptr); tptr += 4; break; default: goto error; /* error */ } } else { tptr++; plen = length; } hlen = (tptr-ptr); goto remain; } ________________________________ From: Jachym Holecek To: Pablo Platt Sent: Wed, June 9, 2010 12:48:12 AM Subject: Re: [erlang-questions] {packet, PacketType} for little-signed packets Hello, # Pablo Platt 2010-06-08: > {packet, ...} will be much faster, reduce the code and possible errors. > If someone can point me to what file need to be patched I can try to do it myself. These seem like good places to start: erts/emulator/beam/packet_parser.c erts/emulator/drivers/common/inet_drv.c > Subject: Re: [erlang-questions] {packet, PacketType} for little-signed packets ^^^^^^ Huh? Are they seriously using signed integers for message length? Have fun, -- Jachym From raimo+erlang-questions@REDACTED Wed Jun 9 15:40:23 2010 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 9 Jun 2010 15:40:23 +0200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> <20100604062538.GB11662@erix.ericsson.se> <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> Message-ID: <20100609134023.GA18679@erix.ericsson.se> On Wed, Jun 09, 2010 at 01:53:29PM +1200, Richard O'Keefe wrote: > > On Jun 4, 2010, at 6:25 PM, Raimo Niskanen wrote: > >>>This was a little bit unrelated to the topic. Given that you can't > >>>call a non-exported function with that syntax, that code is > >>>certainly > >>>not calling the local fun spawn/1, since it's not exported. > >> > >>Note that I wasn't suggesting that the call should be *allowed*, > >>only that it is *there*. There's a big difference between > >>"there are NO calls to this function" and > > > >But there *are* no calls to the local function spawn/1. > > Yes there is, it's just not a *local* call. I might argue that since it is a call to an exported function it must be to some *other* function, not the local with the same name. For example (as I said) when code upgrading the call to the exported function could be to the new module version. > > > >The local function spawn/1 will never be used and > >that is what that warning says. > > No it isn't, really. If the error message said > There is a remote call to local function spawn/1 > but it is not exported so it can never be used > that way. > I might agree with you. > : > > Now let's change the example one more time. > > 1 -module(foo). > 2 -export([zoo/0]). > 3 bar(X) when X < 0 -> ugh(-X); > 4 bar(X) -> X+1. > 5 ugh(X) when X < 0 -> bar(-X); > 6 ugh(X) -> X-1. > 7 zoo() -> is_function(fun bar/1), is_function(fun ugh/1). > > ./foo.erl:7: Warning: the call to is_function/1 has no effect > > The functions bar/1 and ugh/1 are no more reachable than before. > There is no possible call from the outside that will ever result in > either function being invoked. But suddenly they are "used". > > Judging from the outside, what we have is > a function is reachable iff > (1) it is exported or > (2) there is a local call to it from a reachable function or > (3) a 'fun f/n' term referring to it occurs in a reachable function. > > A function can be *USED* fifty million times without being > reachable, and as a test case like the one above proved, a > function can be reachable without being used. > > This means that the wording of the error message is misleading. > > >>In short, I am not quarreling with the decision to report an > >>error here, only commenting that the error message is extremely > >>misleading. > > > >#1 is. #2 not really. > > No, really. Whether the error message in question occurs or not > has nothing to do with whether the function is used, only with > whether it is reachable. If you get the error message, no amount > of adding *uses* will remove it, unless they happen to be reachable > ones. > > The message "no exported function directly or indirectly mentions > f/n" would not be misleading. Even better, it would draw the > programmer's attention to the probable cause: a missing -export. You are right, of course. I am just used to the "not used" in this context meaning that if the function is removed the only thing that will happen is that the module gets smaller, or more correctly as you said: "no exported function directly or indirectly mentions f/n". "not used" is sloppier but shorter. -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From cowboymathu@REDACTED Wed Jun 9 20:33:10 2010 From: cowboymathu@REDACTED (=?UTF-8?B?TUF0aHV2YXRoYW5hbiBNT3UgfHwgIOCuruCupOCvgeCuteCupOCuqeCuqeCvjSDgrq7gr4w=?=) Date: Thu, 10 Jun 2010 00:03:10 +0530 Subject: Binary Representation Message-ID: Hi All, How these two representations come same? <<"\241">> and <<16#A1:8>> Regards, -- Mathuvathanan Mou. From bob@REDACTED Wed Jun 9 21:36:12 2010 From: bob@REDACTED (Bob Ippolito) Date: Wed, 9 Jun 2010 12:36:12 -0700 Subject: [erlang-questions] Binary Representation In-Reply-To: References: Message-ID: 2010/6/9 MAthuvathanan MOu || ???????? ?? : > > How these two representations come same? > > <<"\241">> > > and > > <<16#A1:8>> \241 is octal, e.g. 8#241 -bob From dougedmunds@REDACTED Wed Jun 9 22:15:18 2010 From: dougedmunds@REDACTED (Doug Edmunds (gmail)) Date: Wed, 09 Jun 2010 13:15:18 -0700 Subject: Device contexts using wx module Message-ID: <4C0FF656.2000208@gmail.com> I am trying to figure out how to use device contexts using the wx module. I found this C++ code which draws a line in a window. I can't figure out how to do this in Erlang. Anyone? Source code at: http://zetcode.com/tutorials/wxwidgetstutorial/gdi/ Image at: http://zetcode.com/tutorials/wxwidgetstutorial/images/line.jpg -------- line.h #include class Line : public wxFrame { public: Line(const wxString& title); void OnPaint(wxPaintEvent& event); }; --------- line.cpp #include "line.h" Line::Line(const wxString& title) : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(280, 180)) { this->Connect(wxEVT_PAINT, wxPaintEventHandler(Line::OnPaint)); this->Centre(); } void Line::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this); wxCoord x1 = 50, y1 = 60; wxCoord x2 = 190, y2 = 60; dc.DrawLine(x1, y1, x2, y2); } --------- main.h #include class MyApp : public wxApp { public: virtual bool OnInit(); }; --------- main.cpp #include "main.h" #include "line.h" IMPLEMENT_APP(MyApp) bool MyApp::OnInit() { Line *line = new Line(wxT("Line")); line->Show(true); return true; } Thanks. -dae From fdmanana@REDACTED Wed Jun 9 23:30:52 2010 From: fdmanana@REDACTED (Filipe David Manana) Date: Wed, 9 Jun 2010 22:30:52 +0100 Subject: gen_server handle_info vs handle_call Message-ID: Hello, Regarding gen_server, I would like to confirm if handle_info is synchronous like handle_call, that is: 1) Process P1 does a gen_server:call(Server, Msg) 2) An handle_info call is caused by a process P2 (because it died, was spawned by the gen_server which processes flag trap_exit) 3) Execution of the handle_info code is not executed until the handle_call code (being executed for process P1) finishes Is this correct? cheers -- Filipe David Manana, fdmanana@REDACTED "Reasonable men adapt themselves to the world. Unreasonable men adapt the world to themselves. That's why all progress depends on unreasonable men." From gleber.p@REDACTED Wed Jun 9 23:35:03 2010 From: gleber.p@REDACTED (Gleb Peregud) Date: Wed, 9 Jun 2010 23:35:03 +0200 Subject: [erlang-questions] gen_server handle_info vs handle_call In-Reply-To: References: Message-ID: Yes gen_server handles calls, casts and messages in a sequential manner - it will handle them one by one. On Wed, Jun 9, 2010 at 23:30, Filipe David Manana wrote: > Hello, > > Regarding gen_server, I would like to confirm if handle_info is synchronous > like handle_call, that is: > > 1) Process P1 does a gen_server:call(Server, Msg) > 2) An handle_info call is caused by a process P2 (because it died, was > spawned by the gen_server which processes flag trap_exit) > 3) Execution of the handle_info code is not executed until the handle_call > code (being executed for process P1) finishes > > Is this correct? > > cheers > > > -- > Filipe David Manana, > fdmanana@REDACTED > > "Reasonable men adapt themselves to the world. > Unreasonable men adapt the world to themselves. > That's why all progress depends on unreasonable men." > From mevans@REDACTED Thu Jun 10 00:59:29 2010 From: mevans@REDACTED (Evans, Matthew) Date: Wed, 9 Jun 2010 18:59:29 -0400 Subject: Mnesia fragmented tables: mnesia:dirty_next and mnesia:dirty_first Message-ID: Hi, I have a fragmented database where I want to do an mnesia:dirty_first(Tab), and mnesia:dirty_next(Tab,Key). These don't appear to be supported. I have got around this by: 1) Using mnesia:table_info/2 to get the frag hash state. 2) Create a list of all my fragments (as atoms), in a specific order. The above data is saved in a state record. Then whenever I get a get_next I call mnesia_frag_hash:key_to_frag_number/2, and from the list of fragments I saved in 2, above, I can get the actual fragment to search in. I can then call mnesia:dirty_next(Fragment,Key). If I get '$end_of_table' I can move to the next fragment in the list of fragments and so on until the list of fragments is exhausted. Other than doing something similar with mnesia:dirty_slot/2 is there any other way to do a get_next traversal of a fragmented table? Thanks Matt From igorrs@REDACTED Thu Jun 10 02:14:24 2010 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Wed, 9 Jun 2010 21:14:24 -0300 Subject: [erlang-questions] Mnesia fragmented tables: mnesia:dirty_next and mnesia:dirty_first In-Reply-To: References: Message-ID: On Wed, Jun 9, 2010 at 7:59 PM, Evans, Matthew wrote: > Hi, > > I have a fragmented database where I want to do an mnesia:dirty_first(Tab), and mnesia:dirty_next(Tab,Key). > > These don't appear to be supported. The mnesia_frag module can probably handle that, if you call mnesia:activity/4 like this: F = mnesia:activity(sync_dirty, fun mnesia:first/1, [my_table], mnesia_frag). mnesia:activity(sync_dirty, fun mnesia:next/2, [my_table, F], mnesia_frag). ... But maybe it will be more efficient to use a cursor, after creating it inside of a dirty operation: Cursor = mnesia:activity(sync_dirty, fun qlc:cursor/1, [qlc:q([R || R <- mnesia:table(my_table)])], mnesia_frag). However, if you need to be able to handle errors (e.g. an unavailable fragment) smoothly (retrieve all the data that is available), you should actually do something like what you are already doing. Being that the case, I recommend that you read this post: http://igorrs.blogspot.com/2010/05/mnesia-one-year-later-part-2.html Good luck. Igor. > I have got around this by: > > 1) Using mnesia:table_info/2 to get the frag hash state. > > 2) Create a list of all my fragments (as atoms), in a specific order. > > The above data is saved in a state record. > > Then whenever I get a get_next I call mnesia_frag_hash:key_to_frag_number/2, and from the list of fragments I saved in 2, above, I can get the actual fragment to search in. > > I can then call mnesia:dirty_next(Fragment,Key). If I get '$end_of_table' I can move to the next fragment in the list of fragments and so on until the list of fragments is exhausted. > > Other than doing something similar with mnesia:dirty_slot/2 is there any other way to do a get_next traversal of a fragmented table? > > Thanks > > Matt -- "The secret of joy in work is contained in one word - excellence. To know how to do something well is to enjoy it." - Pearl S. Buck. From dmitriid@REDACTED Thu Jun 10 09:29:42 2010 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Thu, 10 Jun 2010 10:29:42 +0300 Subject: =?windows-1252?Q?[ANN]_TryErlang.org_=97_online_tutorials_and_in?= =?windows-1252?Q?teractive_console?= Message-ID: Oddly enough the authors haven't made an announcement here :) http://www.tryerlang.org/ tryerlang.org is an hands-on, interactive tutorial that allows you to try the power of Erlang directly in your browser, without installing anything in your machine. The idea and the interface are heavily inspired by the tryruby.org and tryhaskell.orgprojects. Roberto Aloi, you rock! From dangud@REDACTED Thu Jun 10 10:46:32 2010 From: dangud@REDACTED (Dan Gudmundsson) Date: Thu, 10 Jun 2010 10:46:32 +0200 Subject: [erlang-questions] Device contexts using wx module In-Reply-To: <4C0FF656.2000208@gmail.com> References: <4C0FF656.2000208@gmail.com> Message-ID: -module(dl). -export([test/0]). -include_lib("wx/include/wx.hrl"). test() -> Wx = wx:new(), Frame = wxFrame:new(Wx, -1, "Draw Lines", [{size, {280, 180}}]), OnPaint = fun(_Evt, _Obj) -> Paint = wxPaintDC:new(Frame), wxDC:drawLine(Paint, {50, 60}, {190,60}), wxPaintDC:destroy(Paint) end, wxFrame:connect(Frame, paint, [{callback, OnPaint}]), wxFrame:center(Frame), wxFrame:show(Frame). /Dan On Wed, Jun 9, 2010 at 10:15 PM, Doug Edmunds (gmail) wrote: > I am trying to figure out how to use device contexts > using the wx module. ?I found this C++ code which draws > a line in a window. I can't figure out how to do > this in Erlang. ?Anyone? > > Source code at: > http://zetcode.com/tutorials/wxwidgetstutorial/gdi/ > Image at: > http://zetcode.com/tutorials/wxwidgetstutorial/images/line.jpg > > -------- > line.h > > #include > > class Line : public wxFrame > { > public: > ? ?Line(const wxString& title); > > ? ?void OnPaint(wxPaintEvent& event); > > }; > > --------- > line.cpp > > #include "line.h" > > > Line::Line(const wxString& title) > ? ? ? : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(280, 180)) > { > ?this->Connect(wxEVT_PAINT, wxPaintEventHandler(Line::OnPaint)); > ?this->Centre(); > } > > void Line::OnPaint(wxPaintEvent& event) > { > ?wxPaintDC dc(this); > > ?wxCoord x1 = 50, y1 = 60; > ?wxCoord x2 = 190, y2 = 60; > > ?dc.DrawLine(x1, y1, x2, y2); > } > > --------- > main.h > > #include > > class MyApp : public wxApp > { > ?public: > ? ?virtual bool OnInit(); > }; > > --------- > main.cpp > > #include "main.h" > #include "line.h" > > IMPLEMENT_APP(MyApp) > > bool MyApp::OnInit() > { > > ? ?Line *line = new Line(wxT("Line")); > ? ?line->Show(true); > > ? ?return true; > } > > > Thanks. > > -dae > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From tomas.kukosa@REDACTED Thu Jun 10 15:37:55 2010 From: tomas.kukosa@REDACTED (Kukosa, Tomas) Date: Thu, 10 Jun 2010 15:37:55 +0200 Subject: SCTP support Message-ID: Hello, I have problem with opening SCTP socket. See ----------- Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.5 (abort with ^G) 1> gen_sctp:open(). ** exception error: bad argument in function gen_sctp:open/1 called as gen_sctp:open([]) 2> ------------- I try it on SLES 11 64bit (kernel 2.6.27). SCTP on this system works well if I use sctp_darn (from lksctp-tools package) or if I use OpenJDK7 with SCTP support. Erlang/OTP has been configured and compiled with --enable-sctp option. What shall I check to find where the problem could be? When I try to localize problem I have found that following call fails: 2> prim_inet:open(sctp). {error,badarg} Any hint is welcome. Best regards, Tomas From ram-a.kumar@REDACTED Thu Jun 10 16:30:23 2010 From: ram-a.kumar@REDACTED (Ram-A Kumar) Date: Thu, 10 Jun 2010 10:30:23 -0400 Subject: Query Optimizer on Fragmented Mnesia Table Bypassed on Indexed values..? Message-ID: Hi, I have a fragmented mnesia table with 32 fragments and a total of 722367 records distributed across the fragments. The 3rd and 4th field of my Mnesia table are indexed. I perform a simple qlc join as follows QQ = qlc:q([list_to_tuple(tuple_to_list(X)++tuple_to_list(Y)) || X <-mnesia:table(Mnesia_Tab), Y <- Data, element(4, X) =:= element(1, Y)]), F = fun()-> qlc:cursor(QQ) end, mnesia:activity(async_dirty, F, [], mnesia_frag). After handling the cursor it returns 125487 results in 6 secs. So far so good ! Mnesia is cool ! However, if you change the query a little bit L1 = 4, L2 = 1, and change the statement to QQ = qlc:q([list_to_tuple(tuple_to_list(X)++tuple_to_list(Y)) || X <-mnesia:table(Mnesia_Tab), Y <- Data, element(L1, X) =:= element(L2, Y)]) it takes 24 secs to return the query with same 125487 entries. Further, even this takes 24 secs QQ = qlc:q([list_to_tuple(tuple_to_list(X)++tuple_to_list(Y)) || X <-mnesia:table(Mnesia_Tab), Y <- Data, element(4, X) =:= element(L2, Y)]) After looking at the qlc:info(QQ), i have noticed that the query optimizer gets bypassed when it takes 24 secs.. The first one gets converted into begin V1 = qlc:q([[G1|G2] || G2 <- [{\"20\",\"NY\"},\n {\"101\",\"NYC\"},\n {\"103\",\"NYC\"},\n {\"108\",\"NYC\"},\n {\"112\",\"NYC\"}],\n G1 <-\n mnesia:table(user_feed_frag,\n [{n_objects,100},{lock,read}]),\n element(1, G1) =:= element(4, G2)],\n [{join,lookup}]),\n qlc:q([list_to_tuple(tuple_to_list(X) ++ tuple_to_list(Y)) || [X|Y] <- V1])\nend The query otimizer got called .. The latter got converted into qlc:q([list_to_tuple(tuple_to_list(X) ++ tuple_to_list(Y)) || X <-\n mnesia:table(user_feed_frag,\n [{n_objects,100},{lock,read}]),\n Y <-\n [{\"20\",\"NY\"},\n {\"101\",\"NYC\"},\n {\"103\",\"NYC\"},\n {\"108\",\"NYC\"},\n {\"112\",\"NYC\"}],\n element(L1, X) =:= element(L2, Y) The query optimizer DOES NOT get called.. I have tried passing MACROS and FUNS inside the qlc:q but looks like the query optimizer does not recognize unless it gets the index values at compile time.. Does anybody has faced similar problems...or any suggestions.. Thanks for reading the post.. PS: If you try returning a list of 240,000 the node crashes..Thats another problem Kind regards, Ram-A Kumar --- This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have received this communication in error) please notify the sender immediately and destroy this communication. Any unauthorized copying, disclosure or distribution of the material in this communication is strictly forbidden. Deutsche Bank does not render legal or tax advice, and the information contained in this communication should not be regarded as such. From mevans@REDACTED Thu Jun 10 16:32:50 2010 From: mevans@REDACTED (Evans, Matthew) Date: Thu, 10 Jun 2010 10:32:50 -0400 Subject: [erlang-questions] Mnesia fragmented tables: mnesia:dirty_next and mnesia:dirty_first In-Reply-To: References: Message-ID: Thanks for the information. I have another question about QLC. How is this constructed internally? In my case the table is disc_only_copies, does QLC read X records into RAM? Or the whole table? Thanks Matt -----Original Message----- From: Igor Ribeiro Sucupira [mailto:igorrs@REDACTED] Sent: Wednesday, June 09, 2010 8:14 PM To: Evans, Matthew Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Mnesia fragmented tables: mnesia:dirty_next and mnesia:dirty_first On Wed, Jun 9, 2010 at 7:59 PM, Evans, Matthew wrote: > Hi, > > I have a fragmented database where I want to do an mnesia:dirty_first(Tab), and mnesia:dirty_next(Tab,Key). > > These don't appear to be supported. The mnesia_frag module can probably handle that, if you call mnesia:activity/4 like this: F = mnesia:activity(sync_dirty, fun mnesia:first/1, [my_table], mnesia_frag). mnesia:activity(sync_dirty, fun mnesia:next/2, [my_table, F], mnesia_frag). ... But maybe it will be more efficient to use a cursor, after creating it inside of a dirty operation: Cursor = mnesia:activity(sync_dirty, fun qlc:cursor/1, [qlc:q([R || R <- mnesia:table(my_table)])], mnesia_frag). However, if you need to be able to handle errors (e.g. an unavailable fragment) smoothly (retrieve all the data that is available), you should actually do something like what you are already doing. Being that the case, I recommend that you read this post: http://igorrs.blogspot.com/2010/05/mnesia-one-year-later-part-2.html Good luck. Igor. > I have got around this by: > > 1) Using mnesia:table_info/2 to get the frag hash state. > > 2) Create a list of all my fragments (as atoms), in a specific order. > > The above data is saved in a state record. > > Then whenever I get a get_next I call mnesia_frag_hash:key_to_frag_number/2, and from the list of fragments I saved in 2, above, I can get the actual fragment to search in. > > I can then call mnesia:dirty_next(Fragment,Key). If I get '$end_of_table' I can move to the next fragment in the list of fragments and so on until the list of fragments is exhausted. > > Other than doing something similar with mnesia:dirty_slot/2 is there any other way to do a get_next traversal of a fragmented table? > > Thanks > > Matt -- "The secret of joy in work is contained in one word - excellence. To know how to do something well is to enjoy it." - Pearl S. Buck. From mevans@REDACTED Thu Jun 10 16:56:15 2010 From: mevans@REDACTED (Evans, Matthew) Date: Thu, 10 Jun 2010 10:56:15 -0400 Subject: [erlang-questions] Mnesia fragmented tables: mnesia:dirty_next and mnesia:dirty_first In-Reply-To: References: Message-ID: By that I mean how is a QLC cursor implemented? The reason for using a disc only copies, fragmented table, is because the number of records could be rather large (10's of millions). Matt -----Original Message----- From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On Behalf Of Evans, Matthew Sent: Thursday, June 10, 2010 10:33 AM To: Igor Ribeiro Sucupira Cc: erlang-questions@REDACTED Subject: RE: [erlang-questions] Mnesia fragmented tables: mnesia:dirty_next and mnesia:dirty_first Thanks for the information. I have another question about QLC. How is this constructed internally? In my case the table is disc_only_copies, does QLC read X records into RAM? Or the whole table? Thanks Matt -----Original Message----- From: Igor Ribeiro Sucupira [mailto:igorrs@REDACTED] Sent: Wednesday, June 09, 2010 8:14 PM To: Evans, Matthew Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Mnesia fragmented tables: mnesia:dirty_next and mnesia:dirty_first On Wed, Jun 9, 2010 at 7:59 PM, Evans, Matthew wrote: > Hi, > > I have a fragmented database where I want to do an mnesia:dirty_first(Tab), and mnesia:dirty_next(Tab,Key). > > These don't appear to be supported. The mnesia_frag module can probably handle that, if you call mnesia:activity/4 like this: F = mnesia:activity(sync_dirty, fun mnesia:first/1, [my_table], mnesia_frag). mnesia:activity(sync_dirty, fun mnesia:next/2, [my_table, F], mnesia_frag). ... But maybe it will be more efficient to use a cursor, after creating it inside of a dirty operation: Cursor = mnesia:activity(sync_dirty, fun qlc:cursor/1, [qlc:q([R || R <- mnesia:table(my_table)])], mnesia_frag). However, if you need to be able to handle errors (e.g. an unavailable fragment) smoothly (retrieve all the data that is available), you should actually do something like what you are already doing. Being that the case, I recommend that you read this post: http://igorrs.blogspot.com/2010/05/mnesia-one-year-later-part-2.html Good luck. Igor. > I have got around this by: > > 1) Using mnesia:table_info/2 to get the frag hash state. > > 2) Create a list of all my fragments (as atoms), in a specific order. > > The above data is saved in a state record. > > Then whenever I get a get_next I call mnesia_frag_hash:key_to_frag_number/2, and from the list of fragments I saved in 2, above, I can get the actual fragment to search in. > > I can then call mnesia:dirty_next(Fragment,Key). If I get '$end_of_table' I can move to the next fragment in the list of fragments and so on until the list of fragments is exhausted. > > Other than doing something similar with mnesia:dirty_slot/2 is there any other way to do a get_next traversal of a fragmented table? > > Thanks > > Matt -- "The secret of joy in work is contained in one word - excellence. To know how to do something well is to enjoy it." - Pearl S. Buck. ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED From rumata-estor@REDACTED Thu Jun 10 17:10:31 2010 From: rumata-estor@REDACTED (Dmitry Belyaev) Date: Thu, 10 Jun 2010 19:10:31 +0400 Subject: inet_res:getbyname/2 and udp:connect/3 Message-ID: <4C110067.80704@nm.ru> I think, we've found a bug in inet_res. It causes request to inet_res:getbyname/2 to respond {error, timeout} if *first* nameserver in /etc/resolv.conf inexistent (or down in my case). I couldn't find any info about gen_udp:connect nor erlang:port_get_data/1. But commenting following line helped. http://github.com/erlang/otp/blob/dev/lib/kernel/src/inet_res.erl#L676 query_udp(S, Id, Buffer, IP, Port, Timer, Retry, I, Tm, Verbose) -> Timeout = inet:timeout( (Tm * (1 bsl I)) div Retry, Timer), ?verbose(Verbose, "Try UDP server : ~p:~p (timeout=~w)\n", [IP, Port, Timeout]), %% udp_connect(S, IP, Port), udp_send(S, IP, Port, Buffer), query_udp_recv(S, IP, Port, Id, Timeout, Verbose). Can anyone tell me is it really a bug? And what gen_udp:connect/3 do? -- Dmitry Belyaev From markjwallis@REDACTED Thu Jun 10 20:31:45 2010 From: markjwallis@REDACTED (Mark Wallis) Date: Thu, 10 Jun 2010 11:31:45 -0700 Subject: [erlang-questions] SCTP support In-Reply-To: References: Message-ID: Hi Tomas, I ran into the same issue with RB13B04 on RH ES running 2.6.18-92 with lksctp1.0.9 that I had installed from source. In the end I removed 1.0.9 and installed an RPM for lksctp 1.0.7 and after that Erlang SCTP worked. I expect the problem was due to the way I had installed 1.0.9 and not a dependency on 1.0.7 but this should you some idea where to look. Regards Mark. On Thu, Jun 10, 2010 at 6:37 AM, Kukosa, Tomas < tomas.kukosa@REDACTED> wrote: > Hello, > > I have problem with opening SCTP socket. See > ----------- > Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7.5 (abort with ^G) > 1> gen_sctp:open(). > ** exception error: bad argument > in function gen_sctp:open/1 > called as gen_sctp:open([]) > 2> > ------------- > > I try it on SLES 11 64bit (kernel 2.6.27). > > SCTP on this system works well if I use sctp_darn (from lksctp-tools > package) or if I use OpenJDK7 with SCTP support. > > Erlang/OTP has been configured and compiled with --enable-sctp option. > > What shall I check to find where the problem could be? > > When I try to localize problem I have found that following call fails: > 2> prim_inet:open(sctp). > {error,badarg} > > Any hint is welcome. > > Best regards, > Tomas > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From anders.nygren@REDACTED Thu Jun 10 22:30:59 2010 From: anders.nygren@REDACTED (Anders Nygren) Date: Thu, 10 Jun 2010 15:30:59 -0500 Subject: [erlang-questions] SCTP support In-Reply-To: References: Message-ID: Do You have lksctp-tools-devel installed? /Anders On Thu, Jun 10, 2010 at 8:37 AM, Kukosa, Tomas wrote: > Hello, > > I have problem with opening SCTP socket. See > ----------- > Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7.5 ?(abort with ^G) > 1> gen_sctp:open(). > ** exception error: bad argument > ? ? in function ?gen_sctp:open/1 > ? ? ? ?called as gen_sctp:open([]) > 2> > ------------- > > I try it on SLES 11 64bit (kernel 2.6.27). > > SCTP on this system works well if I use sctp_darn (from lksctp-tools package) or if I use OpenJDK7 with SCTP support. > > Erlang/OTP has been configured and compiled with --enable-sctp option. > > What shall I check to find where the problem could be? > > When I try to localize problem I have found that following call fails: > 2> prim_inet:open(sctp). > {error,badarg} > > Any hint is welcome. > > Best regards, > ?Tomas > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From ok@REDACTED Fri Jun 11 01:16:41 2010 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 11 Jun 2010 11:16:41 +1200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> <20100604062538.GB11662@erix.ericsson.se> <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> Message-ID: <9E15FCB4-7777-43A1-A99F-B4303D805392@cs.otago.ac.nz> On Jun 9, 2010, at 5:42 PM, Igor Ribeiro Sucupira wrote: > > What I see here is that the function bar/1 will never be executed and > will never be called (consider code execution), but its value is used > in code that can be executed and that's something that I call "usage". I was a little surprised to find that the compiler does not optimise is_function(fun...) to 'true'. I would have expected all type tests to be partially evaluated by the compiler; it's an easy optimisation, and while it's not expected to matter for human-written code, that kind of optimisation can be important for machine-generated code. > So maybe this is one of the main sources of disagreement in this > thread: the strength one thinks there is in the relation between > "reachable code" and the concept of "usage". It's not a question of "strength", it's a question of two logically independent concepts, and of the error message using words that strongly suggest the wrong one of the pair. From cebernard@REDACTED Fri Jun 11 01:36:20 2010 From: cebernard@REDACTED (Chris Bernard) Date: Thu, 10 Jun 2010 19:36:20 -0400 Subject: [erlang-questions] EUnit Help In-Reply-To: References: <007170FE7206414489341A0BC625CF1F@SSI.CORP> <4A36B10B.6080209@it.uu.se> Message-ID: <3CDB049E-F2C5-4547-AF4F-BA2AEFFA2A65@gmail.com> I try to answer this help request below, but first I'd like to pose a general question to everyone. I'm interested to hear folks' opinions on using EUnit to test Behavior implementations, individually and in groups. Where do you tend to draw the line and say, "Ok, better use Common Test for this"? (and why?) A few potential answers might be: a) EUnit for non-Behaviors, Common Test for the rest b) EUnit for single Behaviors without Supervisors, Common Test for the rest c) EUnit for Applications on one node or machine, Common Test for the rest d) EUnit for Application functional and integration tests, Common Test for system and load testing More generally, some criteria for this decision could be: - Control Flow: Sequential or Concurrent - Design: Raw Processes or Behaviors - Use Case Flow: Normal or Exception - Unit Size: Module, Process Group, Application, Release - Logical Distribution: Single or Multiple Nodes - Physical Distribution: Local or Distributed I'm just spitballing here. Hopefully this is enough to elicit some opinions (other than "I Hate Unit Testing) :-) About a year ago there was an interesting thread here, "EUnit vs. Common Test" -- that was a good start to the conversation. But when I look around for open source project examples of using EUnit to test Behaviors and Applications, I don't see much yet. Have I missed one? Ok, now I'll attempt to answer your question, Alex. I can't speak to any differences in behavior between versions of EUnit. But... If you have a gen_server that's trapping exits and you want to use EUnit to test the scenario where the gen_server gets sent a shutdown request (i.e. exit(Pid, shutdown) or exit(Pid, {shutdown, term()})), triggering a call to terminate/2 with Reason indicating shutdown, then you need to ensure two things: 1) the gen_server is not linked to the EUnit process running the test 2) the gen_server receives the shutdown request from a process to which it's linked. If you just spawn_link this gen_server directly from an EUnit test (simple or generated), then the gen_server will be linked to the EUnit process, and when it dies, it will kill the EUnit process running the test as well. This generates the error you report. Since EUnit's only means of error detection is via exceptions or timeouts (not EUnit process deaths), this error is expected behavior. (BTW, If you have (1) without (2), the Reason passed to terminate/2 is 'normal', not 'shutdown' or {shutdown, term()}). One way to make this work is to simply wrap the calls to start_link() and exit() in a fun and spawn it in the test, like this: foo_shutdown_test() -> spawn(fun() -> {ok, Pid} = foo:start_link(), exit(Pid, shutdown) % or exit(Pid, {shutdown, any_term()}) end), wait_for_death_or_get_event(), ?assert(whatever()). But do you really need to start the gen_server to test this? You can get a lot of value from simply calling terminate/2 with fake args to simulate scenarios without the extra wrapping/start_linking/exiting. Things are simpler if you're testing scenarios where a gen_server handle_X callback function returns a 'stop' tuple, causing terminate/2 to be called with a Reason of 'normal' -- or if the terminate/2 behavior doesn't care about the Reason at all (which seems common). In these cases you don't need to add the wrapper process. I hope that helps. Cheers, Chris Bernard On Jun 3, 2010, at 4:50 AM, Alex Arnon wrote: > Hi, > > I am also running into a similar issue with my tests. > I am running unit tests that spawn-link a gen_server (tests are > defined in > same module), then send it a shut down request. > The tests work on R12B5, but fail with the following on R13B1 and > R13B4. > Note that the final error is different from David's: > > (emacs@REDACTED)2> eunit:test(dbr_status_server). > dbr_status_server: server_stop_0_test...*skipped* > undefined > *unexpected termination of test process* > ::shutdown > > ======================================================= > Failed: 0. Skipped: 0. Passed: 1. > One or more tests were cancelled. > error > > > A unit test that does not invoke the gen_server passes with no > problem (see > 'Passed: 1' above). > > Please help! :) > > > > > On Mon, Jun 15, 2009 at 11:37 PM, Richard Carlsson > wrote: > >> David Mercer wrote: >> >>> *unexpected termination of test process* >>> >>> ::{badarg,[{io,put_chars,[<0.133.0>,unicode,<<>>]}, >>> {eunit_proc,handle_test,2}, >>> {eunit_proc,tests_inorder,3}, >>> {eunit_proc,with_timeout,3}, >>> {eunit_proc,run_group,2}, >>> {eunit_proc,child_process,2}]} >>> >> >> Are you running R13B (not R13B01) with an unpatched EUnit? In that >> case, >> either install the fixed 2.1.1 version that can be found on the >> download >> page (http://www.erlang.org/download.html), or upgrade to R13B01. >> Sorry >> for the inconvenience. >> >> /Richard >> >> >> ________________________________________________________________ >> erlang-questions mailing list. See http://www.erlang.org/faq.html >> erlang-questions (at) erlang.org >> >> From ok@REDACTED Fri Jun 11 01:58:46 2010 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 11 Jun 2010 11:58:46 +1200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <20100609134023.GA18679@erix.ericsson.se> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> <20100604062538.GB11662@erix.ericsson.se> <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> <20100609134023.GA18679@erix.ericsson.se> Message-ID: <191C55E9-5770-4176-A956-C1DD8FBAB6C1@cs.otago.ac.nz> On Jun 10, 2010, at 1:40 AM, Raimo Niskanen wrote: > I might argue that since it is a call to an exported function it > must be to > some *other* function, not the local with the same name. Why? Suppose we have a module -module(foo). -export([bar/1]). bar(N) when N > 0 -> ?MODULE:bar(N-1); bar(0) -> 'DONG!'. In what sense is the call to ?MODULE:bar/1 a call to some *other* function than the bar/1 here before us? It is often an excellent thing to write a self-tail-call as a remote call so that the module can be replaced and the function switch over to the new version. However, the vast majority of such calls will NOT arrive at a different version, and it seems absurd to describe such calls as calls "to some *other* function". How can it be a call to a function other than the function it immediately calls? > I am just used to the "not used" in this context meaning that if the > function > is removed the only thing that will happen is that the module gets > smaller, > or more correctly as you said: "no exported function directly or > indirectly > mentions f/n". > > "not used" is sloppier but shorter. Other people are not used to that meaning. Since we have agreement that '"not used" is sloppier', the only remaining questions are when to replace it with something that isn't sloppy and what that should be. Another example. -module(foo). -export([h/1]). f() -> 'F'. g() -> 'G'. i(X, X) -> f(); i(_, _) -> g(). h(X) -> i(X, X). There is no possible execution path on which g/0 will be called. The compiler is silent about this. Manually unfold the call to i/2: h(X) when X =:= X -> f(); h(_) -> g(). and the compiler warns that the second clause of h/1 can never be used, but it still doesn't warn that g/0 can't be called. Change it to h(X) when is_list([X]) -> f(); h(_) -> g(). and there are no warnings at all. Change it to h(_) -> f(); h(_) -> g(). and the compiler rightly warns about a clause that cannot match and still fails to warn that g/1 cannot be reached. On the other hand, introduce a syntax error in the first clause (but not the second): h(_) -> f); h(_) -> g(). and now the compiler *does* warn that g/0 is unused, even though there's an error-free clause right there calling it. YMMV but for me this is the usual reason for such warnings. I was wrong above. There -is- another question. What is the purpose of this message? Is that purpose better served by counting paths through unmatchable clauses or by discarding such paths? Is that purpose well served by reporting this 'problem' when the compiler knows that it has not been able to inspect all the possibly relevant code because of a syntax error? OK, it's a minor point and time I shut up, but bogus 'unused' warnings have irritated me for a long time. The Erlang compiler cannot be expected to solve the Halting Problem, and I don't expect that. From igorrs@REDACTED Fri Jun 11 02:34:14 2010 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Thu, 10 Jun 2010 21:34:14 -0300 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <191C55E9-5770-4176-A956-C1DD8FBAB6C1@cs.otago.ac.nz> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> <20100604062538.GB11662@erix.ericsson.se> <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> <20100609134023.GA18679@erix.ericsson.se> <191C55E9-5770-4176-A956-C1DD8FBAB6C1@cs.otago.ac.nz> Message-ID: On Thu, Jun 10, 2010 at 8:58 PM, Richard O'Keefe wrote: > > On Jun 10, 2010, at 1:40 AM, Raimo Niskanen wrote: >> >> I might argue that since it is a call to an exported function it must be >> to some *other* function, not the local with the same name. > > Why? ?Suppose we have a module > > ? ? ? ?-module(foo). > ? ? ? ?-export([bar/1]). Although he didn't say it explicitly, he was talking about your original code, in which the function bar/1 was not exported. So, the matter was again the same: the call was to an exported function, your original bar/1 function was not exported, that makes it unreachable, we think it's reasonable to call that "unused" and you don't. There was not much more in the last messages of this discussion. :-) Best regards. Igor. > ? ? ? ?bar(N) when N > 0 -> ?MODULE:bar(N-1); > ? ? ? ?bar(0) -> 'DONG!'. From shehan@REDACTED Fri Jun 11 03:59:40 2010 From: shehan@REDACTED (shehan) Date: Fri, 11 Jun 2010 07:29:40 +0530 Subject: [erlang-questions] SCTP support In-Reply-To: Message-ID: <20100611020010.E6BA119DC295@mail.wavenet.lk> Hi Tomas, Pls install below lksctp RPMS.Then problem should be solved. lksctp-tools lksctp-tools-doc lksctp-tools-devel Br, Shehan -----Original Message----- From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On Behalf Of Kukosa, Tomas Sent: Thursday, June 10, 2010 7:08 PM To: erlang-questions@REDACTED Subject: [erlang-questions] SCTP support Hello, I have problem with opening SCTP socket. See ----------- Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.5 (abort with ^G) 1> gen_sctp:open(). ** exception error: bad argument in function gen_sctp:open/1 called as gen_sctp:open([]) 2> ------------- I try it on SLES 11 64bit (kernel 2.6.27). SCTP on this system works well if I use sctp_darn (from lksctp-tools package) or if I use OpenJDK7 with SCTP support. Erlang/OTP has been configured and compiled with --enable-sctp option. What shall I check to find where the problem could be? When I try to localize problem I have found that following call fails: 2> prim_inet:open(sctp). {error,badarg} Any hint is welcome. Best regards, Tomas ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED __________ Information from ESET NOD32 Antivirus, version of virus signature database 5186 (20100610) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com From tomas.kukosa@REDACTED Fri Jun 11 08:54:53 2010 From: tomas.kukosa@REDACTED (Kukosa, Tomas) Date: Fri, 11 Jun 2010 08:54:53 +0200 Subject: [erlang-questions] SCTP support In-Reply-To: <20100611020010.E6BA119DC295@mail.wavenet.lk> References: <20100611020010.E6BA119DC295@mail.wavenet.lk> Message-ID: Hi Shehan, I had already lksctp-tools and lksctp-tools-devel installed. Also output of Erlan configuration and make looks good from SCTP point of view. checking for netinet/sctp.h... yes checking whether SCTP_UNORDERED is declared... yes checking whether SCTP_ADDR_OVER is declared... yes checking whether SCTP_ABORT is declared... yes checking whether SCTP_EOF is declared... yes checking whether SCTP_SENDALL is declared... no checking whether SCTP_ADDR_CONFIRMED is declared... yes checking for struct sctp_paddrparams.spp_pathmtu... yes checking for struct sctp_paddrparams.spp_sackdelay... yes checking for struct sctp_paddrparams.spp_flags... yes checking for struct sctp_remote_error.sre_data... yes checking for struct sctp_send_failed.ssf_data... yes I tried also precompiled Erlang from SUSE repository (http://download.opensuse.org/repositories/devel:/languages:/erlang/SLE_11/x86_64/) but unfortunately with the same result. Any other idea what to check? I will try what happens on 32bit system. Best regards, Tomas -----Original Message----- From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On Behalf Of shehan Sent: Friday, June 11, 2010 4:00 AM To: Kukosa, Tomas Cc: erlang-questions@REDACTED Subject: RE: [erlang-questions] SCTP support Hi Tomas, Pls install below lksctp RPMS.Then problem should be solved. lksctp-tools lksctp-tools-doc lksctp-tools-devel Br, Shehan -----Original Message----- From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On Behalf Of Kukosa, Tomas Sent: Thursday, June 10, 2010 7:08 PM To: erlang-questions@REDACTED Subject: [erlang-questions] SCTP support Hello, I have problem with opening SCTP socket. See ----------- Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.5 (abort with ^G) 1> gen_sctp:open(). ** exception error: bad argument in function gen_sctp:open/1 called as gen_sctp:open([]) 2> ------------- I try it on SLES 11 64bit (kernel 2.6.27). SCTP on this system works well if I use sctp_darn (from lksctp-tools package) or if I use OpenJDK7 with SCTP support. Erlang/OTP has been configured and compiled with --enable-sctp option. What shall I check to find where the problem could be? When I try to localize problem I have found that following call fails: 2> prim_inet:open(sctp). {error,badarg} Any hint is welcome. Best regards, Tomas ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED __________ Information from ESET NOD32 Antivirus, version of virus signature database 5186 (20100610) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED From clist@REDACTED Fri Jun 11 09:16:43 2010 From: clist@REDACTED (Angel Alvarez) Date: Fri, 11 Jun 2010 09:16:43 +0200 Subject: Estrange problem with national chars Message-ID: <201006110916.44009.clist@uah.es> Hi Ive been in trouble trying to display localised messages in spanish. While inputting strings in utf8 seems fine, every string compile into the code gets garbled. Terminal, text editor and shell are in unicode (utf8) but i can display messages with strings in spanish. Anyone can point me on the ritght direcction? Thanks!!! /Angel io:getopts(). [{expand_fun,#Fun}, {echo,true}, {binary,false}, {encoding,unicode}] -module(mytest). -compile(export_all). kk() -> io:format("Test message with in-code spanish chars: cig?e?a, cami?n~n",[]). kk(Message) -> io:format("Test message with in-code spanish chars: cig?e?a, cami?n and inputted spanish chars: ~s~n",[Message]). sinosuke@REDACTED:~/Datos/Personal/Erlang> erl Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.2 (abort with ^G) 1> mytest:kk(). Test message with in-code spanish chars: cig??e??a, cami??n ok 2> mytest:kk("Atenci?n"). Test message with in-code spanish chars: cig??e??a, cami??n and inputted spanish chars: Atenci?n ok -- Este correo no tiene dibujos. Las formas extra?as en la pantalla son letras. __________________________________________ Clist UAH a.k.a Angel __________________________________________ Evitar la programaci?n defensiva. Manual de Erlang From hans.bolinder@REDACTED Fri Jun 11 09:40:04 2010 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Fri, 11 Jun 2010 09:40:04 +0200 Subject: [erlang-questions] Query Optimizer on Fragmented Mnesia Table Bypassed on Indexed values..? In-Reply-To: References: Message-ID: <19473.59476.674203.506774@ornendil.du.uab.ericsson.se> [Ram-A Kumar:] > I have tried passing MACROS and FUNS inside the qlc:q but looks like the > query optimizer does not recognize unless it gets the index values at > compile time.. Yes, that is a property of qlc. It should be mentioned in the docs. Best regards, Hans Bolinder, Erlang/OTP team, Ericsson From clist@REDACTED Fri Jun 11 09:53:13 2010 From: clist@REDACTED (Angel Alvarez) Date: Fri, 11 Jun 2010 09:53:13 +0200 Subject: [erlang-questions] strange problem with national chars In-Reply-To: <201006110916.44009.clist@uah.es> References: <201006110916.44009.clist@uah.es> Message-ID: <201006110953.13641.clist@uah.es> Hi again It seems that source erlang must be in latin1, so saving mytest.erl as latin1 yields the desired result, in the spirit of http://www.erlang.org/doc/apps/stdlib/unicode_usage.html that clearly says that erlang strings are latin1, i used to put english messages in my toy programms, but now i need to make an app in spanish How can i use utf8 tools (text editors) and still get strings ok without converting them prior to compile to latin1?? Regards, Angel El Viernes, 11 de Junio de 2010 09:16:43 Angel Alvarez escribi?: > Hi > > Ive been in trouble trying to display localised messages in spanish. > > While inputting strings in utf8 seems fine, every string compile into the code gets garbled. Terminal, text editor and shell are in unicode (utf8) > but i can display messages with strings in spanish. > > > Anyone can point me on the ritght direcction? > > Thanks!!! > > > /Angel > > io:getopts(). > [{expand_fun,#Fun}, > {echo,true}, > {binary,false}, > {encoding,unicode}] > > -module(mytest). > -compile(export_all). > > kk() -> > io:format("Test message with in-code spanish chars: cig?e?a, cami?n~n",[]). > kk(Message) -> > io:format("Test message with in-code spanish chars: cig?e?a, cami?n and inputted spanish chars: ~s~n",[Message]). > > sinosuke@REDACTED:~/Datos/Personal/Erlang> erl > Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7.2 (abort with ^G) > 1> mytest:kk(). > Test message with in-code spanish chars: cig??e??a, cami??n > ok > 2> mytest:kk("Atenci?n"). > Test message with in-code spanish chars: cig??e??a, cami??n and inputted spanish chars: Atenci?n > ok > > > > -- Este correo no tiene dibujos. Las formas extra?as en la pantalla son letras. __________________________________________ Clist UAH a.k.a Angel __________________________________________ Evitar la programaci?n defensiva. Manual de Erlang From raimo+erlang-questions@REDACTED Fri Jun 11 12:20:21 2010 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 11 Jun 2010 12:20:21 +0200 Subject: [erlang-questions] SCTP support In-Reply-To: References: <20100611020010.E6BA119DC295@mail.wavenet.lk> Message-ID: <20100611102021.GA13852@erix.ericsson.se> The symptom you describe: > 2> prim_inet:open(sctp). > {error,badarg} suggests that the emulator has/finds no sctp support. Check your build logs, that you run what you build and then check whith strace what happens during emulator start: $ strace -f -o strace.txt erl Erlang R13B04 (erts-5.7.5.1) [64-bit] [smp:4:4] [rq:4] [async-threads:0] [kernel-poll:false] Eshell V5.7.5.1 (abort with ^G) 1> [Ctrl-\] $ $ less strace.txt # search for libsctp There should be a section that tries to load libsctp.so from several locations and one should succeed or the sctp socket open will fail. Such as: 13418 open("/home/raimo/lib/tls/x86_64/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/home/raimo/lib/tls/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/home/raimo/lib/x86_64/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/home/raimo/lib/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/opt/local/lib/tls/x86_64/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/opt/local/lib/tls/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/opt/local/lib/x86_64/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/opt/local/lib/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/usr/local/lib/tls/x86_64/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/usr/local/lib/tls/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/usr/local/lib/x86_64/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/usr/local/lib/libsctp.so.1", O_RDONLY) = 7 On Fri, Jun 11, 2010 at 08:54:53AM +0200, Kukosa, Tomas wrote: > Hi Shehan, > > I had already lksctp-tools and lksctp-tools-devel installed. > Also output of Erlan configuration and make looks good from SCTP point of view. > > checking for netinet/sctp.h... yes > checking whether SCTP_UNORDERED is declared... yes > checking whether SCTP_ADDR_OVER is declared... yes > checking whether SCTP_ABORT is declared... yes > checking whether SCTP_EOF is declared... yes > checking whether SCTP_SENDALL is declared... no > checking whether SCTP_ADDR_CONFIRMED is declared... yes > checking for struct sctp_paddrparams.spp_pathmtu... yes > checking for struct sctp_paddrparams.spp_sackdelay... yes > checking for struct sctp_paddrparams.spp_flags... yes > checking for struct sctp_remote_error.sre_data... yes > checking for struct sctp_send_failed.ssf_data... yes > > > I tried also precompiled Erlang from SUSE repository (http://download.opensuse.org/repositories/devel:/languages:/erlang/SLE_11/x86_64/) > but unfortunately with the same result. > > Any other idea what to check? > > I will try what happens on 32bit system. > > Best regards, > Tomas > > > -----Original Message----- > From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On Behalf Of shehan > Sent: Friday, June 11, 2010 4:00 AM > To: Kukosa, Tomas > Cc: erlang-questions@REDACTED > Subject: RE: [erlang-questions] SCTP support > > Hi Tomas, > Pls install below lksctp RPMS.Then problem should be solved. > > lksctp-tools > > lksctp-tools-doc > > lksctp-tools-devel > > Br, > Shehan > -----Original Message----- > From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On > Behalf Of Kukosa, Tomas > Sent: Thursday, June 10, 2010 7:08 PM > To: erlang-questions@REDACTED > Subject: [erlang-questions] SCTP support > > Hello, > > I have problem with opening SCTP socket. See > ----------- > Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7.5 (abort with ^G) > 1> gen_sctp:open(). > ** exception error: bad argument > in function gen_sctp:open/1 > called as gen_sctp:open([]) > 2> > ------------- > > I try it on SLES 11 64bit (kernel 2.6.27). > > SCTP on this system works well if I use sctp_darn (from lksctp-tools > package) or if I use OpenJDK7 with SCTP support. > > Erlang/OTP has been configured and compiled with --enable-sctp option. > > What shall I check to find where the problem could be? > > When I try to localize problem I have found that following call fails: > 2> prim_inet:open(sctp). > {error,badarg} > > Any hint is welcome. > > Best regards, > Tomas > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > > __________ Information from ESET NOD32 Antivirus, version of virus signature > database 5186 (20100610) __________ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com > > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From tomas.kukosa@REDACTED Fri Jun 11 13:35:49 2010 From: tomas.kukosa@REDACTED (Kukosa, Tomas) Date: Fri, 11 Jun 2010 13:35:49 +0200 Subject: [erlang-questions] SCTP support In-Reply-To: <20100611102021.GA13852@erix.ericsson.se> References: <20100611020010.E6BA119DC295@mail.wavenet.lk> <20100611102021.GA13852@erix.ericsson.se> Message-ID: Thank you very much for hints! I have found that it did not try to load libsctp at all. When I clear everything and run ./configure and make again it works now. Thanks again for support. Tomas 1> X=gen_sctp:open(). {ok,#Port<0.503>} 2> {ok,S}=X. {ok,#Port<0.503>} 3> gen_sctp:close(S). ok 4> -----Original Message----- From: Raimo Niskanen [mailto:raimo+erlang-questions@REDACTED] Sent: Friday, June 11, 2010 12:20 PM To: Kukosa, Tomas; erlang-questions@REDACTED Subject: Re: [erlang-questions] SCTP support The symptom you describe: > 2> prim_inet:open(sctp). > {error,badarg} suggests that the emulator has/finds no sctp support. Check your build logs, that you run what you build and then check whith strace what happens during emulator start: $ strace -f -o strace.txt erl Erlang R13B04 (erts-5.7.5.1) [64-bit] [smp:4:4] [rq:4] [async-threads:0] [kernel-poll:false] Eshell V5.7.5.1 (abort with ^G) 1> [Ctrl-\] $ $ less strace.txt # search for libsctp There should be a section that tries to load libsctp.so from several locations and one should succeed or the sctp socket open will fail. Such as: 13418 open("/home/raimo/lib/tls/x86_64/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/home/raimo/lib/tls/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/home/raimo/lib/x86_64/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/home/raimo/lib/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/opt/local/lib/tls/x86_64/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/opt/local/lib/tls/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/opt/local/lib/x86_64/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/opt/local/lib/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/usr/local/lib/tls/x86_64/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/usr/local/lib/tls/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/usr/local/lib/x86_64/libsctp.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) 13418 open("/usr/local/lib/libsctp.so.1", O_RDONLY) = 7 On Fri, Jun 11, 2010 at 08:54:53AM +0200, Kukosa, Tomas wrote: > Hi Shehan, > > I had already lksctp-tools and lksctp-tools-devel installed. > Also output of Erlan configuration and make looks good from SCTP point of view. > > checking for netinet/sctp.h... yes > checking whether SCTP_UNORDERED is declared... yes > checking whether SCTP_ADDR_OVER is declared... yes > checking whether SCTP_ABORT is declared... yes > checking whether SCTP_EOF is declared... yes > checking whether SCTP_SENDALL is declared... no > checking whether SCTP_ADDR_CONFIRMED is declared... yes > checking for struct sctp_paddrparams.spp_pathmtu... yes > checking for struct sctp_paddrparams.spp_sackdelay... yes > checking for struct sctp_paddrparams.spp_flags... yes > checking for struct sctp_remote_error.sre_data... yes > checking for struct sctp_send_failed.ssf_data... yes > > > I tried also precompiled Erlang from SUSE repository (http://download.opensuse.org/repositories/devel:/languages:/erlang/SLE_11/x86_64/) > but unfortunately with the same result. > > Any other idea what to check? > > I will try what happens on 32bit system. > > Best regards, > Tomas > > > -----Original Message----- > From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On Behalf Of shehan > Sent: Friday, June 11, 2010 4:00 AM > To: Kukosa, Tomas > Cc: erlang-questions@REDACTED > Subject: RE: [erlang-questions] SCTP support > > Hi Tomas, > Pls install below lksctp RPMS.Then problem should be solved. > > lksctp-tools > > lksctp-tools-doc > > lksctp-tools-devel > > Br, > Shehan > -----Original Message----- > From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On > Behalf Of Kukosa, Tomas > Sent: Thursday, June 10, 2010 7:08 PM > To: erlang-questions@REDACTED > Subject: [erlang-questions] SCTP support > > Hello, > > I have problem with opening SCTP socket. See > ----------- > Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7.5 (abort with ^G) > 1> gen_sctp:open(). > ** exception error: bad argument > in function gen_sctp:open/1 > called as gen_sctp:open([]) > 2> > ------------- > > I try it on SLES 11 64bit (kernel 2.6.27). > > SCTP on this system works well if I use sctp_darn (from lksctp-tools > package) or if I use OpenJDK7 with SCTP support. > > Erlang/OTP has been configured and compiled with --enable-sctp option. > > What shall I check to find where the problem could be? > > When I try to localize problem I have found that following call fails: > 2> prim_inet:open(sctp). > {error,badarg} > > Any hint is welcome. > > Best regards, > Tomas > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > > __________ Information from ESET NOD32 Antivirus, version of virus signature > database 5186 (20100610) __________ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com > > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From rumata-estor@REDACTED Fri Jun 11 15:15:48 2010 From: rumata-estor@REDACTED (Dmitry Belyaev) Date: Fri, 11 Jun 2010 17:15:48 +0400 Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <4C110067.80704@nm.ru> References: <4C110067.80704@nm.ru> Message-ID: <4C123704.1020707@nm.ru> In fact, the problem appears if first nameserver is 127.0.0.1 and others are on another interface. Dmitry Belyaev On 06/10/2010 07:10 PM, Dmitry Belyaev wrote: > I think, we've found a bug in inet_res. > > It causes request to inet_res:getbyname/2 to respond {error, timeout} > if *first* nameserver in /etc/resolv.conf inexistent (or down in my > case). > > I couldn't find any info about gen_udp:connect nor > erlang:port_get_data/1. > But commenting following line helped. > http://github.com/erlang/otp/blob/dev/lib/kernel/src/inet_res.erl#L676 > > query_udp(S, Id, Buffer, IP, Port, Timer, Retry, I, Tm, Verbose) -> > Timeout = inet:timeout( (Tm * (1 bsl I)) div Retry, Timer), > ?verbose(Verbose, "Try UDP server : ~p:~p (timeout=~w)\n", [IP, Port, > Timeout]), > %% udp_connect(S, IP, Port), > udp_send(S, IP, Port, Buffer), > query_udp_recv(S, IP, Port, Id, Timeout, Verbose). > > > Can anyone tell me is it really a bug? And what gen_udp:connect/3 do? > From info@REDACTED Fri Jun 11 18:45:56 2010 From: info@REDACTED (info) Date: Fri, 11 Jun 2010 18:45:56 +0200 Subject: implementation of multiple timers Message-ID: <201006111845519531233@its3.ch> Hi all, I would like to associate a timer to a gen_tcp. The loop is called by a gen_server. As the number of sockets is unlimited in my application then the number of timers shall also be it. According to your experience, what is the best approach for the implementation of the timers management ? John loop(socket)-> case gen_tcp:recv(Socket, 0) of {ok, Data} -> timer(off), %handling of data timer(on), loop(socket); {error,closed} -> timer(on), exit(normal) end. From igorrs@REDACTED Fri Jun 11 20:06:21 2010 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Fri, 11 Jun 2010 15:06:21 -0300 Subject: Shutting down Mnesia with replicas and dirty reads Message-ID: Hello, I'm doing some shutdown tests with Mnesia, which are equivalent to this scenario: - A Mnesia pool with 3 nodes. Let's call them X, Y, and Z. - Nodes X and Y both hold a copy of all data. - Node Z is performing reads and writes, but doesn't have any local data (Mnesia ends up being just a "router" to X and Y). - I stop Mnesia on node X and see what happens. It seems that the only operations that fail are sync_dirty reads (which are the only dirty operations I perform). From a quick look at Mnesia's source code, I believe this is expected to happen (for I dirty read, Mnesia just checks the where_to_read property and performs the operation on that node, without retrying). My question is: using transactions/sync_transactions, are all operations guaranteed to succeed even if one of the replicas goes down during the operation, as long as there's at least one replica remaining, accessible and perfectly operational? Thanks. Igor. -- "The secret of joy in work is contained in one word - excellence. To know how to do something well is to enjoy it." - Pearl S. Buck. From mikpe@REDACTED Fri Jun 11 20:31:25 2010 From: mikpe@REDACTED (Mikael Pettersson) Date: Fri, 11 Jun 2010 20:31:25 +0200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <191C55E9-5770-4176-A956-C1DD8FBAB6C1@cs.otago.ac.nz> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> <20100604062538.GB11662@erix.ericsson.se> <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> <20100609134023.GA18679@erix.ericsson.se> <191C55E9-5770-4176-A956-C1DD8FBAB6C1@cs.otago.ac.nz> Message-ID: <19474.33021.717233.152228@pilspetsen.it.uu.se> Richard O'Keefe writes: > > On Jun 10, 2010, at 1:40 AM, Raimo Niskanen wrote: > > I might argue that since it is a call to an exported function it > > must be to > > some *other* function, not the local with the same name. > > Why? Suppose we have a module > > -module(foo). > -export([bar/1]). > bar(N) when N > 0 -> ?MODULE:bar(N-1); > bar(0) -> 'DONG!'. > > In what sense is the call to ?MODULE:bar/1 a call to some *other* > function than the bar/1 here before us? Because in Erlang a call with both module and function names supplied is a "remote" call, which always invokes the latest version of the module whose name was given. So if a process P is executing code in version 1 of the module, a newer version 2 of the module is loaded, and P calls ?MODULE:F(...), then that call invokes F in version 2 of the module, not version 1. From davidw@REDACTED Sat Jun 12 02:26:03 2010 From: davidw@REDACTED (David Welton) Date: Sat, 12 Jun 2010 02:26:03 +0200 Subject: [erlang-questions] Applications, supervisors, and servers, oh my In-Reply-To: <4BFC5EA8.9010001@m5net.com> References: <4BFC5EA8.9010001@m5net.com> Message-ID: With thanks to Bernard for his answers, I'm still struggling with how to structure an application in the proper way. To be very concrete about what I'm doing, I'm working on some code that combines twitter, irc, and the web, in the form of: http://github.com/davidw/erlang_twitter http://github.com/gdamjan/erlang-irc-bot and mochiweb I've run into several things that I'm simply unsure of: 1) Should I make each of those parts an "application" (in the Erlang sense) unto itself? If so, who starts all of them, and where in the code? 2) Should I call into their supervisor code and make a "supervision tree" that way? Experimentation indicates that applications run on their own and don't seem amenable to being added underneath a supervisor, which means that if they crash, I can't tell the whole system to go down as I might with an one_for_all in the supervisor. 3) I'm still not sure of the best patterns for passing things around... For instance, I need to tell the twitter code which ID's to follow, which involves some lookups. If the twitter code crashes (as it is wont to do; I'm still working on it, and... so is twitter:-), I need to re-add a gen_event from the irc code to continue getting notifications. I think, at least. This means that the irc code needs to know when the twitter code has crashed, and when it's back up. using erlang:monitor buys me a 'DOWN' event, but in that I'm not sure how to know when the twitter_stream server is up and running again and ready to receive gen_server:call's. Either that or the twitter_stream code should save its state somehow between crashes and go back to its previous state when it dies. Sorry if that's all a bit jumbled, but I'm confused myself! Thank you, -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From tony.arcieri@REDACTED Sat Jun 12 07:03:47 2010 From: tony.arcieri@REDACTED (Tony Arcieri) Date: Fri, 11 Jun 2010 23:03:47 -0600 Subject: Line numbers in exception backtraces Message-ID: Any word on getting line numbers added to backtraces (i.e. source code line where an exception was raised)? I was wondering if there were any EEPs on this front recently. I didn't see any from a cursory Googleing. Also, if there are any parse transforms that presently work for this purpose (are smart_exceptions maintained?) I'd also like to know about those. -- Tony Arcieri Medioh! A Kudelski Brand From mikpe@REDACTED Sat Jun 12 11:45:26 2010 From: mikpe@REDACTED (Mikael Pettersson) Date: Sat, 12 Jun 2010 11:45:26 +0200 Subject: [erlang-questions] beam[8449]: segfault at 0 ip 0000000000437e10 sp 00007fffce250948 error 4 in beam[400000+174000] In-Reply-To: <4C0A1B45.1070304@gmail.com> References: <4BFA2DEC.50707@gmail.com> <19450.17437.149260.11204@pilspetsen.it.uu.se> <4BFA71AE.5060708@gmail.com> <19450.31693.774522.332905@pilspetsen.it.uu.se> <4BFB4309.1060507@gmail.com> <19451.44811.595873.338827@pilspetsen.it.uu.se> <4BFD250F.6020202@gmail.com> <19453.25855.346911.194353@pilspetsen.it.uu.se> <4C0A1B45.1070304@gmail.com> Message-ID: <19475.22326.25668.128042@pilspetsen.it.uu.se> Eric Liang wrote: > On 05/27/2010 02:14 AM, Mikael Pettersson wrote: > > Eric Liang wrote: > > =20 > >> I've done a build of the source, but it just can't match the object. H= > ow > >> do you make it? I use the command: apt-get source to get the source, s= > o > >> it does have the same version with the object. > >> =20 > > I did: > > > > =20 > >> tar zxvf otp_src_R13B03.tar.gz > >> cd otp_src_R13B03 > >> ./configure; make > >> =20 > > The binary files of interest are bin/x86_64-unknown-linux-gnu/beam and = > > > erts/emulator/obj/x86_64-unknown-linux-gnu/opt/plain/erl_goodfit_alloc.= > o. > > > > =20 > Thanks Mikael, and sorry for replying you too late as the seg-fault is > not occured every time. > > I get the debug symbols by this: > > http://forum.nginx.org/read.php?26,93440,94735 > > >>> You can get a stack dump from the crash by attaching gdb to the > >>> soon-to-crash beam process. Now instead of being terminated gdb will > >>> get control of the process and you should be able to print a stack > >>> trace with bt or where. (This does require that there's a sufficient > >>> time window from the start of the application to the crash.) > >>> =3D20 > >>> =20 > >> I've make a core dump 4 seconds before it crash, as mentioned above,=3D= > 20 > >> because don't get the right symbols, it just with some quesion-marks: > >> > >> Core was generated by `/usr/lib/erlang/erts-5.7.2/bin/beam'. > >> #0 0x00007f0a28ecd5a9 in ?? () > >> (gdb) whe > >> #0 0x00007f0a28ecd5a9 in ?? () > >> #1 0x0000000000000000 in ?? () > >> (gdb) > >> =20 > > A core dump from a time point before the crash is useless. Either get a= > > > core dump from the crash itself (execute `ulimit -c unlimited' in bash > > before running the test), or attach gdb, continue the process, and wait= > > > for gdb to receive control when the crash occurs. > > =20 > > I do set the ulimit -c in /etc/profile and after I reboot it: > > sunny@REDACTED:~$ ulimit -c > unlimited > sunny@REDACTED:~/commands$ cat /proc/sys/kernel/core_pattern > /tmp/core.%t.%e.%p > > And I the test is ok: > > sunny@REDACTED:~$ kill -s SIGSEGV $$ > Connection to dev-2 closed. > sunny@REDACTED:~$ ls /tmp/ > core.1275730620.bash.12566 > > But still no core file generated,when the error occurs. > > Anyway, I attatched the running process by gdb, and here is the result: > > Program received signal SIGSEGV, Segmentation fault. > unlink_free_block (allctr=3D0x7ad480, block=3D0x0) at > beam/erl_goodfit_alloc.c:453 > 453 Uint sz =3D BLK_SZ(blk); > (gdb) whe > #0 unlink_free_block (allctr=3D0x7ad480, block=3D0x0) at > beam/erl_goodfit_alloc.c:453 > #1 0x0000000000437fd6 in get_free_block (allctr=3D0x7ad480, > size=3D, cand_blk=3D0x0, cand_size=3D0) > at beam/erl_goodfit_alloc.c:421 > #2 0x00000000004322c6 in mbc_alloc_block (allctr=3D0x7ad480, size=3D= > 72) > at beam/erl_alloc_util.c:631 > #3 mbc_alloc (allctr=3D0x7ad480, size=3D72) at beam/erl_alloc_util.c= > :758 > #4 0x00000000004b1697 in erts_alloc () at beam/erl_alloc.h:179 > #5 exit_async () at beam/erl_async.c:132 > #6 0x000000000043c13d in system_cleanup (exit_code=3D d > out>) at beam/erl_init.c:1306 > #7 0x000000000043c443 in erl_exit (n=3D0, fmt=3D0x54649c "") at > beam/erl_init.c:1380 > #8 0x000000000045d042 in halt_0 (A__p=3D) at > beam/bif.c:3319 > #9 0x00000000004d081f in process_main () at beam/beam_emu.c:2008 > #10 0x000000000043d56c in erl_start (argc=3D34, argv=3D ed > out>) at beam/erl_init.c:1233 > #11 0x00000000004269b9 in main (argc=3D8049792, argv=3D0x0) at > sys/unix/erl_main.c:29 > (gdb) f 1 > #1 0x0000000000437fd6 in get_free_block (allctr=3D0x7ad480, > size=3D, cand_blk=3D0x0, cand_size=3D0) > at beam/erl_goodfit_alloc.c:421 > 421 unlink_free_block(allctr, blk); > (gdb) l 421 > 416 /* We are guaranteed to find a block that fits in this > bucket */ > 417 blk =3D search_bucket(allctr, min_bi, size); > 418 ASSERT(blk); > 419 if (cand_blk && cand_size <=3D BLK_SZ(blk)) > 420 return NULL; /* cand_blk was better */ > 421 unlink_free_block(allctr, blk); > 422 return blk; > 423 } > 424 =20 > 425 =20 > (gdb) > > As the running process use the no-debug symbol version beam, I guess the > ASSERT in line:418 does not work. So I dig in > > (gdb) p allctr > $1 =3D (Allctr_t *) 0x7ad480 > (gdb) p min_bi > $2 =3D > (gdb) p size > $3 =3D > (gdb) p *allctr > $4 =3D {name_prefix =3D 0x534227 "sl_", alloc_no =3D 3, name =3D {all= > oc =3D 0, > realloc =3D 0, free =3D 0}, > vsn_str =3D 0x53602f "2.1", t =3D 0, ramv =3D 0, sbc_threshold =3D = > 524288, > sbc_move_threshold =3D 80, > mbc_move_threshold =3D 50, main_carrier_size =3D 131072, max_mseg_s= > bcs > =3D 256, max_mseg_mbcs =3D 5, > largest_mbc_size =3D 10485760, smallest_mbc_size =3D 1048576, > mbc_growth_stages =3D 10, mseg_opt =3D {cache =3D 1, > preserv =3D 1, abs_shrink_th =3D 4145152, rel_shrink_th =3D 80}, > mbc_header_size =3D 32, sbc_header_size =3D 32, > min_mbc_size =3D 16384, min_mbc_first_free_size =3D 4096, > min_block_size =3D 32, mbc_list =3D {first =3D 0x7f4f93a5d010, > last =3D 0x7f4f93a5d010}, sbc_list =3D {first =3D 0x0, last =3D 0= > x0}, > main_carrier =3D 0x7f4f93a5d010, > get_free_block =3D 0x437f40 , link_free_block =3D > 0x437d00 , > unlink_free_block =3D 0x437e10 , info_options =3D= > > 0x438480 , > get_next_mbc_size =3D 0x430e40 , creating_mbc =3D= > > 0x438100 , > destroying_mbc =3D 0x438100 , init_atoms =3D > 0x4385c0 , mutex =3D {mtx =3D {pt_mtx =3D { > __data =3D {__lock =3D 0, __count =3D 0, __owner =3D 0, __nus= > ers =3D > 0, __kind =3D 0, __spins =3D 0, __list =3D { > __prev =3D 0x0, __next =3D 0x0}}, __size =3D '\000' ats > 39 times>, __align =3D 0}, is_rec_mtx =3D 0, > prev =3D 0x0, next =3D 0x0}}, thread_safe =3D 0, ts_list =3D {p= > rev =3D > 0x0, next =3D 0x0}, atoms_initialized =3D 0, > stopped =3D 0, calls =3D {this_alloc =3D {giga_no =3D 0, no =3D 246= > 0}, > this_free =3D {giga_no =3D 0, no =3D 2458}, > this_realloc =3D {giga_no =3D 0, no =3D 0}, mseg_alloc =3D {giga_= > no =3D 0, > no =3D 0}, mseg_dealloc =3D {giga_no =3D 0, no =3D 0}, > mseg_realloc =3D {giga_no =3D 0, no =3D 0}, sys_alloc =3D {giga_n= > o =3D 0, > no =3D 1}, sys_free =3D {giga_no =3D 0, no =3D 0}, > sys_realloc =3D {giga_no =3D 0, no =3D 0}}, sbcs =3D {curr_mseg =3D= > {no =3D > 0, size =3D 0}, curr_sys_alloc =3D {no =3D 0, > size =3D 0}, max =3D {no =3D 0, size =3D 0}, max_ever =3D {no =3D= > 0, size > =3D 0}, blocks =3D {curr =3D {no =3D 0, size =3D 0}, > max =3D {no =3D 0, size =3D 0}, max_ever =3D {no =3D 0, size =3D= > 0}}}, > mbcs =3D {curr_mseg =3D {no =3D 0, size =3D 0}, > curr_sys_alloc =3D {no =3D 1, size =3D 131112}, max =3D {no =3D 1= > , size =3D > 131112}, max_ever =3D {no =3D 0, size =3D 0}, > blocks =3D {curr =3D {no =3D 4, size =3D 384}, max =3D {no =3D 14= > 4, size =3D > 13848}, max_ever =3D {no =3D 0, size =3D 0}}}} > (gdb) > > And stalled here, do you have any advices? and also, any other > suggestions would be appreciated. TIA. This shows that in erl_goodfit_alloc.c, the ASSERT(blk) at the end of get_free_block() is bogus and that unlink_free_blk() can be invoked with a NULL blk, which will cause a crash. You should send this to the erlang-bugs mailing list. It needs either the attention of someone who is intimately familiar with the logic of these allocators (I'm not), or for you to make a self-contained test case available (which you might not be able to do if it's proprietary). /Mikael From fdmanana@REDACTED Sat Jun 12 16:33:43 2010 From: fdmanana@REDACTED (Filipe David Manana) Date: Sat, 12 Jun 2010 15:33:43 +0100 Subject: tracing non exported functions Message-ID: Hello, Recently I've been playing with erlang:trace_pattern. Its documentation says it works only for exported functions. Is there any other BIFs that would allow me to have the same functionality but to trace non-exported functions as well? (in the same way as trace_pattern and trace) cheers -- Filipe David Manana, fdmanana@REDACTED "Reasonable men adapt themselves to the world. Unreasonable men adapt the world to themselves. That's why all progress depends on unreasonable men." From steven.charles.davis@REDACTED Sat Jun 12 21:57:03 2010 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 12 Jun 2010 12:57:03 -0700 (PDT) Subject: erlang in erlang Message-ID: So, there I was this morning thinking, surely there's an erlang implementation of the A.K.Erlang calculations. Wandering around a bit I saw a few online calculators, and some windows programs selling at ~150-200 bucks or more. Crazy. I thought, "just how hard can it be?". So after a few hours, I had a (seemingly correct) module in erlang that calculates Erlang units, Erlang-B, Extended-Erlang-B, Erlang-C and for fun added functions for "Average Speed of Answer" and "Service Availability". In less than 200 lines. I'm now wondering how these can be used/modified to get objective assesments of internet (esp Web/HTTP) services... ----- erl_calc.erl ----- %% -module(erl_calc). %% Base formula API for Erlang analysis -export([erlangs/2, erlang_b/3, extended_erlang_b/4, erlang_c/3, engset/4]). %% Useful derivative data -export([wait_time/3, service_level/4]). %% References: %% http://en.wikipedia.org/wiki/Erlang_(unit) %% http://www.mitan.co.uk/erlang/elgcmath.htm %% A measure of intensity erlangs(Rate, Duration) -> Rate * Duration. %% A measure of the probability of blocking erlang_b(Rate, Duration, Agents) -> E = erlangs(Rate, Duration), erlang_b_calc(E, Agents). %% A measure of the probability of blocking when a percentage of users retry extended_erlang_b(Rate, Duration, Agents, RecallFactor) -> E = erlangs(Rate, Duration), extended_erlang_b_calc(E, Agents, RecallFactor, E). %% A measure of the probability of having to wait erlang_c(Rate, Duration, Agents) -> E = erlangs(Rate, Duration), erlang_c_calc(E, Agents). %% TODO: Implement this sometime engset(_Rate, _Duration, _Agents, _Sources) -> not_implemented. %% wait_time(Rate, Duration, Agents) -> E = erlangs(Rate, Duration), EC = erlang_c_calc(E, Agents), EC * Duration / (Agents * (1 - E / Agents)). %% service_level(Rate, Duration, Agents, Target) -> E = erlangs(Rate, Duration), W = -(Agents - E) * Target / Duration, 1 - erlang_c_calc(E, Agents) * math:exp(W). %% private % erlang_b_calc(E, Agents) -> 1.0 / erlang_b_calc(1, Agents, E, 1.0). % erlang_b_calc(Count, Agents, E, Acc) when Count =< Agents -> Acc0 = 1.0 + Count / E * Acc, erlang_b_calc(Count + 1, Agents, E, Acc0); erlang_b_calc(_, _, _, Acc) -> Acc. % extended_erlang_b_calc(E, Agents, RecallFactor, Acc) -> P = erlang_b_calc(Acc, Agents), R = E * P * RecallFactor, case E + R of Acc -> P; E0 -> extended_erlang_b_calc(E, Agents, RecallFactor, E0) end. % erlang_c_calc(E, Agents) -> X = math:pow(E, Agents) / factorial(Agents), Y = Agents / (Agents - E), Sum = erlang_c_calc(E, Agents - 1, 0), F / (Sum + X * Y). % erlang_c_calc(E, A, Acc) when A >= 0 -> X = math:pow(E, A) / factorial(A), erlang_c_calc(E, A - 1, X + Acc); erlang_c_calc(_, _, Acc) -> Acc. % factorial(0) -> 1; factorial(N) when N > 0 -> factorial(N, 1). % factorial(N, Acc) when N > 0 -> factorial(N - 1, N * Acc); factorial(_, Acc) -> Acc. --------------- Subject change: if you didn't see this how-to site from github, it's really nicely done. http://gitref.org/ /s From nraychaudhuri@REDACTED Sat Jun 12 22:19:47 2010 From: nraychaudhuri@REDACTED (Nilanjan Raychaudhuri) Date: Sat, 12 Jun 2010 16:19:47 -0400 Subject: Similarities between web programming and functional programming Message-ID: <2C042DAC-416E-435A-A3CF-0376B7BB5B01@pillartechnology.com> Hi all, As a newbie into functional programming I am curious to know how functional programming style fits into building web applications? And how it compares to building web apps in Ruby or Java. Any pointer to article/literature will be helpful. Thanks Nilanjan From jesper.louis.andersen@REDACTED Sat Jun 12 22:37:17 2010 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Sat, 12 Jun 2010 22:37:17 +0200 Subject: [erlang-questions] Similarities between web programming and functional programming In-Reply-To: <2C042DAC-416E-435A-A3CF-0376B7BB5B01@pillartechnology.com> References: <2C042DAC-416E-435A-A3CF-0376B7BB5B01@pillartechnology.com> Message-ID: On Sat, Jun 12, 2010 at 10:19 PM, Nilanjan Raychaudhuri wrote: > Hi all, > > As a newbie into functional programming I am curious to know how functional programming style fits into building web applications? And how it > compares to building web apps in Ruby or Java. > > Any pointer to article/literature will be helpful. Look at the following function: handle(Request) -> X = ..., Template = ..., render_response(?HTTP_OK, X, Template). It has the specification contract -spec handle(request()) -> response(). That is, handling incoming web requests are (sometimes pure) functions from request() objects to response() objects. At this point, we are essentially done. There isn't much more to it. Of course, we have only defined a rough skeleton of how to do it, and a lot of the fleshy details have been omitted. What makes it easy is that the web is essentially stateless: All needed information is in the request() object. If we store data locally, there will be some kind of token() object (a cookie, say) in the request() object allowing us to get hold of our server-side state. One could imagine calling another process to get hold of this data (it is not much different from Ruby, Python or Java calling into an SQL database for their data). In general web-server handling is very amenable to the functional programming paradigm. You may regard the above as being unnecessarily low level, but it is very easy to use a couple of wrapper functions to peel off layers of complexity so you end up with the innards of a web framework such as Rails, Django or Pylons. Erlang gives you an insane amount of tools to manipulate web-applications. It seems that much of the heightened interest in Erlang as of late is channeled towards building web-tools and webapps in general. So not only will you have an excellent language for doing web application development; you will also enjoy standing on the shoulders of giants. -- J. From wallentin.dahlberg@REDACTED Sun Jun 13 03:04:34 2010 From: wallentin.dahlberg@REDACTED (Wallentin Dahlberg) Date: Sun, 13 Jun 2010 03:04:34 +0200 Subject: [erlang-questions] tracing non exported functions In-Reply-To: References: Message-ID: erlang:trace_pattern/3 will do what you ask. Use option "local" or "meta". Regards, Bj?rn-Egil 2010/6/12 Filipe David Manana > Hello, > > Recently I've been playing with erlang:trace_pattern. Its documentation > says > it works only for exported functions. > Is there any other BIFs that would allow me to have the same functionality > but to trace non-exported functions as well? (in the same way as > trace_pattern and trace) > > cheers > > -- > Filipe David Manana, > fdmanana@REDACTED > > "Reasonable men adapt themselves to the world. > Unreasonable men adapt the world to themselves. > That's why all progress depends on unreasonable men." > From eric.l.2046@REDACTED Sun Jun 13 05:11:52 2010 From: eric.l.2046@REDACTED (Eric Liang) Date: Sun, 13 Jun 2010 11:11:52 +0800 Subject: [erlang-questions] beam[8449]: segfault at 0 ip 0000000000437e10 sp 00007fffce250948 error 4 in beam[400000+174000] In-Reply-To: <19475.22326.25668.128042@pilspetsen.it.uu.se> References: <4BFA2DEC.50707@gmail.com> <19450.17437.149260.11204@pilspetsen.it.uu.se> <4BFA71AE.5060708@gmail.com> <19450.31693.774522.332905@pilspetsen.it.uu.se> <4BFB4309.1060507@gmail.com> <19451.44811.595873.338827@pilspetsen.it.uu.se> <4BFD250F.6020202@gmail.com> <19453.25855.346911.194353@pilspetsen.it.uu.se> <4C0A1B45.1070304@gmail.com> <19475.22326.25668.128042@pilspetsen.it.uu.se> Message-ID: <4C144C78.8010405@gmail.com> On 06/12/2010 05:45 PM, Mikael Pettersson wrote: > Eric Liang wrote: > >> On 05/27/2010 02:14 AM, Mikael Pettersson wrote: >> >>> Eric Liang wrote: >>> =20 >>> >>>> I've done a build of the source, but it just can't match the object. H= >>>> >> ow >> >>>> do you make it? I use the command: apt-get source to get the source, s= >>>> >> o >> >>>> it does have the same version with the object. >>>> =20 >>>> >>> I did: >>> >>> =20 >>> >>>> tar zxvf otp_src_R13B03.tar.gz >>>> cd otp_src_R13B03 >>>> ./configure; make >>>> =20 >>>> >>> The binary files of interest are bin/x86_64-unknown-linux-gnu/beam and = >>> >> >>> erts/emulator/obj/x86_64-unknown-linux-gnu/opt/plain/erl_goodfit_alloc.= >>> >> o. >> >>> =20 >>> >> Thanks Mikael, and sorry for replying you too late as the seg-fault is >> not occured every time. >> >> I get the debug symbols by this: >> >> http://forum.nginx.org/read.php?26,93440,94735 >> >> >>>>> You can get a stack dump from the crash by attaching gdb to the >>>>> soon-to-crash beam process. Now instead of being terminated gdb will >>>>> get control of the process and you should be able to print a stack >>>>> trace with bt or where. (This does require that there's a sufficient >>>>> time window from the start of the application to the crash.) >>>>> =3D20 >>>>> =20 >>>>> >>>> I've make a core dump 4 seconds before it crash, as mentioned above,=3D= >>>> >> 20 >> >>>> because don't get the right symbols, it just with some quesion-marks: >>>> >>>> Core was generated by `/usr/lib/erlang/erts-5.7.2/bin/beam'. >>>> #0 0x00007f0a28ecd5a9 in ?? () >>>> (gdb) whe >>>> #0 0x00007f0a28ecd5a9 in ?? () >>>> #1 0x0000000000000000 in ?? () >>>> (gdb) >>>> =20 >>>> >>> A core dump from a time point before the crash is useless. Either get a= >>> >> >>> core dump from the crash itself (execute `ulimit -c unlimited' in bash >>> before running the test), or attach gdb, continue the process, and wait= >>> >> >>> for gdb to receive control when the crash occurs. >>> =20 >>> >> I do set the ulimit -c in /etc/profile and after I reboot it: >> >> sunny@REDACTED:~$ ulimit -c >> unlimited >> sunny@REDACTED:~/commands$ cat /proc/sys/kernel/core_pattern >> /tmp/core.%t.%e.%p >> >> And I the test is ok: >> >> sunny@REDACTED:~$ kill -s SIGSEGV $$ >> Connection to dev-2 closed. >> sunny@REDACTED:~$ ls /tmp/ >> core.1275730620.bash.12566 >> >> But still no core file generated,when the error occurs. >> >> Anyway, I attatched the running process by gdb, and here is the result: >> >> Program received signal SIGSEGV, Segmentation fault. >> unlink_free_block (allctr=3D0x7ad480, block=3D0x0) at >> beam/erl_goodfit_alloc.c:453 >> 453 Uint sz =3D BLK_SZ(blk); >> (gdb) whe >> #0 unlink_free_block (allctr=3D0x7ad480, block=3D0x0) at >> beam/erl_goodfit_alloc.c:453 >> #1 0x0000000000437fd6 in get_free_block (allctr=3D0x7ad480, >> size=3D, cand_blk=3D0x0, cand_size=3D0) >> at beam/erl_goodfit_alloc.c:421 >> #2 0x00000000004322c6 in mbc_alloc_block (allctr=3D0x7ad480, size=3D= >> 72) >> at beam/erl_alloc_util.c:631 >> #3 mbc_alloc (allctr=3D0x7ad480, size=3D72) at beam/erl_alloc_util.c= >> :758 >> #4 0x00000000004b1697 in erts_alloc () at beam/erl_alloc.h:179 >> #5 exit_async () at beam/erl_async.c:132 >> #6 0x000000000043c13d in system_cleanup (exit_code=3D> d >> out>) at beam/erl_init.c:1306 >> #7 0x000000000043c443 in erl_exit (n=3D0, fmt=3D0x54649c "") at >> beam/erl_init.c:1380 >> #8 0x000000000045d042 in halt_0 (A__p=3D) at >> beam/bif.c:3319 >> #9 0x00000000004d081f in process_main () at beam/beam_emu.c:2008 >> #10 0x000000000043d56c in erl_start (argc=3D34, argv=3D> ed >> out>) at beam/erl_init.c:1233 >> #11 0x00000000004269b9 in main (argc=3D8049792, argv=3D0x0) at >> sys/unix/erl_main.c:29 >> (gdb) f 1 >> #1 0x0000000000437fd6 in get_free_block (allctr=3D0x7ad480, >> size=3D, cand_blk=3D0x0, cand_size=3D0) >> at beam/erl_goodfit_alloc.c:421 >> 421 unlink_free_block(allctr, blk); >> (gdb) l 421 >> 416 /* We are guaranteed to find a block that fits in this >> bucket */ >> 417 blk =3D search_bucket(allctr, min_bi, size); >> 418 ASSERT(blk); >> 419 if (cand_blk && cand_size <=3D BLK_SZ(blk)) >> 420 return NULL; /* cand_blk was better */ >> 421 unlink_free_block(allctr, blk); >> 422 return blk; >> 423 } >> 424 =20 >> 425 =20 >> (gdb) >> >> As the running process use the no-debug symbol version beam, I guess the >> ASSERT in line:418 does not work. So I dig in >> >> (gdb) p allctr >> $1 =3D (Allctr_t *) 0x7ad480 >> (gdb) p min_bi >> $2 =3D >> (gdb) p size >> $3 =3D >> (gdb) p *allctr >> $4 =3D {name_prefix =3D 0x534227 "sl_", alloc_no =3D 3, name =3D {all= >> oc =3D 0, >> realloc =3D 0, free =3D 0}, >> vsn_str =3D 0x53602f "2.1", t =3D 0, ramv =3D 0, sbc_threshold =3D = >> 524288, >> sbc_move_threshold =3D 80, >> mbc_move_threshold =3D 50, main_carrier_size =3D 131072, max_mseg_s= >> bcs >> =3D 256, max_mseg_mbcs =3D 5, >> largest_mbc_size =3D 10485760, smallest_mbc_size =3D 1048576, >> mbc_growth_stages =3D 10, mseg_opt =3D {cache =3D 1, >> preserv =3D 1, abs_shrink_th =3D 4145152, rel_shrink_th =3D 80}, >> mbc_header_size =3D 32, sbc_header_size =3D 32, >> min_mbc_size =3D 16384, min_mbc_first_free_size =3D 4096, >> min_block_size =3D 32, mbc_list =3D {first =3D 0x7f4f93a5d010, >> last =3D 0x7f4f93a5d010}, sbc_list =3D {first =3D 0x0, last =3D 0= >> x0}, >> main_carrier =3D 0x7f4f93a5d010, >> get_free_block =3D 0x437f40 , link_free_block =3D >> 0x437d00 , >> unlink_free_block =3D 0x437e10 , info_options =3D= >> >> 0x438480 , >> get_next_mbc_size =3D 0x430e40 , creating_mbc =3D= >> >> 0x438100 , >> destroying_mbc =3D 0x438100 , init_atoms =3D >> 0x4385c0 , mutex =3D {mtx =3D {pt_mtx =3D { >> __data =3D {__lock =3D 0, __count =3D 0, __owner =3D 0, __nus= >> ers =3D >> 0, __kind =3D 0, __spins =3D 0, __list =3D { >> __prev =3D 0x0, __next =3D 0x0}}, __size =3D '\000' > ats >> 39 times>, __align =3D 0}, is_rec_mtx =3D 0, >> prev =3D 0x0, next =3D 0x0}}, thread_safe =3D 0, ts_list =3D {p= >> rev =3D >> 0x0, next =3D 0x0}, atoms_initialized =3D 0, >> stopped =3D 0, calls =3D {this_alloc =3D {giga_no =3D 0, no =3D 246= >> 0}, >> this_free =3D {giga_no =3D 0, no =3D 2458}, >> this_realloc =3D {giga_no =3D 0, no =3D 0}, mseg_alloc =3D {giga_= >> no =3D 0, >> no =3D 0}, mseg_dealloc =3D {giga_no =3D 0, no =3D 0}, >> mseg_realloc =3D {giga_no =3D 0, no =3D 0}, sys_alloc =3D {giga_n= >> o =3D 0, >> no =3D 1}, sys_free =3D {giga_no =3D 0, no =3D 0}, >> sys_realloc =3D {giga_no =3D 0, no =3D 0}}, sbcs =3D {curr_mseg =3D= >> {no =3D >> 0, size =3D 0}, curr_sys_alloc =3D {no =3D 0, >> size =3D 0}, max =3D {no =3D 0, size =3D 0}, max_ever =3D {no =3D= >> 0, size >> =3D 0}, blocks =3D {curr =3D {no =3D 0, size =3D 0}, >> max =3D {no =3D 0, size =3D 0}, max_ever =3D {no =3D 0, size =3D= >> 0}}}, >> mbcs =3D {curr_mseg =3D {no =3D 0, size =3D 0}, >> curr_sys_alloc =3D {no =3D 1, size =3D 131112}, max =3D {no =3D 1= >> , size =3D >> 131112}, max_ever =3D {no =3D 0, size =3D 0}, >> blocks =3D {curr =3D {no =3D 4, size =3D 384}, max =3D {no =3D 14= >> 4, size =3D >> 13848}, max_ever =3D {no =3D 0, size =3D 0}}}} >> (gdb) >> >> And stalled here, do you have any advices? and also, any other >> suggestions would be appreciated. TIA. >> > This shows that in erl_goodfit_alloc.c, the ASSERT(blk) at the > end of get_free_block() is bogus and that unlink_free_blk() can > be invoked with a NULL blk, which will cause a crash. > > You should send this to the erlang-bugs mailing list. It needs > either the attention of someone who is intimately familiar with > the logic of these allocators (I'm not), or for you to make a > self-contained test case available (which you might not be able > to do if it's proprietary). > OK, I'll try to send to the erlang-bugs mailling list. Thanks a lot for your help, and I'll mail you if any progress is made. :) Eric -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 261 bytes Desc: OpenPGP digital signature URL: From fritchie@REDACTED Sun Jun 13 21:30:18 2010 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Sun, 13 Jun 2010 14:30:18 -0500 Subject: ACM Erlang Workshop 2010: submission deadline approaching Message-ID: <58230.1276457418@snookles.snookles.com> Hi, all. As workshop chair, I'd be remiss if I didn't mention that the deadline for submitting proposals for the ACM Erlang Workshop is quickly approaching. Submissions for both tracks are accepted through Monday, June 14. I didn't choose specific timezone, so feel free to pick any one that you wish. :-) If you missed the earlier announcements about this year's workshop, details can be found at: http://www.erlang.org/workshop/2010/ -Scott From vinoski@REDACTED Mon Jun 14 03:27:41 2010 From: vinoski@REDACTED (Steve Vinoski) Date: Sun, 13 Jun 2010 21:27:41 -0400 Subject: [erlang-questions] Similarities between web programming and functional programming In-Reply-To: <2C042DAC-416E-435A-A3CF-0376B7BB5B01@pillartechnology.com> References: <2C042DAC-416E-435A-A3CF-0376B7BB5B01@pillartechnology.com> Message-ID: On Sat, Jun 12, 2010 at 4:19 PM, Nilanjan Raychaudhuri wrote: > Hi all, > > As a newbie into functional programming I am curious to know how functional programming style fits into building web applications? And how it > compares to building web apps in Ruby or Java. > > Any pointer to article/literature will be helpful. For a little over a year now I've write a bimonthly magazine column called "The Functional Web" for IEEE Internet Computing magazine (though I missed a couple issues due to workload). All issues can be found here: http://steve.vinoski.net/blog/internet-computing-columns/ You might take a look at the introductory article for the column to see if it helps answer your question: http://steve.vinoski.net/pdf/IC-Welcome_to_the_Functional_Web.pdf --steve From francesco@REDACTED Sun Jun 13 22:27:08 2010 From: francesco@REDACTED (Francesco Cesarini (Erlang Solutions)) Date: Sun, 13 Jun 2010 21:27:08 +0100 Subject: =?windows-1252?Q?Re=3A_=5Berlang-questions=5D_=5BANN=5D_Tr?= =?windows-1252?Q?yErlang=2Eorg_=97_online_tutorials_and_intera?= =?windows-1252?Q?ctive_console?= In-Reply-To: References: Message-ID: <4C153F1C.3030804@erlang-solutions.com> It was supposed to be a quiet launch, and we got 2500+ unique visitors in the first 12 hours. Mostly experienced users, judging from the creative attempts to sink the system :-). No one has suceeded yet, the only short outage we had was load related, where the VM (Not the Erlang one) could not cope with the traffic. Roberto likes a nice challenge. If you are able to get past his security measures and kill the site (Dos attacks do not count, as it is still not running on its dedicated machine), he has promised to cook you a delicious home made Sicilian dinner ;-) /F On 10/06/2010 08:29, Dmitrii Dimandt wrote: > Oddly enough the authors haven't made an announcement here :) > > http://www.tryerlang.org/ > > tryerlang.org is an hands-on, interactive tutorial that allows you to try the power of Erlang directly in your browser, without installing anything in your machine. The idea and the interface are heavily inspired by the tryruby.org and tryhaskell.orgprojects. > > > > Roberto Aloi, you rock! > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From gleber.p@REDACTED Mon Jun 14 09:44:15 2010 From: gleber.p@REDACTED (Gleb Peregud) Date: Mon, 14 Jun 2010 09:44:15 +0200 Subject: =?UTF-8?Q?Re=3A_=5Berlang=2Dquestions=5D_=5BANN=5D_TryErlang=2Eorg_=E2=80=94_onlin?= =?UTF-8?Q?e_tutorials_and_interactive_console?= In-Reply-To: <4C153F1C.3030804@erlang-solutions.com> References: <4C153F1C.3030804@erlang-solutions.com> Message-ID: On Sun, Jun 13, 2010 at 22:27, Francesco Cesarini (Erlang Solutions) wrote: > Roberto likes a nice challenge. If you are able to get past his security > measures and kill the site (Dos attacks do not count, as it is still not > running on its dedicated machine), he has promised to cook you a delicious > home made Sicilian dinner ;-) It returns 503 now. I wonder if Roberto owes someone a meal :) From torben.lehoff@REDACTED Mon Jun 14 09:51:04 2010 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Mon, 14 Jun 2010 09:51:04 +0200 Subject: =?windows-1252?Q?Re=3A_=5Berlang=2Dquestions=5D_=5BANN=5D_TryErlang=2Eorg_=97_onlin?= =?windows-1252?Q?e_tutorials_and_interactive_console?= In-Reply-To: References: <4C153F1C.3030804@erlang-solutions.com> Message-ID: He does - Nick (my colleague) took it down with a nasty binary. 5 minutes of "hard work" based on previous self-experienced pain. Cheers, Torben On Mon, Jun 14, 2010 at 09:44, Gleb Peregud wrote: > On Sun, Jun 13, 2010 at 22:27, Francesco Cesarini (Erlang Solutions) > wrote: > > Roberto likes a nice challenge. If you are able to get past his security > > measures and kill the site (Dos attacks do not count, as it is still not > > running on its dedicated machine), he has promised to cook you a > delicious > > home made Sicilian dinner ;-) > > It returns 503 now. I wonder if Roberto owes someone a meal :) > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > -- http://www.linkedin.com/in/torbenhoffmann From mazen.harake@REDACTED Mon Jun 14 09:54:34 2010 From: mazen.harake@REDACTED (Mazen Harake) Date: Mon, 14 Jun 2010 10:54:34 +0300 Subject: [erlang-questions] [ANN] TryErlang.org =?UTF-8?B?4oCUIG9ubGlu?= =?UTF-8?B?ZSB0dXRvcmlhbHMgYW5kIGludGVyYWN0aXZlIGNvbnNvbGU=?= In-Reply-To: References: <4C153F1C.3030804@erlang-solutions.com> Message-ID: <4C15E03A.6080906@erlang-solutions.com> Obviously the "exploit" has to be published after it has been patched... right? :-D /M On 14/06/2010 10:51, Torben Hoffmann wrote: > He does - Nick (my colleague) took it down with a nasty binary. 5 minutes > of "hard work" based on previous self-experienced pain. > > Cheers, > Torben > > On Mon, Jun 14, 2010 at 09:44, Gleb Peregud wrote: > > >> On Sun, Jun 13, 2010 at 22:27, Francesco Cesarini (Erlang Solutions) >> wrote: >> >>> Roberto likes a nice challenge. If you are able to get past his security >>> measures and kill the site (Dos attacks do not count, as it is still not >>> running on its dedicated machine), he has promised to cook you a >>> >> delicious >> >>> home made Sicilian dinner ;-) >>> >> It returns 503 now. I wonder if Roberto owes someone a meal :) >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> >> > > --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From torben.lehoff@REDACTED Mon Jun 14 09:58:17 2010 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Mon, 14 Jun 2010 09:58:17 +0200 Subject: =?windows-1252?Q?Re=3A_=5Berlang=2Dquestions=5D_=5BANN=5D_TryErlang=2Eorg_=97_onlin?= =?windows-1252?Q?e_tutorials_and_interactive_console?= In-Reply-To: <4C15E03A.6080906@erlang-solutions.com> References: <4C153F1C.3030804@erlang-solutions.com> <4C15E03A.6080906@erlang-solutions.com> Message-ID: FreeDinnerList = lists:seq(1, 1000000). list_to_binary(FreeDinnerList). On Mon, Jun 14, 2010 at 09:54, Mazen Harake < mazen.harake@REDACTED> wrote: > Obviously the "exploit" has to be published after it has been patched... > > right? :-D > > /M > > > On 14/06/2010 10:51, Torben Hoffmann wrote: > >> He does - Nick (my colleague) took it down with a nasty binary. 5 minutes >> of "hard work" based on previous self-experienced pain. >> >> Cheers, >> Torben >> >> On Mon, Jun 14, 2010 at 09:44, Gleb Peregud wrote: >> >> >> >>> On Sun, Jun 13, 2010 at 22:27, Francesco Cesarini (Erlang Solutions) >>> wrote: >>> >>> >>>> Roberto likes a nice challenge. If you are able to get past his security >>>> measures and kill the site (Dos attacks do not count, as it is still not >>>> running on its dedicated machine), he has promised to cook you a >>>> >>>> >>> delicious >>> >>> >>>> home made Sicilian dinner ;-) >>>> >>>> >>> It returns 503 now. I wonder if Roberto owes someone a meal :) >>> >>> ________________________________________________________________ >>> erlang-questions (at) erlang.org mailing list. >>> See http://www.erlang.org/faq.html >>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>> >>> >>> >>> >> >> >> > > --------------------------------------------------- > > --------------------------------------------------- > > WE'VE CHANGED NAMES! > > Since January 1st 2010 Erlang Training and Consulting Ltd. has become > ERLANG SOLUTIONS LTD. > > www.erlang-solutions.com > > -- http://www.linkedin.com/in/torbenhoffmann From mazen.harake@REDACTED Mon Jun 14 10:14:30 2010 From: mazen.harake@REDACTED (Mazen Harake) Date: Mon, 14 Jun 2010 11:14:30 +0300 Subject: [erlang-questions] [ANN] TryErlang.org =?UTF-8?B?4oCUIG9ubGlu?= =?UTF-8?B?ZSB0dXRvcmlhbHMgYW5kIGludGVyYWN0aXZlIGNvbnNvbGU=?= In-Reply-To: References: <4C153F1C.3030804@erlang-solutions.com> <4C15E03A.6080906@erlang-solutions.com> Message-ID: <4C15E4E6.30304@erlang-solutions.com> Fair enough, but I expected something that takes control of the VM :) /M On 14/06/2010 10:58, Torben Hoffmann wrote: > FreeDinnerList = lists:seq(1, 1000000). > list_to_binary(FreeDinnerList). > > > On Mon, Jun 14, 2010 at 09:54, Mazen Harake > > wrote: > > Obviously the "exploit" has to be published after it has been > patched... > > right? :-D > > /M > > > On 14/06/2010 10:51, Torben Hoffmann wrote: > > He does - Nick (my colleague) took it down with a nasty > binary. 5 minutes > of "hard work" based on previous self-experienced pain. > > Cheers, > Torben > > On Mon, Jun 14, 2010 at 09:44, Gleb Peregud > wrote: > > > On Sun, Jun 13, 2010 at 22:27, Francesco Cesarini (Erlang > Solutions) > > wrote: > > Roberto likes a nice challenge. If you are able to get > past his security > measures and kill the site (Dos attacks do not count, > as it is still not > running on its dedicated machine), he has promised to > cook you a > > delicious > > home made Sicilian dinner ;-) > > It returns 503 now. I wonder if Roberto owes someone a meal :) > > ________________________________________________________________ > erlang-questions (at) erlang.org > mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; > mailto:erlang-questions-unsubscribe@REDACTED > > > > > > > > --------------------------------------------------- > > --------------------------------------------------- > > WE'VE CHANGED NAMES! > > Since January 1st 2010 Erlang Training and Consulting Ltd. has > become ERLANG SOLUTIONS LTD. > > www.erlang-solutions.com > > > > > -- > http://www.linkedin.com/in/torbenhoffmann --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From hm@REDACTED Mon Jun 14 10:20:56 2010 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Mon, 14 Jun 2010 10:20:56 +0200 Subject: [erlang-questions] Shutting down Mnesia with replicas and dirty reads In-Reply-To: References: Message-ID: On Fri, Jun 11, 2010 at 8:06 PM, Igor Ribeiro Sucupira wrote: > My question is: using transactions/sync_transactions, are all > operations guaranteed to succeed even if one of the replicas goes down > during the operation, as long as there's at least one replica > remaining, accessible and perfectly operational? Yes, but when the replica goes down it may cause the transaction to be restarted. If it is restarted it will imply that your fun will be executed again. /H?kan --- H?kan Mattsson Tail-f Systems From bg.branko@REDACTED Mon Jun 14 11:16:02 2010 From: bg.branko@REDACTED (Branko Vukelic) Date: Mon, 14 Jun 2010 11:16:02 +0200 Subject: =?UTF-8?Q?Re=3A_=5Berlang=2Dquestions=5D_=5BANN=5D_TryErlang=2Eorg_=E2=80=94_onlin?= =?UTF-8?Q?e_tutorials_and_interactive_console?= In-Reply-To: <4C15E4E6.30304@erlang-solutions.com> References: <4C153F1C.3030804@erlang-solutions.com> <4C15E03A.6080906@erlang-solutions.com> <4C15E4E6.30304@erlang-solutions.com> Message-ID: Francesco, I'm not going to try and explot it or anything (I'm one of those intended audience members, an Erlang newbie). :) Instead, I went through the tutorials the intended (?) way, up until the part on lists and tuples. Here are my observations so far: 1. When multiple commands are introduced, the shell goes to next step after trying the first one, without allowing me to try out all presented commands (so I have to go back to look at the information). 2. The 1st step in the lists tutorial got me stuck. I define a simple list like [1,2,3] and it tells me it's not what it asked for, and won't continue any further. As for 1, it would be very convenient if it asked for an `ok.` in case there are multiple commands, no? Anyway, thanks for the try erlang, it's looking great! Best regards, -- Branko Vukeli? bg.branko@REDACTED studio@REDACTED Check out my blog: http://www.brankovukelic.com/ Check out my portfolio: http://www.flickr.com/photos/foxbunny/ Registered Linux user #438078 (http://counter.li.org/) I hang out on identi.ca: http://identi.ca/foxbunny Gimp Brushmakers Guild http://bit.ly/gbg-group From roberto.aloi@REDACTED Mon Jun 14 11:21:32 2010 From: roberto.aloi@REDACTED (Roberto Aloi) Date: Mon, 14 Jun 2010 09:21:32 +0000 (GMT) Subject: =?utf-8?Q?Re:_[erlang-questions]_[ANN]_TryErlang.org?= =?utf-8?Q?_=E2=80=94_online_tutorials_and_interactive_console?= In-Reply-To: Message-ID: <1499599730.466271276507292969.JavaMail.root@zimbra> Hi there, > 1. When multiple commands are introduced, the shell goes to next step > after trying the first one, without allowing me to try out all > presented commands (so I have to go back to look at the information). I'm going to introduce the back. and next. commands, since many people asked for this. > 2. The 1st step in the lists tutorial got me stuck. I define a simple > list like [1,2,3] and it tells me it's not what it asked for, and > won't continue any further. That's a known bug. Working on it. In the meantime, you can use an empty list to step over. > Anyway, thanks for the try erlang, it's looking great! Thank you for not trying to kill it :) Regards, Roberto Aloi -- University of Kent - Erlang Solutions Ltd. Blog: http://aloiroberto.wordpress.com Twitter: @prof3ta --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From bg.branko@REDACTED Mon Jun 14 11:25:34 2010 From: bg.branko@REDACTED (Branko Vukelic) Date: Mon, 14 Jun 2010 11:25:34 +0200 Subject: =?UTF-8?Q?Re=3A_=5Berlang=2Dquestions=5D_=5BANN=5D_TryErlang=2Eorg_=E2=80=94_onlin?= =?UTF-8?Q?e_tutorials_and_interactive_console?= In-Reply-To: <1499599730.466271276507292969.JavaMail.root@zimbra> References: <1499599730.466271276507292969.JavaMail.root@zimbra> Message-ID: On Mon, Jun 14, 2010 at 11:21 AM, Roberto Aloi wrote: >> Anyway, thanks for the try erlang, it's looking great! > Thank you for not trying to kill it :) Haha. Wish I could. The Sicilian meal sounded delicious. :D -- Branko Vukeli? bg.branko@REDACTED studio@REDACTED Check out my blog: http://www.brankovukelic.com/ Check out my portfolio: http://www.flickr.com/photos/foxbunny/ Registered Linux user #438078 (http://counter.li.org/) I hang out on identi.ca: http://identi.ca/foxbunny Gimp Brushmakers Guild http://bit.ly/gbg-group From roberto.aloi@REDACTED Mon Jun 14 11:29:17 2010 From: roberto.aloi@REDACTED (Roberto Aloi) Date: Mon, 14 Jun 2010 09:29:17 +0000 (GMT) Subject: =?utf-8?Q?Re:_[erlang-questions]_[ANN]_TryErlang.org?= =?utf-8?Q?_=E2=80=94_online_tutorials_and_interactive_console?= In-Reply-To: <4C153F1C.3030804@erlang-solutions.com> Message-ID: <1193380106.466401276507757177.JavaMail.root@zimbra> Hi all, > It was supposed to be a quiet launch, and we got 2500+ unique visitors > > in the first 12 hours. Mostly experienced users, judging from the > creative attempts to sink the system :-). No one has suceeded yet, the > > only short outage we had was load related, where the VM (Not the > Erlang > one) could not cope with the traffic. Yep. This was the main reason. > Roberto likes a nice challenge. If you are able to get past his > security > measures and kill the site (Dos attacks do not count, as it is still > not > running on its dedicated machine), he has promised to cook you a > delicious home made Sicilian dinner ;-) lol. Well, I'm a bit busy at the moment with patching tryerlang.org after the recent attacks but feel free to visit a Sicilian restaurant in your favourite city and to charge Erlang Solutions for it :-p For those who are in London, I'll be very happy to discuss the attacks in front of one or two beers :) Cheers, Roberto Aloi -- University of Kent - Erlang Solutions Ltd. Blog: http://aloiroberto.wordpress.com Twitter: @prof3ta --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From bg.branko@REDACTED Mon Jun 14 11:37:17 2010 From: bg.branko@REDACTED (Branko Vukelic) Date: Mon, 14 Jun 2010 11:37:17 +0200 Subject: =?UTF-8?Q?Re=3A_=5Berlang=2Dquestions=5D_=5BANN=5D_TryErlang=2Eorg_=E2=80=94_onlin?= =?UTF-8?Q?e_tutorials_and_interactive_console?= In-Reply-To: <1193380106.466401276507757177.JavaMail.root@zimbra> References: <4C153F1C.3030804@erlang-solutions.com> <1193380106.466401276507757177.JavaMail.root@zimbra> Message-ID: Roberto, Will it be possible to input multi-line functions, etc, when Try Erlang is released? Currently it gives me a syntax error if I break on `->`, `[`, etc. Regards, -- Branko Vukeli? bg.branko@REDACTED studio@REDACTED Check out my blog: http://www.brankovukelic.com/ Check out my portfolio: http://www.flickr.com/photos/foxbunny/ Registered Linux user #438078 (http://counter.li.org/) I hang out on identi.ca: http://identi.ca/foxbunny Gimp Brushmakers Guild http://bit.ly/gbg-group From roberto.aloi@REDACTED Mon Jun 14 11:48:08 2010 From: roberto.aloi@REDACTED (Roberto Aloi) Date: Mon, 14 Jun 2010 09:48:08 +0000 (GMT) Subject: =?utf-8?Q?Re:_[erlang-questions]_[ANN]_TryErlang.org?= =?utf-8?Q?_=E2=80=94_online_tutorials_and_interactive_console?= In-Reply-To: Message-ID: <355409836.466661276508888599.JavaMail.root@zimbra> Hi, > Will it be possible to input multi-line functions, etc, when Try > Erlang is released? Currently it gives me a syntax error if I break > on > `->`, `[`, etc. Right now the shell doesn't work with multi-line, but this is definitely in the wish-list. Roberto Aloi -- University of Kent - Erlang Solutions Ltd. Blog: http://aloiroberto.wordpress.com Twitter: @prof3ta --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From ulf.wiger@REDACTED Mon Jun 14 13:57:31 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Mon, 14 Jun 2010 13:57:31 +0200 Subject: RFC: Erjang's Java API prototype Message-ID: <4C16192B.5080408@erlang-solutions.com> I think this is well worth looking into, especially for those who like discussing semantics, overloading, type inference and such. http://www.javalimit.com/2010/06/a-java-api-for-erjang.html High marks for elegance. There are some open issues that could benefit from some attention from the language sticklers in the Erlang community. BR, Ulf W -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From raimo+erlang-questions@REDACTED Mon Jun 14 16:01:21 2010 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 14 Jun 2010 16:01:21 +0200 Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <4C110067.80704@nm.ru> References: <4C110067.80704@nm.ru> Message-ID: <20100614140121.GA15603@erix.ericsson.se> On Thu, Jun 10, 2010 at 07:10:31PM +0400, Dmitry Belyaev wrote: > I think, we've found a bug in inet_res. It seems so. > > It causes request to inet_res:getbyname/2 to respond {error, timeout} if > *first* nameserver in /etc/resolv.conf inexistent (or down in my case). The code apparently gives up on the first {error,timeout}, and that sounds like a bad strategy. > > I couldn't find any info about gen_udp:connect nor erlang:port_get_data/1. > But commenting following line helped. > http://github.com/erlang/otp/blob/dev/lib/kernel/src/inet_res.erl#L676 > > query_udp(S, Id, Buffer, IP, Port, Timer, Retry, I, Tm, Verbose) -> > Timeout = inet:timeout( (Tm * (1 bsl I)) div Retry, Timer), > ?verbose(Verbose, "Try UDP server : ~p:~p (timeout=~w)\n", [IP, Port, > Timeout]), > %% udp_connect(S, IP, Port), > udp_send(S, IP, Port, Buffer), > query_udp_recv(S, IP, Port, Id, Timeout, Verbose). > > > Can anyone tell me is it really a bug? And what gen_udp:connect/3 do? I regard it as a bug. But the correct fix ought to be to recurse on timeout in inet_res:query_nss_edns/7 and inet_res:query_nss_dns/7, like for _Error. I will fix it in a future release. gen_udp:connect/3 calls int connect(int socket, const struct sockaddr *address, socklen_t address_len); on the socket. Excerpt from man connect: If the initiating socket is not connection-mode, then connect() shall set the socket's peer address, and no connection is made. For SOCK_DGRAM sockets, the peer address identifies where all datagrams are sent on subsequent send() functions, and limits the remote sender for subsequent recv() functions. If address is a null address for the protocol, the socket's peer address shall be reset. i.e default destination is set and reception is limited. I think it is receiving from only the inteded DNS server that is the purpose. > > -- > Dmitry Belyaev > -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From amir.nagri@REDACTED Mon Jun 14 17:08:06 2010 From: amir.nagri@REDACTED (amiruddin nagri) Date: Mon, 14 Jun 2010 08:08:06 -0700 (PDT) Subject: Accounting Engine in Erlang Message-ID: We have a requirement of making an accounting engine that handles all the journal entries, transactions, portfolios etc. The communication with the engine is based on simple protocol, the things to be taken care of in the order are consistency and performance. I have looked around some of the products based on erlang, specifically couch db, couch db promises eventual consistency and horizontal scaling. Is the issue of consistency not solvable using erlang, or if we implement consistency using erlang we won't be able use the performance and scaling feature of erlang to maximum. Also, if you have any suggestions of the choice of programming language, we have been looking into other functional languages like Haskell and Clojure. But we have not dig deep on the performance aspects of these languages, if someone can shed a light on the pros- cons of these languages, it will help us very much to come to a decision. -Regards, Amir From g9414002.pccu.edu.tw@REDACTED Mon Jun 14 17:27:38 2010 From: g9414002.pccu.edu.tw@REDACTED (=?UTF-8?B?6buD6ICA6LOiIChZYXUtSHNpZW4gSHVhbmcp?=) Date: Mon, 14 Jun 2010 23:27:38 +0800 Subject: [erlang-questions] Similarities between web programming and functional programming In-Reply-To: <2C042DAC-416E-435A-A3CF-0376B7BB5B01@pillartechnology.com> References: <2C042DAC-416E-435A-A3CF-0376B7BB5B01@pillartechnology.com> Message-ID: On Sun, Jun 13, 2010 at 4:19 AM, Nilanjan Raychaudhuri < nraychaudhuri@REDACTED> wrote: > Hi all, > > As a newbie into functional programming I am curious to know how functional > programming style fits into building web applications? And how it > compares to building web apps in Ruby or Java. > > Any pointer to article/literature will be helpful. > > Thanks > Nilanjan In general, subjects in Functional Programming may be: * Value is function, and anything is value. * Immutable value. * Lazy evaluation strategy, and what about that when some but not all arguments are given to a function you get another function. (I forgot terms about the later one.) * Higher order function. * Pure function, or imperative, with side-effect. How does it fit Web Programming? In my opinion, 1. Anything is value, yes, some techniques and paradigm of Web Programming such as that about XML technologies follow this style. XSLT can be written FUNctionally. Parts of web technology are not Software Engineering any more but Data Engineering. 2. Immutable value means that program runs without depending on state. Microsoft .Net Framework tried making the stateless Web environment stateful. In functional programming, when you send a different request, the program generates another set of values instead of making a response with a modified state. 3. Partial application of function arguments is powerful than other programming styles. Consider a web form as a function that it accepted some of it arguments and `became' another function, that is, another web form or the original form holding some arguments and waiting for other arguments. 4. High order function plays role of glue. Web Programming is performed in parallel; you and your colleagues write each's programs, and you put those together, and those works as a whole. High-order function do somethings similarly: Functions may be glued by some function, and those work as a whole while each can be run separately for the debugging purpose. You post the question in Erlang mailing-list. About Erlang, its Concurreny-Oriented Programming style is more feasible for Web Programming and more discussible than functional programming features. Best Regards, Y.-H. H. From tony.arcieri@REDACTED Mon Jun 14 18:47:34 2010 From: tony.arcieri@REDACTED (Tony Arcieri) Date: Mon, 14 Jun 2010 10:47:34 -0600 Subject: [erlang-questions] Similarities between web programming and functional programming In-Reply-To: References: <2C042DAC-416E-435A-A3CF-0376B7BB5B01@pillartechnology.com> Message-ID: On Sat, Jun 12, 2010 at 2:37 PM, Jesper Louis Andersen < jesper.louis.andersen@REDACTED> wrote: > Look at the following function: > > handle(Request) -> > X = ..., > Template = ..., > render_response(?HTTP_OK, X, Template). > > It has the specification contract > -spec handle(request()) -> response(). > > That is, handling incoming web requests are (sometimes pure) functions > from request() objects to response() objects. At this point, we are > essentially done. There isn't much more to it. The problem with this approach is you must construct the entire response before you can even begin sending it back to the client. This is especially problematic with things like the document section which contain directives to fetch additional assets from the server (e.g. stylesheets, javascripts) A better approach is to stream the response back to the client as it's generated. -- Tony Arcieri Medioh! A Kudelski Brand From info@REDACTED Mon Jun 14 19:10:40 2010 From: info@REDACTED (info) Date: Mon, 14 Jun 2010 19:10:40 +0200 Subject: how to handle a complex timer process ? Message-ID: <201006141910379374317@its3.ch> Hi all, I want to manage a timer with several actions. - creation: creation of the timer process with "Period" as parameter. The timer shall be in suspend state. - start: the timer is started. - restart: the timer restarts with the Period. - stop: the timer is stopped. The timer shall be in wait state. A start starts the timer. - kill: the timer process is killed. - after the timeout, a message is sent to another process. The timer shall be in suspend state. For the creation, I do: Pid = spawn (fun,?MODULE,the_timer,[Period]), and after I manage like this: Pid ! {start} Pid ! {stop} Pid ! {restart} Pid ! {kill} The structure of the timer is like this: the_timer(Period)-> receive {start}-> ??? {restart}-> the_timer(Period); {stop}-> ??? {kill}-> ??? after Period -> Pid0 -> {one_message}, ??? end. How to handle the state ? how to keep the time after a stop and to start again with this time ? how to kill the process ? How to start the timer only if a start message is received ? From chad@REDACTED Mon Jun 14 20:15:56 2010 From: chad@REDACTED (Chad DePue) Date: Mon, 14 Jun 2010 15:15:56 -0300 Subject: [erlang-questions] how to handle a complex timer process ? In-Reply-To: <201006141910379374317@its3.ch> References: <201006141910379374317@its3.ch> Message-ID: I'd use a gen_fsm for this, then you can handle the timeout message in each state and transition appropriately. Chad DePue skype: cdepue inakanetworks.com - Erlang consulting rubyrescue.com - Ruby on Rails consulting On Mon, Jun 14, 2010 at 2:10 PM, info wrote: > Hi all, > I want to manage a timer with several actions. > - creation: creation of the timer process with "Period" as parameter. The > timer shall be in suspend state. > - start: the timer is started. > - restart: the timer restarts with the Period. > - stop: the timer is stopped. The timer shall be in wait state. A start > starts the timer. > - kill: the timer process is killed. > - after the timeout, a message is sent to another process. The timer shall > be in suspend state. > > For the creation, I do: > Pid = spawn (fun,?MODULE,the_timer,[Period]), > and after I manage like this: > Pid ! {start} > Pid ! {stop} > Pid ! {restart} > Pid ! {kill} > > The structure of the timer is like this: > > the_timer(Period)-> > receive > {start}-> ??? > {restart}-> > the_timer(Period); > {stop}-> ??? > {kill}-> ??? > after Period -> > Pid0 -> {one_message}, > ??? > end. > > How to handle the state ? how to keep the time after a stop and to start > again with this time ? how to kill the process ? > How to start the timer only if a start message is received ? > From kaiduanx@REDACTED Mon Jun 14 20:17:07 2010 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Mon, 14 Jun 2010 14:17:07 -0400 Subject: [erlang-questions] how to handle a complex timer process ? In-Reply-To: <201006141910379374317@its3.ch> References: <201006141910379374317@its3.ch> Message-ID: Info, Erlang has already provided timer management, please check, erlang:start_timer/erlang:cancel_timer http://www.erlang.org/doc/man/erlang.html#start_timer-3 If you need a timer in gen_fsm, you can use gen_fsm:start_timer. Kaiduan On Mon, Jun 14, 2010 at 1:10 PM, info wrote: > Hi all, > I want to manage a timer with several actions. > - creation: creation of the timer process with "Period" as parameter. The timer shall be in suspend state. > - start: the timer is started. > - restart: the timer restarts with the Period. > - stop: the timer is stopped. The timer shall be in wait state. A start starts the timer. > - kill: the timer process is killed. > - after the timeout, a message is sent to another process. The timer shall be in suspend state. > > For the creation, I do: > Pid = spawn (fun,?MODULE,the_timer,[Period]), > and after I manage like this: > Pid ! {start} > Pid ! {stop} > Pid ! {restart} > Pid ! {kill} > > The structure of the timer is like this: > > the_timer(Period)-> > ? ?receive > ? ? ? ?{start}-> ??? > ? ? ? ?{restart}-> > ? ? ? ? ? ?the_timer(Period); > ? ? ? ?{stop}-> ??? > ? ? ? ?{kill}-> ??? > ? ?after Period -> > ? ? ? ?Pid0 -> {one_message}, > ? ? ? ???? > ? ?end. > > How to handle the state ? how to keep the time after a stop and to start again with this time ? how to kill the process ? > How to start the timer only if a start message is received ? > From g9414002.pccu.edu.tw@REDACTED Mon Jun 14 20:31:27 2010 From: g9414002.pccu.edu.tw@REDACTED (=?UTF-8?B?6buD6ICA6LOiIChZYXUtSHNpZW4gSHVhbmcp?=) Date: Tue, 15 Jun 2010 02:31:27 +0800 Subject: [erlang-questions] how to handle a complex timer process ? In-Reply-To: <201006141910379374317@its3.ch> References: <201006141910379374317@its3.ch> Message-ID: On Tue, Jun 15, 2010 at 1:10 AM, info wrote: > The structure of the timer is like this: > > the_timer(Period)-> > receive > {start}-> ??? > {restart}-> > the_timer(Period); > {stop}-> ??? > {kill}-> ??? > after Period -> > Pid0 -> {one_message}, > ??? > end. > > How to handle the state ? how to keep the time after a stop and to start > again with this time ? how to kill the process ? > How to start the timer only if a start message is received ? > Do not think about how to keep all the state. Think simple things. Part of my solution is: the_timer(Period, N) -> receive start -> receive restart -> .................... stop -> the_timer(Period, N) after 1000 -> io:format("~w~n", [N]), .......... ! start, the_timer(Period, .............) end; kill -> ok after Period -> io:format("I\'m waiting ...~n"), ........................ end. From anthonym@REDACTED Mon Jun 14 20:52:59 2010 From: anthonym@REDACTED (Anthony Molinaro) Date: Mon, 14 Jun 2010 11:52:59 -0700 Subject: Improving performance on a thrift to protobuf proxy Message-ID: <20100614185259.GA4934@alumni.caltech.edu> Hi, I have a thrift server (using the generated thrift server from the thrift distribution) which contains a single method. The method takes two thrift objects (a context, and a list of places to call). The thrift method handler spawns a process for each place to call. Each of those processes, takes the context, combines it with some meta info particular to the place to call, and serializes the request as a protobuf. It then makes an http call using httpc with a timeout, and calls the place to call passing the protobuf as the body of an HTTP GET request. For each incoming request I end up with 6-10 outgoing requests. Right now the server runs pretty well, but it seems to use a lot of CPU, also even though I set a pretty tight timeout on my httpc call (120 msecs), the server often doesn't respond within 200 msecs to the caller. I did a little bit of profiling in isolation (using eprof), but that didn't really show any low hanging fruit (however, I'm not entirely sure I used the right profiling). So I'm looking for pointers to help improve throughput and lower CPU usage. Specifically, - what is the best way to profile this sort of application? using tracing? fprof? eprof? on the live server or try to test in isolation (I profiled in isolation before, but as I said no real low hanging fruit). - is httpc the ideal http client? are there better http client libraries? should I roll my own using event driven non-blocking techniques? does the timeout in httpc really work, or should I do something with a timer? - this is really just sort of a glorified web crawler, has anyone out there written a crawler and have pointers? Any other hints or tips would be greatly appreciated. Thanks, -Anthony -- ------------------------------------------------------------------------ Anthony Molinaro From info@REDACTED Mon Jun 14 23:23:27 2010 From: info@REDACTED (info) Date: Mon, 14 Jun 2010 23:23:27 +0200 Subject: [erlang-questions] how to handle a complex timer process ? References: <201006141910379374317@its3.ch>, Message-ID: <201006142323256920472@its3.ch> Could you show us a skeleton with gen_fsm ? Rgds, John I'd use a gen_fsm for this, then you can handle the timeout message in each state and transition appropriately. Chad DePue skype: cdepue inakanetworks.com - Erlang consulting rubyrescue.com - Ruby on Rails consulting On Mon, Jun 14, 2010 at 2:10 PM, info wrote: Hi all, I want to manage a timer with several actions. - creation: creation of the timer process with "Period" as parameter. The timer shall be in suspend state. - start: the timer is started. - restart: the timer restarts with the Period. - stop: the timer is stopped. The timer shall be in wait state. A start starts the timer. - kill: the timer process is killed. - after the timeout, a message is sent to another process. The timer shall be in suspend state. For the creation, I do: Pid = spawn (fun,?MODULE,the_timer,[Period]), and after I manage like this: Pid ! {start} Pid ! {stop} Pid ! {restart} Pid ! {kill} The structure of the timer is like this: the_timer(Period)-> receive {start}-> ??? {restart}-> the_timer(Period); {stop}-> ??? {kill}-> ??? after Period -> Pid0 -> {one_message}, ??? end. How to handle the state ? how to keep the time after a stop and to start again with this time ? how to kill the process ? How to start the timer only if a start message is received ? From jesper.louis.andersen@REDACTED Mon Jun 14 23:33:47 2010 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Mon, 14 Jun 2010 23:33:47 +0200 Subject: [erlang-questions] Accounting Engine in Erlang In-Reply-To: References: Message-ID: On Mon, Jun 14, 2010 at 5:08 PM, amiruddin nagri wrote: > Is the issue of consistency not solvable using erlang, or if we > implement consistency using erlang we won't be able use the > performance and scaling feature of erlang to maximum. Consistency is certainly to be had while getting good performance and scaling at the same time. How you realize it is up to you however. You should expect to spend some time in the optimization department if you want the application to scale. Perhaps the kool-aid says otherwise, but in reality you can't circumvent spending a little bit of time with the profiler and plan ahead. > Also, if you have any suggestions of the choice of programming > language, we have been looking into other functional languages like > Haskell and Clojure. But we have not dig deep on the performance > aspects of these languages, if someone can shed a light on the pros- > cons of these languages, it will help us very much to come to a > decision. I can only speak for Erlang vs. Haskell. The shameless plug is: http://jlouisramblings.blogspot.com/2010/04/haskell-vs-erlang-for-bittorent-clients.html In Haskell, the perhaps biggest problem will be laziness. For a long-running daemon process it is very easy to end up with a space-leak due to unevaluated lazy thunks. You will have to constantly look at heap profiles to be sure you are not reintroducing a leak when making changes. Expect to spend some time learning how to strictness annotate your programs if you choose Haskell. On the other hand, Haskell's type system will eradicate most bugs early on if your exploit the type system rather than seeing it as a straitjacket. Nothing, save Agda, Epigram or Coq, have a more powerful type system out there. And you can expect a compiler like GHC to produce fairly fast code (provided you know what you are doing). Bottom line of etorrent vs. Combinatorrent is that I have spent far less time optimizing etorrent compared to combinatorrent. But they perform around the same in CPU usage. The Erlang client use more memory, but only a constant factor of some 2-3 times, which is far from alarming (we are still beating the python/C(++) and java clients :). But it took some time with Erlang before I figured out the tradeoffs between mnesia, ETS tables and keeping a large process heap with a dict/gb_tree etc. I have come to call this knowledge the "performance profile" of a language. And, not too surprisingly, it turns out that these are very different from language to language (and implementation to implementation). You should expect to spend some time with a new language before you get the performance profile under your skin. Finally, you should not put too much into synthetic benchmarks. Anil Madhavapeddy (http://http://anil.recoil.org/) found, in his Phd thesis, that writing an SSH client in Ocaml made it much faster than the C client. Yet, C beats Ocaml on most synthetic benchmarks. The argument carries over to, say, Erlang: You can expect your program to reach correctness faster and can thus spend more time on boosting raw performance of the program. There is another important property of Erlang: inspection. For a running Erlang program you can dynamically probe, inspect and trace its operation. In real life, this is a very powerful tool in the toolbox. Numerous times, I have been able to figure out and fix trouble by inspecting the running application. I'm happy to pay quite much raw performance on the prayer altar in order to have this ability. And then there is distribution over multiple nodes, where Erlang is basically running circles around anything else I have seen..., -- J. From gershon.bialer@REDACTED Mon Jun 14 23:54:27 2010 From: gershon.bialer@REDACTED (gershon bialer) Date: Mon, 14 Jun 2010 16:54:27 -0500 Subject: Using supervisor:start_child without an id Message-ID: Hi, As I understand it, OTP supervisors require an id for every process supervised. Since: child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules}. However, I don't want to create an Id everytime, I add a process. Is there anyway to add child processes to a supervisor, without creating a new id? -- Gershon Bialer From jesper.louis.andersen@REDACTED Mon Jun 14 23:56:42 2010 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Mon, 14 Jun 2010 23:56:42 +0200 Subject: [erlang-questions] Using supervisor:start_child without an id In-Reply-To: References: Message-ID: On Mon, Jun 14, 2010 at 11:54 PM, gershon bialer wrote: > As I understand it, OTP supervisors require an id for every process > supervised. Since: > > child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules}. > > However, I don't want to create an Id everytime, I add a process. Is > there anyway to add child processes to a supervisor, without creating > a new id? simple_one_for_one supervisors might be what you want. Read their documentation carefully as they are a tad different from normal id-given supervised processes. -- J. From per@REDACTED Tue Jun 15 00:51:50 2010 From: per@REDACTED (Per Hedeland) Date: Tue, 15 Jun 2010 00:51:50 +0200 (CEST) Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <20100614140121.GA15603@erix.ericsson.se> Message-ID: <201006142251.o5EMpowF095180@pluto.hedeland.org> Raimo Niskanen wrote: > >gen_udp:connect/3 calls > > int connect(int socket, const struct sockaddr *address, > socklen_t address_len); > >on the socket. Excerpt from man connect: > > If the initiating socket is not connection-mode, then connect() > shall set the socket's peer address, and no connection is made. For > SOCK_DGRAM sockets, the peer address identifies where all datagrams > are sent on subsequent send() functions, and limits the remote > sender for subsequent recv() functions. If address is a null address > for the protocol, the socket's peer address shall be reset. > >i.e default destination is set and reception is limited. I think >it is receiving from only the inteded DNS server that is the purpose. Hm, in general the purpose of calling connect() for a UDP socket is this: 1> {ok,S}=gen_udp:open(0). {ok,#Port<0.427>} 2> gen_udp:send(S,"127.0.0.1",12345,<<>>). ok 3> flush(). ok 4> gen_udp:connect(S,"127.0.0.1",12345). ok 5> gen_udp:send(S,"127.0.0.1",12345,<<>>). ok 6> flush(). Shell got {udp_error,#Port<0.427>,econnrefused} ok I.e. if you send to a port that doesn't have a listener (on a host that is running), you get an "immediate" "reply" instead of having to time out waiting for a *real* reply that never arrives (to get into the gory details, the kernel can match the ICMP Port Unreachable message to your socket because it is connected, and delivers it as an error when you try to receive from the socket). However this does not seem to work in passive mode with gen_udp (recv/3 always blocks until Timeout), and since that is what inet_res uses, the purpose of the connect() is unclear. Responses from the wrong IP/Port are thrown away though, and enetunreach/econnrefused errors are handled, so I would guess that at some point this worked for passive mode too (or maybe it was just assumed to work:-) and *is* the purpose. If gen_udp:connect/3 was documented, I think the non-working-as-above in passive mode should be considered a bug... --Per Hedeland From kaiduanx@REDACTED Tue Jun 15 01:20:25 2010 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Mon, 14 Jun 2010 19:20:25 -0400 Subject: [erlang-questions] how to handle a complex timer process ? In-Reply-To: <201006142323256920472@its3.ch> References: <201006141910379374317@its3.ch> <201006142323256920472@its3.ch> Message-ID: John, Please see attached file from an Erlang SIP proxy. The state machine itself is described in the comments. Kaiduan On Mon, Jun 14, 2010 at 5:23 PM, info wrote: > Could you show us a skeleton with gen_fsm ? > Rgds, > John > > I'd use a gen_fsm for this, then you can handle the timeout message in each state and transition appropriately. > > Chad DePue > skype: cdepue > inakanetworks.com - Erlang consulting > rubyrescue.com - Ruby on Rails consulting > > > > > On Mon, Jun 14, 2010 at 2:10 PM, info wrote: > > Hi all, > I want to manage a timer with several actions. > - creation: creation of the timer process with "Period" as parameter. The timer shall be in suspend state. > - start: the timer is started. > - restart: the timer restarts with the Period. > - stop: the timer is stopped. The timer shall be in wait state. A start starts the timer. > - kill: the timer process is killed. > - after the timeout, a message is sent to another process. The timer shall be in suspend state. > > For the creation, I do: > Pid = spawn (fun,?MODULE,the_timer,[Period]), > and after I manage like this: > Pid ! {start} > Pid ! {stop} > Pid ! {restart} > Pid ! {kill} > > The structure of the timer is like this: > > the_timer(Period)-> > ? receive > ? ? ? {start}-> ??? > ? ? ? {restart}-> > ? ? ? ? ? the_timer(Period); > ? ? ? {stop}-> ??? > ? ? ? {kill}-> ??? > ? after Period -> > ? ? ? Pid0 -> {one_message}, > ? ? ? ??? > ? end. > > How to handle the state ? how to keep the time after a stop and to start again with this time ? how to kill the process ? > How to start the timer only if a start message is received ? > -------------- next part -------------- A non-text attachment was scrubbed... Name: erlsip_inv_client_tran.erl Type: text/x-erlang Size: 10968 bytes Desc: not available URL: From ok@REDACTED Tue Jun 15 03:12:04 2010 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 15 Jun 2010 13:12:04 +1200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <19474.33021.717233.152228@pilspetsen.it.uu.se> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> <20100604062538.GB11662@erix.ericsson.se> <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> <20100609134023.GA18679@erix.ericsson.se> <191C55E9-5770-4176-A956-C1DD8FBAB6C1@cs.otago.ac.nz> <19474.33021.717233.152228@pilspetsen.it.uu.se> Message-ID: <7578F2A1-9B6F-4B3E-9BA9-F9BF498B134F@cs.otago.ac.nz> On Jun 12, 2010, at 6:31 AM, Mikael Pettersson wrote: > Richard O'Keefe writes: >> Why? Suppose we have a module >> >> -module(foo). >> -export([bar/1]). >> bar(N) when N > 0 -> ?MODULE:bar(N-1); >> bar(0) -> 'DONG!'. >> >> In what sense is the call to ?MODULE:bar/1 a call to some *other* >> function than the bar/1 here before us? > > Because in Erlang a call with both module and function names > supplied is a "remote" call, which always invokes the latest > version of the module whose name was given. No, the fact that a call is a remote call does NOT make it a call to a function OTHER THAN THE FUNCTION IT CALLS. In this example, the function that is called is foo:bar/1. > So if a process P > is executing code in version 1 of the module, a newer version > 2 of the module is loaded, and P calls ?MODULE:F(...), then > that call invokes F in version 2 of the module, not version 1. As the Spartans once put it, "if". If the module is *NOT* reloaded, which is, let's face it, *almost all the time*, then there is no intelligible criterion by which it could be called "some *other* function". Even if the module is reloaded, that is not SOME OTHER FUNCTION. It is still foo:bar/1. When you talk about a newer version of module 'foo', you call it a newer version, not ANOTHER module. But when you talk about a newer version of foo:bar/1, suddenly it's an *other* function. Let's be consistent in the way we talk about things. From cowboymathu@REDACTED Tue Jun 15 08:12:04 2010 From: cowboymathu@REDACTED (Mathuvathanan Mounasamy) Date: Tue, 15 Jun 2010 11:42:04 +0530 Subject: Bypassing the expression parser Message-ID: Hi All, I read this in this link http://ulf.wiger.net/weblog/2007/11/21/extending-the-erlang-shell-part-2 > The Erlang shell fetches Erlang expressions from the line editor by calling > io:parse_erl_exprs(Prompt). The first thing we need to do is to change > this, so that we get a lower-level representation. Luckily, > io:scan_erl_exprs(Prompt) exists. It allows us to preempt the expression > parser, and potentially do something different. > > I chose to use the ?@? character to break out of the expression parser. For > one thing, it stands out, and clearly doesn?t belong to any Erlang > expression. The token scanner expects a full stop to follow, so the shortest > example of this new mode would be: > > > 1> @. > lists:reverse([1,2,3]). > @ > [3,2,1] > 2> > > When a line starting with ?@? is detected, the user is given an empty line, > for further input. Data is then collected until we enter another ?@? on an > empty line. > > By default, we?re still parsing expressions, and the shell will treat this > just as it would treat a normal multi-line shell command. > > So far, we haven?t gained much, except perhaps freedom from the repeating > prompt. We can still use e.g. v(1) and e(1) to fetch the value of this > command, or to repeat it. > --- But I couldn't understand and achieve this. Can someone please explain how to do this? Thanks, -- Mathuvathanan Mou. From michael.eugene.turner@REDACTED Tue Jun 15 08:19:43 2010 From: michael.eugene.turner@REDACTED (Michael Turner) Date: Tue, 15 Jun 2010 15:19:43 +0900 Subject: A future for gs? Message-ID: I started writing a little diagram editor in gs, but have just run aground on a limitation: there doesn't seem to be any way to track where you are in a canvas when you're scrolling around in one. The scrollbars work, the canvas objects updates canvas object positions appropriately, but it seems I can't find out what part of the canvas I've scrolled *to*. Without that, I can't convert window coordinates to canvas coordinates and back again. I can't even get scrollbar interaction events. I started looking at the gs source and found that there's an API-exposed but undocumented "scrollbar". And you can ask to have a scrollbar created, returning successfully. But you can't do anything with it. You can't even see it. I've also found some code for some dialog boxes, useful (if ugly) for alerts, file selection, etc. The comments describe this module as "internal", but nothing in the gs source directory actually refers to them. They are clearly not ready for prime-time (and so "widgety" that Steve Jobs would vomit). But they do work (sort of.) This package looks like it was dropped mid-stride, even though it seems to have started off in a reasonable direction: wrapping Tcl/Tk. Regretfully, I'm starting to look at wx again, but I find it only reminds me far too much of what I disliked about GUI programming in C++. If you already know the wxWidgets API from some other language, the very similar Erlang bindings might seem like a Godsend. But if you just want to get a GUI up and out of the way (my goal), and you don't have that wdWidgets background, it all just seems verbose, over-parameterized, encyclopedically overwhelming. (IMAO, anyway -- I've done Mac programming, Windows programming, and hated every minute of GUI programming on both.) Is there a future for gs? I've gotten the impression that the sun is setting on Tcl/Tk. Maybe gs will follow it? -michael turner From mikpe@REDACTED Tue Jun 15 09:17:18 2010 From: mikpe@REDACTED (Mikael Pettersson) Date: Tue, 15 Jun 2010 09:17:18 +0200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <7578F2A1-9B6F-4B3E-9BA9-F9BF498B134F@cs.otago.ac.nz> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> <20100604062538.GB11662@erix.ericsson.se> <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> <20100609134023.GA18679@erix.ericsson.se> <191C55E9-5770-4176-A956-C1DD8FBAB6C1@cs.otago.ac.nz> <19474.33021.717233.152228@pilspetsen.it.uu.se> <7578F2A1-9B6F-4B3E-9BA9-F9BF498B134F@cs.otago.ac.nz> Message-ID: <19479.10494.716106.717703@pilspetsen.it.uu.se> Richard O'Keefe writes: > > On Jun 12, 2010, at 6:31 AM, Mikael Pettersson wrote: > > > Richard O'Keefe writes: > >> Why? Suppose we have a module > >> > >> -module(foo). > >> -export([bar/1]). > >> bar(N) when N > 0 -> ?MODULE:bar(N-1); > >> bar(0) -> 'DONG!'. > >> > >> In what sense is the call to ?MODULE:bar/1 a call to some *other* > >> function than the bar/1 here before us? > > > > Because in Erlang a call with both module and function names > > supplied is a "remote" call, which always invokes the latest > > version of the module whose name was given. > > No, the fact that a call is a remote call does NOT make it a > call to a function OTHER THAN THE FUNCTION IT CALLS. Er, that's obvious. > In this example, the function that is called is foo:bar/1. Yes. But foo:bar/1 is not necessarily the same code as the "bar/1 here before us". > > So if a process P > > is executing code in version 1 of the module, a newer version > > 2 of the module is loaded, and P calls ?MODULE:F(...), then > > that call invokes F in version 2 of the module, not version 1. > > As the Spartans once put it, "if". > > If the module is *NOT* reloaded, which is, let's face it, > *almost all the time*, then there is no intelligible criterion > by which it could be called "some *other* function". > > Even if the module is reloaded, that is not SOME OTHER FUNCTION. > It is still foo:bar/1. Only the name/arity remains known. You can make no assumptions about its behaviour, unless you known exactly ahead of time that the replacement module is designed to do so. Scheme has the same issue, since global functions are simply variables bound to function closures, and it allows those bindings to be altered with set!. > When you talk about a newer version of module 'foo', > you call it a newer version, not ANOTHER module. > But when you talk about a newer version of foo:bar/1, > suddenly it's an *other* function. > > Let's be consistent in the way we talk about things. "new version" is for all intents and purposes "new/other code". The Erlang language and its implementation places no(*) requirements on newer versions of modules being compatible with older ones. (Of course there are guidelines / design patterns that do so for the sake of safe live updates, but that's not the issue here.) (*) Maybe the newfangled type specs stuff could be considered to add some such requirements, but even then you can't pretend to know for a fact what code a remote call will invoke. From kenneth.lundin@REDACTED Tue Jun 15 09:18:24 2010 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 15 Jun 2010 09:18:24 +0200 Subject: [erlang-questions] A future for gs? In-Reply-To: References: Message-ID: Hi, gs will not be further developed. We recommend the use of wx. If you like the gs type of API it could probably be built on top of wx. The problem with GS is that as soon as you want to do something serious you end up in bypassing the limited gs API and going directly towards tcl/tk. /Kenneth, Erlang/OTP Ericsson On Tue, Jun 15, 2010 at 8:19 AM, Michael Turner wrote: > I started writing a little diagram editor in gs, but have just run aground > on a limitation: there doesn't seem to be any way to track where you are in > a canvas when you're scrolling around in one. ?The scrollbars work, the > canvas objects updates canvas object positions appropriately, but it seems I > can't find out what part of the canvas I've scrolled *to*. ?Without that, I > can't convert window coordinates to canvas coordinates and back again. > > I can't even get scrollbar interaction events. ?I started looking at the gs > source and found that there's an API-exposed but undocumented "scrollbar". > ?And you can ask to have a scrollbar created, returning successfully. ?But > you can't do anything with it. ?You can't even see it. > > I've also found some code for some dialog boxes, useful (if ugly) for > alerts, file selection, etc. ?The comments describe this module as > "internal", but nothing in the gs source directory actually refers to them. > ?They are clearly not ready for prime-time (and so "widgety" that Steve Jobs > would vomit). ?But they do work (sort of.) > > This package looks like it was dropped mid-stride, even though it seems to > have started off in a reasonable direction: wrapping Tcl/Tk. > > Regretfully, I'm starting to look at wx again, but I find it only reminds me > far too much of what I disliked about GUI programming in C++. ?If you > already know the wxWidgets API from some other language, the very similar > Erlang bindings might seem like a Godsend. ?But if you just want to get a > GUI up and out of the way (my goal), and you don't have that wdWidgets > background, it all just seems verbose, over-parameterized, encyclopedically > overwhelming. ?(IMAO, anyway -- I've done Mac programming, Windows > programming, and hated every minute of GUI programming on both.) > > Is there a future for gs? ?I've gotten the impression that the sun is > setting on Tcl/Tk. ?Maybe gs will follow it? > > -michael turner > From raimo+erlang-questions@REDACTED Tue Jun 15 09:37:05 2010 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Tue, 15 Jun 2010 09:37:05 +0200 Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <201006142251.o5EMpowF095180@pluto.hedeland.org> References: <20100614140121.GA15603@erix.ericsson.se> <201006142251.o5EMpowF095180@pluto.hedeland.org> Message-ID: <20100615073705.GA32705@erix.ericsson.se> On Tue, Jun 15, 2010 at 12:51:50AM +0200, Per Hedeland wrote: > Raimo Niskanen wrote: > > > >gen_udp:connect/3 calls > > > > int connect(int socket, const struct sockaddr *address, > > socklen_t address_len); > > > >on the socket. Excerpt from man connect: > > > > If the initiating socket is not connection-mode, then connect() > > shall set the socket's peer address, and no connection is made. For > > SOCK_DGRAM sockets, the peer address identifies where all datagrams > > are sent on subsequent send() functions, and limits the remote > > sender for subsequent recv() functions. If address is a null address > > for the protocol, the socket's peer address shall be reset. > > > >i.e default destination is set and reception is limited. I think > >it is receiving from only the inteded DNS server that is the purpose. > > Hm, in general the purpose of calling connect() for a UDP socket is > this: > > 1> {ok,S}=gen_udp:open(0). > {ok,#Port<0.427>} > 2> gen_udp:send(S,"127.0.0.1",12345,<<>>). > ok > 3> flush(). > ok > 4> gen_udp:connect(S,"127.0.0.1",12345). > ok > 5> gen_udp:send(S,"127.0.0.1",12345,<<>>). > ok > 6> flush(). > Shell got {udp_error,#Port<0.427>,econnrefused} > ok > > I.e. if you send to a port that doesn't have a listener (on a host that > is running), you get an "immediate" "reply" instead of having to time > out waiting for a *real* reply that never arrives (to get into the gory > details, the kernel can match the ICMP Port Unreachable message to your > socket because it is connected, and delivers it as an error when you try > to receive from the socket). > > However this does not seem to work in passive mode with gen_udp (recv/3 > always blocks until Timeout), and since that is what inet_res uses, the > purpose of the connect() is unclear. Responses from the wrong IP/Port > are thrown away though, and enetunreach/econnrefused errors are handled, > so I would guess that at some point this worked for passive mode too (or > maybe it was just assumed to work:-) and *is* the purpose. Even more probable. > > If gen_udp:connect/3 was documented, I think the non-working-as-above in > passive mode should be considered a bug... We could consider both the non-documentation and the non-working to be bugs... Thank you for the education! > > --Per Hedeland -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From maruthavanan_s@REDACTED Tue Jun 15 09:39:25 2010 From: maruthavanan_s@REDACTED (maruthavanan s) Date: Tue, 15 Jun 2010 03:39:25 -0400 Subject: HTTP post file to URL Message-ID: Hi, Is there any way in httpc module where I can post a file to the URL similar to the curl -f option? Thanks, Marutha From tony@REDACTED Tue Jun 15 09:48:27 2010 From: tony@REDACTED (Tony Rogvall) Date: Tue, 15 Jun 2010 09:48:27 +0200 Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <201006142251.o5EMpowF095180@pluto.hedeland.org> References: <201006142251.o5EMpowF095180@pluto.hedeland.org> Message-ID: <1B3CF176-172C-4C1F-B3E1-0793E7BC99B9@rogvall.se> On 15 jun 2010, at 00.51, Per Hedeland wrote: > {ok,U} = gen_udp:open(0). {ok,#Port<0.682>} > inet:setopts(U, [{active, false}]). ok > gen_udp:connect(U, "127.0.0.1", 12345). ok > gen_udp:send(U, <<1,2,3>>). ok > gen_udp:recv(U, 0, 1000). {error,econnrefused} <================== > gen_udp:recv(U, 0, 1000). {error,timeout} Working? Maybe you missed the first recv? Maybe I am missing something? /Tony > Raimo Niskanen wrote: >> >> gen_udp:connect/3 calls >> >> int connect(int socket, const struct sockaddr *address, >> socklen_t address_len); >> >> on the socket. Excerpt from man connect: >> >> If the initiating socket is not connection-mode, then connect() >> shall set the socket's peer address, and no connection is made. For >> SOCK_DGRAM sockets, the peer address identifies where all datagrams >> are sent on subsequent send() functions, and limits the remote >> sender for subsequent recv() functions. If address is a null address >> for the protocol, the socket's peer address shall be reset. >> >> i.e default destination is set and reception is limited. I think >> it is receiving from only the inteded DNS server that is the purpose. > > Hm, in general the purpose of calling connect() for a UDP socket is > this: > > 1> {ok,S}=gen_udp:open(0). > {ok,#Port<0.427>} > 2> gen_udp:send(S,"127.0.0.1",12345,<<>>). > ok > 3> flush(). > ok > 4> gen_udp:connect(S,"127.0.0.1",12345). > ok > 5> gen_udp:send(S,"127.0.0.1",12345,<<>>). > ok > 6> flush(). > Shell got {udp_error,#Port<0.427>,econnrefused} > ok > > I.e. if you send to a port that doesn't have a listener (on a host that > is running), you get an "immediate" "reply" instead of having to time > out waiting for a *real* reply that never arrives (to get into the gory > details, the kernel can match the ICMP Port Unreachable message to your > socket because it is connected, and delivers it as an error when you try > to receive from the socket). > > However this does not seem to work in passive mode with gen_udp (recv/3 > always blocks until Timeout), and since that is what inet_res uses, the > purpose of the connect() is unclear. Responses from the wrong IP/Port > are thrown away though, and enetunreach/econnrefused errors are handled, > so I would guess that at some point this worked for passive mode too (or > maybe it was just assumed to work:-) and *is* the purpose. > > If gen_udp:connect/3 was documented, I think the non-working-as-above in > passive mode should be considered a bug... > > --Per Hedeland > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > From sedrik@REDACTED Tue Jun 15 10:08:28 2010 From: sedrik@REDACTED (Fredrik Andersson) Date: Tue, 15 Jun 2010 10:08:28 +0200 Subject: Enhancement proposal to edoc Message-ID: Hi fellow Erlang users I am currently in the process of joining a existing project and the current state of documentation of it is quite poor. I still figured that I would generate the edoc documentation for it and get a quick overview of the different modules available. Now I'm wondering if it would be possible to extend Erlang or edoc so that we can specify a class on different exports. This would enable the general Erlang templates to specify a callback class on the standard callback functions in OTP and make for an easier separation. Example %% API: API %this could be a general default -export([my_trixy_function_of_doom, ..]). %% API: callbacks -export([handle_info, handle_cast]). %% API: Internal callbacks -export([init]). I know that this will not solve my general problem with lack of documentation but since most people that write Erlang uses some standard template I figured that functionality that can be utilized to enhance a template is still usable on a poorly documented document. Thoughts? Comments? From raimo+erlang-questions@REDACTED Tue Jun 15 10:20:21 2010 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Tue, 15 Jun 2010 10:20:21 +0200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <7578F2A1-9B6F-4B3E-9BA9-F9BF498B134F@cs.otago.ac.nz> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> <20100604062538.GB11662@erix.ericsson.se> <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> <20100609134023.GA18679@erix.ericsson.se> <191C55E9-5770-4176-A956-C1DD8FBAB6C1@cs.otago.ac.nz> <19474.33021.717233.152228@pilspetsen.it.uu.se> <7578F2A1-9B6F-4B3E-9BA9-F9BF498B134F@cs.otago.ac.nz> Message-ID: <20100615082021.GA787@erix.ericsson.se> On Tue, Jun 15, 2010 at 01:12:04PM +1200, Richard O'Keefe wrote: > > On Jun 12, 2010, at 6:31 AM, Mikael Pettersson wrote: > > >Richard O'Keefe writes: > >>Why? Suppose we have a module > >> > >> -module(foo). > >> -export([bar/1]). > >> bar(N) when N > 0 -> ?MODULE:bar(N-1); > >> bar(0) -> 'DONG!'. > >> > >>In what sense is the call to ?MODULE:bar/1 a call to some *other* > >>function than the bar/1 here before us? > > > >Because in Erlang a call with both module and function names > >supplied is a "remote" call, which always invokes the latest > >version of the module whose name was given. > > No, the fact that a call is a remote call does NOT make it a > call to a function OTHER THAN THE FUNCTION IT CALLS. > > In this example, the function that is called is foo:bar/1. My original point, that I tried to point out with the phrasing "some other function", is that when the compiler sees a call to foo:bar/1, within the module foo and there is no exported function bar/1 in that module; it can not assume that the call to foo:bar/1 is in error nor that it is supposed to be a local call. It will become clear at runtime. It is of course probable that either the call should be to bar/1 or that bar/1 should be exported. But that is still speculation. Perhaps the call should be to an exported function foo:bor/1 or foe:bar/1. -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From ulf.wiger@REDACTED Tue Jun 15 10:31:02 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 15 Jun 2010 10:31:02 +0200 Subject: [erlang-questions] Bypassing the expression parser In-Reply-To: References: Message-ID: <4C173A46.4020305@erlang-solutions.com> Mathuvathanan Mounasamy wrote: > Hi All, > > I read this in this link > http://ulf.wiger.net/weblog/2007/11/21/extending-the-erlang-shell-part-2 > [...] > > But I couldn't understand and achieve this. Can someone please explain how > to do this? It required some patching. The patches are available through links in the blog article, but they have not been ported to the latest version of OTP. http://svn.ulf.wiger.net/ext_shell/ The changes should perhaps be re-written in a form more suitable for OTP patches, but in order to do that work, I would like to have some community feedback indicating that it would actually be worthwhile (in fact, as the code is available, you don't even have to wait for me to do it. ;-) BR, Ulf W -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From michael.eugene.turner@REDACTED Tue Jun 15 12:23:11 2010 From: michael.eugene.turner@REDACTED (Michael Turner) Date: Tue, 15 Jun 2010 19:23:11 +0900 Subject: R: [erlang-questions] A future for gs? In-Reply-To: References: Message-ID: "The problem with GS is that as soon as you want to do something serious you end up in bypassing the limited gs API and going directly towards tcl/tk." But that problem, in turn, is because there has been no further development of GS to expand the limited Erlang API, right? If so, then what I'm hearing here is a tautology: "There will be no further development because there will be no further development." There has to be more to this issue than that. What if there *was* further development of GS, to improve the API? Is the problem simply that nobody has volunteered to do this? Or is it that there's been some formal, official decision to not accept any improvements in future releases of Erlang/OTP? If it's the latter, where was this decision documented and what were the reasons given? And isn't it the very rock-bottom minimum of courtesy to point out clearly, at the very beginning of online documentation for a package, that official support for it has ceased? Had I known that, I might have bitten the wx bullet, in all its leaden toxicity. As it is, I might have just wasted about two weeks exploring an all-but-dead graphics API. Can someone at least tell me how, in Erlang, one goes "directly towards tcl/tk", if I'm interpreting that phrasing correctly? Meaning, I assume, that there's some part of the GS API that allows me to send Tcl commands and get responses back? Or if there is no such way, is there someone here who knows for a fact that there isn't? -michael turner On Tue, Jun 15, 2010 at 4:18 PM, Kenneth Lundin wrote: > Hi, > > gs will not be further developed. We recommend the use of wx. > If you like the gs type of API it could probably be built on top of wx. > The problem with GS is that as soon as you want to do something > serious you end up in > bypassing the limited gs API and going directly towards tcl/tk. > > /Kenneth, Erlang/OTP Ericsson > > On Tue, Jun 15, 2010 at 8:19 AM, Michael Turner > wrote: > > I started writing a little diagram editor in gs, but have just run > aground > > on a limitation: there doesn't seem to be any way to track where you are > in > > a canvas when you're scrolling around in one. The scrollbars work, the > > canvas objects updates canvas object positions appropriately, but it > seems I > > can't find out what part of the canvas I've scrolled *to*. Without that, > I > > can't convert window coordinates to canvas coordinates and back again. > > > > I can't even get scrollbar interaction events. I started looking at the > gs > > source and found that there's an API-exposed but undocumented > "scrollbar". > > And you can ask to have a scrollbar created, returning successfully. > But > > you can't do anything with it. You can't even see it. > > > > I've also found some code for some dialog boxes, useful (if ugly) for > > alerts, file selection, etc. The comments describe this module as > > "internal", but nothing in the gs source directory actually refers to > them. > > They are clearly not ready for prime-time (and so "widgety" that Steve > Jobs > > would vomit). But they do work (sort of.) > > > > This package looks like it was dropped mid-stride, even though it seems > to > > have started off in a reasonable direction: wrapping Tcl/Tk. > > > > Regretfully, I'm starting to look at wx again, but I find it only reminds > me > > far too much of what I disliked about GUI programming in C++. If you > > already know the wxWidgets API from some other language, the very similar > > Erlang bindings might seem like a Godsend. But if you just want to get a > > GUI up and out of the way (my goal), and you don't have that wdWidgets > > background, it all just seems verbose, over-parameterized, > encyclopedically > > overwhelming. (IMAO, anyway -- I've done Mac programming, Windows > > programming, and hated every minute of GUI programming on both.) > > > > Is there a future for gs? I've gotten the impression that the sun is > > setting on Tcl/Tk. Maybe gs will follow it? > > > > -michael turner > > > From dale@REDACTED Tue Jun 15 12:44:29 2010 From: dale@REDACTED (Dale Harvey) Date: Tue, 15 Jun 2010 11:44:29 +0100 Subject: [erlang-questions] Enhancement proposal to edoc In-Reply-To: References: Message-ID: Hey I just wanted to point out http://erldocs.com/ , in the next few days I will push some changes that make it much easier to build erldocs for your own project (as well as some fixes), I will also be keeping a version online that includes some of the more popular open source projects. http://github.com/daleharvey/erldocs.com Cheers Dale On 15 June 2010 09:08, Fredrik Andersson wrote: > Hi fellow Erlang users > > I am currently in the process of joining a existing project and the current > state of documentation of it is quite poor. I still figured that I would > generate the edoc documentation for it and get a quick overview of the > different > modules available. > > Now I'm wondering if it would be possible to extend Erlang or edoc so that > we > can specify a class on different exports. This would enable the general > Erlang > templates to specify a callback class on the standard callback functions in > OTP > and make for an easier separation. > > Example > > %% API: API %this could be a general default > -export([my_trixy_function_of_doom, ..]). > > %% API: callbacks > -export([handle_info, handle_cast]). > > %% API: Internal callbacks > -export([init]). > > I know that this will not solve my general problem with lack of > documentation > but since most people that write Erlang uses some standard template I > figured > that functionality that can be utilized to enhance a template is still > usable on > a poorly documented document. > > Thoughts? Comments? > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From clist@REDACTED Tue Jun 15 12:47:20 2010 From: clist@REDACTED (Angel Alvarez) Date: Tue, 15 Jun 2010 12:47:20 +0200 Subject: national characters in strings and UTF8 enviroments =?iso-8859-1?q?=BFno_problem_for?= anybody? Message-ID: <201006151247.20373.clist@uah.es> Hi again No one, has trouble with utf8 editors? What your best advices to work reliably in non english languages and utf8 systems?? Regards, Angel -- Este correo no tiene dibujos. Las formas extra?as en la pantalla son letras. __________________________________________ Clist UAH a.k.a Angel __________________________________________ Evitar la programaci?n defensiva. Manual de Erlang From connorsml@REDACTED Tue Jun 15 13:10:53 2010 From: connorsml@REDACTED (Michael Connors) Date: Tue, 15 Jun 2010 13:10:53 +0200 Subject: working with files from a database Message-ID: Hi, In Erlang, is there an equivalent to the Python library StringIO? I would like to store files in a database as byte arrays and then retrieve them and serve them as files again later. Thanks, Michael -- Michael Connors Alencon, France From ulf.wiger@REDACTED Tue Jun 15 13:35:22 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 15 Jun 2010 13:35:22 +0200 Subject: [erlang-questions] working with files from a database In-Reply-To: References: Message-ID: <4C17657A.3070300@erlang-solutions.com> Michael Connors wrote: > Hi, > > In Erlang, is there an equivalent to the Python library StringIO? I would > like to store files in a database as byte arrays and then retrieve them and > serve them as files again later. file:read_file(Filename) -> {ok, Binary} You can plop that binary into a mnesia table if you want. Depending on the file sizes, YMMV, of course, but for small files, no problem. As one of my more obscure* hacks in the 'rdbms' contrib, I used the 'external_copies' hack in mnesia (pretty much the stuff that http://code.google.com/p/mnesiaex/ uses for TokyoCabinet backend) to mount a file system directory as an ordered set mnesia table. http://jungerl.cvs.sourceforge.net/viewvc/jungerl/jungerl/lib/rdbms/src/rdbms_rofs.erl?revision=1.1&view=markup The idea was that you define a record with attributes reusing names from the #file_info{} record, or the attribute 'data', which would translate to the contents of the file. The key was the filename relative to the "mount point". After this, read access and selects would work as on any mnesia table, but writes were not allowed at all. * Note that this is not supported by anyone, not even me, and doesn't run on anything newer than OTP R12B. I just thought I'd mention it. BR, Ulf W -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From mazen.harake@REDACTED Tue Jun 15 13:53:16 2010 From: mazen.harake@REDACTED (Mazen Harake) Date: Tue, 15 Jun 2010 14:53:16 +0300 Subject: What License on code on erlang.org? Message-ID: <4C1769AC.3070608@erlang-solutions.com> Hi all, The the following address I can find a bunch of examples "written by Claes Wikstrom in 1998". The question is: What license do these examples fall under? URL: http://www.erlang.org/examples/klacke_examples/ Anyone who knows (Klacke e.g.)? /Mazen --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From bartlomiej@REDACTED Tue Jun 15 14:04:24 2010 From: bartlomiej@REDACTED (=?utf-8?Q?Bart=C5=82omiej_Puzo=C5=84?=) Date: Tue, 15 Jun 2010 12:04:24 +0000 (GMT) Subject: [erlang-questions] lists:seq/3 strange behaviour In-Reply-To: <1919862622.474291276603383194.JavaMail.root@zimbra> Message-ID: <1676893085.474311276603464098.JavaMail.root@zimbra> This behaviour is actually described in lists manual: "Failure: If ToFrom-Incr and Incr is negative, or if Incr==0 and From/=To." If you drop this assumptions, their algorithm for lists:seq (meant to be fast?) may not stop (according to the lists source code). ----- "Piotr Kaleta" escribi?: > What was the reason for lists:seq function to be implemented in a way > > that if you call: > > lists:seq(2, 1, 10) > > it works as expected returning an an empty list, while when beeing > called like: > > lists:seq(20, 1, 10) > > it throws an exception? > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED -- Bart?omiej Puzo? Erlang Solutions bartlomiej.puzon@REDACTED --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From mail@REDACTED Tue Jun 15 14:07:52 2010 From: mail@REDACTED (Tim Fletcher) Date: Tue, 15 Jun 2010 05:07:52 -0700 (PDT) Subject: HTTP post file to URL In-Reply-To: References: Message-ID: > Is there any way in httpc module where I can post a file to the URL similar to the curl -f option? Unless I'm mistaken, -f is the "fail silently" option, which I don't think you want. AFAIK you can stream a response *to* a file, but not stream a request body *from* a file, which leaves you with something like this: {ok, Data} = file:read_file(Path). httpc:request(post, {URL, Headers, ContentType, Data}, [], []). Is that what you're trying to do? Tim From info@REDACTED Tue Jun 15 19:08:13 2010 From: info@REDACTED (info) Date: Tue, 15 Jun 2010 19:08:13 +0200 Subject: start_timer or send_after ? Message-ID: <201006151908134163313@its3.ch> Hi All, What is the difference between start_timer/3 and send_after/3, their explanation is the same ? Rgds, John From info@REDACTED Tue Jun 15 19:10:10 2010 From: info@REDACTED (info) Date: Tue, 15 Jun 2010 19:10:10 +0200 Subject: processes by name Message-ID: <201006151910100075480@its3.ch> Hi All, An error report display processes as number. Is it possible to generate an error report with their names ? Rgds, John From ulf.wiger@REDACTED Tue Jun 15 19:20:57 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 15 Jun 2010 19:20:57 +0200 Subject: [erlang-questions] start_timer or send_after ? In-Reply-To: <201006151908134163313@its3.ch> References: <201006151908134163313@its3.ch> Message-ID: <4C17B679.4080908@erlang-solutions.com> info wrote: > Hi All, What is the difference between start_timer/3 and > send_after/3, their explanation is the same ? Start_timer/3 includes the reference in the timeout message, so that you can know for sure that the message pertains to _your_ timeout. BR, Ulf W -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From torben.lehoff@REDACTED Tue Jun 15 22:45:12 2010 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Tue, 15 Jun 2010 22:45:12 +0200 Subject: [erlang-questions] processes by name In-Reply-To: <201006151910100075480@its3.ch> References: <201006151910100075480@its3.ch> Message-ID: Hi John, To the best of my knowledge you cannot get an error report on processes to show their names, but if you create a process using one of the OTP components the error reports are a lot nicer. Or you could go the extra mile and create your own registion+monitor process which should keep track of the processes and their names, but I think that going the OTP route is better since you get so many things for almost free. I find it so nice that you can prototype quite easily even with OTP and since you are operating inside a framework you will most of the time be able to evolve your code gradually to production quality without having to throw away the prototype. Sorry for the a-side, but I just couldn't hold it back ;-) Cheers, Torben On Tue, Jun 15, 2010 at 19:10, info wrote: > Hi All, > An error report display processes as number. Is it possible to generate an > error report with their names ? > > Rgds, > John > -- http://www.linkedin.com/in/torbenhoffmann From ok@REDACTED Wed Jun 16 00:45:28 2010 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 16 Jun 2010 10:45:28 +1200 Subject: [erlang-questions] Overriding built-in functions in a module In-Reply-To: <19479.10494.716106.717703@pilspetsen.it.uu.se> References: <4821BB78-AC10-4961-A0A9-E19E800849BE@cs.otago.ac.nz> <20100604062538.GB11662@erix.ericsson.se> <10E7EA8B-2475-4AEB-A810-5496A1C68254@cs.otago.ac.nz> <20100609134023.GA18679@erix.ericsson.se> <191C55E9-5770-4176-A956-C1DD8FBAB6C1@cs.otago.ac.nz> <19474.33021.717233.152228@pilspetsen.it.uu.se> <7578F2A1-9B6F-4B3E-9BA9-F9BF498B134F@cs.otago.ac.nz> <19479.10494.716106.717703@pilspetsen.it.uu.se> Message-ID: On Jun 15, 2010, at 7:17 PM, Mikael Pettersson wrote: > Richard O'Keefe writes: >> No, the fact that a call is a remote call does NOT make it a >> call to a function OTHER THAN THE FUNCTION IT CALLS. > > Er, that's obvious. If it's that obvious, why have people been arguing against it? > >> In this example, the function that is called is foo:bar/1. > > Yes. But foo:bar/1 is not necessarily the same code as the > "bar/1 here before us". I have already answered that point, at length and repeatedly. It's the same *module* whether we reload it or not. It's the same *function* whether we reload it or not. It might (or might NOT) be a different version of the *code*, but that's another thing. Right now, in the code before is, there is a function definition, and a call which, if executed, would invoke *THAT* definition and not some other entirely imaginary definition. The claim that the compiler makes is a claim about the code as it stands, not about some non-existent flying spaghetti module. You could with equal logic justify the compiler warning on each and every remote call: 'Beware: this may destroy life on Earth.' Please, I do know what remote calls do in Erlang, and I do know about hot loading. Don't try to teach your grandfather to suck eggs. And don't bother with Scheme examples: I've even written a Scheme compiler. I know Scheme semantics too. Even in Scheme, a call to some-global is a call to (whatever is the current state of) some-global, not a call to some *other* function. From per@REDACTED Wed Jun 16 01:15:29 2010 From: per@REDACTED (Per Hedeland) Date: Wed, 16 Jun 2010 01:15:29 +0200 (CEST) Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <1B3CF176-172C-4C1F-B3E1-0793E7BC99B9@rogvall.se> Message-ID: <201006152315.o5FNFTNv025765@pluto.hedeland.org> Tony Rogvall wrote: > >> gen_udp:recv(U, 0, 1000). >{error,econnrefused} <================== > >> gen_udp:recv(U, 0, 1000). >{error,timeout} > > >Working? Seems so. >Maybe you missed the first recv? No. >Maybe I am missing something? Dunno - but it doesn't work for me: $ uname -msr FreeBSD 7.2-RELEASE i386 $ erl Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.2 (abort with ^G) 1> {ok,U} = gen_udp:open(0). {ok,#Port<0.427>} 2> inet:setopts(U, [{active, false}]). ok 3> gen_udp:connect(U, "127.0.0.1", 12345). ok 4> gen_udp:send(U, <<1,2,3>>). ok 5> gen_udp:recv(U, 0, 1000). {error,timeout} (after ~ 1 second) What version of OTP did you try on? What OS? --Per From ok@REDACTED Wed Jun 16 02:58:31 2010 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 16 Jun 2010 12:58:31 +1200 Subject: [erlang-questions] Enhancement proposal to edoc In-Reply-To: References: Message-ID: <4A85DEAA-B159-4F2C-850C-4A7929DA18E3@cs.otago.ac.nz> On Jun 15, 2010, at 8:08 PM, Fredrik Andersson wrote: > Hi fellow Erlang users > > I am currently in the process of joining a existing project and the > current > state of documentation of it is quite poor. I still figured that I > would > generate the edoc documentation for it and get a quick overview of > the different > modules available. > > Now I'm wondering if it would be possible to extend Erlang or edoc > so that we > can specify a class on different exports. This would enable the > general Erlang > templates to specify a callback class on the standard callback > functions in OTP > and make for an easier separation. EEP 5 describes a better way to do this. ( http://www.erlang.org/eeps/eep-0005.html ) May it come soon. The problem with putting the information in the documentation is that the documentation is not checked, so the code and the documentation may not agree. From tony@REDACTED Wed Jun 16 02:22:55 2010 From: tony@REDACTED (Tony Rogvall) Date: Wed, 16 Jun 2010 02:22:55 +0200 Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <201006152315.o5FNFTNv025765@pluto.hedeland.org> References: <201006152315.o5FNFTNv025765@pluto.hedeland.org> Message-ID: > > What version of OTP did you try on? What OS? > > --Per Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] on Darwin p13 10.3.0 Darwin Kernel Version 10.3.0: Fri Feb 26 11:58:09 PST 2010; root:xnu-1504.3.12~1/RELEASE_I386 i386 Something with the loopback interface ? Is it possible to trace the loopback interface and see that it generates the ICMP? Try an other interface where there is a host ... /Tony From nraychaudhuri@REDACTED Wed Jun 16 04:35:43 2010 From: nraychaudhuri@REDACTED (Nilanjan Raychaudhuri) Date: Tue, 15 Jun 2010 22:35:43 -0400 Subject: [erlang-questions] Similarities between web programming and functional programming In-Reply-To: References: <2C042DAC-416E-435A-A3CF-0376B7BB5B01@pillartechnology.com> Message-ID: <0530A2C4-8CA1-457A-9043-19986FB7D12C@pillartechnology.com> I see the resemblance with HTTP GET type request and pure function but what about HTTP POST and the side-effects? Thanks Nilanjan On Jun 12, 2010, at 4:37 PM, Jesper Louis Andersen wrote: > On Sat, Jun 12, 2010 at 10:19 PM, Nilanjan Raychaudhuri > wrote: >> Hi all, >> >> As a newbie into functional programming I am curious to know how functional programming style fits into building web applications? And how it >> compares to building web apps in Ruby or Java. >> >> Any pointer to article/literature will be helpful. > > Look at the following function: > > handle(Request) -> > X = ..., > Template = ..., > render_response(?HTTP_OK, X, Template). > > It has the specification contract > -spec handle(request()) -> response(). > > That is, handling incoming web requests are (sometimes pure) functions > from request() objects to response() objects. At this point, we are > essentially done. There isn't much more to it. Of course, we have only > defined a rough skeleton of how to do it, and a lot of the fleshy > details have been omitted. What makes it easy is that the web is > essentially stateless: All needed information is in the request() > object. If we store data locally, there will be some kind of token() > object (a cookie, say) in the request() object allowing us to get hold > of our server-side state. One could imagine calling another process to > get hold of this data (it is not much different from Ruby, Python or > Java calling into an SQL database for their data). > > In general web-server handling is very amenable to the functional > programming paradigm. You may regard the above as being unnecessarily > low level, but it is very easy to use a couple of wrapper functions to > peel off layers of complexity so you end up with the innards of a web > framework such as Rails, Django or Pylons. > > Erlang gives you an insane amount of tools to manipulate > web-applications. It seems that much of the heightened interest in > Erlang as of late is channeled towards building web-tools and webapps > in general. So not only will you have an excellent language for doing > web application development; you will also enjoy standing on the > shoulders of giants. > > > -- > J. From nraychaudhuri@REDACTED Wed Jun 16 04:47:20 2010 From: nraychaudhuri@REDACTED (Nilanjan Raychaudhuri) Date: Tue, 15 Jun 2010 22:47:20 -0400 Subject: [erlang-questions] Similarities between web programming and functional programming In-Reply-To: References: <2C042DAC-416E-435A-A3CF-0376B7BB5B01@pillartechnology.com> Message-ID: Thanks Steve, I read your articles regularly. I think webmachine is an good example of how build web applications in functional language. Have you looked into http://www.waterken.com/dev/Web/Calculus/ ? I liked the idea of thinking resources in terms of closures. Thanks Nilanjan On Jun 13, 2010, at 9:27 PM, Steve Vinoski wrote: > On Sat, Jun 12, 2010 at 4:19 PM, Nilanjan Raychaudhuri > wrote: >> Hi all, >> >> As a newbie into functional programming I am curious to know how functional programming style fits into building web applications? And how it >> compares to building web apps in Ruby or Java. >> >> Any pointer to article/literature will be helpful. > > For a little over a year now I've write a bimonthly magazine column > called "The Functional Web" for IEEE Internet Computing magazine > (though I missed a couple issues due to workload). All issues can be > found here: > > http://steve.vinoski.net/blog/internet-computing-columns/ > > You might take a look at the introductory article for the column to > see if it helps answer your question: > > http://steve.vinoski.net/pdf/IC-Welcome_to_the_Functional_Web.pdf > > --steve From nraychaudhuri@REDACTED Wed Jun 16 05:01:05 2010 From: nraychaudhuri@REDACTED (Nilanjan Raychaudhuri) Date: Tue, 15 Jun 2010 23:01:05 -0400 Subject: [erlang-questions] Similarities between web programming and functional programming In-Reply-To: References: <2C042DAC-416E-435A-A3CF-0376B7BB5B01@pillartechnology.com> Message-ID: Good points, do you any Erlang web framework doing this right now? Especially I liked the idea of a web form represented as a partial function. I am not sure I understood the concurrency-oriented style is more feasible for web programming part in your response. Do you mean actors as a way to handle http requests? Thanks Nilanjan On Jun 14, 2010, at 11:27 AM, ??? (Yau-Hsien Huang) wrote: > On Sun, Jun 13, 2010 at 4:19 AM, Nilanjan Raychaudhuri < > nraychaudhuri@REDACTED> wrote: > >> Hi all, >> >> As a newbie into functional programming I am curious to know how functional >> programming style fits into building web applications? And how it >> compares to building web apps in Ruby or Java. >> >> Any pointer to article/literature will be helpful. >> >> Thanks >> Nilanjan > > > In general, subjects in Functional Programming may be: > * Value is function, and anything is value. > * Immutable value. > * Lazy evaluation strategy, and what about that when some but not all > arguments are > given to a function you get another function. (I forgot terms about the > later one.) > * Higher order function. > * Pure function, or imperative, with side-effect. > > How does it fit Web Programming? In my opinion, > 1. Anything is value, yes, some techniques and paradigm of Web Programming > such > as that about XML technologies follow this style. XSLT can be written > FUNctionally. > Parts of web technology are not Software Engineering any more but Data > Engineering. > 2. Immutable value means that program runs without depending on state. > Microsoft > .Net Framework tried making the stateless Web environment stateful. In > functional > programming, when you send a different request, the program generates > another > set of values instead of making a response with a modified state. > 3. Partial application of function arguments is powerful than other > programming styles. > Consider a web form as a function that it accepted some of it arguments > and > `became' another function, that is, another web form or the original form > holding > some arguments and waiting for other arguments. > 4. High order function plays role of glue. Web Programming is performed in > parallel; > you and your colleagues write each's programs, and you put those > together, > and those works as a whole. High-order function do somethings similarly: > Functions may be glued by some function, and those work as a whole while > each can be run separately for the debugging purpose. > > You post the question in Erlang mailing-list. About Erlang, its > Concurreny-Oriented > Programming style is more feasible for Web Programming and more discussible > than functional programming features. > > Best Regards, > Y.-H. H. From per@REDACTED Wed Jun 16 08:07:03 2010 From: per@REDACTED (Per Hedeland) Date: Wed, 16 Jun 2010 08:07:03 +0200 (CEST) Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: Message-ID: <201006160607.o5G673MM074568@pluto.hedeland.org> Tony Rogvall wrote: > >> What version of OTP did you try on? What OS? > >Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] = >[hipe] [kernel-poll:false] > >on > >Darwin p13 10.3.0 Darwin Kernel Version 10.3.0: Fri Feb 26 11:58:09 PST = >2010; root:xnu-1504.3.12~1/RELEASE_I386 i386 OK - I get the same behaviour as before with R13B04 on FreeBSD (using the FreeBSD "port" in both cases) though, so it seems it is a "OS- specific" problem. But since it works in passive mode and the difference between active and passive is all in Erlang/inet_drv (right?), I guess it's a problem with the Erlang/OTP build for FreeBSD rather than with FreeBSD "itself". >Something with the loopback interface ? Very unlikely given the above. >Is it possible to trace the loopback interface and see that it generates >the ICMP? Indeed it is: 07:51:01.439571 IP 127.0.0.1.61776 > 127.0.0.1.12345: UDP, length 3 07:51:01.439613 IP 127.0.0.1 > 127.0.0.1: ICMP 127.0.0.1 udp port 12345 unreachable, length 36 Happens in both active and passive mode. >Try an other interface where there is a host ... Haven't done that, maybe I will (right now I happen to be on a network where other hosts don't have the courtesy to send ICMP unreachables:-). I noticed something else interesting though - in passive mode: 9> gen_udp:send(U, <<1,2,3>>). ok 10> gen_udp:send(U, <<1,2,3>>). {error,econnrefused} 11> gen_udp:send(U, <<1,2,3>>). ok 12> gen_udp:send(U, <<1,2,3>>). {error,econnrefused} 13> gen_udp:send(U, <<1,2,3>>). ok 14> gen_udp:send(U, <<1,2,3>>). {error,econnrefused} I.e. the error is detected, but only on a subsequent send() (which doesn't actually send anything). --Per From tony@REDACTED Wed Jun 16 14:35:24 2010 From: tony@REDACTED (Tony Rogvall) Date: Wed, 16 Jun 2010 14:35:24 +0200 Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <201006160607.o5G673MM074568@pluto.hedeland.org> References: <201006160607.o5G673MM074568@pluto.hedeland.org> Message-ID: <3FFA3A18-FBE1-4C96-A03F-64EDDAEBB396@rogvall.se> On 16 jun 2010, at 08.07, Per Hedeland wrote: > >> Try an other interface where there is a host ... > > Haven't done that, maybe I will (right now I happen to be on a network > where other hosts don't have the courtesy to send ICMP unreachables:-). > I noticed something else interesting though - in passive mode: > > 9> gen_udp:send(U, <<1,2,3>>). > ok > 10> gen_udp:send(U, <<1,2,3>>). > {error,econnrefused} > 11> gen_udp:send(U, <<1,2,3>>). > ok > 12> gen_udp:send(U, <<1,2,3>>). > {error,econnrefused} > 13> gen_udp:send(U, <<1,2,3>>). > ok > 14> gen_udp:send(U, <<1,2,3>>). > {error,econnrefused} > > I.e. the error is detected, but only on a subsequent send() (which > doesn't actually send anything). > Cool! send is failing on subsequent send, but recv is not ???? This is strange times. Do you think this behavior is documented anywhere? A small C program may clear this issue for us ? /Tony A small comment intended for the list readers that do understand what we are talking about. When running the inet_res:resolve function (and friends) it will never return {error,econnrefused} But the result {error,timeout} even before the timeout value. This may be a bug or not, for now it is "historical reasons" and "convenient". The reasons is that one or several name severs may get econnrefused while others may timeout. To get the {error, econnrefused} speed things up when trying servers where DNS servers may have crashed. But in the general case, server may be down/burned, routers is down/corrupt, this will not help since no one will send the ICMP reply message on the network. Example: inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,1},53}]},verbose], 5000). Query: {msg,[{header,{header,[{id,7}, {qr,0}, {opcode,'query'}, {aa,0}, {tc,0}, {rd,true}, {ra,0}, {pr,0}, {rcode,0}]}}, {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, {type,a}, {class,in}]}]}, {anlist,[]}, {nslist,[]}, {arlist,[]}]} Try UDP server : {127,0,0,1}:53 (timeout=666) UDP server error: {error,econnrefused} {error,timeout} Trying a host that do not exist: inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,2},53}]},verbose], 5000). Query: {msg,[{header,{header,[{id,8}, {qr,0}, {opcode,'query'}, {aa,0}, {tc,0}, {rd,true}, {ra,0}, {pr,0}, {rcode,0}]}}, {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, {type,a}, {class,in}]}]}, {anlist,[]}, {nslist,[]}, {arlist,[]}]} Try UDP server : {127,0,0,2}:53 (timeout=666) UDP server error: {error,timeout} Try UDP server : {127,0,0,2}:53 (timeout=1333) UDP server error: {error,timeout} Try UDP server : {127,0,0,2}:53 (timeout=2666) UDP server error: {error,timeout} {error,timeout} /Tony From rumata-estor@REDACTED Wed Jun 16 14:47:48 2010 From: rumata-estor@REDACTED (Dmitry Belyaev) Date: Wed, 16 Jun 2010 16:47:48 +0400 Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <3FFA3A18-FBE1-4C96-A03F-64EDDAEBB396@rogvall.se> References: <201006160607.o5G673MM074568@pluto.hedeland.org> <3FFA3A18-FBE1-4C96-A03F-64EDDAEBB396@rogvall.se> Message-ID: <4C18C7F4.7030403@nm.ru> Try to add one working nameserver after 127.0.0.1 like this (like for my router): inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,1},53}, {{192,168,0,1},53}]},verbose], 5000). Even if second server is working, the result will be the same. Dmitry Belyaev On 06/16/2010 04:35 PM, Tony Rogvall wrote: > > On 16 jun 2010, at 08.07, Per Hedeland wrote: > > >> >>> Try an other interface where there is a host ... >>> >> Haven't done that, maybe I will (right now I happen to be on a network >> where other hosts don't have the courtesy to send ICMP unreachables:-). >> I noticed something else interesting though - in passive mode: >> >> 9> gen_udp:send(U,<<1,2,3>>). >> ok >> 10> gen_udp:send(U,<<1,2,3>>). >> {error,econnrefused} >> 11> gen_udp:send(U,<<1,2,3>>). >> ok >> 12> gen_udp:send(U,<<1,2,3>>). >> {error,econnrefused} >> 13> gen_udp:send(U,<<1,2,3>>). >> ok >> 14> gen_udp:send(U,<<1,2,3>>). >> {error,econnrefused} >> >> I.e. the error is detected, but only on a subsequent send() (which >> doesn't actually send anything). >> >> > Cool! > send is failing on subsequent send, but recv is not ???? This is strange times. > Do you think this behavior is documented anywhere? > A small C program may clear this issue for us ? > > /Tony > > A small comment intended for the list readers that do understand what we are talking about. > > When running the inet_res:resolve function (and friends) it will never return {error,econnrefused} > But the result {error,timeout} even before the timeout value. This may be a bug or not, for now it is "historical reasons" and > "convenient". The reasons is that one or several name severs may get econnrefused while others may timeout. > To get the {error, econnrefused} speed things up when trying servers where DNS servers may have crashed. > But in the general case, server may be down/burned, routers is down/corrupt, this will not help since no one will send > the ICMP reply message on the network. > > Example: > > inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,1},53}]},verbose], 5000). > Query: {msg,[{header,{header,[{id,7}, > {qr,0}, > {opcode,'query'}, > {aa,0}, > {tc,0}, > {rd,true}, > {ra,0}, > {pr,0}, > {rcode,0}]}}, > {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, > {type,a}, > {class,in}]}]}, > {anlist,[]}, > {nslist,[]}, > {arlist,[]}]} > Try UDP server : {127,0,0,1}:53 (timeout=666) > UDP server error: {error,econnrefused} > {error,timeout} > > Trying a host that do not exist: > > inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,2},53}]},verbose], 5000). > Query: {msg,[{header,{header,[{id,8}, > {qr,0}, > {opcode,'query'}, > {aa,0}, > {tc,0}, > {rd,true}, > {ra,0}, > {pr,0}, > {rcode,0}]}}, > {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, > {type,a}, > {class,in}]}]}, > {anlist,[]}, > {nslist,[]}, > {arlist,[]}]} > Try UDP server : {127,0,0,2}:53 (timeout=666) > UDP server error: {error,timeout} > Try UDP server : {127,0,0,2}:53 (timeout=1333) > UDP server error: {error,timeout} > Try UDP server : {127,0,0,2}:53 (timeout=2666) > UDP server error: {error,timeout} > {error,timeout} > > > > > > /Tony > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > From rbhat@REDACTED Wed Jun 16 14:55:00 2010 From: rbhat@REDACTED (Rajesh Bhat) Date: Wed, 16 Jun 2010 07:55:00 -0500 Subject: Erlang - Question on memory usage reported Message-ID: <6329B957BA5C514DBF5FBED87A88388204D2317B44@spswchi6mail1.peak6.net> Hi All, Apologies for the long email... I am running an application that starts up with a memory footprint of around ~725MB when started (Approx 9000 processes on startup).. Application spawns processes as new requests are processed and grows to about 50K processes and memory usage of 5.1GB during the day. Output of memory(). is as follows - memory(). [{total,5196843904}, {processes,3676103336}, {processes_used,3670262752}, {system,1520740568}, {atom,768433}, {atom_used,743978}, {binary,199344664}, {code,8016451}, {ets,1304839200}] At the end of the day, a cleanup job reviews the process state and kills the pids that are not required and cleans up the ets table. Essentially returning it to start up stage of around 9K processes. Running the memory command in erlang shell reports - memory(). [{total,721747840}, {processes,584000792}, {processes_used,552084576}, {system,137747048}, {atom,768433}, {atom_used,744177}, {binary,44468264}, {code,8016451}, {ets,80471216}] Which is pretty consistent with what I am expecting, however running 'htop' on the system still indicates Erlang beam process with a resident memory usage of around 5.1GB. Any pointers that explains this behavior is greatly appreciated. Is there a way to release the memory? There was a suggestion in one of the Erlang forums that bouncing the Supervisor process as part of the clean up could be one of the options? Anyone with similar experience? I am running the version - Erlang R13B02 (erts-5.7.3) Thanks much -- Rajesh Bhat. ______________________________________________ See http://www.peak6.com/email_disclaimer.php for terms and conditions related to this email From tony@REDACTED Wed Jun 16 14:51:29 2010 From: tony@REDACTED (Tony Rogvall) Date: Wed, 16 Jun 2010 14:51:29 +0200 Subject: DOWN record Message-ID: <857B4D56-18CB-4FB6-AD61-375F59C27F40@rogvall.se> Hi list. A quick survey. Are there more people than me that sometimes define the record: -record('DOWN', { ref, %% monitor reference type, %% type of object 'process' id, %% object id (pid) reason %% reason for termination }). ? To simplify matching of 'DOWN' messages ? Example: handle_info(#'DOWN' { ref=Ref }, State) -> ... /Tony From raimo+erlang-questions@REDACTED Wed Jun 16 15:55:35 2010 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 16 Jun 2010 15:55:35 +0200 Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <4C18C7F4.7030403@nm.ru> References: <201006160607.o5G673MM074568@pluto.hedeland.org> <3FFA3A18-FBE1-4C96-A03F-64EDDAEBB396@rogvall.se> <4C18C7F4.7030403@nm.ru> Message-ID: <20100616135535.GA6086@erix.ericsson.se> On Wed, Jun 16, 2010 at 04:47:48PM +0400, Dmitry Belyaev wrote: > Try to add one working nameserver after 127.0.0.1 like this (like for my > router): > > inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,1},53}, > {{192,168,0,1},53}]},verbose], 5000). > > Even if second server is working, the result will be the same. That bug is on my todo list... > > Dmitry Belyaev > > > On 06/16/2010 04:35 PM, Tony Rogvall wrote: > > > >On 16 jun 2010, at 08.07, Per Hedeland wrote: > > > > > >> > >>>Try an other interface where there is a host ... > >>> > >>Haven't done that, maybe I will (right now I happen to be on a network > >>where other hosts don't have the courtesy to send ICMP unreachables:-). > >>I noticed something else interesting though - in passive mode: > >> > >>9> gen_udp:send(U,<<1,2,3>>). > >>ok > >>10> gen_udp:send(U,<<1,2,3>>). > >>{error,econnrefused} > >>11> gen_udp:send(U,<<1,2,3>>). > >>ok > >>12> gen_udp:send(U,<<1,2,3>>). > >>{error,econnrefused} > >>13> gen_udp:send(U,<<1,2,3>>). > >>ok > >>14> gen_udp:send(U,<<1,2,3>>). > >>{error,econnrefused} > >> > >>I.e. the error is detected, but only on a subsequent send() (which > >>doesn't actually send anything). > >> > >> > >Cool! > >send is failing on subsequent send, but recv is not ???? This is strange > >times. > >Do you think this behavior is documented anywhere? > >A small C program may clear this issue for us ? > > > >/Tony > > > >A small comment intended for the list readers that do understand what we > >are talking about. > > > >When running the inet_res:resolve function (and friends) it will never > >return {error,econnrefused} > >But the result {error,timeout} even before the timeout value. This may be > >a bug or not, for now it is "historical reasons" and > >"convenient". The reasons is that one or several name severs may get > >econnrefused while others may timeout. > >To get the {error, econnrefused} speed things up when trying servers where > >DNS servers may have crashed. > >But in the general case, server may be down/burned, routers is > >down/corrupt, this will not help since no one will send > >the ICMP reply message on the network. > > > >Example: > > > >inet_res:resolve("www.rogvall.se", in, a, > >[{nameservers,[{{127,0,0,1},53}]},verbose], 5000). > >Query: {msg,[{header,{header,[{id,7}, > > {qr,0}, > > {opcode,'query'}, > > {aa,0}, > > {tc,0}, > > {rd,true}, > > {ra,0}, > > {pr,0}, > > {rcode,0}]}}, > > {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, > > {type,a}, > > {class,in}]}]}, > > {anlist,[]}, > > {nslist,[]}, > > {arlist,[]}]} > >Try UDP server : {127,0,0,1}:53 (timeout=666) > >UDP server error: {error,econnrefused} > >{error,timeout} > > > >Trying a host that do not exist: > > > >inet_res:resolve("www.rogvall.se", in, a, > >[{nameservers,[{{127,0,0,2},53}]},verbose], 5000). > >Query: {msg,[{header,{header,[{id,8}, > > {qr,0}, > > {opcode,'query'}, > > {aa,0}, > > {tc,0}, > > {rd,true}, > > {ra,0}, > > {pr,0}, > > {rcode,0}]}}, > > {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, > > {type,a}, > > {class,in}]}]}, > > {anlist,[]}, > > {nslist,[]}, > > {arlist,[]}]} > >Try UDP server : {127,0,0,2}:53 (timeout=666) > >UDP server error: {error,timeout} > >Try UDP server : {127,0,0,2}:53 (timeout=1333) > >UDP server error: {error,timeout} > >Try UDP server : {127,0,0,2}:53 (timeout=2666) > >UDP server error: {error,timeout} > >{error,timeout} > > > > > > > > > > > >/Tony > > > > > >________________________________________________________________ > >erlang-questions (at) erlang.org mailing list. > >See http://www.erlang.org/faq.html > >To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > > > > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From rumata-estor@REDACTED Wed Jun 16 16:02:06 2010 From: rumata-estor@REDACTED (Dmitry Belyaev) Date: Wed, 16 Jun 2010 18:02:06 +0400 Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <40FCFE64-A346-4085-BFED-C67B91F397DF@rogvall.se> References: <201006160607.o5G673MM074568@pluto.hedeland.org> <3FFA3A18-FBE1-4C96-A03F-64EDDAEBB396@rogvall.se> <4C18C7F4.7030403@nm.ru> <40FCFE64-A346-4085-BFED-C67B91F397DF@rogvall.se> Message-ID: <4C18D95E.20203@nm.ru> Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.5 (abort with ^G) 1> inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,1},53},{{95,108,198,5},53}]},verbose], 1000). Query: {msg,[{header,{header,[{id,1}, {qr,0}, {opcode,'query'}, {aa,0}, {tc,0}, {rd,true}, {ra,0}, {pr,0}, {rcode,0}]}}, {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, {type,a}, {class,in}]}]}, {anlist,[]}, {nslist,[]}, {arlist,[]}]} Try UDP server : {127,0,0,1}:53 (timeout=666) UDP server error: {error,econnrefused} Try UDP server : {95,108,198,5}:53 (timeout=666) UDP server error: {error,timeout} Try UDP server : {95,108,198,5}:53 (timeout=326) UDP server error: {error,timeout} Try UDP server : {95,108,198,5}:53 (timeout=0) UDP server timeout {error,timeout} 2> Probably it depends on OS: Linux rumata-nb 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010 i686 GNU/Linux Dmitry Belyaev On 06/16/2010 05:17 PM, Tony Rogvall wrote: > > On 16 jun 2010, at 14.47, Dmitry Belyaev wrote: > > >> Try to add one working nameserver after 127.0.0.1 like this (like for my router): >> >> inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,1},53}, {{192,168,0,1},53}]},verbose], 5000). >> >> Even if second server is working, the result will be the same. >> >> Dmitry Belyaev >> >> > In may case it works, are you sure your router is on 192.168.0.1, mine is on 192.168.0.254 > Also the router must support DNS forwarding. > > My output: > > inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,1},53},{{192,168,0,254},53}]},verbose], 1000). > Query: {msg,[{header,{header,[{id,14}, > {qr,0}, > {opcode,'query'}, > {aa,0}, > {tc,0}, > {rd,true}, > {ra,0}, > {pr,0}, > {rcode,0}]}}, > {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, > {type,a}, > {class,in}]}]}, > {anlist,[]}, > {nslist,[]}, > {arlist,[]}]} > Try UDP server : {127,0,0,1}:53 (timeout=666) > UDP server error: {error,econnrefused} > Try UDP server : {192,168,0,254}:53 (timeout=666) > Got reply: {msg,[{header,{header,[{id,14}, > {qr,true}, > {opcode,'query'}, > {aa,false}, > {tc,false}, > {rd,true}, > {ra,true}, > {pr,false}, > {rcode,0}]}}, > {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, > {type,a}, > {class,in}]}]}, > {anlist,[{rr,[{domain,"www.rogvall.se"}, > {type,cname}, > {class,in}, > {ttl,20410}, > {data,"rogvall.se"}]}, > {rr,[{domain,"rogvall.se"}, > {type,a}, > {class,in}, > {ttl,20410}, > {data,{85,112,160,12}}]}]}, > {nslist,[{rr,[{domain,"rogvall.se"}, > {type,ns}, > {class,in}, > {ttl,85210}, > {data,"ns02.netcamp.se"}]}, > {rr,[{domain,"rogvall.se"}, > {type,ns}, > {class,in}, > {ttl,85210}, > {data,"ns01.netcamp.se"}]}, > {rr,[{domain,"rogvall.se"}, > {type,ns}, > {class,in}, > {ttl,85210}, > {data,"ns03.netcamp.se"}]}]}, > {arlist,[{rr,[{domain,"ns01.netcamp.se"}, > {type,a}, > {class,in}, > {ttl,1343}, > {data,{85,112,160,6}}]}, > {rr,[{domain,"ns03.netcamp.se"}, > {type,a}, > {class,in}, > {ttl,1343}, > {data,{85,112,162,6}}]}]}]} > {ok,{dns_rec,{dns_header,14,true,'query',false,false,true, > true,false,0}, > [{dns_query,"www.rogvall.se",a,in}], > [{dns_rr,"www.rogvall.se",cname,in,0,20410,"rogvall.se", > undefined,[],false}, > {dns_rr,"rogvall.se",a,in,0,20410, > {85,112,160,12}, > undefined,[],false}], > [{dns_rr,"rogvall.se",ns,in,0,85210,"ns02.netcamp.se", > undefined,[],false}, > {dns_rr,"rogvall.se",ns,in,0,85210,"ns01.netcamp.se", > undefined,[],false}, > {dns_rr,"rogvall.se",ns,in,0,85210,"ns03.netcamp.se", > undefined,[],false}], > [{dns_rr,"ns01.netcamp.se",a,in,0,1343, > {85,112,160,6}, > undefined,[],false}, > {dns_rr,"ns03.netcamp.se",a,in,0,1343, > {85,112,162,6}, > undefined,[],false}]}} > > /Tony > > > > > From rumata-estor@REDACTED Wed Jun 16 16:10:02 2010 From: rumata-estor@REDACTED (Dmitry Belyaev) Date: Wed, 16 Jun 2010 18:10:02 +0400 Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <4C18D95E.20203@nm.ru> References: <201006160607.o5G673MM074568@pluto.hedeland.org> <3FFA3A18-FBE1-4C96-A03F-64EDDAEBB396@rogvall.se> <4C18C7F4.7030403@nm.ru> <40FCFE64-A346-4085-BFED-C67B91F397DF@rogvall.se> <4C18D95E.20203@nm.ru> Message-ID: <4C18DB3A.1000702@nm.ru> Forgot to check the second: 2> inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{95,108,198,5},53},{{127,0,0,1},53}]},verbose], 1000). Query: {msg,[{header,{header,[{id,2}, {qr,0}, {opcode,'query'}, {aa,0}, {tc,0}, {rd,true}, {ra,0}, {pr,0}, {rcode,0}]}}, {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, {type,a}, {class,in}]}]}, {anlist,[]}, {nslist,[]}, {arlist,[]}]} Try UDP server : {95,108,198,5}:53 (timeout=666) Got reply: {msg,[{header,{header,[{id,2}, {qr,true}, {opcode,'query'}, {aa,false}, {tc,false}, {rd,true}, {ra,true}, {pr,false}, {rcode,0}]}}, {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, {type,a}, {class,in}]}]}, {anlist,[{rr,[{domain,"www.rogvall.se"}, {type,cname}, {class,in}, {ttl,20695}, {data,"rogvall.se"}]}, {rr,[{domain,"rogvall.se"}, {type,a}, {class,in}, {ttl,20695}, {data,{85,112,160,12}}]}]}, {nslist,[]}, {arlist,[]}]} {ok,{dns_rec,{dns_header,2,true,'query',false,false,true, true,false,0}, [{dns_query,"www.rogvall.se",a,in}], [{dns_rr,"www.rogvall.se",cname,in,0,20695,"rogvall.se", undefined,[],false}, {dns_rr,"rogvall.se",a,in,0,20695, {85,112,160,12}, undefined,[],false}], [],[]}} 3> Dmitry Belyaev On 06/16/2010 06:02 PM, Dmitry Belyaev wrote: > > Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.7.5 (abort with ^G) > 1> inet_res:resolve("www.rogvall.se", in, a, > [{nameservers,[{{127,0,0,1},53},{{95,108,198,5},53}]},verbose], 1000). > Query: {msg,[{header,{header,[{id,1}, > {qr,0}, > {opcode,'query'}, > {aa,0}, > {tc,0}, > {rd,true}, > {ra,0}, > {pr,0}, > {rcode,0}]}}, > {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, > {type,a}, > {class,in}]}]}, > {anlist,[]}, > {nslist,[]}, > {arlist,[]}]} > Try UDP server : {127,0,0,1}:53 (timeout=666) > UDP server error: {error,econnrefused} > Try UDP server : {95,108,198,5}:53 (timeout=666) > UDP server error: {error,timeout} > Try UDP server : {95,108,198,5}:53 (timeout=326) > UDP server error: {error,timeout} > Try UDP server : {95,108,198,5}:53 (timeout=0) > UDP server timeout > {error,timeout} > 2> > > Probably it depends on OS: > Linux rumata-nb 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 > UTC 2010 i686 GNU/Linux > > Dmitry Belyaev > > > On 06/16/2010 05:17 PM, Tony Rogvall wrote: >> >> On 16 jun 2010, at 14.47, Dmitry Belyaev wrote: >> >>> Try to add one working nameserver after 127.0.0.1 like this (like >>> for my router): >>> >>> inet_res:resolve("www.rogvall.se", in, a, >>> [{nameservers,[{{127,0,0,1},53}, {{192,168,0,1},53}]},verbose], 5000). >>> >>> Even if second server is working, the result will be the same. >>> >>> Dmitry Belyaev >>> >> In may case it works, are you sure your router is on 192.168.0.1, >> mine is on 192.168.0.254 >> Also the router must support DNS forwarding. >> >> My output: >> >> inet_res:resolve("www.rogvall.se", in, a, >> [{nameservers,[{{127,0,0,1},53},{{192,168,0,254},53}]},verbose], 1000). >> Query: {msg,[{header,{header,[{id,14}, >> {qr,0}, >> {opcode,'query'}, >> {aa,0}, >> {tc,0}, >> {rd,true}, >> {ra,0}, >> {pr,0}, >> {rcode,0}]}}, >> {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, >> {type,a}, >> {class,in}]}]}, >> {anlist,[]}, >> {nslist,[]}, >> {arlist,[]}]} >> Try UDP server : {127,0,0,1}:53 (timeout=666) >> UDP server error: {error,econnrefused} >> Try UDP server : {192,168,0,254}:53 (timeout=666) >> Got reply: {msg,[{header,{header,[{id,14}, >> {qr,true}, >> {opcode,'query'}, >> {aa,false}, >> {tc,false}, >> {rd,true}, >> {ra,true}, >> {pr,false}, >> {rcode,0}]}}, >> {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, >> {type,a}, >> {class,in}]}]}, >> {anlist,[{rr,[{domain,"www.rogvall.se"}, >> {type,cname}, >> {class,in}, >> {ttl,20410}, >> {data,"rogvall.se"}]}, >> {rr,[{domain,"rogvall.se"}, >> {type,a}, >> {class,in}, >> {ttl,20410}, >> {data,{85,112,160,12}}]}]}, >> {nslist,[{rr,[{domain,"rogvall.se"}, >> {type,ns}, >> {class,in}, >> {ttl,85210}, >> {data,"ns02.netcamp.se"}]}, >> {rr,[{domain,"rogvall.se"}, >> {type,ns}, >> {class,in}, >> {ttl,85210}, >> {data,"ns01.netcamp.se"}]}, >> {rr,[{domain,"rogvall.se"}, >> {type,ns}, >> {class,in}, >> {ttl,85210}, >> {data,"ns03.netcamp.se"}]}]}, >> {arlist,[{rr,[{domain,"ns01.netcamp.se"}, >> {type,a}, >> {class,in}, >> {ttl,1343}, >> {data,{85,112,160,6}}]}, >> {rr,[{domain,"ns03.netcamp.se"}, >> {type,a}, >> {class,in}, >> {ttl,1343}, >> {data,{85,112,162,6}}]}]}]} >> {ok,{dns_rec,{dns_header,14,true,'query',false,false,true, >> true,false,0}, >> [{dns_query,"www.rogvall.se",a,in}], >> [{dns_rr,"www.rogvall.se",cname,in,0,20410,"rogvall.se", >> undefined,[],false}, >> {dns_rr,"rogvall.se",a,in,0,20410, >> {85,112,160,12}, >> undefined,[],false}], >> [{dns_rr,"rogvall.se",ns,in,0,85210,"ns02.netcamp.se", >> undefined,[],false}, >> {dns_rr,"rogvall.se",ns,in,0,85210,"ns01.netcamp.se", >> undefined,[],false}, >> {dns_rr,"rogvall.se",ns,in,0,85210,"ns03.netcamp.se", >> undefined,[],false}], >> [{dns_rr,"ns01.netcamp.se",a,in,0,1343, >> {85,112,160,6}, >> undefined,[],false}, >> {dns_rr,"ns03.netcamp.se",a,in,0,1343, >> {85,112,162,6}, >> undefined,[],false}]}} >> >> /Tony >> >> >> >> > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From ttom.kelly@REDACTED Wed Jun 16 16:11:20 2010 From: ttom.kelly@REDACTED (tom kelly) Date: Wed, 16 Jun 2010 15:11:20 +0100 Subject: heart restarting erlang node Message-ID: Hi List, We're experiencing a weird problem here where our node seems to spontaneously reboot. It looks like heart is causing it but we can't figure out why. It has occurred at irregular intervals ranging from 8 hours to two days since we first noticed it last week. "hwclock" and "date" are in sync and the machine is not using NTP. We're sure we're not approaching any system limit and the load on the machine doesn't seem to be a factor either. If anyone has experienced this before we'd be extremely grateful for any help. The relevant section of the log is below. Thanks, Tom. ===== ALIVE Tue Jun 15 19:12:56 BST 2010 ===== ALIVE Tue Jun 15 19:27:56 BST 2010 ===== ALIVE Tue Jun 15 19:42:56 BST 2010 ===== Tue Jun 15 19:51:08 BST 2010 heart: Tue Jun 15 19:51:08 2010: Erlang has closed. /usr/lib/erlang/lib/os_mon-2.1.8/priv/bin/memsup: Erlang has closed. Erlang has closed heart: Tue Jun 15 19:51:09 2010: Executed "/usr/lib/erlang/bin/run_erl -daemon /var/run/em/pipe/ /em/log/ "/usr/bin/erl -env ERL_MAX_PORTS 128000 +P 128000 +A 256 -sname em@REDACTED -heart -smp enable +K true -pa ../libs/yaws/ebin -pa ../libs/xmlrpc/ebin -pa gui/mgmt/ebin -pa gui/ebin -pa ebin -mnesia dir '\"/em/db\"' -config /em/system.config -yaws embedded true -s em_boot"". Terminating. ===== ===== LOGGING STARTED Tue Jun 15 19:51:09 BST 2010 ===== heart_beat_kill_pid = 11874 Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [smp:12] [async-threads:256] [hipe] [kernel-poll:true] starting em... Eshell V5.6.5 (abort with ^G) (em@REDACTED)1> 2010-06-15 19:51:09 <0.41.0> em_main INFO: starting em_main... 2010-06-15 19:51:09 <0.44.0> em_main INFO: starting sasl... =PROGRESS REPORT= 2010-06-15 19:51:09 <0.50.0> [{supervisor,{local,sasl_safe_sup}}, {started,[{pid,<0.51.0>}, {name,alarm_handler}, From kenneth.lundin@REDACTED Wed Jun 16 16:11:23 2010 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 16 Jun 2010 16:11:23 +0200 Subject: Erlang/OTP R14A has been released Message-ID: Erlang/OTP R14A has been released. This is a beta-release before the R14B release which is planned for September 1:st. You can find the README file for the release at http://www.erlang.org/download/otp_src_R14A.readme The source distribution and binary distribution for Windows can be downloaded from http://www.erlang.org/download/otp_src_R14A.tar.gz http://www.erlang.org/download/otp_win32_R14A.exe The distribution can also be downloaded using the BitTorrent protocol. Use the following torrent files to download the source distribution and binary distribution for Windows: http://www.erlang.org/download/otp_src_R14A.tar.gz.torrent http://www.erlang.org/download/otp_win32_R14A.exe.torrent Note: To unpack the TAR archive you need a GNU TAR compatible program. For installation instructions please read the README file that is part of the distribution. The on-line documentation can be found at: http://www.erlang.org/doc/ You can also download the complete HTML documentation or the Unix manual files http://www.erlang.org/download/otp_doc_html_R14A.tar.gz http://www.erlang.org/download/otp_doc_man_R14A.tar.gz We also want to thank those that sent us patches, suggestions and bug reports, The OTP Team Kenneth Lundin, Erlang/OTP, Ericsson AB From tony@REDACTED Wed Jun 16 15:17:07 2010 From: tony@REDACTED (Tony Rogvall) Date: Wed, 16 Jun 2010 15:17:07 +0200 Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <4C18C7F4.7030403@nm.ru> References: <201006160607.o5G673MM074568@pluto.hedeland.org> <3FFA3A18-FBE1-4C96-A03F-64EDDAEBB396@rogvall.se> <4C18C7F4.7030403@nm.ru> Message-ID: <40FCFE64-A346-4085-BFED-C67B91F397DF@rogvall.se> On 16 jun 2010, at 14.47, Dmitry Belyaev wrote: > Try to add one working nameserver after 127.0.0.1 like this (like for my router): > > inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,1},53}, {{192,168,0,1},53}]},verbose], 5000). > > Even if second server is working, the result will be the same. > > Dmitry Belyaev > In may case it works, are you sure your router is on 192.168.0.1, mine is on 192.168.0.254 Also the router must support DNS forwarding. My output: inet_res:resolve("www.rogvall.se", in, a, [{nameservers,[{{127,0,0,1},53},{{192,168,0,254},53}]},verbose], 1000). Query: {msg,[{header,{header,[{id,14}, {qr,0}, {opcode,'query'}, {aa,0}, {tc,0}, {rd,true}, {ra,0}, {pr,0}, {rcode,0}]}}, {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, {type,a}, {class,in}]}]}, {anlist,[]}, {nslist,[]}, {arlist,[]}]} Try UDP server : {127,0,0,1}:53 (timeout=666) UDP server error: {error,econnrefused} Try UDP server : {192,168,0,254}:53 (timeout=666) Got reply: {msg,[{header,{header,[{id,14}, {qr,true}, {opcode,'query'}, {aa,false}, {tc,false}, {rd,true}, {ra,true}, {pr,false}, {rcode,0}]}}, {qdlist,[{dns_query,[{domain,"www.rogvall.se"}, {type,a}, {class,in}]}]}, {anlist,[{rr,[{domain,"www.rogvall.se"}, {type,cname}, {class,in}, {ttl,20410}, {data,"rogvall.se"}]}, {rr,[{domain,"rogvall.se"}, {type,a}, {class,in}, {ttl,20410}, {data,{85,112,160,12}}]}]}, {nslist,[{rr,[{domain,"rogvall.se"}, {type,ns}, {class,in}, {ttl,85210}, {data,"ns02.netcamp.se"}]}, {rr,[{domain,"rogvall.se"}, {type,ns}, {class,in}, {ttl,85210}, {data,"ns01.netcamp.se"}]}, {rr,[{domain,"rogvall.se"}, {type,ns}, {class,in}, {ttl,85210}, {data,"ns03.netcamp.se"}]}]}, {arlist,[{rr,[{domain,"ns01.netcamp.se"}, {type,a}, {class,in}, {ttl,1343}, {data,{85,112,160,6}}]}, {rr,[{domain,"ns03.netcamp.se"}, {type,a}, {class,in}, {ttl,1343}, {data,{85,112,162,6}}]}]}]} {ok,{dns_rec,{dns_header,14,true,'query',false,false,true, true,false,0}, [{dns_query,"www.rogvall.se",a,in}], [{dns_rr,"www.rogvall.se",cname,in,0,20410,"rogvall.se", undefined,[],false}, {dns_rr,"rogvall.se",a,in,0,20410, {85,112,160,12}, undefined,[],false}], [{dns_rr,"rogvall.se",ns,in,0,85210,"ns02.netcamp.se", undefined,[],false}, {dns_rr,"rogvall.se",ns,in,0,85210,"ns01.netcamp.se", undefined,[],false}, {dns_rr,"rogvall.se",ns,in,0,85210,"ns03.netcamp.se", undefined,[],false}], [{dns_rr,"ns01.netcamp.se",a,in,0,1343, {85,112,160,6}, undefined,[],false}, {dns_rr,"ns03.netcamp.se",a,in,0,1343, {85,112,162,6}, undefined,[],false}]}} /Tony From kenrobinsonster@REDACTED Wed Jun 16 16:36:25 2010 From: kenrobinsonster@REDACTED (Ken Robinson) Date: Thu, 17 Jun 2010 00:36:25 +1000 Subject: [erlang-questions] gen_fsm crashes In-Reply-To: References: Message-ID: Hi All, I decided to do trace on all the calls in gen_fsm with my state machine code transport_tx_fsm.erl (which goes from state sending to sending, it's in the standard I'm implementing). As I do not have a timeout on the gen_fsm it should used inifinity as the timeout value on the loop. Early on it does and enters the loop appropriately: (<0.92.0>) call gen_fsm:loop(<0.89.0>,transport_tx_fsm,sending,[],transport_tx_fsm,infinity,[{statistics,{{{2010,6,16},{23,31,51}},{reductions,29},0,0}}, {log,{10,[]}}, {trace,true}]) ok I get it to do some work via a test and then it appears to want to go back into the loop with the timeout value infinity: (<0.92.0>) call gen_fsm:handle_msg({'$gen_event',{send,{sendrec,<<"?">>, ... <<1,1>>}}},<0.89.0>,transport_tx_fsm,sending,[],transport_tx_fsm,infinity,[{statistics,{{{2010,6,16},{23,31,51}}, ... {trace,true}]) Unfortunately it appears to crash when the code tries to enter the loop with the timeout value which is is a tuple: (<0.92.0>) call gen_fsm:loop(<0.89.0>,transport_tx_fsm,sending,{send,{sendrec,undefined,undefined,undefined,undefined,undefined,undefined, undefined,1,undefined}},transport_tx_fsm,{[],#Fun},[{statistics,{{{2010,6,16},{23,31,51}}, ... {trace,true}]) This appears to cause the error: =CRASH REPORT==== 16-Jun-2010::23:32:09 === crasher: initial call: transport_tx_fsm:init/1 pid: <0.92.0> registered_name: transport_tx_fsm exception error: bad receive timeout value in function gen_fsm:loop/7 ... It then restarts using my supervisor. Is this a known bug or should I add some debug info to better track down this error? Would adding timeout fix this problem. Ken. On Wed, Jun 9, 2010 at 12:12 AM, Ken Robinson wrote: > Hi All, > Inspecting the gen_fsm.erl code from std_lib, it has a main > loop(Parent, Name, StateName, StateData, Mod, Timeout, Debug) method. > Appears one can have a bad receive timeout value. Need to now see what > is a good way to track down that value. I see that Debug has options > like trace and log. I am now trying to start up the application so > these Debug options are active. > Ken. > > On Tue, Jun 1, 2010 at 11:55 PM, kenrobinson wrote: >> Hi All, >> This being my first post to this list, please feel free to correct any >> mistakes I make on the group ?etiquette on posts. >> >> I am running a supervisor which uses the standard restart strategy. >> Here is a snippet from my .app file covering the gen_fsm which >> crashes. >> >> ?{transport_tx_fsm, %% tag >> ? {transport_tx_fsm, start_link, []}, >> ? permanent, >> ? 10000, >> ? worker, >> ? [transport_tx_fsm]}, >> >> >> I start up using the following command line: >> erl -pa test ebin priv -sname ken1 -boot start_sasl >> >> I load using application:load(jaus) and application:start(jaus). It >> starts correctly. >> >> I also load some test code using l(transport_tx_fsm_test) and fire off >> a message to transport_tx_fsm. Test code is sent to it like so: >> ? ?gen_fsm:send_event(transport_tx_fsm, {send, SR}), >> >> After it crashes, it appears to restart and process the message (see >> below). >> >> My question is what does the bad timeout value signify where I haven't >> started the gen_fsm with a timeout value? >> regards, >> Ken >> >> =CRASH REPORT==== 30-May-2010::23:54:53 === >> ?crasher: >> ? ?initial call: transport_tx_fsm:init/1 >> ? ?pid: <0.103.0> >> ? ?registered_name: transport_tx_fsm >> ? ?exception error: bad receive timeout value >> ? ? ?in function ?gen_fsm:loop/7 >> ? ?ancestors: [jaus_supervisor,<0.53.0>] >> ? ?messages: [] >> ? ?links: [<0.61.0>] >> ? ?dictionary: [] >> ? ?trap_exit: false >> ? ?status: running >> ? ?heap_size: 377 >> ? ?stack_size: 24 >> ? ?reductions: 476 >> ?neighbours: >> >> =SUPERVISOR REPORT==== 30-May-2010::23:54:53 === >> ? ? Supervisor: {local,jaus_supervisor} >> ? ? Context: ? ?child_terminated >> ? ? Reason: ? ? timeout_value >> ? ? Offender: ? [{pid,<0.103.0>}, >> ? ? ? ? ? ? ? ? ?{name,transport_tx_fsm}, >> ? ? ? ? ? ? ? ? ?{mfa,{transport_tx_fsm,start_link,[]}}, >> ? ? ? ? ? ? ? ? ?{restart_type,permanent}, >> ? ? ? ? ? ? ? ? ?{shutdown,10000}, >> ? ? ? ? ? ? ? ? ?{child_type,worker}] >> >> 23:54:53.896740 2010-05-30 [info] Called init message in >> transport_tx_fsm >> >> 23:54:53.896821 2010-05-30 [info] handle_info udp args >> ClientSocket #Port<0.1353> >> ?Host ? ? ? ? {127,0,0,1} >> Port ? ? ? ? 47761 >> Data ? ? ? ? <<2,0,128,0,192,3,2,1,0,6,5,64,0,1,1,19,0>> >> State ? ? ? ?{state} >> >> >> =PROGRESS REPORT==== 30-May-2010::23:54:53 === >> ? ? ? ? ?supervisor: {local,jaus_supervisor} >> ? ? ? ? ? ? started: [{pid,<0.105.0>}, >> ? ? ? ? ? ? ? ? ? ? ? {name,transport_tx_fsm}, >> ? ? ? ? ? ? ? ? ? ? ? {mfa,{transport_tx_fsm,start_link,[]}}, >> ? ? ? ? ? ? ? ? ? ? ? {restart_type,permanent}, >> ? ? ? ? ? ? ? ? ? ? ? {shutdown,10000}, >> ? ? ? ? ? ? ? ? ? ? ? {child_type,worker}] >> 23:54:53.901490 2010-05-30 [info] unwrap arg >> <<2,0,128,0,192,3,2,1,0,6,5,64,0,1,1,19,0>> >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> > From 12ukwn@REDACTED Wed Jun 16 16:53:31 2010 From: 12ukwn@REDACTED (Jean-Yves F. Barbier) Date: Wed, 16 Jun 2010 16:53:31 +0200 Subject: utf-8 PB Message-ID: <20100616165331.006cc602@anubis.defcon1> Debian sid erlang-base-hipe 1:13.b.4-dfsg-6 =========================== Hi list, I'm brand new to Erlang, and fighting with UTF-8 display. On command line, an io:format("~ts~n", ["???????"]). works perfectly, however into a module it don't work at all: start() -> Label = "???????", io:format("~ts~n", [Label]). returns: ?????????????? iconv the erl file from utf8 to iso8859-1 didn't changed anything. I read a lot, and saw there's unicode:xxx orders, but examples aren't talking to me and I don't understand very much how it works. I also need to display utf8 right into wxerlang (and don't see how to do that either) JY -- Don't let people drive you crazy when you know it's in walking distance. From clist@REDACTED Wed Jun 16 18:31:06 2010 From: clist@REDACTED (Angel Alvarez) Date: Wed, 16 Jun 2010 18:31:06 +0200 Subject: [erlang-questions] utf-8 PB In-Reply-To: <20100616165331.006cc602@anubis.defcon1> References: <20100616165331.006cc602@anubis.defcon1> Message-ID: <201006161831.07124.clist@uah.es> The shell has no trouble displaying uft8 chars ive made some string in spanish compiled propely if you save the source code as latin1 but no luck if you use utf8 editors Also you cat do io:get_line data and get that data displayed properly but when you have compiled strings in the code it in utf8 mode it doesnt work... If you manage to get some feedbak form the list, drop me a line :-( Regards, Angel El Mi?rcoles, 16 de Junio de 2010 16:53:31 Jean-Yves F. Barbier escribi?: > Debian sid > erlang-base-hipe 1:13.b.4-dfsg-6 > =========================== > > Hi list, > > I'm brand new to Erlang, and fighting with UTF-8 display. > > On command line, an io:format("~ts~n", ["???????"]). works perfectly, > however into a module it don't work at all: > start() -> > Label = "???????", > io:format("~ts~n", [Label]). > > returns: ?????????????? > > iconv the erl file from utf8 to iso8859-1 didn't changed anything. > > I read a lot, and saw there's unicode:xxx orders, but examples aren't > talking to me and I don't understand very much how it works. > > I also need to display utf8 right into wxerlang (and don't see how to > do that either) > > JY -- No imprima este correo si no es necesario. El medio ambiente est? en nuestras manos. ->>---------------------------------------------------------- Angel J. Alvarez Miguel, Servicios Inform?ticos Edificio Torre de Control, Campus Externo UAH Alcal? de Henares 28806, Madrid ** ESPA?A ** RedIRIS Jabber: angel.uah.es@REDACTED --------------------------------------------[www.uah.es]-<<-- Warning: Microsoft_bribery.ISO contains OOXML code. -- Este correo no tiene dibujos. Las formas extra?as en la pantalla son letras. __________________________________________ Clist UAH a.k.a Angel __________________________________________ Vivimos en un sociedad exquisitamente dependiente de la ciencia y la tecnolog?a, cuando muy poco gente conoce algo de la ciencia ? de la tecnolog?a. From attila.r.nohl@REDACTED Wed Jun 16 18:40:26 2010 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Wed, 16 Jun 2010 18:40:26 +0200 Subject: [erlang-questions] utf-8 PB In-Reply-To: <201006161831.07124.clist@uah.es> References: <20100616165331.006cc602@anubis.defcon1> <201006161831.07124.clist@uah.es> Message-ID: As far as I know, an Erlang source file must use the latin-1 character set. So if you want UTF-8 strings, read them from a file. That's useful for a possible internationalization anyway. 2010/6/16, Angel Alvarez : > The shell has no trouble displaying uft8 chars > > ive made some string in spanish compiled propely if you save the source code > as latin1 but no luck if you use utf8 editors > > Also you cat do io:get_line data and get that data displayed properly but > when you have compiled strings in the code it in utf8 mode it doesnt work... > > If you manage to get some feedbak form the list, drop me a line :-( > > > Regards, Angel > > El Mi?rcoles, 16 de Junio de 2010 16:53:31 Jean-Yves F. Barbier escribi?: >> Debian sid >> erlang-base-hipe 1:13.b.4-dfsg-6 >> =========================== >> >> Hi list, >> >> I'm brand new to Erlang, and fighting with UTF-8 display. >> >> On command line, an io:format("~ts~n", ["???????"]). works perfectly, >> however into a module it don't work at all: >> start() -> >> Label = "???????", >> io:format("~ts~n", [Label]). >> >> returns: ??????? ?????? >> >> iconv the erl file from utf8 to iso8859-1 didn't changed anything. >> >> I read a lot, and saw there's unicode:xxx orders, but examples aren't >> talking to me and I don't understand very much how it works. >> >> I also need to display utf8 right into wxerlang (and don't see how to >> do that either) >> >> JY > > > > -- > No imprima este correo si no es necesario. El medio ambiente est? en > nuestras manos. > ->>---------------------------------------------------------- > > Angel J. Alvarez Miguel, Servicios Inform?ticos > Edificio Torre de Control, Campus Externo UAH > Alcal? de Henares 28806, Madrid ** ESPA?A ** > > RedIRIS Jabber: angel.uah.es@REDACTED > --------------------------------------------[www.uah.es]-<<-- > Warning: Microsoft_bribery.ISO contains OOXML code. > -- > Este correo no tiene dibujos. Las formas extra?as en la pantalla son letras. > __________________________________________ > > Clist UAH a.k.a Angel > __________________________________________ > Vivimos en un sociedad exquisitamente dependiente de la ciencia y la > tecnolog?a, cuando muy poco gente conoce algo de la ciencia ? de la > tecnolog?a. > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From 12ukwn@REDACTED Wed Jun 16 19:07:18 2010 From: 12ukwn@REDACTED (Jean-Yves F. Barbier) Date: Wed, 16 Jun 2010 19:07:18 +0200 Subject: [erlang-questions] utf-8 PB In-Reply-To: References: <20100616165331.006cc602@anubis.defcon1> <201006161831.07124.clist@uah.es> Message-ID: <20100616190718.7fee0aca@anubis.defcon1> Le Wed, 16 Jun 2010 18:40:26 +0200, Attila Rajmund Nohl a ?crit : At this moment, I don't know how to do that. But I also read about internationalization and, AFAI understood, the easiest way to accomplish that is to use macros and redirect toward the directory & files according to the actual locale, is it the right way to do? > As far as I know, an Erlang source file must use the latin-1 character > set. So if you want UTF-8 strings, read them from a file. That's > useful for a possible internationalization anyway. -- Eternal nothingness is fine if you happen to be dressed for it. -- Woody Allen From vladdu55@REDACTED Wed Jun 16 19:59:30 2010 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 16 Jun 2010 19:59:30 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: References: Message-ID: On Wed, Jun 16, 2010 at 16:11, Kenneth Lundin wrote: > Erlang/OTP R14A has been released. Wonderful! A question about this entry in the readme file: The Erlang scanner has been augmented with two new tokens: .. and .... Why and where are they used? Or is it preparation for things to come? best regards, Vlad From rapsey@REDACTED Wed Jun 16 20:11:21 2010 From: rapsey@REDACTED (Rapsey) Date: Wed, 16 Jun 2010 20:11:21 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: References: Message-ID: The binary module and nif improvements are great. Just the other day I was thinking about using NIF for something, but abandoned the idea simply because there was no way to send messages from a NIF thread. Sergej On Wed, Jun 16, 2010 at 4:11 PM, Kenneth Lundin wrote: > Erlang/OTP R14A has been released. > This is a beta-release before the R14B release which is planned for > September 1:st. > > You can find the README file for the release at > > http://www.erlang.org/download/otp_src_R14A.readme > > The source distribution and binary distribution for Windows can be > downloaded from > > http://www.erlang.org/download/otp_src_R14A.tar.gz > http://www.erlang.org/download/otp_win32_R14A.exe > > The distribution can also be downloaded using the BitTorrent > protocol. Use the following torrent files to download the source > distribution and binary distribution for Windows: > > http://www.erlang.org/download/otp_src_R14A.tar.gz.torrent > http://www.erlang.org/download/otp_win32_R14A.exe.torrent > > Note: To unpack the TAR archive you need a GNU TAR compatible program. > > For installation instructions please read the README file that is part > of the distribution. > > The on-line documentation can be found at: http://www.erlang.org/doc/ > You can also download the complete HTML documentation or the Unix manual > files > > http://www.erlang.org/download/otp_doc_html_R14A.tar.gz > http://www.erlang.org/download/otp_doc_man_R14A.tar.gz > > We also want to thank those that sent us patches, suggestions and bug > reports, > > The OTP Team > Kenneth Lundin, Erlang/OTP, Ericsson AB > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From 12ukwn@REDACTED Wed Jun 16 20:52:17 2010 From: 12ukwn@REDACTED (Jean-Yves F. Barbier) Date: Wed, 16 Jun 2010 20:52:17 +0200 Subject: locale Message-ID: <20100616205217.0f519f48@anubis.defcon1> Hi list, Is there a primitive that returns the system locale? -- Never promise more than you can perform. -- Publilius Syrus From rvirding@REDACTED Wed Jun 16 21:00:57 2010 From: rvirding@REDACTED (Robert Virding) Date: Wed, 16 Jun 2010 21:00:57 +0200 Subject: [erlang-questions] RFC: Erjang's Java API prototype In-Reply-To: <4C16192B.5080408@erlang-solutions.com> References: <4C16192B.5080408@erlang-solutions.com> Message-ID: Why do I get the feeling that I am one of those to whom Ulf is referring? :-) In Erlang you have basically two different types of "things": immutable data structures and processes. Processes are things which obey process semantics (async messages, error signals, process isolation, etc) and have internal state, how they are actually implemented is completely irrelevant. Even ETS tables, which don't seem like processes, behave almost like processes as you can view the ets API as wrappers around message passing. (Aside: it is a great shame we don't have proper EIDs and a proper asynch message interface to ETS tables, think of the wonderful code you write). So where am I going with all this. If you want to interface something external to Erlang, in this case Java objects, in a clean Erlangy way then you should try to get it to look like either as immutable data or as a process. As Kresten had presented them they don't. So I don't approve. :-) Note, I have no problems with Erjang interfacing Java object or other languages or objects on the JVM, if you have all these libraries you should try and use them, you can't seriously expect different Erlang implementations running on different systems to have the same external environment. It is solely on how it looks from the Erlang side. I am now going to expose my ignorance about Java. Couldn't you use hashmaps to implement ETS tables and thereby get the best of both worlds? You could open an existing hashmap or create a new one when you open an ETS table. This would solve *this* case, but the general problem remains of now to access Java things in an Erlangy way. One final comment is about why it is important. Most of Erlangs error handling mechanism builds on processes, process semantics and immutable data. If you start messing this you are going to get strange effects which can be very hard to find the reason for. But I am definitely one of "the language sticklers in the Erlang community". Robert P.S. I am sending this to both erlang-questions and as a comment to Krestens blog. On 14 June 2010 13:57, Ulf Wiger wrote: > > I think this is well worth looking into, especially for > those who like discussing semantics, overloading, type > inference and such. > > http://www.javalimit.com/2010/06/a-java-api-for-erjang.html > > High marks for elegance. There are some open issues that could > benefit from some attention from the language sticklers in the > Erlang community. > > BR, > Ulf W > -- > Ulf Wiger > CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd > http://www.erlang-solutions.com > --------------------------------------------------- > > --------------------------------------------------- > > WE'VE CHANGED NAMES! > > Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG > SOLUTIONS LTD. > > www.erlang-solutions.com > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From 12ukwn@REDACTED Wed Jun 16 22:31:48 2010 From: 12ukwn@REDACTED (Jean-Yves F. Barbier) Date: Wed, 16 Jun 2010 22:31:48 +0200 Subject: hrl files Message-ID: <20100616223148.7f7bebc7@anubis.defcon1> Hi list, is it possible to compile .hrl files? -- What if there had been room at the inn? -- Linda Festa on the origins of Christianity From silent_vendetta@REDACTED Wed Jun 16 23:33:13 2010 From: silent_vendetta@REDACTED (Chris Hicks) Date: Wed, 16 Jun 2010 14:33:13 -0700 Subject: TCP clarification Message-ID: I'm going to be talking between two Erlang programs through a single port, no distributed Erlang for this project, and wanted to make sure I was thinking about things the right way. First I start listening on the port and spawn a worker process which will accept a connection on that port: spawn_initial_worker(Port) -> case gen_tcp:listen(Port, [binary, {reuseaddr, true}, {packet, 0}, {active, false}]) of {ok, LSock} -> spawn(?MODULE, worker, [self(), LSock]), spawn_loop(LSock) end. Yes I do want the above to crash if it can't listen. As the only communication gateway into this program if it can't listen there are problems. I then send it into the loop spawn_loop(LSock) which will continually spawn new workers to handle each new incoming connection (may increase to a larger pool of workers later if needed): spawn_loop(LSock) -> receive next_worker -> spawn_link(?MODULE, worker, [self(), S]) end, spawn_loop(LSock). This is the worker process: worker(Server, LSock) -> case gen_tcp:accept(LSock) of {ok, Socket} -> Server ! next_worker, %%verify data integrity then spawn process to handle data {error, Reason} -> %%some sort of system logging code here to track problems end. The way I understand it the Port is basically just an address where programs can thread any number of communications through. Each time gen_tcp:accept(LSock) is called a connection is made between the accepting process and the process on the "other" side trying to connect and send some data on that port. Once they do connect they are in an exclusive two-way communication that will be maintained until the connection is closed. Calling gen_tcp:close(Socket) will close that specific socket (the two-way communication between those two processes) while leaving all other active socket connections unaffected. I would also only need to call gen_tcp:close(Socket) once for any active socket, otherwise if I call it first from the sending process, then call it from the above worker process I would get an {error, Reason} response from the worker process. Is that a generally accurate understanding of how to use ports/sockets? _________________________________________________________________ Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2 From shahrdad1@REDACTED Wed Jun 16 22:43:23 2010 From: shahrdad1@REDACTED (Shahrdad Shadab) Date: Wed, 16 Jun 2010 13:43:23 -0700 (PDT) Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: Message-ID: <537999.42009.qm@web52902.mail.re2.yahoo.com> I couldn't get Erlide working with it. It seems Erlide is having problem with compiler options in the new release. I keep getting "malformed options (not erlang terms)" when I click on 'compiler' setting of Erlide. I tried to manually add compiler options but it didn't work. If anyone can find a solution please let me know. Thanks a lot Shahrdad --- On Wed, 6/16/10, Rapsey wrote: > From: Rapsey > Subject: Re: [erlang-questions] Erlang/OTP R14A has been released > To: erlang-questions@REDACTED > Date: Wednesday, June 16, 2010, 2:11 PM > The binary module and nif > improvements are great. Just the other day I was > thinking about using NIF for something, but abandoned the > idea simply > because there was no way to send messages from a NIF > thread. > > > Sergej > > On Wed, Jun 16, 2010 at 4:11 PM, Kenneth Lundin wrote: > > > Erlang/OTP R14A has been released. > > This is a beta-release before the R14B release which > is planned for > > September 1:st. > > > > You can find the README file for the release at > > > > http://www.erlang.org/download/otp_src_R14A.readme > > > > The source distribution and binary distribution for > Windows can be > > downloaded from > > > > http://www.erlang.org/download/otp_src_R14A.tar.gz > > http://www.erlang.org/download/otp_win32_R14A.exe > > > > The distribution can also be downloaded using the > BitTorrent > > protocol. Use the following torrent files to download > the source > > distribution and binary distribution for Windows: > > > > http://www.erlang.org/download/otp_src_R14A.tar.gz.torrent > > http://www.erlang.org/download/otp_win32_R14A.exe.torrent > > > > Note: To unpack the TAR archive you need a GNU TAR > compatible program. > > > > For installation instructions please read the README > file that is part > > of the distribution. > > > > The on-line documentation can be found at: http://www.erlang.org/doc/ > > You can also download the complete HTML documentation > or the Unix manual > > files > > > > http://www.erlang.org/download/otp_doc_html_R14A.tar.gz > > http://www.erlang.org/download/otp_doc_man_R14A.tar.gz > > > > We also want to thank those that sent us patches, > suggestions and bug > > reports, > > > > The OTP Team > > Kenneth Lundin, Erlang/OTP, Ericsson AB > > > > > ________________________________________________________________ > > erlang-questions (at) erlang.org mailing list. > > See http://www.erlang.org/faq.html > > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > > > From rvirding@REDACTED Wed Jun 16 23:56:32 2010 From: rvirding@REDACTED (Robert Virding) Date: Wed, 16 Jun 2010 23:56:32 +0200 Subject: [erlang-questions] hrl files In-Reply-To: <20100616223148.7f7bebc7@anubis.defcon1> References: <20100616223148.7f7bebc7@anubis.defcon1> Message-ID: You can only compile a complete module, with module declaration, exports and functions. So if a .hrl file contains all of this then it is possible to compile a .hrl file. This is usually how .hrl files are used though, they are generally used as include files. Robert On 16 June 2010 22:31, Jean-Yves F. Barbier <12ukwn@REDACTED> wrote: > Hi list, > > is it possible to compile .hrl files? > > -- > What if there had been room at the inn? > ? ? ? ? ? ? ? ?-- Linda Festa on the origins of Christianity > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From silent_vendetta@REDACTED Thu Jun 17 00:19:51 2010 From: silent_vendetta@REDACTED (Chris Hicks) Date: Wed, 16 Jun 2010 15:19:51 -0700 Subject: [erlang-questions] TCP clarification In-Reply-To: References: Message-ID: And can anyone tell me what the trick is to keeping things formatted when sending them. The stuff below had been laid out all nice and clean for easy reading when I sent it. > From: silent_vendetta@REDACTED > To: erlang-questions@REDACTED > Date: Wed, 16 Jun 2010 14:33:13 -0700 > Subject: [erlang-questions] TCP clarification > > > I'm going to be talking between two Erlang programs through a single port, no distributed Erlang for this project, and wanted to make sure I was thinking about things the right way. First I start listening on the port and spawn a worker process which will accept a connection on that port: > spawn_initial_worker(Port) -> case gen_tcp:listen(Port, [binary, {reuseaddr, true}, {packet, 0}, {active, false}]) of {ok, LSock} -> spawn(?MODULE, worker, [self(), LSock]), spawn_loop(LSock) end. > Yes I do want the above to crash if it can't listen. As the only communication gateway into this program if it can't listen there are problems. I then send it into the loop spawn_loop(LSock) which will continually spawn new workers to handle each new incoming connection (may increase to a larger pool of workers later if needed): > spawn_loop(LSock) -> receive next_worker -> spawn_link(?MODULE, worker, [self(), S]) end, spawn_loop(LSock). > This is the worker process: > worker(Server, LSock) -> case gen_tcp:accept(LSock) of {ok, Socket} -> Server ! next_worker, %%verify data integrity then spawn process to handle data {error, Reason} -> %%some sort of system logging code here to track problems end. > The way I understand it the Port is basically just an address where programs can thread any number of communications through. Each time gen_tcp:accept(LSock) is called a connection is made between the accepting process and the process on the "other" side trying to connect and send some data on that port. Once they do connect they are in an exclusive two-way communication that will be maintained until the connection is closed. Calling gen_tcp:close(Socket) will close that specific socket (the two-way communication between those two processes) while leaving all other active socket connections unaffected. I would also only need to call gen_tcp:close(Socket) once for any active socket, otherwise if I call it first from the sending process, then call it from the above worker process I would get an {error, Reason} response from the worker process. Is that a generally accurate understanding of how to use ports/sockets? > > _________________________________________________________________ > Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. > http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2 _________________________________________________________________ The New Busy is not the old busy. Search, chat and e-mail from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3 From per@REDACTED Thu Jun 17 00:33:49 2010 From: per@REDACTED (Per Hedeland) Date: Thu, 17 Jun 2010 00:33:49 +0200 (CEST) Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <3FFA3A18-FBE1-4C96-A03F-64EDDAEBB396@rogvall.se> Message-ID: <201006162233.o5GMXn98096412@pluto.hedeland.org> Tony Rogvall wrote: >Cool! >send is failing on subsequent send, but recv is not ???? This is strange >times. Erlang gen_udp:recv() is not failing. >Do you think this behavior is documented anywhere? 'man inet_drv' maybe? >A small C program may clear this issue for us ? A small C program (below) works perfectly: $ ./conn_udp recv: Connection refused I might point out that the "connect UDP socket in resolver code" trick was invented in BSD code at a point in time when not much else even *had* TCP/IP.:-) But inet_drv is "slightly" more complex than that program... >To get the {error, econnrefused} speed things up when trying servers >where DNS servers may have crashed. Yes, but it's not DNS-specific of course, it can be useful for any UDP-based protocol. >But in the general case, server may be down/burned, routers is >down/corrupt, this will not help since no one will send >the ICMP reply message on the network. True - and add to that misconfigured firewalls that drop all ICMP packets and there is probably not much usefulness left. Maybe just as a way to quickly find out if you are running a local server. --Per conn_udp.c--------------------------------------------- #include #include #include #include #include #include int error(char *str) { perror(str); exit(1); } int main() { struct sockaddr_in addr; int fd; char buf[1]; addr.sin_addr.s_addr = inet_addr("127.0.0.1"); addr.sin_family = AF_INET; addr.sin_port = htons(12345); buf[0] = 'x'; if ((fd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) error("socket"); if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) error("connect"); if (send(fd, buf, sizeof(buf), 0) < 0) error("send"); if (recv(fd, buf, sizeof(buf), 0) < 0) error("recv"); return 0; } From ok@REDACTED Thu Jun 17 05:16:52 2010 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 17 Jun 2010 15:16:52 +1200 Subject: [erlang-questions] hrl files In-Reply-To: <20100616223148.7f7bebc7@anubis.defcon1> References: <20100616223148.7f7bebc7@anubis.defcon1> Message-ID: <19FDA720-F24C-42EA-BA70-77D786497CC0@cs.otago.ac.nz> On Jun 17, 2010, at 8:31 AM, Jean-Yves F. Barbier wrote: > Hi list, > > is it possible to compile .hrl files? Whenever you compile a .erl file you are compiling the contents of any .hrl files it includes. If you mean something like "precompiled headers" from C land, the reason for that is that your typical C source file is 100 lines of code #including 20,000 lines of system headers. Erlang isn't _that_ bad, so there would be far less benefit from preprocessing .hrl files. From hokan.stenholm@REDACTED Thu Jun 17 04:57:46 2010 From: hokan.stenholm@REDACTED (=?UTF-8?B?SMOla2FuIFN0ZW5ob2xt?=) Date: Thu, 17 Jun 2010 04:57:46 +0200 Subject: [erlang-questions] utf-8 PB In-Reply-To: <20100616190718.7fee0aca@anubis.defcon1> References: <20100616165331.006cc602@anubis.defcon1> <201006161831.07124.clist@uah.es> <20100616190718.7fee0aca@anubis.defcon1> Message-ID: <4C198F2A.6040802@bredband.net> Jean-Yves F. Barbier wrote: > Le Wed, 16 Jun 2010 18:40:26 +0200, > Attila Rajmund Nohl a ?crit : > > At this moment, I don't know how to do that. > But I also read about internationalization and, AFAI understood, the > easiest way to accomplish that is to use macros and redirect toward the > directory & files according to the actual locale, is it the right way to do? > > >> As far as I know, an Erlang source file must use the latin-1 character >> set. So if you want UTF-8 strings, read them from a file. That's >> useful for a possible internationalization anyway. >> > > > > You can use gettext (http://github.com/etnt/gettext) for translations, usage in source code simple, although setting up gettext itself is a bit more work. Usage: * Add gettext to your project and build it. * Add code that start the gettext process and ensure that its loads its .po files (.po files are translation files that can be reloaded at any time). * Include the gettext.hrl file in your erl files if they need to do translations. * You can then use the TXT/1, TXT/2, STXT/2 and STXT/3 macors. * TXT/1 and STXT/2 rely on that process-dictionary value (gettext_language) being set in the current process, if you retrieve translated texts from other processes, you should ensure that they use the same language (or pass your current choice along). * TXT/2 and STXT/3 also take the language as an argument. ==================================================== Gettext using code will look like this: io:format("Hello world", []) becomes ?TXT("Hello world") while FN = "....", LN = "....", ?STXT("Good day $first_name$ $last_name$", [{first_name, FN}, {last_name, LN}]), which allows you to reorder your format strings ($...$) arguments, replace code like: io:format("Good day ~s ~s", [FN, LN]), which can't nicely handle needs like reordering the FN and LN arguments (in certain languages) and which yields format strings that are hard to understand for translators (they don't see what "~s ~s" is if they only have access to the po file). ==================================================== Notes: * Add TXT/STXT usage as soon as possible if you want to avoid unnecessary work of rewriting io:formats, supply good $...$ format values and want to reduce the risk of adding to many / to few TXT/STXT usages because your unsure if its needed. * It may be useful to write a run_in_language_context/2 function that takes a fun (the code to run) and a language to use while this fun is run - so that you change and revert the process-dictionary value (gettext_lamguage), without occasionally forgetting to change it back. * po files can be manipulated by the GNU Gettext command line tools. * Poedit may be useful for translators to translate * If there is no translation you will simply get your original (source code string back). * You should have a make build target (or tool) that can create a "master" po file, that contains the strings currently used by the TXT/STXT macros in the source code. This "master" file can then be merged with current (translated) po files using the GNU gettext tools. "gettext_compile:parse_transform/2" that processes the erlang parse tree looking for gettext:key2str/1 [a] calls and the "-compile({parse_transform,gettext_compile})." in gettext.hrl can be helpful for this. [a]: gettext:key2str/1 is the basis of all text macros - erlc parse trees have their macros expanded so you can't look directly for them. * The format string in TXT and STXT must be a "...." string in the source code, or the gettext_compile code will fail to extract it. * It's probably fairly easy to write a regexp that can extract the 'TXT("......"' parts, which should be faster than having to compile all files to create parse trees for use by gettext_compile. From litaocheng@REDACTED Thu Jun 17 06:29:16 2010 From: litaocheng@REDACTED (litao cheng) Date: Thu, 17 Jun 2010 12:29:16 +0800 Subject: Is it possible to add an filter property for the erlang process? Message-ID: hi, buddies. my question is if it's possible to add an "filter" property for the erlang process, so that process can drop the uninterested messages. then we can reduce the needless memory consuming. like this: % spawn a process with filter : {foo, _} PidA = spawn(?MODULE, do_something, [], [{filter, {foo, _}}]), % the message {foo, hello} will be saved to PidA message queue, because it match the filter PidA ! {foo, hello}, % this message will be dropped PidA ! {bar, world}, % reset the filter process_flag(filter, [_|_]), % this message will be stored in message queue PidA ! "hello world", ok. by this feature, I can write the code like this ( in my logging library, which is similar with python logging module): {ok, _} = logging:start_logger("logname"), Logger = logging:get_logger("logname"), Logger:set_level(?CRITICAL), Logger:debug("log"), Logger:warning("log"), Logger:critical("log"), ok logger is an parameterized module, logging is an gen_server process, in logging module: handle_call({set_level, Level}, _From, State) -> process_flag(filter, #log_record{level = MsgLevel} when MsgLevel > Level), {reply, ok, State}; in my logging library, I have two methods to resolve this problem: * dynamic compile the logger module, in the debug, info, warning, error function check if the log allowed * in logging gen_server process handl_xxx function, test if the log record is allowed all two solutions have flew. I want to known if this process filter feature is valuable? thanks From silent_vendetta@REDACTED Thu Jun 17 08:12:23 2010 From: silent_vendetta@REDACTED (Chris Hicks) Date: Wed, 16 Jun 2010 23:12:23 -0700 Subject: [erlang-questions] Is it possible to add an filter property for the erlang process? Message-ID: Can't you just do this with an _Other clause in your receive statement? So something along the lines of: receive{foo, Message} ->dosomethingfancyhere,loop(); _Other ->loop()end. > Date: Thu, 17 Jun 2010 12:29:16 +0800 > From: litaocheng@REDACTED > To: erlang-questions@REDACTED > Subject: [erlang-questions] Is it possible to add an filter property for the erlang process? > > hi, buddies. > my question is if it's possible to add an "filter" property for the erlang > process, so that process can drop the uninterested messages. then we can > reduce the needless memory consuming. > > like this: > % spawn a process with filter : {foo, _} > PidA = spawn(?MODULE, do_something, [], [{filter, {foo, _}}]), > > % the message {foo, hello} will be saved to PidA message queue, because it > match the filter > PidA ! {foo, hello}, > > % this message will be dropped > PidA ! {bar, world}, > > % reset the filter > process_flag(filter, [_|_]), > > % this message will be stored in message queue > PidA ! "hello world", > ok. > > by this feature, I can write the code like this ( in my logging library, > which is similar with python logging module): > {ok, _} = logging:start_logger("logname"), > Logger = logging:get_logger("logname"), > Logger:set_level(?CRITICAL), > Logger:debug("log"), > Logger:warning("log"), > Logger:critical("log"), > ok > > logger is an parameterized module, logging is an gen_server process, in > logging module: > handle_call({set_level, Level}, _From, State) -> > process_flag(filter, #log_record{level = MsgLevel} when MsgLevel > > Level), > {reply, ok, State}; > > in my logging library, I have two methods to resolve this problem: > * dynamic compile the logger module, in the debug, info, warning, error > function check if the log allowed > * in logging gen_server process handl_xxx function, test if the log record > is allowed > all two solutions have flew. > > I want to known if this process filter feature is valuable? > thanks _________________________________________________________________ Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1 From hans.bolinder@REDACTED Thu Jun 17 08:40:22 2010 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Thu, 17 Jun 2010 08:40:22 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: References: Message-ID: <19481.50006.967743.552477@ornendil.du.uab.ericsson.se> [Vlad Dumitrescu:] > A question about this entry in the readme file: > The Erlang scanner has been augmented with two new tokens: .. and .... > > Why and where are they used? They are used in types. A third token used in types only, '::', was introduced in R12B, I think, probably for technical reasons. Now it is possible to state an integer range as "1 .. 10" (with a space after '..'). Before R14A the second dot was scanned as a 'dot' token. Best regards, Hans Bolinder, Erlang/OTP team, Ericsson From vladdu55@REDACTED Thu Jun 17 08:59:32 2010 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 17 Jun 2010 08:59:32 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: <537999.42009.qm@web52902.mail.re2.yahoo.com> References: <537999.42009.qm@web52902.mail.re2.yahoo.com> Message-ID: On Wed, Jun 16, 2010 at 22:43, Shahrdad Shadab wrote: > I couldn't get Erlide working with it. It seems Erlide is having problem > with compiler options in the new release. I keep getting "malformed options (not erlang terms)" when I click on 'compiler' setting of Erlide. I tried to manually add compiler options ?but it didn't work. Hi! The problem is that R14 doesn't load beam files compiled with R11 anymore. A version of erlide that uses R12 as base will be available soon (hopefully today). regards, Vlad From chandrashekhar.mullaparthi@REDACTED Thu Jun 17 10:27:30 2010 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Thu, 17 Jun 2010 09:27:30 +0100 Subject: [erlang-questions] heart restarting erlang node In-Reply-To: References: Message-ID: Hi Tom, On 16 June 2010 15:11, tom kelly wrote: > Hi List, > > We're experiencing a weird problem here where our node seems to > spontaneously reboot. It looks like heart is causing it but we can't figure > out why. > > Have you had a look at the SASL logs? There might be crash reports leading up to the restart which might give clues. cheers Chandru From raimo+erlang-questions@REDACTED Thu Jun 17 11:28:35 2010 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 17 Jun 2010 11:28:35 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: References: Message-ID: <20100617092835.GA1782@erix.ericsson.se> The Github repository is now updated to the R14A release. http://github.com/erlang/otp Branches 'dev', 'master' as well as tag 'OTP_R14A' are right now the same. Yesterday I managed to push a not entirely ready 'master' and unfortunately tag 'OTP_R14A'. Sorry about that. To check if you have the correct OTP_R14A tag: git rev-parse OTP_R14A shall return 661e11f4d9af2392a1880d142b6d7372ea868920 and git rev-parse master shall return c1e94fa9a6fe4ae717d35dfbd1b628dc2e06d26a If not; you want to delete the old and get the new tag: git tag -d OTP_R14A git fetch tag OTP_R14A where often is 'origin'. Remember to fetch/merge/pull the updated 'master' branch too. Apologies for any inconvenience. On Wed, Jun 16, 2010 at 04:11:23PM +0200, Kenneth Lundin wrote: > Erlang/OTP R14A has been released. > This is a beta-release before the R14B release which is planned for > September 1:st. > > You can find the README file for the release at > > http://www.erlang.org/download/otp_src_R14A.readme > > The source distribution and binary distribution for Windows can be > downloaded from > > http://www.erlang.org/download/otp_src_R14A.tar.gz > http://www.erlang.org/download/otp_win32_R14A.exe > > The distribution can also be downloaded using the BitTorrent > protocol. Use the following torrent files to download the source > distribution and binary distribution for Windows: > > http://www.erlang.org/download/otp_src_R14A.tar.gz.torrent > http://www.erlang.org/download/otp_win32_R14A.exe.torrent > > Note: To unpack the TAR archive you need a GNU TAR compatible program. > > For installation instructions please read the README file that is part > of the distribution. > > The on-line documentation can be found at: http://www.erlang.org/doc/ > You can also download the complete HTML documentation or the Unix manual files > > http://www.erlang.org/download/otp_doc_html_R14A.tar.gz > http://www.erlang.org/download/otp_doc_man_R14A.tar.gz > > We also want to thank those that sent us patches, suggestions and bug > reports, > > The OTP Team > Kenneth Lundin, Erlang/OTP, Ericsson AB > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From ttom.kelly@REDACTED Thu Jun 17 11:49:45 2010 From: ttom.kelly@REDACTED (tom kelly) Date: Thu, 17 Jun 2010 10:49:45 +0100 Subject: [erlang-questions] heart restarting erlang node In-Reply-To: References: Message-ID: Hi Chandru, Our sasl log seems to have been over-written when the node restarted, so anything interesting there was lost, we'll update to catch this log if this re-occurs. We've found this post from Serge Aleynikov which we're investigating: http://www.erlang.org/pipermail/erlang-questions/2006-December/024365.html But I'm not yet sure it's the same issue. This can cause heart to restart our system but only after memory usage was sustained around 90% for 5-10 minutes which wasn't the case for all of our restarts. //Tom. On Thu, Jun 17, 2010 at 9:27 AM, Chandru < chandrashekhar.mullaparthi@REDACTED> wrote: > Hi Tom, > > On 16 June 2010 15:11, tom kelly wrote: > >> Hi List, >> >> We're experiencing a weird problem here where our node seems to >> spontaneously reboot. It looks like heart is causing it but we can't >> figure >> out why. >> >> > Have you had a look at the SASL logs? There might be crash reports leading > up to the restart which might give clues. > > cheers > Chandru > > From vladdu55@REDACTED Thu Jun 17 12:06:15 2010 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 17 Jun 2010 12:06:15 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: <537999.42009.qm@web52902.mail.re2.yahoo.com> References: <537999.42009.qm@web52902.mail.re2.yahoo.com> Message-ID: On Wed, Jun 16, 2010 at 22:43, Shahrdad Shadab wrote: > I couldn't get Erlide working with it. An updated erlide that is otherwise identical to 0.8.1 (but called 0.8.3) is now available at http://erlide.org/update best regards, Vlad From ulf.wiger@REDACTED Thu Jun 17 12:11:00 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 17 Jun 2010 12:11:00 +0200 Subject: [erlang-questions] DOWN record In-Reply-To: <857B4D56-18CB-4FB6-AD61-375F59C27F40@rogvall.se> References: <857B4D56-18CB-4FB6-AD61-375F59C27F40@rogvall.se> Message-ID: <4C19F4B4.6090806@erlang-solutions.com> I don't, but I can't explain why I don't... Are you getting ready to advocate a hrl file provided by OTP, listing record defs for common OTP messages, - #'DOWN'{} - #system{} - #'EXIT' - ... I would definitely support that. BR, Ulf W Tony Rogvall wrote: > Hi list. > > A quick survey. > > Are there more people than me that sometimes define the record: > > -record('DOWN', > { > ref, %% monitor reference > type, %% type of object 'process' > id, %% object id (pid) > reason %% reason for termination > }). > > ? > > To simplify matching of 'DOWN' messages ? > Example: > > handle_info(#'DOWN' { ref=Ref }, State) -> > ... > > > /Tony > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From chandrashekhar.mullaparthi@REDACTED Thu Jun 17 12:36:07 2010 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Thu, 17 Jun 2010 11:36:07 +0100 Subject: [erlang-questions] heart restarting erlang node In-Reply-To: References: Message-ID: Ok - we have a heart script which backups sasl_logfiles directory before restarting the node. You might want to consider doing something like that. Or increase the size of each logfile and the number of logfiles. cheers Chandru On 17 June 2010 10:49, tom kelly wrote: > Hi Chandru, > > Our sasl log seems to have been over-written when the node restarted, so > anything interesting there was lost, we'll update to catch this log if this > re-occurs. > > > We've found this post from Serge Aleynikov which we're investigating: > http://www.erlang.org/pipermail/erlang-questions/2006-December/024365.html > > But I'm not yet sure it's the same issue. This can cause heart to restart > our system but only after memory usage was sustained around 90% for 5-10 > minutes which wasn't the case for all of our restarts. > > //Tom. > > > > On Thu, Jun 17, 2010 at 9:27 AM, Chandru < > chandrashekhar.mullaparthi@REDACTED> wrote: > >> Hi Tom, >> >> On 16 June 2010 15:11, tom kelly wrote: >> >>> Hi List, >>> >>> We're experiencing a weird problem here where our node seems to >>> spontaneously reboot. It looks like heart is causing it but we can't >>> figure >>> out why. >>> >>> >> Have you had a look at the SASL logs? There might be crash reports >> leading up to the restart which might give clues. >> >> cheers >> Chandru >> >> > From thijsterlouw@REDACTED Thu Jun 17 13:01:54 2010 From: thijsterlouw@REDACTED (Thijs Terlouw) Date: Thu, 17 Jun 2010 19:01:54 +0800 Subject: Wrong large 64bit return-values from Erlang Linkedin Driver Message-ID: Hello, I'm trying to return signed 64bit integers (on a 32bit system) from a custom Erlang linkedin driver. I try to use the ERL_DRV_INT64 type on the C-side. Because ERL_DRV_INT64 requires a pointer to ErlDrvSInt64, I first malloc a buffer, store it there, get a pointer to the result and then return that pointer. For small values this works great. Whenever I use values >134217727 (0x7FFFFFF) it will return wrong values. I have gone over my own code many times and cannot find any bugs. Then I looked at the Erlang code, and it seems that inside the function erts_bld_sint64(Uint **hpp, Uint *szp, Sint64 si64) (erts/emulator/beam/utils.c) the value is checked: if smaller than this it will construct a regular integer, if bigger, it will go into the BigNum branch. On the Erlang side I use erl_ddll to load the driver and open several ports (spawn_driver). I do not believe there is any bug in my Erlang-side, because I use the same gen_linkedin_driver.erl module for several drivers. Is there a bug in the way Erlang handles the very large integers (long long in C-language)? Or am I making some mistakes? I saw they were quite new (ERTS 5.7.4). I am using : Erlang R13B04 (erts-5.7.5) [source] [smp:4:4] [rq:4] [async-threads:30] [hipe] [kernel-poll:true] Below is my test driver bignum.c with hardcoded test-value: ================== #include #include #define INIT_INT64_LEN 512 #define INIT_TERM_LEN 4096 int test_decode(ErlDrvPort port, char* buf, int len, char** rbuf, int rlen) { long long signed testvalue = 4294967296LL; // 2^32, fail //long long signed testvalue = 234LL; // this is OK //buffer to store the terms ErlDrvTermData* term_data; int term_length; int term_used; int resp; //temp buffer for my int64 data ErlDrvSInt64* int64_data; int int64_length; int int64_used; //init term-data term_data = (ErlDrvTermData*) malloc(INIT_TERM_LEN * sizeof(ErlDrvTermData)); if(term_data == NULL) goto done; term_length = INIT_TERM_LEN; term_used = 0; //init int64-data int64_data = (ErlDrvSInt64*) malloc(INIT_INT64_LEN * sizeof(ErlDrvSInt64)); if(int64_data == NULL) goto done; int64_length = INIT_INT64_LEN; int64_used = 0; int ret = -1; //add a large integer to the output term_data[term_used++] = ERL_DRV_INT64; int64_data[int64_used++] = (ErlDrvSInt64) testvalue; ErlDrvSInt64* pos = int64_data + (int64_used-1); term_data[term_used++] = (ErlDrvTermData) pos; //sanity check fprintf(stderr, "testvalue: %lld, pos: %ld, *pos: %lld\n", testvalue, pos, *pos); *rbuf = NULL; resp = driver_send_term( port, driver_caller(port), term_data, term_used ); if(resp == 1) ret = 0; if(term_data != NULL) free(term_data); if(int64_data != NULL) free(int64_data); done: return ret; } static ErlDrvData bignum_start(ErlDrvPort port, char *buff) { if(port == NULL) return ERL_DRV_ERROR_GENERAL; set_port_control_flags(port, PORT_CONTROL_FLAG_BINARY); return (ErlDrvData) port; } static int bignum_control( ErlDrvData drv_data, unsigned int command, char* buf, int len, char** rbuf, int rlen ) { switch(command) { case 0: return test_decode((ErlDrvPort) drv_data, buf, len, rbuf, rlen); default: return -1; } } static ErlDrvEntry bignum_driver_entry = { NULL, /* Init */ bignum_start, NULL, /* Stop */ NULL, /* Output */ NULL, /* Input Ready */ NULL, /* Output Ready */ "bignum_drv", /* Driver Name */ NULL, /* Finish */ NULL, /* Handle */ bignum_control, /* Control */ NULL, /* Timeout */ NULL, /* Outputv */ NULL, /* Ready Async */ NULL, /* Flush */ NULL, /* Call */ NULL, /* Event */ ERL_DRV_EXTENDED_MARKER, ERL_DRV_EXTENDED_MAJOR_VERSION, ERL_DRV_EXTENDED_MINOR_VERSION, ERL_DRV_FLAG_USE_PORT_LOCKING, NULL, /* Reserved */ NULL, /* Process Exit */ }; DRIVER_INIT(bignum_drv) /* must match name in driver_entry */ { return &bignum_driver_entry; } =============== From ulf.wiger@REDACTED Thu Jun 17 13:05:58 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 17 Jun 2010 13:05:58 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: <19481.50006.967743.552477@ornendil.du.uab.ericsson.se> References: <19481.50006.967743.552477@ornendil.du.uab.ericsson.se> Message-ID: <4C1A0196.5070304@erlang-solutions.com> Hans Bolinder wrote: > > Now it is possible to state an integer range as "1 .. 10" (with a > space after '..'). Before R14A the second dot was scanned as a 'dot' > token. So now we could introduce [1 .. 10] as syntactic sugar for lists:seq(1,10)? :) BR, Ulf W -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From vladdu55@REDACTED Thu Jun 17 13:42:02 2010 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 17 Jun 2010 13:42:02 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: <4C1A0196.5070304@erlang-solutions.com> References: <19481.50006.967743.552477@ornendil.du.uab.ericsson.se> <4C1A0196.5070304@erlang-solutions.com> Message-ID: On Thu, Jun 17, 2010 at 13:05, Ulf Wiger wrote: > Hans Bolinder wrote: >> >> Now it is possible to state an integer range as "1 .. 10" (with a >> space after '..'). Before R14A the second dot was scanned as a 'dot' >> token. > > So now we could introduce [1 .. 10] as syntactic sugar for > lists:seq(1,10)? ?:) Then it won't take long until someone suggests to allow [3, 7, 8..12, 23, 123..155, 88] ! regards, Vlad From 12ukwn@REDACTED Thu Jun 17 14:10:10 2010 From: 12ukwn@REDACTED (Jean-Yves F. Barbier) Date: Thu, 17 Jun 2010 14:10:10 +0200 Subject: [erlang-questions] utf-8 PB In-Reply-To: <4C198F2A.6040802@bredband.net> References: <20100616165331.006cc602@anubis.defcon1> <201006161831.07124.clist@uah.es> <20100616190718.7fee0aca@anubis.defcon1> <4C198F2A.6040802@bredband.net> Message-ID: <20100617141010.50f192f3@anubis.defcon1> Le Thu, 17 Jun 2010 04:57:46 +0200, H?kan Stenholm a ?crit : Thanks for this very complete howto H?kan!! Just one more precision: the way I understand it, I'll be able to translate any string I want AFAI use the syntax you gave me (?) Because I saw many project not written in Erlang where you can only translate some strings (ie: not the menu items, which could be very annoying if they don't speak English at all.) JY ... > You can use gettext (http://github.com/etnt/gettext) for translations, > usage in source code simple, although setting up gettext itself is a bit > more work. Usage: > > * Add gettext to your project and build it. > * Add code that start the gettext process and ensure that its loads its > .po files (.po files are translation files that can be reloaded at any > time). > > * Include the gettext.hrl file in your erl files if they need to do > translations. > * You can then use the TXT/1, TXT/2, STXT/2 and STXT/3 macors. > * TXT/1 and STXT/2 rely on that process-dictionary value > (gettext_language) being set in the current process, if you retrieve > translated texts from other processes, you should ensure that they use > the same language (or pass your current choice along). > * TXT/2 and STXT/3 also take the language as an argument. > > ==================================================== > > Gettext using code will look like this: > > io:format("Hello world", []) becomes ?TXT("Hello world") > > while > > FN = "....", > LN = "....", > ?STXT("Good day $first_name$ $last_name$", [{first_name, FN}, > {last_name, LN}]), > > which allows you to reorder your format strings ($...$) arguments, > replace code like: > > io:format("Good day ~s ~s", [FN, LN]), > > which can't nicely handle needs like reordering the FN and LN arguments > (in certain languages) and which yields format strings that are hard to > understand for translators (they don't see what "~s ~s" is if they only > have access to the po file). > > > ==================================================== > > Notes: > > * Add TXT/STXT usage as soon as possible if you want to avoid > unnecessary work of rewriting io:formats, supply good $...$ format > values and want to reduce the risk of adding to many / to few TXT/STXT > usages because your unsure if its needed. > > * It may be useful to write a run_in_language_context/2 function that > takes a fun (the code to run) and a language to use while this fun is > run - so that you change and revert the process-dictionary value > (gettext_lamguage), without occasionally forgetting to change it back. > > * po files can be manipulated by the GNU Gettext command line tools. > > * Poedit may be useful for translators to translate > > * If there is no translation you will simply get your original (source > code string back). > > * You should have a make build target (or tool) that can create a > "master" po file, that contains the strings currently used by the > TXT/STXT macros in the source code. This "master" file can then be > merged with current (translated) po files using the GNU gettext tools. > > "gettext_compile:parse_transform/2" that processes the erlang parse tree > looking for gettext:key2str/1 [a] calls and the > "-compile({parse_transform,gettext_compile})." in gettext.hrl can be > helpful for this. > > [a]: gettext:key2str/1 is the basis of all text macros - erlc parse > trees have their macros expanded so you can't look directly for them. > > * The format string in TXT and STXT must be a "...." string in the > source code, or the gettext_compile code will fail to extract it. > > * It's probably fairly easy to write a regexp that can extract the > 'TXT("......"' parts, which should be faster than having to compile all > files to create parse trees for use by gettext_compile. -- Health nuts are going to feel stupid someday, lying in hospitals dying of nothing. -- Redd Foxx From tony@REDACTED Thu Jun 17 13:15:15 2010 From: tony@REDACTED (Tony Rogvall) Date: Thu, 17 Jun 2010 13:15:15 +0200 Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <201006162233.o5GMXn98096412@pluto.hedeland.org> References: <201006162233.o5GMXn98096412@pluto.hedeland.org> Message-ID: <326E8C9A-A0AE-48E9-A1F7-4180A90F07CF@rogvall.se> On 17 jun 2010, at 00.33, Per Hedeland wrote: > Tony Rogvall wrote: >> Cool! >> send is failing on subsequent send, but recv is not ???? This is strange >> times. > > Erlang gen_udp:recv() is not failing. No, I meant it returned ok instead of {error, econnrefused} > >> Do you think this behavior is documented anywhere? > > 'man inet_drv' maybe? > > man inet_drv No manual entry for inet_drv I was thinking in terms of how to get connected UDP working on more than one platform. I have been testing a similar C program (as the one you write) on Linux and Darwin and think it is a bit confusing to say the least. If I test poll under Darwin (10.3.0) it will timeout, I have set the timeout to 5s and the timeout is early. So it is clearly a bug. ./cudp poll: timeout (too early) poll: revents=0 (poll under Darwin exist but is not very useful since it can only be used for sockets and pipes, also buggy ;-) if I run select under Darwin it will work as intended. BTW select is normally chosen as poll method for Darwin. ./cudp select: readable read:select:: Connection refused under Linux (2.6.32-22) select is also working. ./cudp select: readable read:select:: Connection refused Poll is also working but return only POLLERR in revents. ./cudp poll: revents=8 (POLLERR) read:poll:: Connection refused This may be the problem, I have not read erl_check_io.c in depth but someone may have ;-) >> A small C program may clear this issue for us ? > > A small C program (below) works perfectly: > > $ ./conn_udp > recv: Connection refused > > I might point out that the "connect UDP socket in resolver code" trick > was invented in BSD code at a point in time when not much else even > *had* TCP/IP.:-) > > But inet_drv is "slightly" more complex than that program... > >> To get the {error, econnrefused} speed things up when trying servers >> where DNS servers may have crashed. > > Yes, but it's not DNS-specific of course, it can be useful for any > UDP-based protocol. > >> But in the general case, server may be down/burned, routers is >> down/corrupt, this will not help since no one will send >> the ICMP reply message on the network. > > True - and add to that misconfigured firewalls that drop all ICMP > packets and there is probably not much usefulness left. Maybe just as a > way to quickly find out if you are running a local server. > > --Per > > conn_udp.c--------------------------------------------- > > #include > #include > #include > #include > #include > #include > > int error(char *str) > { > perror(str); > exit(1); > } > > int main() > { > struct sockaddr_in addr; > int fd; > char buf[1]; > > addr.sin_addr.s_addr = inet_addr("127.0.0.1"); > addr.sin_family = AF_INET; > addr.sin_port = htons(12345); > buf[0] = 'x'; > if ((fd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) > error("socket"); > if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) > error("connect"); > if (send(fd, buf, sizeof(buf), 0) < 0) > error("send"); > if (recv(fd, buf, sizeof(buf), 0) < 0) > error("recv"); > > return 0; > } cudp.c ---------------------------------------- // // Connected UDP test // #include #include #include #include // #define USE_SELECT // #define USE_POLL #ifdef USE_SELECT #include #endif #ifdef USE_POLL #include #endif #include #define TIMEOUT 5000 #define LOCAL_PORT 0 #define LOCAL_ADDR INADDR_ANY #define REMOTE_PORT 53 #define REMOTE_ADDR INADDR_LOOPBACK main() { struct sockaddr_in laddr; struct sockaddr_in raddr; int s; socklen_t len; char obuf[3]; char ibuf[3]; if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { perror("socket"); exit(1); } laddr.sin_family = AF_INET; laddr.sin_port = htons(LOCAL_PORT); laddr.sin_addr.s_addr = htonl(LOCAL_ADDR); len = sizeof(laddr); if (bind(s, (struct sockaddr*) &laddr, len) < 0) { perror("bind"); exit(1); } raddr.sin_family = AF_INET; raddr.sin_port = htons(REMOTE_PORT); raddr.sin_addr.s_addr = htonl(REMOTE_ADDR); len = sizeof(raddr); if (connect(s, (struct sockaddr*) &raddr, len) < 0) { perror("bind"); exit(1); } obuf[0] = 1; obuf[1] = 2; obuf[2] = 3; if (write(s, obuf, 3) < 0) { perror("write"); exit(1); } #ifdef USE_POLL { int n; struct pollfd fds[1]; fds[0].fd = s; fds[0].events = POLLIN; // |POLLOUT; fds[0].revents = 0; if ((n=poll(fds, 1, TIMEOUT)) < 0) { perror("poll"); exit(1); } if (n == 0) { fprintf(stderr, "poll: timeout\n"); fprintf(stderr, "poll: revents=%x\n", fds[0].revents); exit(1); } if (fds[0].revents & (POLLIN|POLLOUT|POLLERR)) { fprintf(stderr, "poll: revents=%x\n", fds[0].revents); if (read(s, ibuf, 3) < 0) { perror("read:poll:"); exit(1); } } else { fprintf(stderr, "poll: no event\n"); exit(1); } } #elif defined(USE_SELECT) { int n; fd_set readfds; fd_set writefds; fd_set errorfds; struct timeval timeout; FD_ZERO(&readfds); FD_SET(s, &readfds); FD_ZERO(&writefds); // FD_SET(s, &writefds); FD_ZERO(&errorfds); FD_SET(s, &errorfds); timeout.tv_sec = TIMEOUT / 1000; timeout.tv_usec = (TIMEOUT % 1000)*1000; if (select(s+1, &readfds, &writefds, &errorfds, &timeout) < 0) { perror("select"); exit(1); } if (n == 0) { fprintf(stderr, "select: timeout\n"); exit(1); } if (FD_ISSET(s, &readfds)) fprintf(stderr, "select: readable\n"); if (FD_ISSET(s, &writefds)) fprintf(stderr, "select: writable\n"); if (FD_ISSET(s, &errorfds)) fprintf(stderr, "select: error\n"); if (FD_ISSET(s, &readfds)) { if (read(s, ibuf, 3) < 0) { perror("read:select:"); exit(1); } } else { fprintf(stderr, "select: no event\n"); exit(1); } } #else if (read(s, ibuf, 3) < 0) { perror("read"); exit(1); } #endif close(s); exit(0); } From ulf.wiger@REDACTED Thu Jun 17 14:23:50 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 17 Jun 2010 14:23:50 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: References: <19481.50006.967743.552477@ornendil.du.uab.ericsson.se> <4C1A0196.5070304@erlang-solutions.com> Message-ID: <4C1A13D6.6070009@erlang-solutions.com> Vlad Dumitrescu wrote: > On Thu, Jun 17, 2010 at 13:05, Ulf Wiger wrote: >> Hans Bolinder wrote: >>> Now it is possible to state an integer range as "1 .. 10" (with a >>> space after '..'). Before R14A the second dot was scanned as a 'dot' >>> token. >> So now we could introduce [1 .. 10] as syntactic sugar for >> lists:seq(1,10)? :) > > Then it won't take long until someone suggests to allow [3, 7, 8..12, > 23, 123..155, 88] ! Not to mention [1 .. ] (an infinite list) :) The Best is the enemy of the Good... BR, Ulf W -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From sedrik@REDACTED Thu Jun 17 14:38:57 2010 From: sedrik@REDACTED (Fredrik Andersson) Date: Thu, 17 Jun 2010 14:38:57 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: References: <19481.50006.967743.552477@ornendil.du.uab.ericsson.se> <4C1A0196.5070304@erlang-solutions.com> <4C1A13D6.6070009@erlang-solutions.com> Message-ID: On Thu, Jun 17, 2010 at 2:23 PM, Ulf Wiger wrote: > Vlad Dumitrescu wrote: >> >> On Thu, Jun 17, 2010 at 13:05, Ulf Wiger >> wrote: >>> >>> Hans Bolinder wrote: >>>> >>>> Now it is possible to state an integer range as "1 .. 10" (with a >>>> space after '..'). Before R14A the second dot was scanned as a 'dot' >>>> token. >>> >>> So now we could introduce [1 .. 10] as syntactic sugar for >>> lists:seq(1,10)? ?:) >> >> Then it won't take long until someone suggests to allow [3, 7, 8..12, >> 23, 123..155, 88] ! > > Not to mention [1 .. ] (an infinite list) ? :) I think the correct syntax would be [1 .. char:rotate90(8)] of course you would have to supply the char:rotate90 function. (oops accidentally only responded to Ulf) > > The Best is the enemy of the Good... > > BR, > Ulf W > -- > Ulf Wiger > CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd > http://www.erlang-solutions.com > --------------------------------------------------- > > --------------------------------------------------- > > WE'VE CHANGED NAMES! > > Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG > SOLUTIONS LTD. > > www.erlang-solutions.com > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From mikpe@REDACTED Thu Jun 17 14:40:01 2010 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 17 Jun 2010 14:40:01 +0200 Subject: [erlang-questions] Wrong large 64bit return-values from Erlang Linkedin Driver In-Reply-To: References: Message-ID: <19482.6049.782805.700482@pilspetsen.it.uu.se> Thijs Terlouw writes: > Hello, > > I'm trying to return signed 64bit integers (on a 32bit system) from a > custom Erlang linkedin driver. I try to use the ERL_DRV_INT64 type on > the C-side. Because ERL_DRV_INT64 requires a pointer to ErlDrvSInt64, > I first malloc a buffer, store it there, get a pointer to the result > and then return that pointer. For small values this works great. > > Whenever I use values >134217727 (0x7FFFFFF) it will return wrong > values. I have gone over my own code many times and cannot find any > bugs. Then I looked at the Erlang code, and it seems that inside the > function erts_bld_sint64(Uint **hpp, Uint *szp, Sint64 si64) > (erts/emulator/beam/utils.c) the value is checked: if smaller than > this it will construct a regular integer, if bigger, it will go into > the BigNum branch. > > On the Erlang side I use erl_ddll to load the driver and open several > ports (spawn_driver). I do not believe there is any bug in my > Erlang-side, because I use the same gen_linkedin_driver.erl module for > several drivers. > > Is there a bug in the way Erlang handles the very large integers (long > long in C-language)? Or am I making some mistakes? I saw they were > quite new (ERTS 5.7.4). > > I am using : > Erlang R13B04 (erts-5.7.5) [source] [smp:4:4] [rq:4] > [async-threads:30] [hipe] [kernel-poll:true] > > Below is my test driver bignum.c with hardcoded test-value: > > ================== > #include > #include > > #define INIT_INT64_LEN 512 > #define INIT_TERM_LEN 4096 > > int > test_decode(ErlDrvPort port, char* buf, int len, char** rbuf, int rlen) > { > long long signed testvalue = 4294967296LL; // 2^32, fail > //long long signed testvalue = 234LL; // this is OK > > //buffer to store the terms > ErlDrvTermData* term_data; > int term_length; > int term_used; > int resp; > > //temp buffer for my int64 data > ErlDrvSInt64* int64_data; > int int64_length; > int int64_used; > > //init term-data > term_data = (ErlDrvTermData*) malloc(INIT_TERM_LEN * > sizeof(ErlDrvTermData)); > if(term_data == NULL) goto done; > term_length = INIT_TERM_LEN; > term_used = 0; > > //init int64-data > int64_data = (ErlDrvSInt64*) malloc(INIT_INT64_LEN * sizeof(ErlDrvSInt64)); > if(int64_data == NULL) goto done; > int64_length = INIT_INT64_LEN; > int64_used = 0; > > int ret = -1; > > //add a large integer to the output > term_data[term_used++] = ERL_DRV_INT64; > int64_data[int64_used++] = (ErlDrvSInt64) testvalue; > ErlDrvSInt64* pos = int64_data + (int64_used-1); > term_data[term_used++] = (ErlDrvTermData) pos; > > //sanity check > fprintf(stderr, "testvalue: %lld, pos: %ld, *pos: %lld\n", testvalue, > pos, *pos); > > *rbuf = NULL; > resp = driver_send_term( > port, > driver_caller(port), > term_data, > term_used > ); > if(resp == 1) ret = 0; > > if(term_data != NULL) free(term_data); > if(int64_data != NULL) free(int64_data); > done: > return ret; > } > > > static ErlDrvData > bignum_start(ErlDrvPort port, char *buff) > { > if(port == NULL) return ERL_DRV_ERROR_GENERAL; > set_port_control_flags(port, PORT_CONTROL_FLAG_BINARY); > return (ErlDrvData) port; > } > > static int > bignum_control( > ErlDrvData drv_data, > unsigned int command, > char* buf, > int len, > char** rbuf, > int rlen > ) > { > switch(command) > { > case 0: > return test_decode((ErlDrvPort) drv_data, buf, len, rbuf, rlen); > default: > return -1; > } > } > > static ErlDrvEntry > bignum_driver_entry = > { > NULL, /* Init */ > bignum_start, > NULL, /* Stop */ > NULL, /* Output */ > NULL, /* Input Ready */ > NULL, /* Output Ready */ > "bignum_drv", /* Driver Name */ > NULL, /* Finish */ > NULL, /* Handle */ > bignum_control, /* Control */ > NULL, /* Timeout */ > NULL, /* Outputv */ > NULL, /* Ready Async */ > NULL, /* Flush */ > NULL, /* Call */ > NULL, /* Event */ > ERL_DRV_EXTENDED_MARKER, > ERL_DRV_EXTENDED_MAJOR_VERSION, > ERL_DRV_EXTENDED_MINOR_VERSION, > ERL_DRV_FLAG_USE_PORT_LOCKING, > NULL, /* Reserved */ > NULL, /* Process Exit */ > }; > > DRIVER_INIT(bignum_drv) /* must match name in driver_entry */ > { > return &bignum_driver_entry; > } > > =============== Can you please provide a self-contained test? I.e., an Erlang module that loads your driver, invokes it, and checks the result? And whatever build instructions are needed for your driver. From ulf.wiger@REDACTED Thu Jun 17 14:48:47 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 17 Jun 2010 14:48:47 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: References: <19481.50006.967743.552477@ornendil.du.uab.ericsson.se> <4C1A0196.5070304@erlang-solutions.com> Message-ID: <4C1A19AF.9020906@erlang-solutions.com> Vlad Dumitrescu wrote: > On Thu, Jun 17, 2010 at 13:05, Ulf Wiger wrote: >> Hans Bolinder wrote: >>> Now it is possible to state an integer range as "1 .. 10" (with a >>> space after '..'). Before R14A the second dot was scanned as a 'dot' >>> token. >> So now we could introduce [1 .. 10] as syntactic sugar for >> lists:seq(1,10)? :) > > Then it won't take long until someone suggests to allow [3, 7, 8..12, > 23, 123..155, 88] ! Well, seriously though, I previously wrote a little parse_transform, ct_expand (part of http://github.com/esl/parse_trans), that could do compile-time evaluation of an expression, e.g. ct_expand:term(lists:seq(1,10)) would be expanded at compile-time to [1,2,3,4,5,6,7,8,9,10]. For this particular example, it is of course of little use, since it is harder to understand and 9 keystrokes longer, but Paul Mineiro provided a much better use case in this blog post: http://dukesoferl.blogspot.com/2009/08/metaprogramming-with-ctexpand.html As long as a construct like [1,2,3 .. 10,11] would contain only constant terms, it could be expanded at compile-time. If not, it should perhaps be treated much like "foo" ++ Suffix, which is allowed, whereas Prefix ++ "foo" is a legal constructor, but not a legal pattern. I think it is perfectly reasonable to disallow that for starters, until someone provides an implementation that handles it in a complete and predictable way. In the case where it is a constant list, the expansion is entirely straightforward and improves readability significantly. It is also a pattern used in other languages, and given that it is allowed in type specs (implying that people are still expected to understand what it means), it makes sense to allow it also in code. EEP time? Personally, I don't have the time right now. BR, Ulf W -- Ulf Wiger CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From vladdu55@REDACTED Thu Jun 17 15:05:12 2010 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 17 Jun 2010 15:05:12 +0200 Subject: [erlide] Dropped support for R11 Message-ID: Hi, Version 0.8.1.201005250801 is the last to support R11, unless it will be required by enough users (or payed for with enough beers!). This is because R14 can no longer load R11 beam files and we don't have resources to keep two tracks alive. I have warned for that for some time ago and nobody protested, so I hope nobody will this time either. Version 0.8.3.201006171129 is functionally identical except that the Erlang code is compiled with R12. Unstable and nightly builds will be numbered 0.8.4 and onwards when they are updated to R12. regards, Vlad From ulf.wiger@REDACTED Thu Jun 17 15:30:48 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 17 Jun 2010 15:30:48 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: References: Message-ID: <4C1A2388.8010803@erlang-solutions.com> On 06/16/2010 04:11 PM, Kenneth Lundin wrote: > Erlang/OTP R14A has been released. > This is a beta-release before the R14B release which is planned for > September 1:st. > > You can find the README file for the release at > > http://www.erlang.org/download/otp_src_R14A.readme --- kernel-2.13.5.3 ------------------------------------------- OTP-8686 A bug introduced in kernel-2.13.5.3 has been fixed. Cool. :) --- mnesia-4.4.14 --------------------------------------------- OTP-8519 Added mnesia:subscribe(activity) contributed by Bernard Duggan. Given that my patches for schema merging and overload sampling were graduated, I had to dive into the code to verify that they were, in fact, part of OTP R14A. They are - just not mentioned in the release notes. Lots of good stuff in this release, and great to see so many contributions from the community. Congrats to us all! :) BR, Ulf W --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From zabrane3@REDACTED Thu Jun 17 15:45:33 2010 From: zabrane3@REDACTED (zabrane Mikael) Date: Thu, 17 Jun 2010 15:45:33 +0200 Subject: Reliable way to handle Java node crashs? Message-ID: Hi List, I've a java node waiting for some "data messages" from an Erlang node. As soon as a "data message" arrives, it gets processed by this Java node (very intensive data processing). Occasionally, this Java node crashes during the processing phase and the Erlang node never gets back any response. All my system hangup. The Erlang part can send only one message at any time and must wait for a response before sending the next one (this is my current design of the system) to the Java node. Questions: 1. How can i start my "Java node" automatically from within Erlang? Currently, I'm running the Java node manually on a separate shell, wait for it to open its mailbox. Then, i run the Erlang code in another shell. This is a real nightmare to handle the "restarts" manually when the Java node crashes. 2. What's the best way to robustify my Java node so it'll never stop even after a crash? The ideal for me is to get it send back an {error, Reason} message to Erlang node and wait for a next message to process. Code snippet will be very welcome guys ! Thanks in advance -- Regards Zabrane From g@REDACTED Thu Jun 17 16:10:19 2010 From: g@REDACTED (Garrett Smith) Date: Thu, 17 Jun 2010 09:10:19 -0500 Subject: [erlang-questions] Reliable way to handle Java node crashs? In-Reply-To: References: Message-ID: Hi Zanrane, On Thu, Jun 17, 2010 at 8:45 AM, zabrane Mikael wrote: > Hi List, > > I've a java node waiting for some "data messages" from an Erlang node. > As soon as a "data message" arrives, it gets processed by this Java node > (very intensive data processing). > Occasionally, this Java node crashes during the processing phase and the > Erlang node never gets back any response. All my system hangup. > The Erlang part can send only one message at any time and must wait for a > response before sending the next one (this is my current design of the > system) > to the Java node. > > Questions: > 1. How can i start my "Java node" automatically from within Erlang? > Currently, I'm running the Java node manually on a separate shell, wait for > it to open > its mailbox. Then, i run the Erlang code in another shell. This is a real > nightmare to handle the "restarts" manually when the Java node crashes. Why not launch the Java process from an Erlang supervisor and monitor its process with a port? I haven't worked with Java based Erlang nodes myself -- I use the port interface, which has worked very well. You need to deal with mashalling message payload, but I imagine Erlang's Java library provides some help there. If not, there's the standby of Json, XML, CSV, etc. > 2. What's the best way to robustify my Java node so it'll never stop even > after a crash? The ideal for me is to get it send back an {error, Reason} > message > to Erlang node and wait for a next message to process. If you supervise the external (system) process via an Erlang port, you'll get the restart behavior that recovers the Java app on a crash. If you take this approach, you'll want to "crash" your Java process on unhandled errors (i.e. System.exit() to terminate the process). The supervisor monitoring the port will detect this and restart the Java app (via the port) as per its restart spec. > Code snippet will be very welcome guys ! > > Thanks in advance > -- > Regards > Zabrane > Garrett From ulf.wiger@REDACTED Thu Jun 17 16:13:47 2010 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 17 Jun 2010 16:13:47 +0200 Subject: [erlang-questions] Erlang/OTP R14A has been released In-Reply-To: References: Message-ID: <4C1A2D9B.1000006@erlang-solutions.com> On 06/16/2010 04:11 PM, Kenneth Lundin wrote: > Erlang/OTP R14A has been released. > This is a beta-release before the R14B release which is planned for > September 1:st. > > You can find the README file for the release at > > http://www.erlang.org/download/otp_src_R14A.readme --- xmerl-1.2.5 ------------------------------------------------- OTP-8537 All Erlang files are now built by the test server instead of the test directory Makefile. Erlang files in data directories are now built by the test suites instead of using prebuilt versions under version control. Does this refer to the xmerl test suites? If so, let me just point out that they haven't yet been released. ;-) I know that releasing the test suites is an ongoing process. Perhaps it was your intention to include the xmerl test suites in this release? BR, Ulf W --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From kenrobinsonster@REDACTED Thu Jun 17 16:15:35 2010 From: kenrobinsonster@REDACTED (Ken Robinson) Date: Fri, 18 Jun 2010 00:15:35 +1000 Subject: [erlang-questions] gen_fsm crashes In-Reply-To: References: Message-ID: Problem solved. It's me :) The man page of gen_fsm read in part: ... If the function returns {next_state,NextStateName,NewStateData}, {next_state,NextStateName,NewStateData,Timeout} or {next_state,NextStateName,NewStateData,hibernate} ... What I was doing was providing 4 instead of 3 parameters which meant it thought I was now providing a timeout value. Because the value is a nonsense timeout value (an empty list along with the function), it comes up with "bad receive timeout value". Ken. On Thu, Jun 17, 2010 at 12:36 AM, Ken Robinson wrote: > Hi All, > > I decided to do trace on all the calls in gen_fsm with my state > machine code transport_tx_fsm.erl (which goes from state sending to > sending, it's in the standard I'm implementing). > As I do not have a timeout on the gen_fsm it should used inifinity as > the timeout value on the loop. > > Early on it does and enters the loop appropriately: > (<0.92.0>) call > gen_fsm:loop(<0.89.0>,transport_tx_fsm,sending,[],transport_tx_fsm,infinity,[{statistics,{{{2010,6,16},{23,31,51}},{reductions,29},0,0}}, > ?{log,{10,[]}}, > ?{trace,true}]) > ok > > I get it to do some work via a test and then it appears to want to go > back into the loop with the timeout value infinity: > (<0.92.0>) call gen_fsm:handle_msg({'$gen_event',{send,{sendrec,<<"?">>, > ?... > > <<1,1>>}}},<0.89.0>,transport_tx_fsm,sending,[],transport_tx_fsm,infinity,[{statistics,{{{2010,6,16},{23,31,51}}, > ?... > ?{trace,true}]) > > Unfortunately it appears to crash when the code tries to enter the > loop with the timeout value which is is a tuple: > (<0.92.0>) call > gen_fsm:loop(<0.89.0>,transport_tx_fsm,sending,{send,{sendrec,undefined,undefined,undefined,undefined,undefined,undefined, > ? ? ? ? ? ? ? undefined,1,undefined}},transport_tx_fsm,{[],#Fun},[{statistics,{{{2010,6,16},{23,31,51}}, > ... > ?{trace,true}]) > > This appears to cause the error: > =CRASH REPORT==== 16-Jun-2010::23:32:09 === > ?crasher: > ? ?initial call: transport_tx_fsm:init/1 > ? ?pid: <0.92.0> > ? ?registered_name: transport_tx_fsm > ? ?exception error: bad receive timeout value > ? ? ?in function ?gen_fsm:loop/7 > ... > > It then restarts using my supervisor. > > Is this a known bug or should I add some debug info to better track > down this error? Would adding timeout fix this problem. > Ken. > > > > On Wed, Jun 9, 2010 at 12:12 AM, Ken Robinson wrote: >> Hi All, >> Inspecting the gen_fsm.erl code from std_lib, it has a main >> loop(Parent, Name, StateName, StateData, Mod, Timeout, Debug) method. >> Appears one can have a bad receive timeout value. Need to now see what >> is a good way to track down that value. I see that Debug has options >> like trace and log. I am now trying to start up the application so >> these Debug options are active. >> Ken. >> >> On Tue, Jun 1, 2010 at 11:55 PM, kenrobinson wrote: >>> Hi All, >>> This being my first post to this list, please feel free to correct any >>> mistakes I make on the group ?etiquette on posts. >>> >>> I am running a supervisor which uses the standard restart strategy. >>> Here is a snippet from my .app file covering the gen_fsm which >>> crashes. >>> >>> ?{transport_tx_fsm, %% tag >>> ? {transport_tx_fsm, start_link, []}, >>> ? permanent, >>> ? 10000, >>> ? worker, >>> ? [transport_tx_fsm]}, >>> >>> >>> I start up using the following command line: >>> erl -pa test ebin priv -sname ken1 -boot start_sasl >>> >>> I load using application:load(jaus) and application:start(jaus). It >>> starts correctly. >>> >>> I also load some test code using l(transport_tx_fsm_test) and fire off >>> a message to transport_tx_fsm. Test code is sent to it like so: >>> ? ?gen_fsm:send_event(transport_tx_fsm, {send, SR}), >>> >>> After it crashes, it appears to restart and process the message (see >>> below). >>> >>> My question is what does the bad timeout value signify where I haven't >>> started the gen_fsm with a timeout value? >>> regards, >>> Ken >>> >>> =CRASH REPORT==== 30-May-2010::23:54:53 === >>> ?crasher: >>> ? ?initial call: transport_tx_fsm:init/1 >>> ? ?pid: <0.103.0> >>> ? ?registered_name: transport_tx_fsm >>> ? ?exception error: bad receive timeout value >>> ? ? ?in function ?gen_fsm:loop/7 >>> ? ?ancestors: [jaus_supervisor,<0.53.0>] >>> ? ?messages: [] >>> ? ?links: [<0.61.0>] >>> ? ?dictionary: [] >>> ? ?trap_exit: false >>> ? ?status: running >>> ? ?heap_size: 377 >>> ? ?stack_size: 24 >>> ? ?reductions: 476 >>> ?neighbours: >>> >>> =SUPERVISOR REPORT==== 30-May-2010::23:54:53 === >>> ? ? Supervisor: {local,jaus_supervisor} >>> ? ? Context: ? ?child_terminated >>> ? ? Reason: ? ? timeout_value >>> ? ? Offender: ? [{pid,<0.103.0>}, >>> ? ? ? ? ? ? ? ? ?{name,transport_tx_fsm}, >>> ? ? ? ? ? ? ? ? ?{mfa,{transport_tx_fsm,start_link,[]}}, >>> ? ? ? ? ? ? ? ? ?{restart_type,permanent}, >>> ? ? ? ? ? ? ? ? ?{shutdown,10000}, >>> ? ? ? ? ? ? ? ? ?{child_type,worker}] >>> >>> 23:54:53.896740 2010-05-30 [info] Called init message in >>> transport_tx_fsm >>> >>> 23:54:53.896821 2010-05-30 [info] handle_info udp args >>> ClientSocket #Port<0.1353> >>> ?Host ? ? ? ? {127,0,0,1} >>> Port ? ? ? ? 47761 >>> Data ? ? ? ? <<2,0,128,0,192,3,2,1,0,6,5,64,0,1,1,19,0>> >>> State ? ? ? ?{state} >>> >>> >>> =PROGRESS REPORT==== 30-May-2010::23:54:53 === >>> ? ? ? ? ?supervisor: {local,jaus_supervisor} >>> ? ? ? ? ? ? started: [{pid,<0.105.0>}, >>> ? ? ? ? ? ? ? ? ? ? ? {name,transport_tx_fsm}, >>> ? ? ? ? ? ? ? ? ? ? ? {mfa,{transport_tx_fsm,start_link,[]}}, >>> ? ? ? ? ? ? ? ? ? ? ? {restart_type,permanent}, >>> ? ? ? ? ? ? ? ? ? ? ? {shutdown,10000}, >>> ? ? ? ? ? ? ? ? ? ? ? {child_type,worker}] >>> 23:54:53.901490 2010-05-30 [info] unwrap arg >>> <<2,0,128,0,192,3,2,1,0,6,5,64,0,1,1,19,0>> >>> >>> ________________________________________________________________ >>> erlang-questions (at) erlang.org mailing list. >>> See http://www.erlang.org/faq.html >>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>> >>> >> > From zabrane3@REDACTED Thu Jun 17 16:59:34 2010 From: zabrane3@REDACTED (zabrane Mikael) Date: Thu, 17 Jun 2010 16:59:34 +0200 Subject: [erlang-questions] Reliable way to handle Java node crashs? In-Reply-To: References: Message-ID: Thanks guys for the advices. 2010/6/17 Robert Raschke > I kick off the Java node as a monitored port from within Erlang. That > way I am in control of starting, noticing crashes, and restarting. I > also have the port set up so that messages written to stdout in the > Java node feed into the logging in Erlang. > > If you want I can dig out some example code when I'm back in the > office next week. > Robert, I'll be more than happy to read some code! Thanks -- Regards Zabrane From g@REDACTED Thu Jun 17 17:00:12 2010 From: g@REDACTED (Garrett Smith) Date: Thu, 17 Jun 2010 10:00:12 -0500 Subject: Java version of erlport Message-ID: I've been working with erlport: http://github.com/hdima/erlport which is a terrific way to implement Python based port apps. It's primary functions: - Handle the request/response loop via stdout - Marshal message payload: Erlang terms <-> Python - Dispatch inbound messages to handler functions using a simple naming convention Is anyone aware of a Java library that does something similar? I understand that the com.ericsson.otp.erlang package can be used to implement full fledged Java based nodes, complete with hook up to epmd, etc. But that's a bit much for my needs. I'd rather have a simple mapping library that made Java based port apps easier to build. Garrett From info@REDACTED Thu Jun 17 18:03:20 2010 From: info@REDACTED (info) Date: Thu, 17 Jun 2010 18:03:20 +0200 Subject: scan rows from a database Message-ID: <201006171803198654366@its3.ch> Hi all, I want to select several rows from a database and execute one function for each row. {selected,Cols,Rows} = odbc(Con,Query), How to scan in a "loop" all returned rows ? could you suggest me answers ? John From bengt.kleberg@REDACTED Thu Jun 17 18:31:53 2010 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 17 Jun 2010 18:31:53 +0200 Subject: [erlang-questions] scan rows from a database In-Reply-To: <201006171803198654366@its3.ch> References: <201006171803198654366@its3.ch> Message-ID: <1276792313.5106.33.camel@seasc1137> Greetings, Is this what you want? {selected,_Cols,Rows} = odbc(Con,Query), Results = [scan(Row) || Row <- Rows], bengt On Thu, 2010-06-17 at 18:03 +0200, info wrote: > Hi all, > I want to select several rows from a database and execute one function for each row. > > {selected,Cols,Rows} = odbc(Con,Query), > > How to scan in a "loop" all returned rows ? could you suggest me answers ? > > John From info@REDACTED Thu Jun 17 19:13:36 2010 From: info@REDACTED (info) Date: Thu, 17 Jun 2010 19:13:36 +0200 Subject: [erlang-questions] scan rows from a database References: <201006171803198654366@its3.ch>, <1276792313.5106.33.camel@seasc1137> Message-ID: <201006171913359597803@its3.ch> As newbie, could you describe what you wrote ... I thought something like that: lists:map(fun(R)->the_function end, Rows) Is it equivalent ? Greetings, Is this what you want? {selected,_Cols,Rows} = odbc(Con,Query), Results = [scan(Row) || Row <- Rows], bengt On Thu, 2010-06-17 at 18:03 +0200, info wrote: > Hi all, > I want to select several rows from a database and execute one function for each row. > > {selected,Cols,Rows} = odbc(Con,Query), > > How to scan in a "loop" all returned rows ? could you suggest me answers ? > > John ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED From jesper.louis.andersen@REDACTED Thu Jun 17 19:15:50 2010 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Thu, 17 Jun 2010 19:15:50 +0200 Subject: [erlang-questions] scan rows from a database In-Reply-To: <201006171913359597803@its3.ch> References: <201006171803198654366@its3.ch> <1276792313.5106.33.camel@seasc1137> <201006171913359597803@its3.ch> Message-ID: On Thu, Jun 17, 2010 at 7:13 PM, info wrote: > As newbie, could you describe what you wrote ... > I thought something like that: > > lists:map(fun(R)->the_function end, Rows) > > Is it equivalent ? Yes, see the part on list comprehensions in the manual. -- J. From info@REDACTED Thu Jun 17 19:27:57 2010 From: info@REDACTED (info) Date: Thu, 17 Jun 2010 19:27:57 +0200 Subject: [erlang-questions] scan rows from a database References: <201006171803198654366@its3.ch>, <1276792313.5106.33.camel@seasc1137>, <201006171913359597803@its3.ch>, Message-ID: <201006171927572257244@its3.ch> In case of errors in "the_function", how to exit ? On Thu, Jun 17, 2010 at 7:13 PM, info wrote: > As newbie, could you describe what you wrote ... > I thought something like that: > > lists:map(fun(R)- >the_function end, Rows) > > Is it equivalent ? Yes, see the part on list comprehensions in the manual. -- J. ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED From kiszl@REDACTED Thu Jun 17 19:28:36 2010 From: kiszl@REDACTED (Zoltan Lajos Kis) Date: Thu, 17 Jun 2010 19:28:36 +0200 Subject: Enforcing a function spec in Dialyzer Message-ID: <4C1A5B44.3090604@tmit.bme.hu> Hi all, Is it possible to enforce Dialyzer to use the spec I provide for a function instead of deducting the specification from the function body? For example in the example below I would like to force my spec on the data() function, making Dialyzer stop issuing warnings about lists:keyfind always returning false, get(Key) always returning 'undefined', and so on... (The rational behind the question is that I rebuild the module every now and then, so calling the data() function will actually return a list of key-value pairs later.) Thank you, Zoltan. ---------------------- -spec( get(atom()) -> any() ). get(Key) -> case lists:keyfind(Key, 1, data()) of {Key, Val} -> Val; false -> 'undefined' end. -spec( data() -> [{atom(), any()}] ). data() -> []. From hokan.stenholm@REDACTED Thu Jun 17 19:49:03 2010 From: hokan.stenholm@REDACTED (=?UTF-8?B?SMOla2FuIFN0ZW5ob2xt?=) Date: Thu, 17 Jun 2010 19:49:03 +0200 Subject: [erlang-questions] utf-8 PB In-Reply-To: <20100617141010.50f192f3@anubis.defcon1> References: <20100616165331.006cc602@anubis.defcon1> <201006161831.07124.clist@uah.es> <20100616190718.7fee0aca@anubis.defcon1> <4C198F2A.6040802@bredband.net> <20100617141010.50f192f3@anubis.defcon1> Message-ID: <4C1A600F.8010506@bredband.net> Jean-Yves F. Barbier wrote: > Le Thu, 17 Jun 2010 04:57:46 +0200, > H?kan Stenholm a ?crit : > > Thanks for this very complete howto H?kan!! > > Just one more precision: the way I understand it, I'll be able to > translate any string I want AFAI use the syntax you gave me (?) > > Because I saw many project not written in Erlang where you can > only translate some strings (ie: not the menu items, which could be very > annoying if they don't speak English at all.) > The idea is to autoextract all text (format strings) used by the TXT/STXT macros (no other strings), when building a "master" po-file, so you have full control over which texts will be translatable. Or putting it another way, only the TXT/STXT macros that use texts existing in a language specific po (translation) file will be translated. This also implies that only texts in the erl/hrl files will be extracted as this is the only place that the macros can exist. As texts are extracted per file it is also possible to limit which files are checked. Example, a po file that translates English to Swedish will have entries like this: msgid "" <----- meta data and encoding header msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: 2010-06-17 16:45+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-1\n" "Content-Transfer-Encoding: 8bit\n" msgid "Hello $name$!" <----- Text used in source code e.g. ?STXT("Hello $name$", [.....]) Extracted by gettext_compile.erl related code msgstr "Hej $name$!" <----- Text (format string) used. The same as msgid when extracted, but then translated by a translator. If $name$ is = "World" the STXT call will return "Hej World!" Note: the format string is translated before it is processed ($...$ values are substituted) by STXT. ...... Note: it is a good idea to ensure that the source code only uses ONE language, the msgid:s in the po files will otherwise be in a mix of languages. ============================== Warning: I've only used gettext with languages that can be used with latin-1 encode characters (Swedish, Danish, Finnish, Norwegian, English), for languages that need more than the first 256 unicode code points (these are identical to the latin-1 values of the same number) there may be issues. The po file format supports various character encodings - latin-1, utf-8 (encoding unicode code points as variable length byte sequences) ... , but I'm not sure if gettext will parse utf-8 encoded po files properly - it may need code to check the encoding (listed at the start of the po file as shown above) to convert the utf-8 byte sequences to single integers (unicode code points). The best thing to do is to test what you get back from gettext when using utf-8 encoded po files. Note: the GNU Gettext tools can compile po files to other non-text formats (.mo files) and tools like Poedit sometimes create them - but they arent' used (or needed) by the erlang gettext library, as it works directly with the .po file. Note: there is po file validation code in gettext to avoid bugs like: msgid "Hello $name$!" msgstr "Hej World!" > JY > > ... > >> You can use gettext (http://github.com/etnt/gettext) for translations, >> usage in source code simple, although setting up gettext itself is a bit >> more work. Usage: >> >> * Add gettext to your project and build it. >> * Add code that start the gettext process and ensure that its loads its >> .po files (.po files are translation files that can be reloaded at any >> time). >> >> * Include the gettext.hrl file in your erl files if they need to do >> translations. >> * You can then use the TXT/1, TXT/2, STXT/2 and STXT/3 macors. >> * TXT/1 and STXT/2 rely on that process-dictionary value >> (gettext_language) being set in the current process, if you retrieve >> translated texts from other processes, you should ensure that they use >> the same language (or pass your current choice along). >> * TXT/2 and STXT/3 also take the language as an argument. >> >> ==================================================== >> >> Gettext using code will look like this: >> >> io:format("Hello world", []) becomes ?TXT("Hello world") >> >> while >> >> FN = "....", >> LN = "....", >> ?STXT("Good day $first_name$ $last_name$", [{first_name, FN}, >> {last_name, LN}]), >> >> which allows you to reorder your format strings ($...$) arguments, >> replace code like: >> >> io:format("Good day ~s ~s", [FN, LN]), >> >> which can't nicely handle needs like reordering the FN and LN arguments >> (in certain languages) and which yields format strings that are hard to >> understand for translators (they don't see what "~s ~s" is if they only >> have access to the po file). >> >> >> ==================================================== >> >> Notes: >> >> * Add TXT/STXT usage as soon as possible if you want to avoid >> unnecessary work of rewriting io:formats, supply good $...$ format >> values and want to reduce the risk of adding to many / to few TXT/STXT >> usages because your unsure if its needed. >> >> * It may be useful to write a run_in_language_context/2 function that >> takes a fun (the code to run) and a language to use while this fun is >> run - so that you change and revert the process-dictionary value >> (gettext_lamguage), without occasionally forgetting to change it back. >> >> * po files can be manipulated by the GNU Gettext command line tools. >> >> * Poedit may be useful for translators to translate >> >> * If there is no translation you will simply get your original (source >> code string back). >> >> * You should have a make build target (or tool) that can create a >> "master" po file, that contains the strings currently used by the >> TXT/STXT macros in the source code. This "master" file can then be >> merged with current (translated) po files using the GNU gettext tools. >> >> "gettext_compile:parse_transform/2" that processes the erlang parse tree >> looking for gettext:key2str/1 [a] calls and the >> "-compile({parse_transform,gettext_compile})." in gettext.hrl can be >> helpful for this. >> >> [a]: gettext:key2str/1 is the basis of all text macros - erlc parse >> trees have their macros expanded so you can't look directly for them. >> >> * The format string in TXT and STXT must be a "...." string in the >> source code, or the gettext_compile code will fail to extract it. >> >> * It's probably fairly easy to write a regexp that can extract the >> 'TXT("......"' parts, which should be faster than having to compile all >> files to create parse trees for use by gettext_compile. >> > > > > From 12ukwn@REDACTED Thu Jun 17 21:11:11 2010 From: 12ukwn@REDACTED (Jean-Yves F. Barbier) Date: Thu, 17 Jun 2010 21:11:11 +0200 Subject: compiler abnormal msg? Message-ID: <20100617211111.70d969a6@anubis.defcon1> Debian sid Athlon XP2600+ =============== Hi list, I just compiled and installed RB14 with the following options: --enable-threads \ --enable-smp-support \ --enable-kernel-poll \ --enable-hipe \ --enable-megaco-flex-scanner \ --enable-dynamic-ssl-lib \ --with-ssl=/usr/include/openssl \ --enable-m32-build \ --enable-lock-checking \ --enable-sctp but when I try to recompile wxErlang/demo (make:all().), I've got a warning for each file !? Such as: ./ex_cursor.erl:none: Warning: this system is not configured for native-code compilation. Does it mean my compilation was "normal" instead of hipe (or something else)? JY -- Think sideways! -- Ed De Bono From per@REDACTED Thu Jun 17 22:19:20 2010 From: per@REDACTED (Per Hedeland) Date: Thu, 17 Jun 2010 22:19:20 +0200 (CEST) Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <326E8C9A-A0AE-48E9-A1F7-4180A90F07CF@rogvall.se> Message-ID: <201006172019.o5HKJKZc029818@pluto.hedeland.org> Tony Rogvall > >On 17 jun 2010, at 00.33, Per Hedeland wrote: > >> Tony Rogvall wrote: >>> Cool! >>> send is failing on subsequent send, but recv is not ???? This is strange >>> times. >> >> Erlang gen_udp:recv() is not failing. > >No, I meant it returned ok instead of {error, econnrefused} > Yes - I meant that it's gen_udp:recv() that is not failing (which it should), as opposed to recv(2) not failing. >> man inet_drv >No manual entry for inet_drv Wow, really?:-) >I was thinking in terms of how to get connected UDP working on more than >one platform. Oh, I think it (i.e. with gen_udp) works on most of them - you already verified on Darwin (AFAIK the VM uses select() there), and now I tried Linux, Solaris, QNX(!) - and NetBSD... - works fine on all of them. That last one had me a little surprised actually, so I also tried a different build (of R13B03-ish) on FreeBSD - and that works fine too! I.e. it seems this is actually a problem with the FreeBSD "port" build of Erlang/OTP (I happened to have such a build of R12B-5 around too - same problem there). Sorry for the noise. FWIW, as you can see from the output of the obnoxious FreeBSD 'ktrace' below, from doing gen_udp:recv() with the port build, inet_drv actually gets the expected ECONNREFUSED on recvfrom(), but ignores it and does a poll() anyway - which times out, of course. Some #ifdef or other flipped the wrong way I guess, there are a few of them... - or maybe one of the patches being applied in the port build that is broken. --Per 18895 beam CALL recvfrom(0x7,0x88818ec4,0x2000,0,0,0) 18895 beam RET recvfrom -1 errno 61 Connection refused 18895 beam CALL gettimeofday(0xbfbfd0f8,0) 18895 beam RET gettimeofday 0 18895 beam CALL gettimeofday(0xbfbfd9c4,0) 18895 beam RET gettimeofday 0 18895 beam CALL poll(0x88500c20,0x4,0x3e8) 18895 beam RET poll 0 18895 beam CALL gettimeofday(0xbfbfd9c8,0) 18895 beam RET gettimeofday 0 18895 beam CALL gettimeofday(0xbfbfe248,0) 18895 beam RET gettimeofday 0 18895 beam CALL ioctl(0,TIOCGWINSZ,0xbfbfe178) 18895 beam RET ioctl 0 18895 beam CALL write(0,0x88864000,0xf) 18895 beam GIO fd 0 wrote 15 bytes "{error,timeout}" From reachsaurabhnarula@REDACTED Thu Jun 17 22:34:43 2010 From: reachsaurabhnarula@REDACTED (Saurabh Narula) Date: Fri, 18 Jun 2010 02:04:43 +0530 Subject: How to use extended ODBC Data Types and Describe Type fails in ODBC Message-ID: Hello Everyone, I have encountered two issues - 1. How to use extended ODBC Data Types that are shown at this link in the documentation? http://www.erlang.org/doc/apps/odbc/databases.html#type I am only able to work with data types that are provided by odbc_data_type method, link - http://www.erlang.org/doc/man/odbc.html (section - common data types) 2. when I trying doing a describe type in ODBC, I get an error "[ODBC Driver 1.0]Cannot return the number of output columns. Query must be executed first SQLSTATE IS: 00000"}" Any Help would be deeply Appreciated. Thank you. Saurabh From kostis@REDACTED Thu Jun 17 22:41:14 2010 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 17 Jun 2010 23:41:14 +0300 Subject: [erlang-questions] Enforcing a function spec in Dialyzer In-Reply-To: <4C1A5B44.3090604@tmit.bme.hu> References: <4C1A5B44.3090604@tmit.bme.hu> Message-ID: <4C1A886A.4030607@cs.ntua.gr> Zoltan Lajos Kis wrote: > Hi all, > > Is it possible to enforce Dialyzer to use the spec I provide for a function > instead of deducting the specification from the function body? > > For example in the example below I would like to force my spec on the > data() function, > making Dialyzer stop issuing warnings about lists:keyfind always > returning false, > get(Key) always returning 'undefined', and so on... You cannot fool dialyzer so easily. Whenever, it infers that the spec you have given is not OK, it continues the analysis with the inferred information rather than the spec. The only way to achieve what you want is to use calls to some yet-to-be-implemented module and not include that module in the analysis as in: -spec data() -> [{atom(), any()}]. data() -> not_yet_implemented:data(). %% Module not_yet_implemented looks as follows: -module(not_yet_implemented). -export([data/1]). data() -> []. %% so that it can be used for testing, but is not given to dialyzer. > (The rational behind the question is that I rebuild the module every now > and then, > so calling the data() function will actually return a list of key-value > pairs later.) > > Thank you, > Zoltan. > > ---------------------- > > -spec( get(atom()) -> any() ). > get(Key) -> > case lists:keyfind(Key, 1, data()) of > {Key, Val} -> Val; > false -> 'undefined' > end. > > -spec( data() -> [{atom(), any()}] ). > data() -> []. From 12ukwn@REDACTED Fri Jun 18 00:20:06 2010 From: 12ukwn@REDACTED (Jean-Yves F. Barbier) Date: Fri, 18 Jun 2010 00:20:06 +0200 Subject: error msg Message-ID: <20100618002006.645e5880@anubis.defcon1> Hi list, After recompiling (native) wx demo examples, I've got an error msg when I try to launch 'gl': 2> demo:start(). {wx_ref,35,wxFrame,<0.36.0>} 3> Unlocking required 'proc_main:<0.43.0>[proclock]' lock! Currently these locks are locked by the scheduler 1 thread: 'proc_main:<0.43.0>[proclock]' 'run_queue:1[mutex]' Abandon what does this mean? -- "... the Mayo Clinic, named after its founder, Dr. Ted Clinic ..." -- Dave Barry From ok@REDACTED Fri Jun 18 00:38:19 2010 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 18 Jun 2010 10:38:19 +1200 Subject: [erlang-questions] Is it possible to add an filter property for the erlang process? In-Reply-To: References: Message-ID: <96427650-52DD-450B-8371-56A9E11FF523@cs.otago.ac.nz> On Jun 17, 2010, at 4:29 PM, litao cheng wrote: > hi, buddies. > my question is if it's possible to add an "filter" property for the > erlang > process, so that process can drop the uninterested messages. then we > can > reduce the needless memory consuming. The idea is at least 12 years old, so you are definitely not the first person to think it might be useful. The presentation of "abstract patterns" pointed out that they are the idea candidates for filtering; it's safe to run them in the context of the sender, so it's possible for unwanted messages to (sometimes) be dropped even before they are copied. However, we don't actually need such a mechanism, because we can program it using another process. Instead of A ------> B we use A ------> Filter ------> B where the identity of B is known only to the Filter process, so no other process can send to it. filtered_spawn(Fun, Predicate) when is_function(Fun, 0), is_function(Predicate, 1) -> spawn(fun () -> Pid = spawn_link(Fun), filtered_spawn_loop(Pid, Predicate) end). filtered_spawn_loop(Pid, Predicate) -> receive Message -> case Predicate(Message) of true -> Pid ! Message ; false -> ok end, filtered_spawn_loop(Pid, Predicate) end. If you want process B to be able to change the Predicate, it's not _enormously_ hard except that now B must know Filter as well as Filter knowing B. filtered_spawn(Fun, Predicate) when is_function(Fun, 0), is_function(Predicate, 1) -> spawn(fun() -> Pid = spawn_link(fun () -> filtered_spawn_target(Fun) end), Pid ! self(), filtered_spawn_loop(Pid, Predicate) end). filtered_spawn_target(Fun) -> receive Filter -> put(my_filter_pid, Filter), Fun() end. set_filter(Predicate) when is_function(Predicate, 1) -> get(my_filter_pid) ! {set_filter,self(),Predicate}. filtered_spawn_loop(Pid, Predicate) -> receive {set_filter,Pid,Predicate1} -> filtered_spawn_loop(Pid, Predicate1) ; Message -> case Predicate(Message) of true -> Pid ! Message ; _ -> ok end, filtered_spawn_loop(Pid, Predicate) end. This is of course UNTESTED CODE meant solely for the purpose of illustrating an idea. Concurrency ALWAYS seems to introduce nasty subtle points, and there's one here. There is in fact a difference between filtering done inside the message sending machinery and filtering done using a filter process. The filter process discards messages *only* when it is running; while it is not scheduled, any number of messages could build up in its mailbox. With filtering done inside the machinery, the filtering cannot be delayed like that. I once read a science fiction story in Analog magazine where the plot gimmick was that a machine had been developed for restoring people's health by restoring the balance of their fields (or some such bafflegab) rather than by means of antibiotics &c. There was a growing problem of "Box addicts"; people who felt sick if they didn't take a treatment with the Box at least every day. It turned out that some "extinct" disease (smallpox? plague?) had been released from an archaeological dig, and the "addicts" didn't have a psychological problem, they were genuinely sick with a fatal disease that the Box could help them survive with but not actually cure. The point here is that a filtering process or filtering machinery is just like the Box. It helps a seriously sick system keep running despite a bug that would otherwise have taken it down. I can't help thinking that simply dropping bad messages and stumbling on will *prevent* the necessary detection and repair of the problem for longer than anyone would want. The Erlang philosophy is not "keep going at all costs, including sanity" but "let it crash". We want bad messages to *crash* something so that we find out. (This is one of the things UBF is for.) Messages that are a *legal* part of the protocol but currently have no effect really ought to be handled by explicit code that accepts them and does nothing with them. It can be hard enough for a maintenance programmer to find out what a protocol is without moving part of it elsewhere and hiding it. > > like this: > % spawn a process with filter : {foo, _} > PidA = spawn(?MODULE, do_something, [], [{filter, {foo, _}}]), > > % the message {foo, hello} will be saved to PidA message queue, > because it > match the filter > PidA ! {foo, hello}, > > % this message will be dropped > PidA ! {bar, world}, > > % reset the filter > process_flag(filter, [_|_]), > > % this message will be stored in message queue > PidA ! "hello world", > ok. > > by this feature, I can write the code like this ( in my logging > library, > which is similar with python logging module): > {ok, _} = logging:start_logger("logname"), > Logger = logging:get_logger("logname"), > Logger:set_level(?CRITICAL), > Logger:debug("log"), > Logger:warning("log"), > Logger:critical("log"), > ok > > logger is an parameterized module, logging is an gen_server process, > in > logging module: > handle_call({set_level, Level}, _From, State) -> > process_flag(filter, #log_record{level = MsgLevel} when MsgLevel > > Level), > {reply, ok, State}; > > in my logging library, I have two methods to resolve this problem: > * dynamic compile the logger module, in the debug, info, warning, > error > function check if the log allowed > * in logging gen_server process handl_xxx function, test if the log > record > is allowed > all two solutions have flew. > > I want to known if this process filter feature is valuable? > thanks From 12ukwn@REDACTED Fri Jun 18 01:45:56 2010 From: 12ukwn@REDACTED (Jean-Yves F. Barbier) Date: Fri, 18 Jun 2010 01:45:56 +0200 Subject: postgresql access Message-ID: <20100618014556.2c3adfaf@anubis.defcon1> Hi list, I want to make an application that'll access a PostgreSQL DB (especially stocked procedures.) Is there a better way to have a full access to it apart ODBC? JY -- War is menstruation envy. From silent_vendetta@REDACTED Fri Jun 18 03:41:22 2010 From: silent_vendetta@REDACTED (Chris Hicks) Date: Thu, 17 Jun 2010 18:41:22 -0700 Subject: TCP performance Message-ID: In designing the TCP server, which will handle all communication, for my project I based my design off of a couple of different tutorials, modified to suit my own needs. What I have is a gen_server that spawns a new process which waits for a connection on the single port of communication, when a connection is accepted this process tells the gen_server that it needs to spawn a new process and then it sends the socket off to another gen_server where the data will be grabbed and processed. As far as I understand it once the socket connection has been accepted there should be no reason why another connection can't be established on that port immediately following. In other words the system doesn't care if the data has been received or not, when it comes to allowing another connection to take place, only that the first connection has been made. Is that true? I ask because I ran a very simple test against the server which simply asked for a connection and then immediately closed it. Everything seems to work flawlessly except that making 1000 connections takes about 3.5 seconds and for my purposes that is a bit too long. The code for the server is below, and hopefully with a tip someone gave me earlier it will be formatted correctly: init(_Args) ->?? ?process_flag(trap_exit, true),?? ?case gen_tcp:listen(54637, [binary, {packet, 0}, {reuseaddr, true}]) of?? ? ? ?{ok, LSock} ->?? ? ? ? ? ?State = #state{lsock = LSock},?? ? ? ? ? ?{ok, accept(State)};?? ? ? ?{error, Reason} ->?? ? ? ? ? ?{stop, Reason} end. accept(State = #state{lsock=LSock}) ->?? ?proc_lib:spawn(?MODULE, accept, [self(), LSock]),?? ?State. accept(Server, LSock) ->?? ?case gen_tcp:accept(LSock) of?? ? ? ?{ok, Socket} ->?? ? ? ? ? ?gen_server:cast(Server, {accepted, self()}),?? ? ? ? ? ?gen_server:cast(gateway_verifier, {connected, Socket});?? ? ? ?{error, closed} ->?? ? ? ? ? ?gen_server:cast(Server, {closed, self()}) end. This is the handle_cast callback for the gateway_verifier gen_server: handle_cast(Request, State) ->?? ?case Request of?? ? ? ?{connected, Socket} ->?? ? ? ? ? ?{noreply, recv({State, Socket})}; ?? ? ? ?{'EXIT', _From, _Reason} ->?? ? ? ? ? ?{noreply, State};?? ? ? ?_Other ->?? ? ? ? ? ?{noreply, State} end. And these are the functions which will start the processing of the data sent along the socket: recv({State, Socket}) ->?? ?proc_lib:spawn(?MODULE, recv, [self(), Socket]), State. recv(_Server, Sock) ->?? ?case gen_tcp:recv(Sock) of?? ? ? ?{ok, _Packet} ->?? ? ? ? ? ?%% Do some fancy stuff here?? ? ? ? ? ?ok;?? ? ? ?{error, Reason} ->?? ? ? ? ? ?{stop, Reason} end. This is my first real attempt at this so I wouldn't be surprised if there were some glaring inefficiencies in there. Any thoughts on how to increase the speed of accepting incoming connections? _________________________________________________________________ Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2 From silent_vendetta@REDACTED Fri Jun 18 03:56:50 2010 From: silent_vendetta@REDACTED (Chris Hicks) Date: Thu, 17 Jun 2010 18:56:50 -0700 Subject: TCP performance Message-ID: I'm under the impression that hotmail and the erlang mailing list do not get along. I'll try to reformat the previous message one more time in a different way and if it doesn't work I guess I'm just going to have to open a second account elsewhere simply for the mailing list... Second attempt: In designing the TCP server, which will handle all communication, for my project I based my design off of a couple of different tutorials, modified to suit my own needs. What I have is a gen_server that spawns a new process which waits for a connection on the single port of communication, when a connection is accepted this process tells the gen_server that it needs to spawn a new process and then it sends the socket off to another gen_server where the data will be grabbed and processed. As far as I understand it once the socket connection has been accepted there should be no reason why another connection can't be established on that port immediately following. In other words the system doesn't care if the data has been received or not, when it comes to allowing another connection to take place, only that the first connection has been made. Is that true? I ask because I ran a very simple test against the server which simply asked for a connection and then immediately closed it. Everything seems to work flawlessly except that making 1000 connections takes about 3.5 seconds and for my purposes that is a bit too long. The code for the server is below, and hopefully with a tip someone gave me earlier it will be formatted correctly: init(_Args) -> process_flag(trap_exit, true), case gen_tcp:listen(54637, [binary, {packet, 0}, {reuseaddr, true}]) of {ok, LSock} -> State = #state{lsock = LSock}, {ok, accept(State)}; {error, Reason} -> {stop, Reason} end. accept(State = #state{lsock=LSock}) -> proc_lib:spawn(?MODULE, accept, [self(), LSock]), State. accept(Server, LSock) -> case gen_tcp:accept(LSock) of {ok, Socket} -> gen_server:cast(Server, {accepted, self()}), gen_server:cast(gateway_verifier, {connected, Socket}); {error, closed} -> gen_server:cast(Server, {closed, self()}) end. This is the handle_cast callback for the gateway_verifier gen_server: handle_cast(Request, State) -> case Request of {connected, Socket} -> {noreply, recv({State, Socket})}; {'EXIT', _From, _Reason} -> {noreply, State}; _Other -> {noreply, State} end. And these are the functions which will start the processing of the data sent along the socket: recv({State, Socket}) -> proc_lib:spawn(?MODULE, recv, [self(), Socket]), State. recv(_Server, Sock) -> case gen_tcp:recv(Sock) of {ok, _Packet} -> %% Do some fancy stuff here ok; {error, Reason} -> {stop, Reason} end. This is my first real attempt at this so I wouldn't be surprised if there were some glaring inefficiencies in there. Any thoughts on how to increase the speed of accepting incoming connections? ---------------------------------------- > From: silent_vendetta@REDACTED > To: erlang-questions@REDACTED > Subject: TCP performance > Date: Thu, 17 Jun 2010 18:41:22 -0700 > > > In designing the TCP server, which will handle all communication, for my project I based my design off of a couple of different tutorials, modified to suit my own needs. What I have is a gen_server that spawns a new process which waits for a connection on the single port of communication, when a connection is accepted this process tells the gen_server that it needs to spawn a new process and then it sends the socket off to another gen_server where the data will be grabbed and processed. > As far as I understand it once the socket connection has been accepted there should be no reason why another connection can't be established on that port immediately following. In other words the system doesn't care if the data has been received or not, when it comes to allowing another connection to take place, only that the first connection has been made. Is that true? > I ask because I ran a very simple test against the server which simply asked for a connection and then immediately closed it. Everything seems to work flawlessly except that making 1000 connections takes about 3.5 seconds and for my purposes that is a bit too long. The code for the server is below, and hopefully with a tip someone gave me earlier it will be formatted correctly: > init(_Args) -> process_flag(trap_exit, true), case gen_tcp:listen(54637, [binary, {packet, 0}, {reuseaddr, true}]) of {ok, LSock} -> State = #state{lsock = LSock}, {ok, accept(State)}; {error, Reason} -> {stop, Reason} end. accept(State = #state{lsock=LSock}) -> proc_lib:spawn(?MODULE, accept, [self(), LSock]), State. accept(Server, LSock) -> case gen_tcp:accept(LSock) of {ok, Socket} -> gen_server:cast(Server, {accepted, self()}), gen_server:cast(gateway_verifier, {connected, Socket}); {error, closed} -> gen_server:cast(Server, {closed, self()}) end. > This is the handle_cast callback for the gateway_verifier gen_server: > handle_cast(Request, State) -> case Request of {connected, Socket} -> {noreply, recv({State, Socket})}; {'EXIT', _From, _Reason} -> {noreply, State}; _Other -> {noreply, State} end. > And these are the functions which will start the processing of the data sent along the socket: > recv({State, Socket}) -> proc_lib:spawn(?MODULE, recv, [self(), Socket]), State. recv(_Server, Sock) -> case gen_tcp:recv(Sock) of {ok, _Packet} -> %% Do some fancy stuff here ok; {error, Reason} -> {stop, Reason} end. > > > This is my first real attempt at this so I wouldn't be surprised if there were some glaring inefficiencies in there. Any thoughts on how to increase the speed of accepting incoming connections? > _________________________________________________________________ > Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. > http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2 _________________________________________________________________ Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1 From litaocheng@REDACTED Fri Jun 18 04:08:57 2010 From: litaocheng@REDACTED (litao cheng) Date: Fri, 18 Jun 2010 10:08:57 +0800 Subject: [erlang-questions] Is it possible to add an filter property for the erlang process? In-Reply-To: <96427650-52DD-450B-8371-56A9E11FF523@cs.otago.ac.nz> References: <96427650-52DD-450B-8371-56A9E11FF523@cs.otago.ac.nz> Message-ID: Richard, Thanks for your entire explanation! thank you all. On Fri, Jun 18, 2010 at 6:38 AM, Richard O'Keefe wrote: > > On Jun 17, 2010, at 4:29 PM, litao cheng wrote: > > hi, buddies. >> my question is if it's possible to add an "filter" property for the erlang >> process, so that process can drop the uninterested messages. then we can >> reduce the needless memory consuming. >> > > The idea is at least 12 years old, so you are definitely > not the first person to think it might be useful. > The presentation of "abstract patterns" pointed out that > they are the idea candidates for filtering; it's safe to > run them in the context of the sender, so it's possible > for unwanted messages to (sometimes) be dropped even before > they are copied. > > However, we don't actually need such a mechanism, because we > can program it using another process. Instead of > > A ------> B > > we use > > A ------> Filter ------> B > > where the identity of B is known only to the Filter process, > so no other process can send to it. > > filtered_spawn(Fun, Predicate) > when is_function(Fun, 0), is_function(Predicate, 1) -> > spawn(fun () -> > Pid = spawn_link(Fun), > filtered_spawn_loop(Pid, Predicate) > end). > > filtered_spawn_loop(Pid, Predicate) -> > receive Message -> > case Predicate(Message) > of true -> Pid ! Message > ; false -> ok > end, > filtered_spawn_loop(Pid, Predicate) > end. > > If you want process B to be able to change the Predicate, > it's not _enormously_ hard except that now B must know > Filter as well as Filter knowing B. > > filtered_spawn(Fun, Predicate) > when is_function(Fun, 0), is_function(Predicate, 1) -> > spawn(fun() -> > Pid = spawn_link(fun () -> filtered_spawn_target(Fun) end), > Pid ! self(), > filtered_spawn_loop(Pid, Predicate) > end). > > filtered_spawn_target(Fun) -> > receive Filter -> > put(my_filter_pid, Filter), > Fun() > end. > > set_filter(Predicate) > when is_function(Predicate, 1) -> > get(my_filter_pid) ! {set_filter,self(),Predicate}. > > filtered_spawn_loop(Pid, Predicate) -> > receive > {set_filter,Pid,Predicate1} -> > filtered_spawn_loop(Pid, Predicate1) > ; Message -> > case Predicate(Message) > of true -> Pid ! Message > ; _ -> ok > end, > filtered_spawn_loop(Pid, Predicate) > end. > > This is of course UNTESTED CODE meant solely for the purpose of > illustrating an idea. > > Concurrency ALWAYS seems to introduce nasty subtle points, > and there's one here. There is in fact a difference between > filtering done inside the message sending machinery and > filtering done using a filter process. The filter process > discards messages *only* when it is running; while it is not > scheduled, any number of messages could build up in its mailbox. > With filtering done inside the machinery, the filtering cannot > be delayed like that. > > I once read a science fiction story in Analog magazine > where the plot gimmick was that a machine had been developed > for restoring people's health by restoring the balance of > their fields (or some such bafflegab) rather than by means of > antibiotics &c. There was a growing problem of "Box addicts"; > people who felt sick if they didn't take a treatment with the > Box at least every day. It turned out that some "extinct" disease > (smallpox? plague?) had been released from an archaeological dig, > and the "addicts" didn't have a psychological problem, they were > genuinely sick with a fatal disease that the Box could help them > survive with but not actually cure. > > The point here is that a filtering process or filtering machinery > is just like the Box. It helps a seriously sick system keep > running despite a bug that would otherwise have taken it down. > I can't help thinking that simply dropping bad messages and > stumbling on will *prevent* the necessary detection and repair of > the problem for longer than anyone would want. > > The Erlang philosophy is not "keep going at all costs, including > sanity" but "let it crash". We want bad messages to *crash* > something so that we find out. (This is one of the things UBF > is for.) > > Messages that are a *legal* part of the protocol but currently have > no effect really ought to be handled by explicit code that accepts > them and does nothing with them. It can be hard enough for a > maintenance programmer to find out what a protocol is without moving > part of it elsewhere and hiding it. > > > >> like this: >> % spawn a process with filter : {foo, _} >> PidA = spawn(?MODULE, do_something, [], [{filter, {foo, _}}]), >> >> % the message {foo, hello} will be saved to PidA message queue, because it >> match the filter >> PidA ! {foo, hello}, >> >> % this message will be dropped >> PidA ! {bar, world}, >> >> % reset the filter >> process_flag(filter, [_|_]), >> >> % this message will be stored in message queue >> PidA ! "hello world", >> ok. >> >> by this feature, I can write the code like this ( in my logging library, >> which is similar with python logging module): >> {ok, _} = logging:start_logger("logname"), >> Logger = logging:get_logger("logname"), >> Logger:set_level(?CRITICAL), >> Logger:debug("log"), >> Logger:warning("log"), >> Logger:critical("log"), >> ok >> >> logger is an parameterized module, logging is an gen_server process, in >> logging module: >> handle_call({set_level, Level}, _From, State) -> >> process_flag(filter, #log_record{level = MsgLevel} when MsgLevel > >> Level), >> {reply, ok, State}; >> >> in my logging library, I have two methods to resolve this problem: >> * dynamic compile the logger module, in the debug, info, warning, error >> function check if the log allowed >> * in logging gen_server process handl_xxx function, test if the log record >> is allowed >> all two solutions have flew. >> >> I want to known if this process filter feature is valuable? >> thanks >> > > From emmiller@REDACTED Fri Jun 18 04:54:00 2010 From: emmiller@REDACTED (Evan Miller) Date: Thu, 17 Jun 2010 21:54:00 -0500 Subject: Aleppo: An Alternative Erlang Pre-Processor Message-ID: I've been performing a series of abominations on the Erlang scanner/parser/compiler pipeline and found myself in need of a preprocessor that's not epp. My problem with epp is that the API is very file oriented (you have to call "open" before you can do any preprocessing) and insists on doing parsing too. I just want to pass in a list of erl_scan-compatible tokens and have the macros expanded and directives executed and receive back a list of preprocessed tokens without any substantial parsing done. So here's a rough cut of Aleppo, an ALternative Erlang Pre-ProcessOr: http://github.com/evanmiller/aleppo It's very alpha but implements basic versions of -define, -undef, -ifdef, -ifndef, -include, and -include_lib and the associated macro expansion. You can't use Aleppo on its own, it's meant to be the missing link between erl_scan and erl_parse for people who like to mess with those things :-) Aleppo is implemented with Yecc. Bonus feature: preprocessor directives can appear inside function forms with no problem. I'm sure there are bugs so send them my way. Best regards, -- Evan Miller http://www.evanmiller.org/ From thijsterlouw@REDACTED Fri Jun 18 08:41:14 2010 From: thijsterlouw@REDACTED (Thijs Terlouw) Date: Fri, 18 Jun 2010 14:41:14 +0800 Subject: [erlang-questions] Wrong large 64bit return-values from Erlang Linkedin Driver In-Reply-To: <19482.6049.782805.700482@pilspetsen.it.uu.se> References: <19482.6049.782805.700482@pilspetsen.it.uu.se> Message-ID: Hi Mikael, I have attached a self-contained test. It consists of a few erlang files (bignum.erl (driver) , gen_linkedin_driver.erl (generic driver) bignumtest.erl (test to use the driver) and reloader.erl (for easy debugging)). It also contains a modified version of the C driver. On my machine (Linux 2.6.16.21-0.8 i686) I just run "make". I have Erlang R13B04: (erts-5.7.5 [source] [smp:4:4] [rq:4] [async-threads:30] [hipe] [kernel-poll:true]). The file also contains a readme.txt how to start the test. It uses eunit for the unit test. Which strangely enough succeeds! usage: tar -xzvf bignumtest.tar.gz cd bignumtest make ./start.sh 1st test: bignumtest:test_driver(). result: "2) 322122547200 =:= 4294967296 => true" expected: "2) 4294967296 =:= 4294967296 => true" Obviously something is very wrong here. It prints a value that is not equal, but when the values are compared, they are equal? 2nd test (unit test) bignumtest:test(). result: The first run all unit tests pass. The second run, it will always result in a core-dump. expected: no core dump A colleague (echouzhou) found a bug inside the function "erts_sint64_to_big" in "erts/emulator/beam/big.c". On lines 1518 and 1528 the *hpp pointer is not incremented correctly. It should be "*hpp += 3;" and "*hpp += 2;". After we changed this and recompiled Erlang, the above tests all succeed without crashing and print the correct values. I didn't look if the same bug is also in other parts of the code. Thijs On Thu, Jun 17, 2010 at 8:40 PM, Mikael Pettersson wrote: > Thijs Terlouw writes: > ?> Hello, > ?> > ?> I'm trying to return signed 64bit integers (on a 32bit system) from a > ?> custom Erlang linkedin driver. I try to use the ERL_DRV_INT64 type on > ?> the C-side. Because ERL_DRV_INT64 requires a pointer to ErlDrvSInt64, > ?> I first malloc a buffer, store it there, get a pointer to the result > ?> and then return that pointer. For small values this works great. > ?> > ?> Whenever I use values >134217727 (0x7FFFFFF) it will return wrong > ?> values. > > Can you please provide a self-contained test? I.e., an Erlang > module that loads your driver, invokes it, and checks the result? > And whatever build instructions are needed for your driver. > -------------- next part -------------- A non-text attachment was scrubbed... Name: bignumtest.tar.gz Type: application/x-gzip Size: 25234 bytes Desc: not available URL: From rtrlists@REDACTED Fri Jun 18 11:06:44 2010 From: rtrlists@REDACTED (Robert Raschke) Date: Fri, 18 Jun 2010 10:06:44 +0100 Subject: [erlang-questions] Reliable way to handle Java node crashs? In-Reply-To: References: Message-ID: On Thu, Jun 17, 2010 at 3:59 PM, zabrane Mikael wrote: > Thanks guys for the advices. > > 2010/6/17 Robert Raschke > > I kick off the Java node as a monitored port from within Erlang. That >> way I am in control of starting, noticing crashes, and restarting. I >> also have the port set up so that messages written to stdout in the >> Java node feed into the logging in Erlang. >> >> If you want I can dig out some example code when I'm back in the >> office next week. >> > > > Robert, I'll be more than happy to read some code! > Thanks > > > -- > Regards > Zabrane > In Erlang I have a gen_server that interfaces to my Java Node with messages. This kicks off the port manager and then does a handshake to transmit some data the Java program needs to do its thing. Please note that I have not actually compiled or run the example code below, this has been adapted from some production code. The port manager is a process that starts the Java node as a port program: -module(java_manager). -export([start_link/1, init/3]). start_link(Node_Name) -> spawn_link(?MODULE, init, [Node_Name]). init(Node_Name) -> process_flag(trap_exit, true), Cmd = mk_java_cmdline(os:type(), Node_Name), error_logger:info_report([{module, ?MODULE}, {java_port, Node_Name}, {'START', Cmd}]), P = open_port({spawn, Cmd}, [stream, {line, 100}, exit_status]), loop(P, Node_Name, [], []). loop(Port, Name, Response, Line) -> receive % These three messages mean that the Java program is no longer running. % So we stop looping. % The first is normal termination, the other two are abnormal. {Port, {exit_status, 0}} -> error_logger:info_report([{module, ?MODULE}, {java_port, Name}, {'EXIT', {status, 0}}]); {Port, {exit_status, N}} -> error_logger:error_report([{module, ?MODULE}, {java_port, Name}, {'EXIT', {status, N}}]), erlang:error({port_status, N}); {'EXIT', Port, Reason} -> error_logger:error_report([{module, ?MODULE}, {java_port, Name}, {'EXIT', Reason}]), erlang:error({port_exit, Reason}); % The data messages come from the standard output of the Java program. % We accumulate the output line by line; potentially having to assemble % each line from pieces. Everything is accumulated through list cons'ing. % Thus all results have to be reversed before use. % Unfinished output lines are tagged with noeol. % We accumulate the line. {Port, {data, {noeol, S}}} -> loop(Port, Name, Response, [S | Line]); % Finished lines are tagged with eol. {Port, {data, {eol, S}}} -> case {S, Line} of % The convention in the Java program is to send a solitary "." to signal % that this particular bit of output is complete. {".", []} -> process_port_data(Name, lists:reverse(Response)), loop(Port, Name, [], []); {S, Line} -> Full_Line = lists:flatten(lists:reverse([S | Line])), loop(Port, Name, [Full_Line | Response], []) end end. % Messages from the Java program are logged as info messages. process_port_data(Name, Text) -> error_logger:info_report([{module, ?MODULE}, {java_port, Name}, {'STDOUT', string:join(Text, "\n")}]). mk_java_cmdline({Ostype, _}, Node_Name) -> mk_java_cmdline(Ostype, Node_Name); mk_java_cmdline(Ostype, Node_Name) -> lists:flatten([ os:find_executable("java"), " -Xrs -classpath myPackage ", " myPackage.myJavaNode ", quote(Ostype, Node_Name), " ", quote(Ostype, my_cookie()) ]). my_cookie() -> atom_to_list(erlang:get_cookie()). quote(win32, S) -> ["\"", S, "\""]; quote(unix, S) -> ["'", S, "'"]. And the Java node looks something like this: package myPackage; import com.ericsson.otp.erlang.*; public class myJavaNode { private static void print(String s) { System.out.println(s); System.out.println("."); System.out.flush(); } public static void main(String[] args) { // System.setProperty("OtpConnection.trace", "4"); if (args.length != 2) { print("Invalid arguments."); System.exit(10); } String node_name = args[0]; String cookie = args[1]; OtpNode node = null; try { node = new OtpNode(node_name, cookie); } catch(java.io.IOException ioe) { String msg = ioe.getMessage(); if (msg != null) { print("OtpNode creation error: " + msg); } System.exit(11); } try { OtpMbox mbox = node.createMbox("myBox"); shake_hands(mbox); // go into your message loop node.closeMbox(mbox); } catch (Exception e) { e.printStackTrace(System.out); System.out.println("."); System.out.flush(); System.exit(12); } node.close(); } private static void shake_hands(OtpMbox mbox) throws Exception { OtpErlangTuple msg = (OtpErlangTuple) mbox.receive(5000); if (msg == null) { print("Handshake timed out."); System.exit(13); } OtpErlangPid from = (OtpErlangPid) msg.elementAt(0); OtpErlangAtom hand = (OtpErlangAtom) msg.elementAt(1); if ("ok".equals(hand.atomValue())) { mbox.link(from); mbox.send(from, new OtpErlangTuple(new OtpErlangObject[] { new OtpErlangAtom("ok"), mbox.self(), })); } else { mbox.send(from, new OtpErlangAtom("who are you?")); print("Not received ok: " + msg); System.exit(14); } } } I hope this'll give you a few ideas. Robby From thijsterlouw@REDACTED Fri Jun 18 11:19:20 2010 From: thijsterlouw@REDACTED (Thijs Terlouw) Date: Fri, 18 Jun 2010 17:19:20 +0800 Subject: [erlang-questions] Wrong large 64bit return-values from Erlang Linkedin Driver In-Reply-To: References: <19482.6049.782805.700482@pilspetsen.it.uu.se> Message-ID: On Fri, Jun 18, 2010 at 2:41 PM, Thijs Terlouw wrote: > I didn't look if the same bug is also in other parts of the > code. The bug is present in other code as well, for example the "erts_uint64_to_big" function has the same problem. It seems to affect all current Erlang versions (up to R13B04 and R14A). There is an additional bug in "erts/emulator/beam/utils.c" in the functions erts_bld_sint64 and erts_bld_uint64. On line 367 and on line 384 it should read "*szp +=" instead of "*szp =" I believe. This solved the problems related to crashes with multiple bignums inside a list for me. After all these changes, it seems to work good for me :) Do I need to submit these bugs to the bugs mailing list as well? I have no idea how to make official patches. Thijs From thijsterlouw@REDACTED Fri Jun 18 12:38:16 2010 From: thijsterlouw@REDACTED (Thijs Terlouw) Date: Fri, 18 Jun 2010 18:38:16 +0800 Subject: [erlang-questions] Wrong large 64bit return-values from Erlang Linkedin Driver In-Reply-To: References: <19482.6049.782805.700482@pilspetsen.it.uu.se> Message-ID: I created a small diff file so you can patch the R13B04 tree. I know it's not the preferred way to patch (I believe I should use GIT), but I cannot use GIT in the office, so this is the best I can do. Hope it helps anyway. Thijs On Fri, Jun 18, 2010 at 5:19 PM, Thijs Terlouw wrote: > On Fri, Jun 18, 2010 at 2:41 PM, Thijs Terlouw wrote: > Do I need to submit these bugs to the bugs mailing list as well? I > have no idea how to make official patches. > > Thijs > -------------- next part -------------- A non-text attachment was scrubbed... Name: erlang_bignum.patch Type: application/octet-stream Size: 1486 bytes Desc: not available URL: From rumata-estor@REDACTED Fri Jun 18 14:13:41 2010 From: rumata-estor@REDACTED (Dmitry Belyaev) Date: Fri, 18 Jun 2010 16:13:41 +0400 Subject: [erlang-questions] RE: TCP performance In-Reply-To: References: Message-ID: <4C1B62F5.4000302@nm.ru> accept/2 is not tail recursive, so it accepts only one connection. accept(Server, LSock) -> case gen_tcp:accept(LSock) of {ok, Socket} -> gen_server:cast(Server, {accepted, self()}), gen_server:cast(gateway_verifier, {connected, Socket}), accept(Server, LSock); %%<------------- {error, closed} -> gen_server:cast(Server, {closed, self()}) end Dmitry Belyaev On 06/18/2010 05:56 AM, Chris Hicks wrote: > > I'm under the impression that hotmail and the erlang mailing list do not get along. I'll try to reformat the previous message one more time in a different way and if it doesn't work I guess I'm just going to have to open a second account elsewhere simply for the mailing list... > > Second attempt: > > In designing the TCP server, which will handle all communication, for my project I based my design off of a couple of different tutorials, modified to suit my own needs. What I have is a gen_server that spawns a new process which waits for a connection on the single port of communication, when a connection is accepted this process tells the gen_server that it needs to spawn a new process and then it sends the socket off to another gen_server where the data will be grabbed and processed. > > As far as I understand it once the socket connection has been accepted there should be no reason why another connection can't be established on that port immediately following. In other words the system doesn't care if the data has been received or not, when it comes to allowing another connection to take place, only that the first connection has been made. Is that true? > > I ask because I ran a very simple test against the server which simply asked for a connection and then immediately closed it. Everything seems to work flawlessly except that making 1000 connections takes about 3.5 seconds and for my purposes that is a bit too long. The code for the server is below, and hopefully with a tip someone gave me earlier it will be formatted correctly: > > > init(_Args) -> > process_flag(trap_exit, true), > case gen_tcp:listen(54637, [binary, {packet, 0}, {reuseaddr, true}]) of > {ok, LSock} -> > State = #state{lsock = LSock}, > {ok, accept(State)}; > {error, Reason} -> > {stop, Reason} > end. > > > accept(State = #state{lsock=LSock}) -> > proc_lib:spawn(?MODULE, accept, [self(), LSock]), > State. > > > accept(Server, LSock) -> > case gen_tcp:accept(LSock) of > {ok, Socket} -> > gen_server:cast(Server, {accepted, self()}), > gen_server:cast(gateway_verifier, {connected, Socket}); > {error, closed} -> > gen_server:cast(Server, {closed, self()}) > end. > > > This is the handle_cast callback for the gateway_verifier gen_server: > > > > handle_cast(Request, State) -> > case Request of > {connected, Socket} -> > {noreply, recv({State, Socket})}; > {'EXIT', _From, _Reason} -> > {noreply, State}; > _Other -> > {noreply, State} > end. > > > And these are the functions which will start the processing of the data sent along the socket: > > > recv({State, Socket}) -> > proc_lib:spawn(?MODULE, recv, [self(), Socket]), > State. > > > recv(_Server, Sock) -> > case gen_tcp:recv(Sock) of > {ok, _Packet} -> > %% Do some fancy stuff here > ok; > {error, Reason} -> {stop, Reason} > end. > > > > This is my first real attempt at this so I wouldn't be surprised if there were some glaring inefficiencies in there. Any thoughts on how to increase the speed of accepting incoming connections? > ---------------------------------------- > >> From: silent_vendetta@REDACTED >> To: erlang-questions@REDACTED >> Subject: TCP performance >> Date: Thu, 17 Jun 2010 18:41:22 -0700 >> >> >> In designing the TCP server, which will handle all communication, for my project I based my design off of a couple of different tutorials, modified to suit my own needs. What I have is a gen_server that spawns a new process which waits for a connection on the single port of communication, when a connection is accepted this process tells the gen_server that it needs to spawn a new process and then it sends the socket off to another gen_server where the data will be grabbed and processed. >> As far as I understand it once the socket connection has been accepted there should be no reason why another connection can't be established on that port immediately following. In other words the system doesn't care if the data has been received or not, when it comes to allowing another connection to take place, only that the first connection has been made. Is that true? >> I ask because I ran a very simple test against the server which simply asked for a connection and then immediately closed it. Everything seems to work flawlessly except that making 1000 connections takes about 3.5 seconds and for my purposes that is a bit too long. The code for the server is below, and hopefully with a tip someone gave me earlier it will be formatted correctly: >> init(_Args) -> process_flag(trap_exit, true), case gen_tcp:listen(54637, [binary, {packet, 0}, {reuseaddr, true}]) of {ok, LSock} -> State = #state{lsock = LSock}, {ok, accept(State)}; {error, Reason} -> {stop, Reason} end. accept(State = #state{lsock=LSock}) -> proc_lib:spawn(?MODULE, accept, [self(), LSock]), State. accept(Server, LSock) -> case gen_tcp:accept(LSock) of {ok, Socket} -> gen_server:cast(Server, {accepted, self()}), gen_server:cast(gateway_verifier, {connected, Socket}); {error, closed} -> gen_server:cast(Server, {closed, self()}) end. >> This is the handle_cast callback for the gateway_verifier gen_server: >> handle_cast(Request, State) -> case Request of {connected, Socket} -> {noreply, recv({State, Socket})}; {'EXIT', _From, _Reason} -> {noreply, State}; _Other -> {noreply, State} end. >> And these are the functions which will start the processing of the data sent along the socket: >> recv({State, Socket}) -> proc_lib:spawn(?MODULE, recv, [self(), Socket]), State. recv(_Server, Sock) -> case gen_tcp:recv(Sock) of {ok, _Packet} -> %% Do some fancy stuff here ok; {error, Reason} -> {stop, Reason} end. >> >> >> This is my first real attempt at this so I wouldn't be surprised if there were some glaring inefficiencies in there. Any thoughts on how to increase the speed of accepting incoming connections? >> _________________________________________________________________ >> Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. >> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2 >> > > _________________________________________________________________ > Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. > http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1 > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > From sverker@REDACTED Fri Jun 18 15:16:40 2010 From: sverker@REDACTED (Sverker Eriksson) Date: Fri, 18 Jun 2010 15:16:40 +0200 Subject: [erlang-questions] Wrong large 64bit return-values from Erlang Linkedin Driver In-Reply-To: References: <19482.6049.782805.700482@pilspetsen.it.uu.se> Message-ID: <4C1B71B8.5090507@erix.ericsson.se> I will put your patch in the pipe for R14B. Thanks for accurate trouble shooting /Sverker, Erlang/OTP Thijs Terlouw wrote: > I created a small diff file so you can patch the R13B04 tree. I know > it's not the preferred way to patch (I believe I should use GIT), but > I cannot use GIT in the office, so this is the best I can do. Hope it > helps anyway. > > Thijs > > On Fri, Jun 18, 2010 at 5:19 PM, Thijs Terlouw wrote: > >> On Fri, Jun 18, 2010 at 2:41 PM, Thijs Terlouw wrote: >> Do I need to submit these bugs to the bugs mailing list as well? I >> have no idea how to make official patches. >> >> Thijs >> >> >> ------------------------------------------------------------------------ >> >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED From istvan.lorincz@REDACTED Fri Jun 18 15:25:13 2010 From: istvan.lorincz@REDACTED (=?iso-8859-1?Q?Istv=E1n_L=F5rincz?=) Date: Fri, 18 Jun 2010 15:25:13 +0200 Subject: timer:tc/3, erlang:now/0 documentation Message-ID: <10CEDD6D91C2AD4F87003AB2D31631AC02D43101@esealmw103.eemea.ericsson.se> Hi! I think the documentation of timer:tc/3 is misleading, because it states, that the function returns the real execution time of the specified MFA. In reality it returns a duration based on virtual time returned by erlang:now/0. On the other hand, the documentation of erlang:now/0 is misleading too somewhat, because it states that it returns the POSIX time, without mentioning that it's true only in case you don't make repetitive calls to erlang:now/0 in a shorter time than 1 microsec. To illustrate this I wrote the following code (tested on Windows Vista Enterprise SP1, Erlang OTP R13B04, Sun SPARC Solaris 5.8, Erlang OTP R11B): ---------------------------------------------------------------- -module(now). -compile(export_all). now_test(0)-> ok; now_test(Counter) -> now(),%%generating unique time-stamps now_test(Counter-1). test(Amount)-> NowStartTime = calendar:now_to_datetime(now()), SysStartTime = calendar:local_time(), {TCRunTime, _Result} = timer:tc( now, now_test, [Amount]), SysRunTime = calendar:time_difference(SysStartTime, calendar:local_time()), NowTime = calendar:now_to_datetime(now()), SysTime = calendar:local_time(), io:format("calendar:local_time(): ~p~n",[SysStartTime]), io:format("calendar:now_to_datetime(now()): ~p~n",[NowStartTime]), io:format("Run time by timer:tc( now, now_test, [Amount]): ~p~n", [TCRunTime]), io:format("Run time by calendar:local_time(): ~p~n",[SysRunTime]), io:format("calendar:local_time(): ~p~n",[SysTime]), io:format("calendar:now_to_datetime(now()): ~p~n",[NowTime]). ---------------------------------------------------------------- 332> erlang:system_info(otp_release). "R13B04" 333> now:test(10000000). calendar:local_time(): {{2010,6,17},{12,5,23}} calendar:now_to_datetime(now()): {{2010,6,17},{10,5,23}} Run time by timer:tc( now, now_test, [Amount]): 10000001 Run time by calendar:local_time(): {0,{0,0,2}} calendar:local_time(): {{2010,6,17},{12,5,25}} calendar:now_to_datetime(now()): {{2010,6,17},{10,5,33}} 334> ---------------------------------------------------------------- 2> erlang:system_info(otp_release). "R11B" 3> now:test(10000000). calendar:local_time(): {{2010,6,17},{12,42,45}} calendar:now_to_datetime(now()): {{2010,6,17},{10,42,45}} Run time by timer:tc( now, now_test, [Amount]): 10000004 Run time by calendar:local_time(): {0,{0,0,7}} calendar:local_time(): {{2010,6,17},{12,42,52}} calendar:now_to_datetime(now()): {{2010,6,17},{10,42,55}} ok 4> Regards, Istv?n From levendsayar@REDACTED Fri Jun 18 17:57:44 2010 From: levendsayar@REDACTED (Levend Sayar) Date: Fri, 18 Jun 2010 18:57:44 +0300 Subject: erlang without wx Message-ID: Hi, everybody. I need erlang runtime. But I do not want any gui related packages. So is it possible to configure erlang source package to supply only the runtime environement ? no debugger, no dialyzer, no gs, no wx TIA _lvnd_ (^_^) From 12ukwn@REDACTED Fri Jun 18 18:05:44 2010 From: 12ukwn@REDACTED (Jean-Yves F. Barbier) Date: Fri, 18 Jun 2010 18:05:44 +0200 Subject: syntax question Message-ID: <20100618180544.44fe430f@anubis.defcon1> Hi list, What does '<<' and '>>' stand for (I can't find an answer as all search engines suppress these strings :( JY -- Halt!! Who goes there, friend or enema? From magnus@REDACTED Fri Jun 18 18:09:48 2010 From: magnus@REDACTED (Magnus Henoch) Date: Fri, 18 Jun 2010 17:09:48 +0100 Subject: syntax question In-Reply-To: <20100618180544.44fe430f@anubis.defcon1> (Jean-Yves F. Barbier's message of "Fri, 18 Jun 2010 18:05:44 +0200") References: <20100618180544.44fe430f@anubis.defcon1> Message-ID: <84vd9g2ugj.fsf@linux-b2a3.site> "Jean-Yves F. Barbier" <12ukwn@REDACTED> writes: > What does '<<' and '>>' stand for (I can't find an answer as all search > engines suppress these strings :( They create "bit strings" or "binaries": http://www.erlang.org/doc/reference_manual/expressions.html#bit_syntax -- Magnus Henoch, magnus@REDACTED Erlang Solutions http://www.erlang-solutions.com/ --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From 12ukwn@REDACTED Fri Jun 18 18:44:18 2010 From: 12ukwn@REDACTED (Jean-Yves F. Barbier) Date: Fri, 18 Jun 2010 18:44:18 +0200 Subject: [erlang-questions] Re: syntax question In-Reply-To: <84vd9g2ugj.fsf@linux-b2a3.site> References: <20100618180544.44fe430f@anubis.defcon1> <84vd9g2ugj.fsf@linux-b2a3.site> Message-ID: <20100618184418.18070263@anubis.defcon1> Le Fri, 18 Jun 2010 17:09:48 +0100, Magnus Henoch a ?crit : Thanks a lot for the link: it help me to understand how epgsql works :) ... > They create "bit strings" or "binaries": > http://www.erlang.org/doc/reference_manual/expressions.html#bit_syntax > -- I wonder if I should put myself in ESCROW!! From vances@REDACTED Fri Jun 18 19:05:40 2010 From: vances@REDACTED (Vance Shipley) Date: Fri, 18 Jun 2010 13:05:40 -0400 Subject: [erlang-questions] DOWN record In-Reply-To: <4C19F4B4.6090806@erlang-solutions.com> References: <857B4D56-18CB-4FB6-AD61-375F59C27F40@rogvall.se> <4C19F4B4.6090806@erlang-solutions.com> Message-ID: <20100618170540.GB1474@h216-235-12-173.host.egate.net> You are really shattering the illusion of records as a type. On Thu, Jun 17, 2010 at 12:11:00PM +0200, Ulf Wiger wrote: } Are you getting ready to advocate a hrl file provided } by OTP, listing record defs for common OTP messages, } } - #'DOWN'{} } - #system{} } - #'EXIT' } - ... -- -Vance From zabrane3@REDACTED Fri Jun 18 19:43:26 2010 From: zabrane3@REDACTED (zabrane Mikael) Date: Fri, 18 Jun 2010 19:43:26 +0200 Subject: Compile "escript" file to a binary executable! Message-ID: Hi list, Is there a way(or even a hack) to compile an "escript" file to a binary executable? Thanks ! -- Regards Zabrane From cebernard@REDACTED Fri Jun 18 21:25:00 2010 From: cebernard@REDACTED (Chris Bernard) Date: Fri, 18 Jun 2010 15:25:00 -0400 Subject: [erlang-questions] Compile "escript" file to a binary executable! In-Reply-To: References: Message-ID: <4C1C56A3-371E-434C-9E9A-70A157BDC40D@gmail.com> Zabrane, The OTP doc says an escript can contain "Erlang source code, an inlined beam file or an inlined archive file." http://www.erlang.org/doc/man/escript.html For an example of an escript containing an inlined archive, check out how the excellent "rebar" bootstraps itself (an OTP application and release build tool). http://bitbucket.org/basho/rebar/src/tip/bootstrap Cheers, Chris Bernard On Jun 18, 2010, at 1:43 PM, zabrane Mikael wrote: > Hi list, > > Is there a way(or even a hack) to compile an "escript" file to a > binary > executable? > > Thanks ! > -- > Regards > Zabrane From silent_vendetta@REDACTED Fri Jun 18 22:21:00 2010 From: silent_vendetta@REDACTED (Chris Hicks) Date: Fri, 18 Jun 2010 13:21:00 -0700 Subject: [erlang-questions] RE: TCP performance Message-ID: I hadn't originally wanted it to be recursive, I just spawned a new process once that one was finished with its thing and let it die. I changed the accept function so that no matter what it recursed, to see if there was an improvement in using a pool of acceptors instead of constantly spawning a new one: accept(Server, LSock) -> case gen_tcp:accept(LSock) of {ok, Socket} -> gen_server:cast(gateway_verifier,{connected, Socket}), accept(Server, LSock);{error, closed} -> accept(Server, LSock) end. And changed handle_cast so that it only spawned a new process if one of the ones it created crashed: handle_cast(Request, State) -> case Request of {accepted, _Pid} -> {noreply, State}; {closed, _Pid} -> {noreply, State}; {'EXIT', _From, _Reason} -> {noreply, create_acceptor(1, State)}; _Other -> {noreply, State} end. Changing to that method over my original one seems to drop the time down by around .1-.2 seconds on average so not much of an improvement. I had a pool of 10 acceptors. I'm running a quad-core 2.4 GHZ machine with 4G of ram and the total CPU time hovers around 40% on average with spikes up to around 50% when running this. One of the cores is much busier, around 75%, than the others but still isn't maxed out. I know I have the cpu cycles to burn so something is keeping it slower. Of course maybe my test case is too naive? I'm basically just bombarding the tcp connection from a single process as I figured it would give me a clear enough indication of how long it would take to handle the connections. Should I change the test code below? gateway(0) -> ok; gateway(Num) -> gen_tcp:connect('localhost', 54637, [binary, {packet, 0}, {reuseaddr, true}]), gateway(Num-1).---------------------------------------- > Date: Fri, 18 Jun 2010 16:13:41 +0400 > From: rumata-estor@REDACTED > To: erlang-questions@REDACTED > Subject: Re: [erlang-questions] RE: TCP performance > > accept/2 is not tail recursive, so it accepts only one connection. > > accept(Server, LSock) -> > case gen_tcp:accept(LSock) of > {ok, Socket} -> > gen_server:cast(Server, {accepted, self()}), > gen_server:cast(gateway_verifier, {connected, Socket}), > accept(Server, LSock); %%<------------- > {error, closed} -> > gen_server:cast(Server, {closed, self()}) > end > > > Dmitry Belyaev > > > On 06/18/2010 05:56 AM, Chris Hicks wrote: >> >> I'm under the impression that hotmail and the erlang mailing list do not get along. I'll try to reformat the previous message one more time in a different way and if it doesn't work I guess I'm just going to have to open a second account elsewhere simply for the mailing list... >> >> Second attempt: >> >> In designing the TCP server, which will handle all communication, for my project I based my design off of a couple of different tutorials, modified to suit my own needs. What I have is a gen_server that spawns a new process which waits for a connection on the single port of communication, when a connection is accepted this process tells the gen_server that it needs to spawn a new process and then it sends the socket off to another gen_server where the data will be grabbed and processed. >> >> As far as I understand it once the socket connection has been accepted there should be no reason why another connection can't be established on that port immediately following. In other words the system doesn't care if the data has been received or not, when it comes to allowing another connection to take place, only that the first connection has been made. Is that true? >> >> I ask because I ran a very simple test against the server which simply asked for a connection and then immediately closed it. Everything seems to work flawlessly except that making 1000 connections takes about 3.5 seconds and for my purposes that is a bit too long. The code for the server is below, and hopefully with a tip someone gave me earlier it will be formatted correctly: >> >> >> init(_Args) -> >> process_flag(trap_exit, true), >> case gen_tcp:listen(54637, [binary, {packet, 0}, {reuseaddr, true}]) of >> {ok, LSock} -> >> State = #state{lsock = LSock}, >> {ok, accept(State)}; >> {error, Reason} -> >> {stop, Reason} >> end. >> >> >> accept(State = #state{lsock=LSock}) -> >> proc_lib:spawn(?MODULE, accept, [self(), LSock]), >> State. >> >> >> accept(Server, LSock) -> >> case gen_tcp:accept(LSock) of >> {ok, Socket} -> >> gen_server:cast(Server, {accepted, self()}), >> gen_server:cast(gateway_verifier, {connected, Socket}); >> {error, closed} -> >> gen_server:cast(Server, {closed, self()}) >> end. >> >> >> This is the handle_cast callback for the gateway_verifier gen_server: >> >> >> >> handle_cast(Request, State) -> >> case Request of >> {connected, Socket} -> >> {noreply, recv({State, Socket})}; >> {'EXIT', _From, _Reason} -> >> {noreply, State}; >> _Other -> >> {noreply, State} >> end. >> >> >> And these are the functions which will start the processing of the data sent along the socket: >> >> >> recv({State, Socket}) -> >> proc_lib:spawn(?MODULE, recv, [self(), Socket]), >> State. >> >> >> recv(_Server, Sock) -> >> case gen_tcp:recv(Sock) of >> {ok, _Packet} -> >> %% Do some fancy stuff here >> ok; >> {error, Reason} -> {stop, Reason} >> end. >> >> >> >> This is my first real attempt at this so I wouldn't be surprised if there were some glaring inefficiencies in there. Any thoughts on how to increase the speed of accepting incoming connections? >> ---------------------------------------- >> >>> From: silent_vendetta@REDACTED >>> To: erlang-questions@REDACTED >>> Subject: TCP performance >>> Date: Thu, 17 Jun 2010 18:41:22 -0700 >>> >>> >>> In designing the TCP server, which will handle all communication, for my project I based my design off of a couple of different tutorials, modified to suit my own needs. What I have is a gen_server that spawns a new process which waits for a connection on the single port of communication, when a connection is accepted this process tells the gen_server that it needs to spawn a new process and then it sends the socket off to another gen_server where the data will be grabbed and processed. >>> As far as I understand it once the socket connection has been accepted there should be no reason why another connection can't be established on that port immediately following. In other words the system doesn't care if the data has been received or not, when it comes to allowing another connection to take place, only that the first connection has been made. Is that true? >>> I ask because I ran a very simple test against the server which simply asked for a connection and then immediately closed it. Everything seems to work flawlessly except that making 1000 connections takes about 3.5 seconds and for my purposes that is a bit too long. The code for the server is below, and hopefully with a tip someone gave me earlier it will be formatted correctly: >>> init(_Args) -> process_flag(trap_exit, true), case gen_tcp:listen(54637, [binary, {packet, 0}, {reuseaddr, true}]) of {ok, LSock} -> State = #state{lsock = LSock}, {ok, accept(State)}; {error, Reason} -> {stop, Reason} end. accept(State = #state{lsock=LSock}) -> proc_lib:spawn(?MODULE, accept, [self(), LSock]), State. accept(Server, LSock) -> case gen_tcp:accept(LSock) of {ok, Socket} -> gen_server:cast(Server, {accepted, self()}), gen_server:cast(gateway_verifier, {connected, Socket}); {error, closed} -> gen_server:cast(Server, {closed, self()}) end. >>> This is the handle_cast callback for the gateway_verifier gen_server: >>> handle_cast(Request, State) -> case Request of {connected, Socket} -> {noreply, recv({State, Socket})}; {'EXIT', _From, _Reason} -> {noreply, State}; _Other -> {noreply, State} end. >>> And these are the functions which will start the processing of the data sent along the socket: >>> recv({State, Socket}) -> proc_lib:spawn(?MODULE, recv, [self(), Socket]), State. recv(_Server, Sock) -> case gen_tcp:recv(Sock) of {ok, _Packet} -> %% Do some fancy stuff here ok; {error, Reason} -> {stop, Reason} end. >>> >>> >>> This is my first real attempt at this so I wouldn't be surprised if there were some glaring inefficiencies in there. Any thoughts on how to increase the speed of accepting incoming connections? >>> _________________________________________________________________ >>> Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. >>> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2 >>> >> >> _________________________________________________________________ >> Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. >> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1 >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> >> > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > _________________________________________________________________ The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5 From comptekki@REDACTED Fri Jun 18 23:34:00 2010 From: comptekki@REDACTED (Wes James) Date: Fri, 18 Jun 2010 15:34:00 -0600 Subject: list comprehension of two lists Message-ID: I see how to do: [X || X <- [1,2,3,4,5,6]] will create [1,2,3,4,5] but how about I have two lists, [1,2,3] and [a,b,c] and I want to output [[1,a], [2,b], [3,c]] can that be done with a list comprehension? thx, -wes From karthik@REDACTED Fri Jun 18 23:48:32 2010 From: karthik@REDACTED (Karthik Kailash) Date: Fri, 18 Jun 2010 14:48:32 -0700 Subject: ejabberd Bottleneck: Understanding Fprof Analysis Message-ID: <015901cb0f2f$ffcbb190$ff6314b0$@com> Hi, I am load testing ejabberd on Erlang 13B03 on a 4-core Ubuntu Server 10.04 LTS VM w/ 16GB of RAM. As the test is running, I notice that the message queue for ejabberd's mod_muc process grows and grows. From a crash dump I observed the message queue for mod_muc is bottlenecking the whole system, it's the only process with a sizable message queue (it's enormous, well over 100,000 queued messages). Using process_info in a remote shell it is possible to see the queue length growing very rapidly in real time (~1000msg/s). I used fprof to do some profiling on the mod_muc process, see the output file here: http://pastebin.com/QXchAKtM. From the log mod_muc:do_route was called around 26,000 times over the course of the 38s of data collection. This is ~1.4ms per packet, which translates to millions of clock cycles, highly inefficient! It seems that nearly all the time is being used in "suspend" calls (if you add up the ACC time for suspend, it becomes 100% of the overall measured time). Indeed, when I call process_info on the mod_muc process in a remote shell in the live server, its status seems to always be "runnable". However, my fprof can only use wallclock time, not the high resolution CPU time, so I'm not sure how accurate all of this is. It's odd that a 4-core box can't even handle 2,500 messages/s of incoming traffic. It seems like the bottleneck is a single process, which if I understand correctly can only run on 1 core. Can anyone help me decipher the fprof output to shed light on what is going on? Thanks, Karthik Karthik Kailash | Product SocialVision, Online Television Becomes a Social Experience CELL . 408.768.7704 | WEB . www.socialvisioninc.com | FACEBOOK . facebook.com/socialvision | TWITTER . twitter.com/socialvision From comptekki@REDACTED Fri Jun 18 23:55:19 2010 From: comptekki@REDACTED (Wes James) Date: Fri, 18 Jun 2010 15:55:19 -0600 Subject: [erlang-questions] list comprehension of two lists In-Reply-To: <4C1BEA77.9090509@bredband.net> References: <4C1BEA77.9090509@bredband.net> Message-ID: On Fri, Jun 18, 2010 at 3:51 PM, H?kan Stenholm wrote: > Wes James wrote: >> >> I see how to do: >> >> [X || X <- [1,2,3,4,5,6]] >> >> will create [1,2,3,4,5] >> >> but how about I have two lists, [1,2,3] and [a,b,c] and I want to output >> >> [[1,a], [2,b], [3,c]] >> >> can that be done with a list comprehension? >> >> thx, >> >> -wes >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> >> > > lists:zip([1,2,3], [a,b,c]). ? ? ? ? ?-> > > [{1,a},{2,b},{3,c}] > > > [[A,B] || {A,B} <- lists:zip([1,2,3], [a,b,c])]. ? ? ? ? -> > > > [[1,a],[2,b],[3,c]] > H?kan, thx - that was too simple.... -wes From rvirding@REDACTED Fri Jun 18 23:58:37 2010 From: rvirding@REDACTED (Robert Virding) Date: Fri, 18 Jun 2010 23:58:37 +0200 Subject: [erlang-questions] list comprehension of two lists In-Reply-To: References: <4C1BEA77.9090509@bredband.net> Message-ID: Or try lists:zipwith/3 to do it one go. Robert On 18 June 2010 23:55, Wes James wrote: > On Fri, Jun 18, 2010 at 3:51 PM, H?kan Stenholm > wrote: >> Wes James wrote: >>> >>> I see how to do: >>> >>> [X || X <- [1,2,3,4,5,6]] >>> >>> will create [1,2,3,4,5] >>> >>> but how about I have two lists, [1,2,3] and [a,b,c] and I want to output >>> >>> [[1,a], [2,b], [3,c]] >>> >>> can that be done with a list comprehension? >>> >>> thx, >>> >>> -wes >>> >>> ________________________________________________________________ >>> erlang-questions (at) erlang.org mailing list. >>> See http://www.erlang.org/faq.html >>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>> >>> >>> >> >> lists:zip([1,2,3], [a,b,c]). ? ? ? ? ?-> >> >> [{1,a},{2,b},{3,c}] >> >> >> [[A,B] || {A,B} <- lists:zip([1,2,3], [a,b,c])]. ? ? ? ? -> >> >> >> [[1,a],[2,b],[3,c]] >> > > H?kan, thx - that was too simple.... > > -wes > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From pekadan@REDACTED Sat Jun 19 01:33:06 2010 From: pekadan@REDACTED (Peter Andersson) Date: Sat, 19 Jun 2010 01:33:06 +0200 Subject: Bug in test specifications, Common Test 1.5 (OTP R14A) Message-ID: Hi, I just wanted to inform you that I've found a silly bug in the latest version of Common Test, v1.5 (i.e. OTP R14A). The problem is that the logdir term in a test specification gets discarded at startup. So, if no explicit logdir start option is given, "./" will be used as log directory, regardless what's stated in the test specification. Bummer. The error has been corrected and the fix will show up in the pu branch next week some time. Keep an eye open for it if this problem affects you. Sorry about the inconvenience! :-$ /Peter The Erlang/OTP team, Ericsson AB From bernie@REDACTED Sat Jun 19 04:30:54 2010 From: bernie@REDACTED (Bernard Duggan) Date: Sat, 19 Jun 2010 12:30:54 +1000 Subject: [erlang-questions] Compile "escript" file to a binary executable! In-Reply-To: <4C1C56A3-371E-434C-9E9A-70A157BDC40D@gmail.com> References: <4C1C56A3-371E-434C-9E9A-70A157BDC40D@gmail.com> Message-ID: <4C1C2BDE.9030404@m5net.com> If I understand Zabrane's question correctly, what he was actually asking is whether there's a way to make an escript into something that can run on its own, without the need for an erlang installation on the machine. To which I suspect the answer is "not really, no". B On 19/06/2010 5:25 AM, Chris Bernard wrote: > Zabrane, > > The OTP doc says an escript can contain "Erlang source code, an > inlined beam file or an inlined archive file." > http://www.erlang.org/doc/man/escript.html > > For an example of an escript containing an inlined archive, check out > how the excellent "rebar" bootstraps itself (an OTP application and > release build tool). > http://bitbucket.org/basho/rebar/src/tip/bootstrap > > Cheers, > Chris Bernard > > > On Jun 18, 2010, at 1:43 PM, zabrane Mikael wrote: > > >> Hi list, >> >> Is there a way(or even a hack) to compile an "escript" file to a >> binary >> executable? >> >> Thanks ! >> -- >> Regards >> Zabrane >> > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From zabrane3@REDACTED Sat Jun 19 07:14:54 2010 From: zabrane3@REDACTED (zabrane Mikael) Date: Sat, 19 Jun 2010 07:14:54 +0200 Subject: [erlang-questions] Compile "escript" file to a binary executable! In-Reply-To: <4C1C2BDE.9030404@m5net.com> References: <4C1C56A3-371E-434C-9E9A-70A157BDC40D@gmail.com> <4C1C2BDE.9030404@m5net.com> Message-ID: Hi Bernard, Chris pointed out a way to do it in "rebar". And it really works: http://hg.basho.com/rebar/src/tip/src/rebar_escripter.erl Regards Zabrane 2010/6/19 Bernard Duggan > If I understand Zabrane's question correctly, what he was actually > asking is whether there's a way to make an escript into something that > can run on its own, without the need for an erlang installation on the > machine. To which I suspect the answer is "not really, no". > > B > > On 19/06/2010 5:25 AM, Chris Bernard wrote: > > Zabrane, > > > > The OTP doc says an escript can contain "Erlang source code, an > > inlined beam file or an inlined archive file." > > http://www.erlang.org/doc/man/escript.html > > > > For an example of an escript containing an inlined archive, check out > > how the excellent "rebar" bootstraps itself (an OTP application and > > release build tool). > > http://bitbucket.org/basho/rebar/src/tip/bootstrap > > > > Cheers, > > Chris Bernard > > > > > > On Jun 18, 2010, at 1:43 PM, zabrane Mikael wrote: > > > > > >> Hi list, > >> > >> Is there a way(or even a hack) to compile an "escript" file to a > >> binary > >> executable? > >> > >> Thanks ! > >> -- > >> Regards > >> Zabrane > >> > > > > ________________________________________________________________ > > erlang-questions (at) erlang.org mailing list. > > See http://www.erlang.org/faq.html > > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > > > > -- Regards Zabrane From info@REDACTED Sat Jun 19 15:49:24 2010 From: info@REDACTED (info) Date: Sat, 19 Jun 2010 15:49:24 +0200 Subject: replace and bad argument Message-ID: <201006191549241117705@its3.ch> I want to replace the "),(" string by the "/" char. re:replace("(a,b),(c,d)","),(","/",[{return,list}]). I received this message: ** exception error: bad argument in function re:replace/4 called as re:replace("(a,b),(c,d)","),(","/",[{return,list}]) From luismarianoguerra@REDACTED Sat Jun 19 16:06:39 2010 From: luismarianoguerra@REDACTED (Mariano Guerra) Date: Sat, 19 Jun 2010 11:06:39 -0300 Subject: [erlang-questions] re:replace and bad argument In-Reply-To: <201006191549241117705@its3.ch> References: <201006191549241117705@its3.ch> Message-ID: On Sat, Jun 19, 2010 at 10:49 AM, info wrote: > I want to replace the "),(" string by the "/" char. > > re:replace("(a,b),(c,d)","),(","/",[{return,list}]). > > I received this message: > > ** exception error: bad argument > ? ? in function ?re:replace/4 > ? ? ? ?called as re:replace("(a,b),(c,d)","),(","/",[{return,list}]) > your regular expression is invalid, you need to quote the parenthesis this should work: 5> re:replace("(a,b),(c,d)","\\),\\(","/",[{return,list}]). "(a,b/c,d)" From russell.brown@REDACTED Sat Jun 19 21:50:10 2010 From: russell.brown@REDACTED (Russell Brown) Date: Sat, 19 Jun 2010 20:50:10 +0100 Subject: code:clash() and symbolic links Message-ID: <5C595EA5-34D2-4738-B9A4-E4A653A52B76@mac.com> Hi, I did a google search on code clash and symbolic links, and checked the man pages for the code module and found nothing to answer this question: why is it that I get lots of code clash if I have a symlink to erlang? My set up is to have erlang-RXXXX and erlang-RXXXX-1 on the same machine and just change the symlink of erlang->erlangRXXXX that I am working with. When I do this however I get code clash warnings for every beam. Without the symlink no code clash. Only the link is on my path/ref'd by $ERL_LIBS, not the target too. Sorry if it has been asked before but I couldn't find it through google-ing. I know it is trivial but I worry that a genuine clash report will be drowned out by the noise. Many thanks Russell From attila.r.nohl@REDACTED Sat Jun 19 23:30:51 2010 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Sat, 19 Jun 2010 23:30:51 +0200 Subject: [erlang-questions] code:clash() and symbolic links In-Reply-To: <5C595EA5-34D2-4738-B9A4-E4A653A52B76@mac.com> References: <5C595EA5-34D2-4738-B9A4-E4A653A52B76@mac.com> Message-ID: 2010/6/19, Russell Brown : > Hi, > I did a google search on code clash and symbolic links, and checked the man > pages for the code module and found nothing to answer this question: why is > it that I get lots of code clash if I have a symlink to erlang? Have you checked the result of code:get_path() in both setups? From kenji.rikitake@REDACTED Sun Jun 20 06:24:50 2010 From: kenji.rikitake@REDACTED (Kenji Rikitake) Date: Sun, 20 Jun 2010 13:24:50 +0900 Subject: R14A FreeBSD unofficial port Message-ID: <20100620042450.GA28253@k2r.org> The following tar.gz archive includes an unofficial port of Erlang R14A for FreeBSD (lang/erlang, erlang-r14a,1) Note 1: R13A port hasn't been released officially, so I expect R14A port won't be released officially either. Note 2: Java functionality untested. Note 3: Compilation/installation ested on FreeBSD 7.3-RELEASE i386. http://www.ne.jp/asahi/bdx/info/software/erlang-r14a,1-20100620.tar.gz Regards, Kenji Rikitake From dougedmunds@REDACTED Sun Jun 20 07:01:20 2010 From: dougedmunds@REDACTED (Doug Edmunds (gmail)) Date: Sat, 19 Jun 2010 22:01:20 -0700 Subject: [erlang-questions] A future for gs? In-Reply-To: References: Message-ID: <4C1DA0A0.7040208@gmail.com> Hello, I've been putting together a wxErlang tutorial. Might help you some if you go that route. At http://wxerlang.dougedmunds.com - Doug Edmunds On 6/14/2010 11:19 PM, Michael Turner wrote: > Regretfully, I'm starting to look at wx again, but I find it only reminds me > far too much of what I disliked about GUI programming in C++. If you > already know the wxWidgets API from some other language, the very similar > Erlang bindings might seem like a Godsend. But if you just want to get a > GUI up and out of the way (my goal), and you don't have that wdWidgets > background, it all just seems verbose, over-parameterized, encyclopedically > overwhelming. (IMAO, anyway -- I've done Mac programming, Windows > programming, and hated every minute of GUI programming on both.) > From info@REDACTED Sun Jun 20 19:43:57 2010 From: info@REDACTED (info) Date: Sun, 20 Jun 2010 19:43:57 +0200 Subject: string to tupple ? Message-ID: <201006201943566702810@its3.ch> After a few manipulation with list, string, I broke my head with this problem. I extract from a mysql database a list representing a list of coordinates. The string is like this "(a,b),(c,d),(e,f) ......." I would like to transform this string in order to easily manipulate each coordinate. What is the best representation in erlang ? - a list of tupples : if yes how to transform it in [{a,b},{c,d},{e,f}, ....] - other representations ? John From rapsey@REDACTED Sun Jun 20 19:50:23 2010 From: rapsey@REDACTED (Rapsey) Date: Sun, 20 Jun 2010 19:50:23 +0200 Subject: [erlang-questions] string to tupple ? In-Reply-To: <201006201943566702810@its3.ch> References: <201006201943566702810@its3.ch> Message-ID: The best representation depends on what operations you need to perform. List of tuples or just a plain list of integers would most likely be best. Parsing that format is pretty easy: L = string:tokens("(a,b),(c,d),(e,f)","(),"). [list_to_integer(C) || C <- L]. Sergej On Sun, Jun 20, 2010 at 7:43 PM, info wrote: > After a few manipulation with list, string, I broke my head with this > problem. > > I extract from a mysql database a list representing a list of coordinates. > The string is like this "(a,b),(c,d),(e,f) ......." > I would like to transform this string in order to easily manipulate each > coordinate. > What is the best representation in erlang ? > - a list of tupples : if yes how to transform it in [{a,b},{c,d},{e,f}, > ....] > - other representations ? > > John > From per@REDACTED Sun Jun 20 22:16:12 2010 From: per@REDACTED (Per Hedeland) Date: Sun, 20 Jun 2010 22:16:12 +0200 (CEST) Subject: [erlang-questions] inet_res:getbyname/2 and udp:connect/3 In-Reply-To: <201006172019.o5HKJKZc029818@pluto.hedeland.org> Message-ID: <201006202016.o5KKGCTi032358@pluto.hedeland.org> Per Hedeland wrote: > I.e. it >seems this is actually a problem with the FreeBSD "port" build of >Erlang/OTP (I happened to have such a build of R12B-5 around too - same >problem there). Actually this wasn't quite correct - it's a problem with the FreeBSD port build only insofar as it uses --enable-sctp (which my other build didn't) - thereby exposing a bug in inet_drv. I.e. connected UDP (and handling of any other errors in UDP recv()) is broken in passive mode for all SCTP-enabled builds. Patch below against R13B04 - R14A has the same bug. --Per --- otp_src_R13B04/erts/emulator/drivers/common/inet_drv.c.ORIG 2010-02-19 19:03:43.000000000 +0100 +++ otp_src_R13B04/erts/emulator/drivers/common/inet_drv.c 2010-06-20 21:57:12.000000000 +0200 @@ -9382,9 +9382,8 @@ if (short_recv) async_error_am(desc, am_short_recv); else -#else - async_error(desc, err); #endif + async_error(desc, err); driver_cancel_timer(desc->port); sock_select(desc,FD_READ,0); } From seancribbs@REDACTED Sun Jun 20 23:00:38 2010 From: seancribbs@REDACTED (Sean Cribbs) Date: Sun, 20 Jun 2010 17:00:38 -0400 Subject: [erlang-questions] string to tupple ? In-Reply-To: References: <201006201943566702810@its3.ch> Message-ID: If you want to be more formal about it, both neotoma and leex/yecc would make short work of that format. Just out of curiosity, any reason why you can't use a mysql driver for Erlang (instead of going to the trouble of parsing)? Here's a small grammar in neotoma's PEG format (untested): coord_list <- pair ("," pair)* `[ hd(Node) | [P || [",", P] <- tl(Node)] ]`; pair <- "(" number "," number ")" `{lists:nth(2,Node), lists:nth(4,Node)}`; number <- [0-9]+ `list_to_integer(Node)`; Sean On Sun, Jun 20, 2010 at 1:50 PM, Rapsey wrote: > The best representation depends on what operations you need to perform. List > of tuples or just a plain list of integers would most likely be best. > Parsing that format is pretty easy: > > L = string:tokens("(a,b),(c,d),(e,f)","(),"). > [list_to_integer(C) || C <- L]. > > > Sergej > > On Sun, Jun 20, 2010 at 7:43 PM, info wrote: > >> After a few manipulation with list, string, I broke my head with this >> problem. >> >> I extract from a mysql database a list representing a list of coordinates. >> The string is like this "(a,b),(c,d),(e,f) ......." >> I would like to transform this string in order to easily manipulate each >> coordinate. >> What is the best representation in erlang ? >> - a list of tupples : if yes how to transform it in [{a,b},{c,d},{e,f}, >> ....] >> - other representations ? >> >> John >> > From rvirding@REDACTED Sun Jun 20 23:28:14 2010 From: rvirding@REDACTED (Robert Virding) Date: Sun, 20 Jun 2010 23:28:14 +0200 Subject: New test release of LFE Message-ID: I have made a test release of LFE on github, http://github.com/rvirding/lfe, which has string literals in binaries and new Makefile, Emakefile and lfe.app. The Makefile should detect if you have rebar and use that if it available. Plus internal stuff as well. Robert From info@REDACTED Sun Jun 20 23:42:11 2010 From: info@REDACTED (info) Date: Sun, 20 Jun 2010 23:42:11 +0200 Subject: [erlang-questions] string to tupple ? References: <201006201943566702810@its3.ch>, , Message-ID: <201006202342107198340@its3.ch> Why do you suspect I don't use a mysql driver ? Data format is independant of the drivers. John If you want to be more formal about it, both neotoma and leex/yecc would make short work of that format. Just out of curiosity, any reason why you can't use a mysql driver for Erlang (instead of going to the trouble of parsing)? Here's a small grammar in neotoma's PEG format (untested): coord_list <- pair ("," pair)* `[ hd(Node) | [P || [",", P] <- tl(Node)] ]`; pair <- "(" number "," number ")" `{lists:nth(2,Node), lists:nth(4,Node)}`; number <- [0-9]+ `list_to_integer(Node)`; Sean On Sun, Jun 20, 2010 at 1:50 PM, Rapsey wrote: > The best representation depends on what operations you need to perform. List > of tuples or just a plain list of integers would most likely be best. > Parsing that format is pretty easy: > > L = string:tokens("(a,b),(c,d),(e,f)","(),"). > [list_to_integer(C) || C <- L]. > > > Sergej > > On Sun, Jun 20, 2010 at 7:43 PM, info wrote: > > > After a few manipulation with list, string, I broke my head with this > > problem. > > > > I extract from a mysql database a list representing a list of coordinates. > > The string is like this "(a,b),(c,d),(e,f) ......." > > I would like to transform this string in order to easily manipulate each > > coordinate. > > What is the best representation in erlang ? > > - a list of tupples : if yes how to transform it in [{a,b},{c,d},{e,f}, > > ....] > > - other representations ? > > > > John > > > ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED From info@REDACTED Mon Jun 21 01:00:13 2010 From: info@REDACTED (info) Date: Mon, 21 Jun 2010 00:00:13 +0100 Subject: [erlang-questions] string to tupple ? References: <201006201943566702810@its3.ch>, Message-ID: <201006210000131378713@its3.ch> An for the second one (list of tupples) ? [list_to_tupple(C) ||C<-L] The best representation depends on what operations you need to perform. List of tuples or just a plain list of integers would most likely be best. Parsing that format is pretty easy: L = string:tokens("(a,b),(c,d),(e,f)","(),"). [list_to_integer(C) || C <- L]. Sergej On Sun, Jun 20, 2010 at 7:43 PM, info wrote: > After a few manipulation with list, string, I broke my head with this > problem. > > I extract from a mysql database a list representing a list of coordinates. > The string is like this "(a,b),(c,d),(e,f) ......." > I would like to transform this string in order to easily manipulate each > coordinate. > What is the best representation in erlang ? > - a list of tupples : if yes how to transform it in [{a,b},{c,d},{e,f}, > ....] > - other representations ? > > John > From info@REDACTED Mon Jun 21 01:08:16 2010 From: info@REDACTED (info) Date: Mon, 21 Jun 2010 00:08:16 +0100 Subject: [erlang-questions] string to tupple ? References: <201006201943566702810@its3.ch>, Message-ID: <201006210008152153013@its3.ch> I tested. I had a bad argument for list_of_integer. I suppose because a,b,c ... are strings ? list_to_integer("46.123456") The best representation depends on what operations you need to perform. List of tuples or just a plain list of integers would most likely be best. Parsing that format is pretty easy: L = string:tokens("(a,b),(c,d),(e,f)","(),"). [list_to_integer(C) || C <- L]. Sergej On Sun, Jun 20, 2010 at 7:43 PM, info wrote: > After a few manipulation with list, string, I broke my head with this > problem. > > I extract from a mysql database a list representing a list of coordinates. > The string is like this "(a,b),(c,d),(e,f) ......." > I would like to transform this string in order to easily manipulate each > coordinate. > What is the best representation in erlang ? > - a list of tupples : if yes how to transform it in [{a,b},{c,d},{e,f}, > ....] > - other representations ? > > John > From ok@REDACTED Mon Jun 21 02:25:03 2010 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 21 Jun 2010 12:25:03 +1200 Subject: [erlang-questions] string to tupple ? In-Reply-To: <201006201943566702810@its3.ch> References: <201006201943566702810@its3.ch> Message-ID: <7563FAAD-CC08-4177-A264-634AB257C633@cs.otago.ac.nz> On Jun 21, 2010, at 5:43 AM, info wrote: > After a few manipulation with list, string, I broke my head with > this problem. > > I extract from a mysql database a list representing a list of > coordinates. > The string is like this "(a,b),(c,d),(e,f) ......." The obvious question is "WHY"? This is not the way textbooks tell you to structure data in a relational data base; E.F.Codd is spinning in his grave. (Of _course_ there are practical considerations that mean you sometimes have to do non-ideal things, and "atomic" always meant "atomic with respect to what the database needs to do with it", otherwise we wouldn't have BLOBs.) > I would like to transform this string in order to easily manipulate > each coordinate. > What is the best representation in erlang ? It depends entirely on what you are going to do with it. > - a list of tupples : if yes how to transform it in [{a,b},{c,d}, > {e,f}, ....] There is only one "p" in "tuple". erl_scan:string("(1,2),(3,4)") gives you this answer: {ok,[{'(',1}, {integer,1,1}, {',',1}, {integer,1,2}, {')',1}, {',',1}, {'(',1}, {integer,1,3}, {',',1}, {integer,1,4}, {')',1}], 1} So string_to_pairs(String) -> {ok,Tokens,_} = erl_scan:string(String), unwrap([{',',1}|Tokens]). unwrap([{',',_},{'(',_},{_,_,X},{',',_},{_,_,Y},{')',_}|Tokens]) -> [{X,Y} | unwrap(Tokens)]; unwrap([]) -> []. is probably the easiest way. This relies on the string containing "(" ")" and "," as punctuation marks plus numbers that look like Erlang integers {integer,_,X} or floats {float,_,Y}. > - other representations ? The obvious one is a pair of lists of numbers. There are lots of other possibilities, depending on - what kind of numbers you are dealing with - what you are going to do with them For example, if you know the numbers are whole numbers, the very simplest code would be [X || {integer,_,X} <- erl_scan:string(String)] which would give you a list of integers. From lloy0076@REDACTED Mon Jun 21 00:41:15 2010 From: lloy0076@REDACTED (David Lloyd) Date: Mon, 21 Jun 2010 08:11:15 +0930 Subject: [erlang-questions] Accounting Engine in Erlang In-Reply-To: References: Message-ID: Erlang is a Turing complete language - of course one could solve consistency with it, if it is solvable as a Turin problem... DSL On 15/06/2010, at 12:38 AM, amiruddin nagri wrote: > > We have a requirement of making an accounting engine that handles all > the journal entries, transactions, portfolios etc. The communication > with the engine is based on simple protocol, the things to be taken > care of in the order are consistency and performance. > > I have looked around some of the products based on erlang, > specifically couch db, couch db promises eventual consistency and > horizontal scaling. > > Is the issue of consistency not solvable using erlang, or if we > implement consistency using erlang we won't be able use the > performance and scaling feature of erlang to maximum. > > Also, if you have any suggestions of the choice of programming > language, we have been looking into other functional languages like > Haskell and Clojure. But we have not dig deep on the performance > aspects of these languages, if someone can shed a light on the pros- > cons of these languages, it will help us very much to come to a > decision. > > -Regards, > Amir > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > From ok@REDACTED Mon Jun 21 02:52:46 2010 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 21 Jun 2010 12:52:46 +1200 Subject: [erlang-questions] list comprehension of two lists In-Reply-To: References: Message-ID: On Jun 19, 2010, at 9:34 AM, Wes James wrote: > I see how to do: > > [X || X <- [1,2,3,4,5,6]] > > will create [1,2,3,4,5] > > but how about I have two lists, [1,2,3] and [a,b,c] and I want to > output > > [[1,a], [2,b], [3,c]] > > can that be done with a list comprehension? EEP 19 ( http://www.erlang.org/eeps/eep-0019.html ) would let you write [[X,Y] || X <- [1,2,3] && Y <- [a,b,c]] EEP 19 was inspired by a similar feature in Clean. Until that or something like it is implemented, no, it _can't_ be done with a list comprehension, at least not in any way that's simpler than calling lists:zip2/2 or lists:zipwith/3. From bernie@REDACTED Mon Jun 21 04:27:18 2010 From: bernie@REDACTED (Bernard Duggan) Date: Mon, 21 Jun 2010 12:27:18 +1000 Subject: Dialyzer startup time Message-ID: <4C1ECE06.2070102@m5net.com> Hi list, When running dialyzer, the first thing it always does is the "Compiling some key modules to native code" step. Am I right in thinking that this phase involves just compiling some actual dialyzer-related code (rather than the code I'm trying to analyze)? If so, surely it isn't necessary to redo this every run given that those files won't have changed (unless I actually upgrade my Erlang install). Is there a way to cache the compilation results or something so that this step (a bit under half the total "dialyzing" time) can be avoided? If not, what would it take to add such a system? Cheers, Bernard From kostis@REDACTED Mon Jun 21 09:02:57 2010 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 21 Jun 2010 10:02:57 +0300 Subject: [erlang-questions] Dialyzer startup time In-Reply-To: <4C1ECE06.2070102@m5net.com> References: <4C1ECE06.2070102@m5net.com> Message-ID: <4C1F0EA1.9020308@cs.ntua.gr> Bernard Duggan wrote: > Hi list, > When running dialyzer, the first thing it always does is the > "Compiling some key modules to native code" step. Well, this is not done always. This step is performed only if you are about to dialyze more than a certain number of files (20, I believe) which in turn typically results in considerably faster analysis time. You can bypass this step by using the --no_native (-nn) option. > Am I right in > thinking that this phase involves just compiling some actual > dialyzer-related code (rather than the code I'm trying to analyze)? Yes. > If so, surely it isn't necessary to redo this every run given that those > files won't have changed (unless I actually upgrade my Erlang install). > Is there a way to cache the compilation results or something so that > this step (a bit under half the total "dialyzing" time) can be avoided? > If not, what would it take to add such a system? There is a way to do this, though not in the way you suggest. I have to warn you that, even though I am using it in my system for more that a year now, I am not sure of its status in Erlang/OTP R14A. If you are interested, give it a try and I'll help you get it working. Starting from a clean system, there is a configure option: --enable-native-libs which you should use at configuration time. Needless to mention, hipe should also be enabled. Then issue a 'make'. Let us know how it works. Cheers, Kostis From torben.lehoff@REDACTED Mon Jun 21 09:22:50 2010 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Mon, 21 Jun 2010 09:22:50 +0200 Subject: [erlang-questions] erlang without wx In-Reply-To: References: Message-ID: Hi Levend, Have a look at Faxien at erlware.org - it might be what you need. Cheers, Torben On Fri, Jun 18, 2010 at 17:57, Levend Sayar wrote: > Hi, everybody. > > I need erlang runtime. But I do not want any gui related packages. > So is it possible to configure erlang source package to supply only the > runtime environement ? > > no debugger, no dialyzer, no gs, no wx > > TIA > > _lvnd_ > (^_^) > -- http://www.linkedin.com/in/torbenhoffmann From dangud@REDACTED Mon Jun 21 11:07:44 2010 From: dangud@REDACTED (Dan Gudmundsson) Date: Mon, 21 Jun 2010 11:07:44 +0200 Subject: [erlang-questions] error msg In-Reply-To: <20100618002006.645e5880@anubis.defcon1> References: <20100618002006.645e5880@anubis.defcon1> Message-ID: Hi Can you give some more info? Which os, uname -a ? How did you build this, what options, what does the banner say, i.e the first line when you start erl. And if you get a core dump can you give us a backtrace? /Dan On Fri, Jun 18, 2010 at 12:20 AM, Jean-Yves F. Barbier <12ukwn@REDACTED> wrote: > Hi list, > > After recompiling (native) wx demo examples, I've got an error msg when I > try to launch 'gl': > > 2> demo:start(). > {wx_ref,35,wxFrame,<0.36.0>} > 3> Unlocking required 'proc_main:<0.43.0>[proclock]' lock! > Currently these locks are locked by the scheduler 1 thread: > ?'proc_main:<0.43.0>[proclock]' > ?'run_queue:1[mutex]' > Abandon > > what does this mean? > > -- > "... the Mayo Clinic, named after its founder, Dr. Ted Clinic ..." > ? ? ? ? ? ? ? ?-- Dave Barry > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From mail@REDACTED Mon Jun 21 11:10:00 2010 From: mail@REDACTED (Tim Fletcher) Date: Mon, 21 Jun 2010 02:10:00 -0700 (PDT) Subject: string to tupple ? In-Reply-To: <7563FAAD-CC08-4177-A264-634AB257C633@cs.otago.ac.nz> References: <201006201943566702810@its3.ch> <7563FAAD-CC08-4177-A264-634AB257C633@cs.otago.ac.nz> Message-ID: <6e02431e-1183-430a-a994-3da58f5e19d8@w31g2000yqb.googlegroups.com> > The obvious question is "WHY"? Presumably you meant "why isn't that data structured relationally" instead of "why extract data from a database" :) One possible answer is that it's someone else's database. > For example, if you know the numbers are whole numbers, > the very simplest code would be > ? ? ? ? [X || {integer,_,X} <- erl_scan:string(String)] > which would give you a list of integers. That'll throw a "bad generator" error. Did you mean this: {ok,Tokens,_} = erl_scan:string("(1,2),(3,4)"), [X || {integer,_,X} <- Tokens]. ? From mail@REDACTED Mon Jun 21 11:11:28 2010 From: mail@REDACTED (Tim Fletcher) Date: Mon, 21 Jun 2010 02:11:28 -0700 (PDT) Subject: string to tupple ? In-Reply-To: <201006201943566702810@its3.ch> References: <201006201943566702810@its3.ch> Message-ID: <62b8be9e-a346-470a-bbb3-737815d9f1f1@g19g2000yqc.googlegroups.com> > I would like to transform this string in order to easily manipulate each coordinate. > What is the best representation in erlang ? > - a list of tupples : if yes how to transform it in [{a,b},{c,d},{e,f}, ....] If you want tuples then another option would be to use regular expressions, for example: String = "(1,2),(3,4)", {match, Groups} = re:run(String, "\\(([^,]+),([^,]+)\\)", [{capture, all_but_first, list}, global]), [{list_to_integer(X), list_to_integer(Y)} || [X, Y] <- Groups]. Also works with floats; just replace the calls to list_to_integer with list_to_float. Tim From martti.kuparinen@REDACTED Mon Jun 21 12:44:15 2010 From: martti.kuparinen@REDACTED (Martti Kuparinen) Date: Mon, 21 Jun 2010 13:44:15 +0300 Subject: Missing -rpath in odbc Message-ID: <1277117055.2087.47.camel@tri10.nomadiclab.com> Hi, I'm working on creating a NetBSD package of R14A and I'm almost ready with it, only ODBC is giving me some problems. It seems like lib/odbc/src should add "-Wl,-R xxx" to the Makefile flags, without it I get a binary which can't find the required library (http://mail-index.netbsd.org/tech-pkg/2010/06/21/msg005681.html). But I'm unsure where to put CC_R_FLAG setting so it's in the "right" place. Would you guys help me with this? lib/odbc/c_src/Makefile.in looks right but the Makefile in the same dir looks nothing like the Makefile.in. PS. For those of you who want to see the almost-ready package, please see http://pkgsrc-wip.cvs.sourceforge.net/viewvc/pkgsrc-wip/wip/erlang/ I'm going to submit most of those patches (see the patches/ directory) to be included in the official Erlang repository once I have everything up and running... Martti From john.hughes@REDACTED Mon Jun 21 13:31:50 2010 From: john.hughes@REDACTED (John Hughes) Date: Mon, 21 Jun 2010 13:31:50 +0200 Subject: Quviq releases a free version of QuickCheck In-Reply-To: <6e02431e-1183-430a-a994-3da58f5e19d8@w31g2000yqb.googlegroups.com> References: <201006201943566702810@its3.ch> <7563FAAD-CC08-4177-A264-634AB257C633@cs.otago.ac.nz> <6e02431e-1183-430a-a994-3da58f5e19d8@w31g2000yqb.googlegroups.com> Message-ID: <99A49097A94D455F8D58F6244BDB22A8@JohnsTablet2009> In conjunction with the Erlang Factory in London, Quviq released a free version of QuickCheck known as QuickCheck Mini, which offers a feature subset more-or-less corresponding to Haskell QuickCheck. There are no restrictions on the use of QuickCheck Mini... commercial use is both allowed and welcomed. Now the release is also available from our website... take a look at quviq.com, and click on the "Downloads" tab. Have fun! John Hughes From jesper.louis.andersen@REDACTED Mon Jun 21 14:36:28 2010 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Mon, 21 Jun 2010 14:36:28 +0200 Subject: [erlang-questions] Quviq releases a free version of QuickCheck In-Reply-To: <99A49097A94D455F8D58F6244BDB22A8@JohnsTablet2009> References: <201006201943566702810@its3.ch> <7563FAAD-CC08-4177-A264-634AB257C633@cs.otago.ac.nz> <6e02431e-1183-430a-a994-3da58f5e19d8@w31g2000yqb.googlegroups.com> <99A49097A94D455F8D58F6244BDB22A8@JohnsTablet2009> Message-ID: On Mon, Jun 21, 2010 at 1:31 PM, John Hughes wrote: > In conjunction with the Erlang Factory in London, Quviq released a free > version of QuickCheck known as QuickCheck Mini, which offers a feature > subset more-or-less corresponding to Haskell QuickCheck. There are no > restrictions on the use of QuickCheck Mini... commercial use is both allowed > and welcomed. Now the release is also available from our website... take a > look at quviq.com, and click on the "Downloads" tab. > > Have fun! This is excellent news. I will try to adopt it for parts of etorrent (or if another soul is willing, drop me an email :) -- J. From ingela@REDACTED Mon Jun 21 15:14:24 2010 From: ingela@REDACTED (Ingela Andin) Date: Mon, 21 Jun 2010 15:14:24 +0200 Subject: [erlang-questions] Missing -rpath in odbc In-Reply-To: <1277117055.2087.47.camel@tri10.nomadiclab.com> References: <1277117055.2087.47.camel@tri10.nomadiclab.com> Message-ID: Hi! 2010/6/21 Martti Kuparinen : > Hi, > > I'm working on creating a NetBSD package of R14A and I'm almost ready > with it, only ODBC is giving me some problems. It seems like > lib/odbc/src should add "-Wl,-R xxx" to the Makefile flags, without it I > get a binary which can't find the required library > (http://mail-index.netbsd.org/tech-pkg/2010/06/21/msg005681.html). > > But I'm unsure where to put CC_R_FLAG setting so it's in the "right" > place. Would you guys help me with this? lib/odbc/c_src/Makefile.in looks > right but the Makefile in the same dir looks nothing like the Makefile.in. lib/odbc/c_src/Makefile.in is the corrct makefile to change. The make file generated from the Makefile.in will then reside in the platform dependent subdirectory for example in my case it will be found in lib/odbc/c_src/i686-pc-linux-gnu. It would be nice if you could make a git patch for R14A also. Regards Ingela OTP team - Ericsson AB From gli.work@REDACTED Mon Jun 21 15:31:04 2010 From: gli.work@REDACTED (Ivan Glushkov) Date: Mon, 21 Jun 2010 17:31:04 +0400 Subject: way to manage erlang console dumper Message-ID: Hi. Is there some way to manage the length after which erlang console dumper begin to shorten complex term print? For example > f(F), F = fun(C) -> lists:concat(lists:duplicate(15, C)) end, F([{1, F("a")}, {2, F("b")}]). [{1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,"aaaaaaaaaaaaaaa"}, {2,"bbbbbbbbbbbbbbb"}, {1,[...]}, {2,...}, {...}|...] Surely, i can insert io:format instead of just entering terms. But it's slightly inconvenient. I expected erlang console to have such an option, but i didn't find one. Thanks. Ivan. From info@REDACTED Mon Jun 21 16:41:52 2010 From: info@REDACTED (info) Date: Mon, 21 Jun 2010 16:41:52 +0200 Subject: [erlang-questions] Re: string to tupple ? References: <201006201943566702810@its3.ch>, <7563FAAD-CC08-4177-A264-634AB257C633@cs.otago.ac.nz>, <6e02431e-1183-430a-a994-3da58f5e19d8@w31g2000yqb.googlegroups.com> Message-ID: <201006211641521967082@its3.ch> > The obvious question is "WHY"? Presumably you meant "why isn't that data structured relationally" instead of "why extract data from a database" :) One possible answer is that it's someone else's database. Exactly ! I must use these data "as is". > For example, if you know the numbers are whole numbers, > the very simplest code would be > [X || {integer,_,X} <- erl_scan:string(String)] > which would give you a list of integers. That'll throw a "bad generator" error. Did you mean this: {ok,Tokens,_} = erl_scan:string("(1,2),(3,4)"), [X || {integer,_,X} <- Tokens]. ? ________________________________________________________________ erlang-questions (at) erlang.org mailing list. See http://www.erlang.org/faq.html To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED From ttom.kelly@REDACTED Mon Jun 21 22:51:33 2010 From: ttom.kelly@REDACTED (tom kelly) Date: Mon, 21 Jun 2010 21:51:33 +0100 Subject: +A attribute Message-ID: Hello List, Are there any guidelines for choosing the value for the +A flag. //Tom. From ok@REDACTED Tue Jun 22 00:06:46 2010 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 22 Jun 2010 10:06:46 +1200 Subject: [erlang-questions] Re: string to tupple ? In-Reply-To: <6e02431e-1183-430a-a994-3da58f5e19d8@w31g2000yqb.googlegroups.com> References: <201006201943566702810@its3.ch> <7563FAAD-CC08-4177-A264-634AB257C633@cs.otago.ac.nz> <6e02431e-1183-430a-a994-3da58f5e19d8@w31g2000yqb.googlegroups.com> Message-ID: On Jun 21, 2010, at 9:10 PM, Tim Fletcher wrote: >> The obvious question is "WHY"? > > Presumably you meant "why isn't that data structured relationally" > instead of "why extract data from a database" :) One possible answer > is that it's someone else's database. An answer from somebody other than the original poster isn't very useful. The question "why did whoever designed the data base fail to store the data in a relationally idiomatic way" remains unanswered. > >> For example, if you know the numbers are whole numbers, >> the very simplest code would be >> [X || {integer,_,X} <- erl_scan:string(String)] >> which would give you a list of integers. > > That'll throw a "bad generator" error. Did you mean this: > > {ok,Tokens,_} = erl_scan:string("(1,2),(3,4)"), > [X || {integer,_,X} <- Tokens]. Yes. A rather silly mistake for me to make, especially with the sample output staring me in the face. From reachsaurabhnarula@REDACTED Tue Jun 22 10:38:44 2010 From: reachsaurabhnarula@REDACTED (Saurabh Narula) Date: Tue, 22 Jun 2010 14:08:44 +0530 Subject: specifying NULL when using ODBC param_query Message-ID: Hello Everyone, Is there any way to specify a null value when using ODBC param_query, in case of SQL_Query we do not really end up facing this problem as we build our own query string and then execute sql_query, sql_query is potentially unsafe of sql injection attacks, and thus using param_query makes alot of sense, but param query makes it hard to specify the data type nuetral NULL value, if we try specifying blank values like 0 in case of number and "" in case of string, these blank values will end up taking space in the database and thus would be expensive in terms of memory consumption, a database specific NULL value would leave the field null with no memory consumption. Thank you everyone in advance. Saurabh From john.hughes@REDACTED Tue Jun 22 11:12:43 2010 From: john.hughes@REDACTED (John Hughes) Date: Tue, 22 Jun 2010 11:12:43 +0200 Subject: [erlang-questions] Quviq releases a free version of QuickCheck In-Reply-To: <99A49097A94D455F8D58F6244BDB22A8@JohnsTablet2009> References: <201006201943566702810@its3.ch> <7563FAAD-CC08-4177-A264-634AB257C633@cs.otago.ac.nz> <6e02431e-1183-430a-a994-3da58f5e19d8@w31g2000yqb.googlegroups.com> <99A49097A94D455F8D58F6244BDB22A8@JohnsTablet2009> Message-ID: For those who just want a URL, the news item is at http://quviq.com/news100621.html and the download is at http://quviq.com/downloads/eqcmini.zip John > In conjunction with the Erlang Factory in London, Quviq released a free > version of QuickCheck known as QuickCheck Mini, which offers a feature > subset more-or-less corresponding to Haskell QuickCheck. There are no > restrictions on the use of QuickCheck Mini... commercial use is both > allowed and welcomed. Now the release is also available from our > website... take a look at quviq.com, and click on the "Downloads" tab. > > Have fun! > > John Hughes From kostis@REDACTED Tue Jun 22 17:43:18 2010 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 22 Jun 2010 18:43:18 +0300 Subject: [announce] PropEr Message-ID: <4C20DA16.4010105@cs.ntua.gr> We are happy to announce the availability of yet another QuickCheck inspired testing tool for Erlang, called PropEr. PropEr is open source, distributed under GPL (version 3 or later) and can be obtained from: http://github.com/manopapad/proper PropEr is currently at a relatively early stage in its development but we believe it is at a point where its features are usable by others. We welcome feedback, feature requests and user contributions. Enjoy! Manolis Papadakis and Kostis Sagonas From mevans@REDACTED Wed Jun 23 01:18:02 2010 From: mevans@REDACTED (Evans, Matthew) Date: Tue, 22 Jun 2010 19:18:02 -0400 Subject: mnesia secondary index Message-ID: Hi, I have a fragmented mnesia table that I need to add a second index to. It appears that to get this working I need to call mnesia:add_table_index/2 for each fragment. i.e. mnesia:add_table_index(content_table,file_id). mnesia:add_table_index(content_table_frag2,file_id). mnesia:add_table_index(content_table_frag3,file_id). .... mnesia:add_table_index(content_table_fragN,file_id). Likewise, to do an index read of the fragmented table I need to search each fragment in turn: mnesia:activity(sync_dirty,fun mnesia:dirty_index_read/3,[content_table,{1,1,1},file_id],mnesia_frag). mnesia:activity(sync_dirty,fun mnesia:dirty_index_read/3,[content_table_frag2,{1,1,1},file_id],mnesia_frag). .... until match found, or .... mnesia:activity(sync_dirty,fun mnesia:dirty_index_read/3,[content_table_fragN,{1,1,1},file_id],mnesia_frag). I guess searching through multiple fragments is quicker than a brute-force mnesia:match_object/1 or mnesia:select/4, but I was wondering if there is a better way to do this? I could, of course, have my own secondary index table (in the example above the key would be file_id and the data would be the primary key I ultimately want). But I now need to ensure the two tables remain in sync. Is there another way anyone is aware of? Thanks Matt From bernie@REDACTED Wed Jun 23 06:17:44 2010 From: bernie@REDACTED (Bernard Duggan) Date: Wed, 23 Jun 2010 14:17:44 +1000 Subject: [erlang-questions] Dialyzer startup time In-Reply-To: <4C1F0EA1.9020308@cs.ntua.gr> References: <4C1ECE06.2070102@m5net.com> <4C1F0EA1.9020308@cs.ntua.gr> Message-ID: <4C218AE8.8080801@m5net.com> Hi Kostis, Thanks for the reply. On 21/06/10 17:02, Kostis Sagonas wrote: >> Hi list, >> When running dialyzer, the first thing it always does is the >> "Compiling some key modules to native code" step. >> > Well, this is not done always. This step is performed only if you are > about to dialyze more than a certain number of files (20, I believe) > which in turn typically results in considerably faster analysis time. > You can bypass this step by using the --no_native (-nn) option. > Sorry, I should have said "when running dialyzer /on our codebase/" :) You're quite right that the net speedup is still significant - for a while we were accidentally running a version of Erlang on one machine that didn't have HiPE compiled in, and the dialyzer run took waaaay longer. >> If so, surely it isn't necessary to redo this every run given that those >> files won't have changed (unless I actually upgrade my Erlang install). >> Is there a way to cache the compilation results or something so that >> this step (a bit under half the total "dialyzing" time) can be avoided? >> If not, what would it take to add such a system? >> > There is a way to do this, though not in the way you suggest. I have to > warn you that, even though I am using it in my system for more that a > year now, I am not sure of its status in Erlang/OTP R14A. > > If you are interested, give it a try and I'll help you get it working. > Starting from a clean system, there is a configure option: > > --enable-native-libs > > which you should use at configuration time. Needless to mention, hipe > should also be enabled. Then issue a 'make'. Let us know how it works. > Well, I've just tried that - it all compiled and built just fine, but I'm still getting the "Compiling some key modules to native code" phase, although now it's taking ~37s rather than ~60s (which I guess is maybe a function of the compiler itself now using native code?). Was that what you were expecting, or should that step go away entirely? Regardless, it's not a huge deal, it just seemed like something that was taking a while and that might have been easy to speed up - it's not going to ruin my day if I'm wrong about that :) Cheers, Bernard From zabrane3@REDACTED Wed Jun 23 08:15:29 2010 From: zabrane3@REDACTED (zabrane Mikael) Date: Wed, 23 Jun 2010 08:15:29 +0200 Subject: [erlang-questions] +A attribute In-Reply-To: References: Message-ID: I'm also interested on that. Any advices guys? 2010/6/21 tom kelly > Hello List, > > Are there any guidelines for choosing the value for the +A flag. > > //Tom. > -- Regards Zabrane From kostis@REDACTED Wed Jun 23 08:20:47 2010 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 23 Jun 2010 09:20:47 +0300 Subject: [erlang-questions] Dialyzer startup time In-Reply-To: <4C218AE8.8080801@m5net.com> References: <4C1ECE06.2070102@m5net.com> <4C1F0EA1.9020308@cs.ntua.gr> <4C218AE8.8080801@m5net.com> Message-ID: <4C21A7BF.9020403@cs.ntua.gr> Bernard Duggan wrote: > Hi Kostis, > Thanks for the reply. > > On 21/06/10 17:02, Kostis Sagonas wrote: >> >> If you are interested, give it a try and I'll help you get it working. >> Starting from a clean system, there is a configure option: >> >> --enable-native-libs >> >> which you should use at configuration time. Needless to mention, hipe >> should also be enabled. Then issue a 'make'. Let us know how it works. >> > Well, I've just tried that - it all compiled and built just fine, but > I'm still getting the "Compiling some key modules to native code" phase, > although now it's taking ~37s rather than ~60s (which I guess is maybe a > function of the compiler itself now using native code?). Was that what > you were expecting, or should that step go away entirely? Unfortunately, this step will not go away entirely (modules loaded early in the startup like lists will always be compiled), but you can bring it down considerably. I am a bit surprised about this ~37s. Is this a very old and single core machine? On my 4+ year old laptop which is single core, this step takes about 22s and on my 4-core office machine it's down to less than 4s (if you did not know it, native code compilation happens in parallel on a multi-core machine when SMP is enabled). What does your Erlang banner look like? On my office it looks as: Erlang R14A (erts-5.8) [source] [smp:4:4] [rq:4] ... [hipe] which means that smp and hipe are enabled and there will be 4 Erlang schedulers + run queues. Also, can you check which OTP libraries/applications were compiled to native code? The ones that matter for this task are files in stdlib, compiler, hipe and dialyzer. If you do not know how to look, you find out about this for some module by the command: 1> [begin code:ensure_loaded(M), code:is_module_native(M) end || M <- [erl_types, cerl, sets, dialyzer_plt]]. [true,true,true,true] > Regardless, it's not a huge deal, it just seemed like something that was > taking a while and that might have been easy to speed up - it's not > going to ruin my day if I'm wrong about that :) Yes, I understand, but it would be nice to get this working, both for you and for others. Cheers, Kostis From zabrane3@REDACTED Wed Jun 23 08:23:59 2010 From: zabrane3@REDACTED (zabrane Mikael) Date: Wed, 23 Jun 2010 08:23:59 +0200 Subject: Heartbeat strange behaviour! Message-ID: Hi guys, While adapting Joe's Web server example at: http://www.sics.se/~joe/tutorials/web_server/web_server.html#m2.3 to Erlang R13B04 (by changing ERLANG_HEART to HEART_COMMAND, and other minor things) on Linux, I was unable to reproduce Joe's server crash test using the "-heart" flag. When killing the server's PID, the "heart" process also terminates. Why? The Heart process is supposed to control the Erlang system ... so why it stops (or gets killed) too? Could someone help on that please? -- Regards Zabrane From chandrashekhar.mullaparthi@REDACTED Wed Jun 23 10:44:22 2010 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Wed, 23 Jun 2010 09:44:22 +0100 Subject: [erlang-questions] mnesia secondary index In-Reply-To: References: Message-ID: Hi Matt, On 23 June 2010 00:18, Evans, Matthew wrote: > Hi, > > I have a fragmented mnesia table that I need to add a second index to. > > It appears that to get this working I need to call mnesia:add_table_index/2 > for each fragment. > > Yes - that is correct. > Likewise, to do an index read of the fragmented table I need to search each > fragment in turn: > Not really - the following code should do. dirty_index_read(Tab, SecondaryKey, Pos) -> F = fun(T, Sk, P) -> mnesia:index_read(T,Sk,P) end, mnesia:activity(async_dirty, F, [Tab, SecondaryKey, Pos], mnesia_frag). cheers Chandru From olivier.boudeville@REDACTED Wed Jun 23 11:57:15 2010 From: olivier.boudeville@REDACTED (Olivier BOUDEVILLE) Date: Wed, 23 Jun 2010 11:57:15 +0200 Subject: Erlang & MULTICONF-10 Message-ID: Hi, Some time ago the 2010 multi-conference (MULTICONF-10), to be held during July 12-14, 2010 in Orlando was advertised on this list. Will there be Erlang users? Would there be some interest in an informal Erlang meeting around the conference? As for me I plan to attend mostly to their HPCS-10 theme, and would be glad to discuss a bit with other Erlang users. Best regards, Olivier Boudeville. --------------------------- Olivier Boudeville EDF R&D : 1, avenue du G?n?ral de Gaulle, 92140 Clamart, France D?partement SINETICS, groupe ASICS (I2A), bureau B-226 Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 65 27 13 Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. ____________________________________________________ This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free. From hynek@REDACTED Wed Jun 23 13:02:22 2010 From: hynek@REDACTED (Hynek Vychodil) Date: Wed, 23 Jun 2010 13:02:22 +0200 Subject: [erlang-questions] Estrange problem with national chars In-Reply-To: <201006110916.44009.clist@uah.es> References: <201006110916.44009.clist@uah.es> Message-ID: It's known issue, module source code is assumed Latin1. (There is not such thing like use utf8; in perl.) On Fri, Jun 11, 2010 at 9:16 AM, Angel Alvarez wrote: > Hi > > Ive been in trouble trying to display localised messages in spanish. > > While inputting strings in utf8 seems fine, every string compile into the code gets garbled. Terminal, text editor and shell are in unicode (utf8) > but i can display messages with strings in spanish. > > > Anyone can point me on the ritght direcction? > > Thanks!!! > > > /Angel > > io:getopts(). > [{expand_fun,#Fun}, > ?{echo,true}, > ?{binary,false}, > ?{encoding,unicode}] > > -module(mytest). > -compile(export_all). > > kk() -> > ? ? ? ?io:format("Test message with in-code spanish chars: cig?e?a, cami?n~n",[]). > kk(Message) -> > ? ? ? ?io:format("Test message with in-code spanish chars: cig?e?a, cami?n and inputted spanish chars: ~s~n",[Message]). > > sinosuke@REDACTED:~/Datos/Personal/Erlang> erl > Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7.2 ?(abort with ^G) > 1> mytest:kk(). > Test message with in-code spanish chars: cig??e??a, cami??n > ok > 2> mytest:kk("Atenci?n"). > Test message with in-code spanish chars: cig??e??a, cami??n and inputted spanish chars: Atenci?n > ok > > > > > -- > Este correo no tiene dibujos. Las formas extra?as en la pantalla son letras. > __________________________________________ > > Clist UAH a.k.a Angel > __________________________________________ > Evitar la programaci?n defensiva. Manual de Erlang > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try GoodData now for free: www.gooddata.com From clist@REDACTED Wed Jun 23 13:16:53 2010 From: clist@REDACTED (Angel Alvarez) Date: Wed, 23 Jun 2010 13:16:53 +0200 Subject: [erlang-questions] Estrange problem with national chars In-Reply-To: References: <201006110916.44009.clist@uah.es> Message-ID: <201006231316.53939.clist@uah.es> Yet the shell doesnt to have this problem: sinosuke@REDACTED:~> erl Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.2 (abort with ^G) 1> P=fun()-> io:format("Cami?n~n",[]) end. #Fun 2> P(). Cami?n ok 3> what's the diference beetwen eval'ing code and compiled-in code? /angel El Mi?rcoles, 23 de Junio de 2010 Hynek Vychodil escribi?: > It's known issue, module source code is assumed Latin1. (There is not > such thing like use utf8; in perl.) > > On Fri, Jun 11, 2010 at 9:16 AM, Angel Alvarez wrote: > > Hi > > > > Ive been in trouble trying to display localised messages in spanish. > > > > While inputting strings in utf8 seems fine, every string compile into the code gets garbled. Terminal, text editor and shell are in unicode (utf8) > > but i can display messages with strings in spanish. > > > > > > Anyone can point me on the ritght direcction? > > > > Thanks!!! > > > > > > /Angel > > > > io:getopts(). > > [{expand_fun,#Fun}, > > ?{echo,true}, > > ?{binary,false}, > > ?{encoding,unicode}] > > > > -module(mytest). > > -compile(export_all). > > > > kk() -> > > ? ? ? ?io:format("Test message with in-code spanish chars: cig?e?a, cami?n~n",[]). > > kk(Message) -> > > ? ? ? ?io:format("Test message with in-code spanish chars: cig?e?a, cami?n and inputted spanish chars: ~s~n",[Message]). > > > > sinosuke@REDACTED:~/Datos/Personal/Erlang> erl > > Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] > > > > Eshell V5.7.2 ?(abort with ^G) > > 1> mytest:kk(). > > Test message with in-code spanish chars: cig??e??a, cami??n > > ok > > 2> mytest:kk("Atenci?n"). > > Test message with in-code spanish chars: cig??e??a, cami??n and inputted spanish chars: Atenci?n > > ok > > > > > > > > > > -- > > Este correo no tiene dibujos. Las formas extra?as en la pantalla son letras. > > __________________________________________ > > > > Clist UAH a.k.a Angel > > __________________________________________ > > Evitar la programaci?n defensiva. Manual de Erlang > > > > ________________________________________________________________ > > erlang-questions (at) erlang.org mailing list. > > See http://www.erlang.org/faq.html > > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > > > > > -- No imprima este correo si no es necesario. El medio ambiente est? en nuestras manos. __________________________________________ Clist UAH a.k.a Angel __________________________________________ China 'limpia' el Tibet para las Olimpiadas. From mevans@REDACTED Wed Jun 23 14:05:19 2010 From: mevans@REDACTED (Evans, Matthew) Date: Wed, 23 Jun 2010 08:05:19 -0400 Subject: [erlang-questions] mnesia secondary index In-Reply-To: References: , Message-ID: Many thanks. I was thrown by me doing: 74> mnesia:activity(sync_dirty,fun mnesia:dirty_index_read/3,[cmfs_content_uuid_table,{1,1,1},file_id],mnesia_frag). [] When I should've done: 73> mnesia:activity(sync_dirty,fun mnesia:index_read/3,[cmfs_content_uuid_table,{1,1,1},file_id],mnesia_frag). [#cmfs_content_uuid_table{content_uuid = 1, file_id = {1,1,1}, nts_start_offset = '_',nts_duration = '_',start_time = '_', end_time = '_',restripe_time = '_',version_id = '_', start_of_content = '_',average_bit_rate = '_', peak_bit_rate = '_',program_id = '_',frame_rate_code = '_', video_format = '_',video_size = '_',pid_info_list = '_', duration = '_',media_type = '_',size = '_',data_state = '_', checksum = '_'}] ________________________________________ From: Chandru [chandrashekhar.mullaparthi@REDACTED] Sent: Wednesday, June 23, 2010 4:44 AM To: Evans, Matthew Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] mnesia secondary index Hi Matt, On 23 June 2010 00:18, Evans, Matthew > wrote: Hi, I have a fragmented mnesia table that I need to add a second index to. It appears that to get this working I need to call mnesia:add_table_index/2 for each fragment. Yes - that is correct. Likewise, to do an index read of the fragmented table I need to search each fragment in turn: Not really - the following code should do. dirty_index_read(Tab, SecondaryKey, Pos) -> F = fun(T, Sk, P) -> mnesia:index_read(T,Sk,P) end, mnesia:activity(async_dirty, F, [Tab, SecondaryKey, Pos], mnesia_frag). cheers Chandru From tuncer.ayaz@REDACTED Wed Jun 23 19:25:16 2010 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Wed, 23 Jun 2010 19:25:16 +0200 Subject: [erlang-questions] Dialyzer startup time In-Reply-To: <4C21A7BF.9020403@cs.ntua.gr> References: <4C1ECE06.2070102@m5net.com> <4C1F0EA1.9020308@cs.ntua.gr> <4C218AE8.8080801@m5net.com> <4C21A7BF.9020403@cs.ntua.gr> Message-ID: Following advice from Kostis the 30 or 20 secs can be reduced to 6secs if you manually rebuild HiPE before installing the otherwise completely built OTP tree. First make sure native compilation will be used: $ cat lib/hipe/native.mk ifndef SECONDARY_BOOTSTRAP ifeq ($(NATIVE_LIBS_ENABLED),yes) ERL_COMPILE_FLAGS += +native endif endif $ grep -C2 native lib/hipe/cerl/Makefile # ---------------------------------------------------- include ../native.mk ERL_COMPILE_FLAGS += +inline +warn_exported_vars +warn_unused_import +warn_missing_spec# +warn_untyped_record Then delete the hipe beams and re-make: $ rm lib/hipe/ebin/*.beam $ make hipe Now you can install your OTP build or replace the HiPE beams in your install. If everything was successful erl_types and erl_bif_types should now also have native code. Not all modules in the OTP tree are configured to be +native compiled so don't be surprised that any module outside of the following apps has no native code: compiler, dialyzer, hipe, kernel, stdlib, syntax_tools From bernie@REDACTED Thu Jun 24 02:10:48 2010 From: bernie@REDACTED (Bernard Duggan) Date: Thu, 24 Jun 2010 10:10:48 +1000 Subject: [erlang-questions] Dialyzer startup time In-Reply-To: <4C21A7BF.9020403@cs.ntua.gr> References: <4C1ECE06.2070102@m5net.com> <4C1F0EA1.9020308@cs.ntua.gr> <4C218AE8.8080801@m5net.com> <4C21A7BF.9020403@cs.ntua.gr> Message-ID: <4C22A288.5090904@m5net.com> Hi Kostis, > What does your Erlang banner look like? On my office it looks as: > > Erlang R14A (erts-5.8) [source] [smp:4:4] [rq:4] ... [hipe] > Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] > Also, can you check which OTP libraries/applications were compiled to > native code? The ones that matter for this task are files in stdlib, > compiler, hipe and dialyzer. > > If you do not know how to look, you find out about this for some module > by the command: > > 1> [begin code:ensure_loaded(M), code:is_module_native(M) end > || M<- [erl_types, cerl, sets, dialyzer_plt]]. > [true,true,true,true] > That was the issue - it turned out that building/installing from a clean source package with --enable-native-libs was, for some reason, not sufficient (ended up with [false, false, false, false]). I had to manually delete and rebuild the beams in the hipe, stdlib and compiler directories then run the install again. That got it, and the native compilation part of dialyzer is now down to <7s (a dual-core laptop, about 3 years old, for reference). Thanks very much for your (and Tuncer's) help. It would be interesting to know why it didn't build native libs the first time, but that could easily be something that's been resolved in R14A (haven't spent the time to upgrade yet - I'm a coward and am waiting for 14B :)). Cheers, Bernard From tuncer.ayaz@REDACTED Thu Jun 24 02:32:59 2010 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Thu, 24 Jun 2010 02:32:59 +0200 Subject: [erlang-questions] Dialyzer startup time In-Reply-To: <4C22A288.5090904@m5net.com> References: <4C1ECE06.2070102@m5net.com> <4C1F0EA1.9020308@cs.ntua.gr> <4C218AE8.8080801@m5net.com> <4C21A7BF.9020403@cs.ntua.gr> <4C22A288.5090904@m5net.com> Message-ID: On Thu, Jun 24, 2010 at 2:10 AM, Bernard Duggan wrote: > > That was the issue - it turned out that building/installing from a clean > source package with --enable-native-libs was, for some reason, not > sufficient (ended up with [false, false, false, false]). I had to manually > delete and rebuild the beams in the hipe, stdlib and compiler directories > then run the install again. That got it, and the native compilation part of > dialyzer is now down to <7s (a dual-core laptop, about 3 years old, for > reference). Yes and 'make check' (Dialyzer run) in the PropEr tree is down to 9s from the previous 12s. > Thanks very much for your (and Tuncer's) help. It would be interesting to > know why it didn't build native libs the first time, but that could easily > be something that's been resolved in R14A (haven't spent the time to upgrade > yet - I'm a coward and am waiting for 14B :)). R14A has the same issue and I had to apply the manual compile step as advised by Kostis. From rapsey@REDACTED Thu Jun 24 08:54:47 2010 From: rapsey@REDACTED (Rapsey) Date: Thu, 24 Jun 2010 08:54:47 +0200 Subject: nif resources Message-ID: If a resource was created within a thread (and released with enif_release_resource), then sent to some erlang process. Will that erlang process have a handle to the resource (thus prevent it from being released) even if it did not save it anywhere (the variable for the resource was ignored)? This is the behavior I am seeing. Unless I kill the process which received the resource, it will never get released. Is there any way to make an erlang process release it's handle to the resource? I'm using R14A thank you, Sergej From sverker@REDACTED Thu Jun 24 10:45:19 2010 From: sverker@REDACTED (Sverker Eriksson) Date: Thu, 24 Jun 2010 10:45:19 +0200 Subject: [erlang-questions] nif resources In-Reply-To: References: Message-ID: <4C231B1F.4070209@erix.ericsson.se> Rapsey wrote: > If a resource was created within a thread (and released with > enif_release_resource), then sent to some erlang process. Will that erlang > process have a handle to the resource (thus prevent it from being released) > even if it did not save it anywhere (the variable for the resource was > ignored)? > This is the behavior I am seeing. Unless I kill the process which received > the resource, it will never get released. Is there any way to make an erlang > process release it's handle to the resource? > I'm using R14A > A resource that is not references by any Erlang process and totally released with enif_release_resource should eventually be garbage collected like any other term. Have you tried erlang:garbage_collect when verifying if the destructor is called? /Sverker, Erlang/OTP From rapsey@REDACTED Thu Jun 24 10:56:11 2010 From: rapsey@REDACTED (Rapsey) Date: Thu, 24 Jun 2010 10:56:11 +0200 Subject: [erlang-questions] nif resources In-Reply-To: <4C231B1F.4070209@erix.ericsson.se> References: <4C231B1F.4070209@erix.ericsson.se> Message-ID: On Thu, Jun 24, 2010 at 10:45 AM, Sverker Eriksson wrote: > Rapsey wrote: > >> If a resource was created within a thread (and released with >> enif_release_resource), then sent to some erlang process. Will that erlang >> process have a handle to the resource (thus prevent it from being >> released) >> even if it did not save it anywhere (the variable for the resource was >> ignored)? >> This is the behavior I am seeing. Unless I kill the process which received >> the resource, it will never get released. Is there any way to make an >> erlang >> process release it's handle to the resource? >> I'm using R14A >> >> > A resource that is not references by any Erlang process and totally > released with enif_release_resource > should eventually be garbage collected like any other term. > > Have you tried erlang:garbage_collect when verifying if the destructor is > called? > > /Sverker, Erlang/OTP > > I played around with it just now, I guess my test method was too simple. The process has to get called a few times for the resource to be cleared by the GC (without needing to explicitly call garbage_collect). If it just sits there after the last message, resource will not get released. Thanks. Sergej From miriam.pena@REDACTED Thu Jun 24 14:29:30 2010 From: miriam.pena@REDACTED (Miriam Pena) Date: Thu, 24 Jun 2010 12:29:30 +0000 (GMT) Subject: Relup file generated by systools ignores application dependencies. Message-ID: <788263182.519251277382570074.JavaMail.root@zimbra> Hi! I am running R13B04 on a Linux Ubuntu. I create a target_system "myapp-FIRST" with the target_system:create() and I want to perform a live upgrade it with a new release version "myapp-SECOND". {release, {"myapp", "FIRST"},{erts,"5.7.5"}, [ {kernel, "2.13.5"}, {stdlib, "1.16.5"}, {sasl, "2.1.9"}, {app1, "1"}, {app2, "1"} ]}. {release, {"myapp", "SECOND"},{erts,"5.7.5"}, [ {kernel, "2.13.5"}, {stdlib, "1.16.5"}, {sasl, "2.1.9"} ]}. Release "myapp-FIRST" has app1 and app2 applications where app2 application depends on app1. Sice "myapp-SECOND" doesn't include this two applications I expect the applications to be stopped and removed from the system when I install release "myapp-SECOND". The new release is unpacked sucesfully but cant be installed, since the Erlang node crashes and dies. (myapp@REDACTED)3> release_handler:install_release("SECOND"). ** exception exit: {shutdown,{gen_server,call, [release_handler, {install_release,"SECOND",restart,[]}, infinity]}} in function gen_server:call/3 (myapp@REDACTED)4> {"Kernel pid terminated",application_controller,"{application_terminated,app2,shutdown}"} Crash dump was written to: erl_crash.dump Kernel pid terminated (application_controller) ({application_terminated,app2,shutdown}) [End] The problem lays in the relup file created via systools: systools:make_relup("myapp-SECOND", ["myapp-FIRST"], ["myapp-FIRST"]), which is not generated properly. When I go from release FIRST to release SECOND, the first application to be removed and purged is the app1 application, but since the app2 have running processes depending on that application, those processes are killed and the node shutdowns. =INFO REPORT==== 24-Jun-2010::12:29:55 === application: app1 exited: stopped type: permanent =ERROR REPORT==== 24-Jun-2010::12:29:55 === supervisor: {local,app2_sup} errorContext: child_terminated reason: killed offender: [{pid,<0.56.0>}, {name,app3}, [...] I would expect that the relup file is generated taking the dependencies specified in the .app files into account but I got them generated in the same order as the .rel files. If I reverse-order the myapp-FIRST.rel I will success to install the new release, but I will not be able to go back to the "myapp-FIRST" release correctly. The new relup file specify that the app2 should be started before app1, and since it cant because of its dependency with app1, the application app2 will not be started. Here is a simplified version of the relup. {"SECOND", [{"FIRST",[], [point_of_no_return, {apply,{application,stop,[app1]}}, {remove,{app1,brutal_purge,brutal_purge}}, {purge,[app1]}, {apply,{application,unload,[app1]}}, {apply,{application,stop,[app2]}}, {remove,{app2,brutal_purge,brutal_purge}}, [...] {purge,[app2, app2_sup, ...]}, {apply,{application,unload,[app2]}}]}], [{"FIRST",[], [{load_object_code,{app1,"1",[app1]}}, {load_object_code,{app2,"1",[app2]}}, point_of_no_return, {load,{app1,brutal_purge,brutal_purge}}, {apply,{application,start,[app1,permanent]}}, {load,{app2,brutal_purge,brutal_purge}}, [...] {apply,{application,start,[app2,permanent]}}]}]}. I am not using apupp files since I am not upgrading applications. I would like to know whether not taking dependencies into account when the relup files are generated via systools is the intended behaviour or a bug. Miriam Pena Villanueva --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From luismarianoguerra@REDACTED Fri Jun 25 01:01:12 2010 From: luismarianoguerra@REDACTED (Mariano Guerra) Date: Thu, 24 Jun 2010 20:01:12 -0300 Subject: [ANN] ErlAr - Spanish Erlang User Group Message-ID: hi, since I couldn't find a user group in Spanish for erlang I decided to create my own :) The group is called ErlAr short for Erlang Argentina, I didn't felt with enough power to create the "Spanish Erlang Users Group" but all native Spanish speakers are more than welcome! The website is here (spanish sorry ;): http://www.erlang-ar.com.ar/ anyone who wants to share some erlang questions, answers, ideas, projects or links in spanish can join and help us move the center or the erlang universe from Sweden to latinamerica :) Saludos From sand.softnet1@REDACTED Fri Jun 25 08:43:23 2010 From: sand.softnet1@REDACTED (Sand T) Date: Fri, 25 Jun 2010 12:13:23 +0530 Subject: Compare XML string Message-ID: Hi, I need to compare two given XML string to ensure that the two strings are identical or not at runtime. Does anyone have any idea on how to do this in erlang? Following are some of the examples Given String Authentication Successful ... Exp String: Authentication Successful ... Eq 2: Given String Authentication Successful ... Expected: Authentication Successful ... Regards, Sandeep From comptekki@REDACTED Fri Jun 25 20:23:02 2010 From: comptekki@REDACTED (Wes James) Date: Fri, 25 Jun 2010 12:23:02 -0600 Subject: string title bif? Message-ID: Is there a BIF that does this (I can't find one, if there is): string:title("this_is_a_title") -> "This Is A Title". Or something like this? If not I'll just create one. It would need to split the string at the "_" and then uppercase the first character of each word. This test works: ------------------- -module(title). -export([start/0]). start() -> title(string:tokens("this_is_a_title","_")). title([H|T]) -> [fc_upper(H)|title(T)]; title([]) -> []. fc_upper([C|R]) -> [string:to_upper(C)]++R. ---------------- thx. -wes From kiszl@REDACTED Fri Jun 25 20:40:28 2010 From: kiszl@REDACTED (Zoltan Lajos Kis) Date: Fri, 25 Jun 2010 20:40:28 +0200 Subject: [erlang-questions] string title bif? In-Reply-To: References: Message-ID: <4C24F81C.3090103@tmit.bme.hu> I think a tiny state-machine with "mapfoldl" is a cleaner (albeit more imperative :o)) approach for this. title(String) -> {Title, _} = lists:mapfoldl(fun f/2, 'sep', String), Title. f($_, _) -> {$ , 'sep'}; f(C, 'sep') -> {string:to_upper(C), 'char'}; f(C, _) -> {C, 'char'}. Regards, Zoltan. On 6/25/2010 8:23 PM, Wes James wrote: > Is there a BIF that does this (I can't find one, if there is): > > string:title("this_is_a_title") -> "This Is A Title". > > Or something like this? If not I'll just create one. > > It would need to split the string at the "_" and then uppercase the > first character of each word. > > This test works: > > ------------------- > > -module(title). > > -export([start/0]). > > start() -> > title(string:tokens("this_is_a_title","_")). > > title([H|T]) -> > [fc_upper(H)|title(T)]; > title([]) -> []. > > fc_upper([C|R]) -> > [string:to_upper(C)]++R. > > ---------------- > > thx. > > -wes > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From comptekki@REDACTED Fri Jun 25 20:53:52 2010 From: comptekki@REDACTED (Wes James) Date: Fri, 25 Jun 2010 12:53:52 -0600 Subject: [erlang-questions] string title bif? In-Reply-To: <4C24F81C.3090103@tmit.bme.hu> References: <4C24F81C.3090103@tmit.bme.hu> Message-ID: title("this is a test") returns "This is a test". It only uppercases the first word. This could work to replace my fc_toupper (first char to upper), though. thx, -wes On Fri, Jun 25, 2010 at 12:40 PM, Zoltan Lajos Kis wrote: > I think a tiny state-machine with "mapfoldl" is a cleaner (albeit more > imperative :o)) approach for this. > > title(String) -> > ? ?{Title, _} = lists:mapfoldl(fun f/2, 'sep', String), > ? ?Title. > > f($_, _) -> {$ , 'sep'}; > f(C, 'sep') -> {string:to_upper(C), 'char'}; > f(C, _) -> {C, 'char'}. > > Regards, > Zoltan. > > > On 6/25/2010 8:23 PM, Wes James wrote: >> >> Is there a BIF that does this (I can't find one, if there is): >> >> string:title("this_is_a_title") -> ?"This Is A Title". >> >> Or something like this? ?If not I'll just create one. >> >> It would need to split the string at the "_" and then uppercase the >> first character of each word. >> >> This test works: >> >> ------------------- >> >> -module(title). >> >> -export([start/0]). >> >> start() -> >> ? ? ? ?title(string:tokens("this_is_a_title","_")). >> >> title([H|T]) -> >> ? ? ? ?[fc_upper(H)|title(T)]; >> title([]) -> ?[]. >> >> fc_upper([C|R]) -> >> ? ? ? ?[string:to_upper(C)]++R. >> >> ---------------- >> >> thx. >> >> -wes >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> > > From kiszl@REDACTED Fri Jun 25 21:07:48 2010 From: kiszl@REDACTED (Zoltan Lajos Kis) Date: Fri, 25 Jun 2010 21:07:48 +0200 Subject: [erlang-questions] string title bif? In-Reply-To: References: <4C24F81C.3090103@tmit.bme.hu> Message-ID: <4C24FE84.9030805@tmit.bme.hu> That's because the code does what you requested: it uppercases letters following an _underscore_. Nevertheless you can add a new clause for spaces as well: f($ , _) -> {$ , 'sep'}; f($_, _) -> {$ , 'sep'}; f(C, 'sep') -> {string:to_upper(C), 'char'}; f(C, _) -> {C, 'char'}. Zoltan. On 6/25/2010 8:53 PM, Wes James wrote: > title("this is a test") returns "This is a test". It only uppercases > the first word. This could work to replace my fc_toupper (first char > to upper), though. > > thx, > > -wes > > On Fri, Jun 25, 2010 at 12:40 PM, Zoltan Lajos Kis wrote: > >> I think a tiny state-machine with "mapfoldl" is a cleaner (albeit more >> imperative :o)) approach for this. >> >> title(String) -> >> {Title, _} = lists:mapfoldl(fun f/2, 'sep', String), >> Title. >> >> f($_, _) -> {$ , 'sep'}; >> f(C, 'sep') -> {string:to_upper(C), 'char'}; >> f(C, _) -> {C, 'char'}. >> >> Regards, >> Zoltan. >> >> >> On 6/25/2010 8:23 PM, Wes James wrote: >> >>> Is there a BIF that does this (I can't find one, if there is): >>> >>> string:title("this_is_a_title") -> "This Is A Title". >>> >>> Or something like this? If not I'll just create one. >>> >>> It would need to split the string at the "_" and then uppercase the >>> first character of each word. >>> >>> This test works: >>> >>> ------------------- >>> >>> -module(title). >>> >>> -export([start/0]). >>> >>> start() -> >>> title(string:tokens("this_is_a_title","_")). >>> >>> title([H|T]) -> >>> [fc_upper(H)|title(T)]; >>> title([]) -> []. >>> >>> fc_upper([C|R]) -> >>> [string:to_upper(C)]++R. >>> >>> ---------------- >>> >>> thx. >>> >>> -wes >>> >>> ________________________________________________________________ >>> erlang-questions (at) erlang.org mailing list. >>> See http://www.erlang.org/faq.html >>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>> >>> >>> >> >> > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > From comptekki@REDACTED Fri Jun 25 21:17:03 2010 From: comptekki@REDACTED (Wes James) Date: Fri, 25 Jun 2010 13:17:03 -0600 Subject: [erlang-questions] string title bif? In-Reply-To: <4C24FE84.9030805@tmit.bme.hu> References: <4C24F81C.3090103@tmit.bme.hu> <4C24FE84.9030805@tmit.bme.hu> Message-ID: Opps - you are right - I forgot to put in the "_" in my test string. thx, -wes On Fri, Jun 25, 2010 at 1:07 PM, Zoltan Lajos Kis wrote: > That's because the code does what you requested: it uppercases letters > following an _underscore_. > Nevertheless you can add a new clause for spaces as well: > > f($ , _) -> ?{$ , 'sep'}; > f($_, _) -> ?{$ , 'sep'}; > f(C, 'sep') -> ?{string:to_upper(C), 'char'}; > f(C, _) -> ?{C, 'char'}. > > Zoltan. > > On 6/25/2010 8:53 PM, Wes James wrote: >> >> title("this is a test") returns "This is a test". ?It only uppercases >> the first word. ?This could work to replace my fc_toupper (first char >> to upper), though. >> >> thx, >> >> -wes >> >> On Fri, Jun 25, 2010 at 12:40 PM, Zoltan Lajos Kis >> ?wrote: >> >>> >>> I think a tiny state-machine with "mapfoldl" is a cleaner (albeit more >>> imperative :o)) approach for this. >>> >>> title(String) -> >>> ? ?{Title, _} = lists:mapfoldl(fun f/2, 'sep', String), >>> ? ?Title. >>> >>> f($_, _) -> ?{$ , 'sep'}; >>> f(C, 'sep') -> ?{string:to_upper(C), 'char'}; >>> f(C, _) -> ?{C, 'char'}. >>> >>> Regards, >>> Zoltan. >>> >>> >>> On 6/25/2010 8:23 PM, Wes James wrote: >>> >>>> >>>> Is there a BIF that does this (I can't find one, if there is): >>>> >>>> string:title("this_is_a_title") -> ? ?"This Is A Title". >>>> >>>> Or something like this? ?If not I'll just create one. >>>> >>>> It would need to split the string at the "_" and then uppercase the >>>> first character of each word. >>>> >>>> This test works: >>>> >>>> ------------------- >>>> >>>> -module(title). >>>> >>>> -export([start/0]). >>>> >>>> start() -> >>>> ? ? ? ?title(string:tokens("this_is_a_title","_")). >>>> >>>> title([H|T]) -> >>>> ? ? ? ?[fc_upper(H)|title(T)]; >>>> title([]) -> ? ?[]. >>>> >>>> fc_upper([C|R]) -> >>>> ? ? ? ?[string:to_upper(C)]++R. >>>> >>>> ---------------- >>>> >>>> thx. >>>> >>>> -wes >>>> >>>> ________________________________________________________________ >>>> erlang-questions (at) erlang.org mailing list. >>>> See http://www.erlang.org/faq.html >>>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>>> >>>> >>>> >>> >>> >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> >> > > From fritchie@REDACTED Fri Jun 25 23:59:51 2010 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Fri, 25 Jun 2010 16:59:51 -0500 Subject: [erlang-questions] Erlang - Question on memory usage reported In-Reply-To: Message of "Wed, 16 Jun 2010 07:55:00 CDT." <6329B957BA5C514DBF5FBED87A88388204D2317B44@spswchi6mail1.peak6.net> Message-ID: <98440.1277503191@snookles.snookles.com> Sorry for replying to a message a week and a half old... Rajesh Bhat wrote: rb> I am running an application that starts up with a memory footprint rb> of around ~725MB when started (Approx 9000 processes on rb> startup).. Application spawns processes as new requests are rb> processed and grows to about 50K processes and memory usage of 5.1GB rb> during the day. [...] rb> At the end of the day, a cleanup job reviews the process state and rb> kills the pids that are not required and cleans up the ets rb> table. [...] rb> [...] however running 'htop' on the system still indicates Erlang rb> beam process with a resident memory usage of around 5.1GB. Any rb> pointers that explains this behavior is greatly appreciated. Is rb> there a way to release the memory? Not easily, no. When a UNIX process calls free(), there's no guarantee that the memory free'd by that call will be returned to the OS now, later, or ever. It depends on how it's allocated. If the allocator used mmap(), then it can't munmap() the memory until (at least) all other chunks in the mmap()'ed region are also freed. If it's allocated using sbrk() or related, you can't move the break back down (to deallocate memory) if there are still live chunks of memory above the break. The Erlang VM uses its own set of allocators instead of using malloc directly, so they add another layer of when-to-release-to-the-OS that I can't comment directly on, sorry. -Scott From fritchie@REDACTED Sat Jun 26 00:15:38 2010 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Fri, 25 Jun 2010 17:15:38 -0500 Subject: [erlang-questions] ejabberd Bottleneck: Understanding Fprof Analysis In-Reply-To: Message of "Fri, 18 Jun 2010 14:48:32 PDT." <015901cb0f2f$ffcbb190$ff6314b0$@com> Message-ID: <99656.1277504138@snookles.snookles.com> Karthik Kailash wrote: kk> I used fprof to do some profiling on the mod_muc process, see the kk> output file here: http://pastebin.com/QXchAKtM. There's a large chunk of time spent by {mnesia,dirty_read,2} that's in turn a bit over half the time used by an RPC call into Mnesia. So, remove the Mnesia calls and you'd see a significant speedup. :-) -Scott From comptekki@REDACTED Sat Jun 26 00:16:27 2010 From: comptekki@REDACTED (Wes James) Date: Fri, 25 Jun 2010 16:16:27 -0600 Subject: using catch - getting error Message-ID: I have this function: lk(Key, L) -> {_, Error} = (catch {value, {_,Vale}} = lists:keysearch(Key, 1, L)), case length(Error) of 0 -> Val = Vale; _ -> Val = 0 end, Val. A list (L) should have all the keys necessary when lk is called, but if the key does not exist, the keysearch will throw an exception. I'm trying to catch that, but I get the error Vale is unsafe. What is the proper way to do this? If the key exists, then put it in Val and return Val, if the key does not exist, catch the error and set Val to 0. How should this be done? thx, -wes From fritchie@REDACTED Sat Jun 26 00:31:09 2010 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Fri, 25 Jun 2010 17:31:09 -0500 Subject: [erlang-questions] +A attribute In-Reply-To: Message of "Wed, 23 Jun 2010 08:15:29 +0200." Message-ID: <859.1277505069@snookles.snookles.com> zabrane Mikael wrote: mz> I'm also interested on that. Any advices guys? Guess how many outstanding file I/O requests you might have going at any one time, then use that plus perhaps a few more. Or pick a number > 0 and see how your app works with the same workload, with and without +A. +A won't help if the workload doesn't do file I/O or use a linked-in driver that uses async threads. -Scott From rvirding@REDACTED Sat Jun 26 00:34:09 2010 From: rvirding@REDACTED (Robert Virding) Date: Sat, 26 Jun 2010 00:34:09 +0200 Subject: [erlang-questions] using catch - getting error In-Reply-To: References: Message-ID: If I have understood you correctly then something like this should do what you wish: lk(Key, L) -> case lists:keysearch(Key, 1, L) of {value,{_,Vale}} -> Vale; false -> 0 end. lists:keysearch/3 returns whether it finds a tuple with the given key, it does not generate an error if it does not find it. So there is no reason to try and match it with the success return value to generate an error if it does not find it. Vale is flagged as unsafe as it only will get a value if lists:keysearch succeeds and not if an error is generated so it is unsafe to use. A variable must have a value for it to be used, variables don't have a default value. For this reason any variable bound within a catch will be flagged as unsafe if used after the catch. Robert On 26 June 2010 00:16, Wes James wrote: > I have this function: > > lk(Key, L) -> > ? ?{_, Error} = (catch {value, {_,Vale}} = lists:keysearch(Key, 1, L)), > ? ?case length(Error) of > ? ? ? ?0 -> > ? ? ? ? ? ? ? ?Val = Vale; > ? ? ? ?_ -> > ? ? ? ? ? ? ? ?Val = 0 > ? ?end, > ? ?Val. > > A list (L) should have all the keys necessary when lk is called, but > if the key does not exist, the keysearch will throw an exception. ?I'm > trying to catch that, but I get the error Vale is unsafe. What is the > proper way to do this? > > If the key exists, then put it in Val and return Val, if the key does > not exist, catch the error and set Val to 0. > > How should this be done? > > thx, > > -wes > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From fritchie@REDACTED Sat Jun 26 00:37:11 2010 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Fri, 25 Jun 2010 17:37:11 -0500 Subject: [erlang-questions] heart restarting erlang node In-Reply-To: Message of "Thu, 17 Jun 2010 10:49:45 BST." Message-ID: <1304.1277505431@snookles.snookles.com> tom kelly wrote: tk> We've found this post from Serge Aleynikov which we're tk> investigating: tk> http://www.erlang.org/pipermail/erlang-questions/2006-December/024365.html tk> But I'm not yet sure it's the same issue. This can cause heart to tk> restart our system but only after memory usage was sustained around tk> 90% for 5-10 minutes which wasn't the case for all of our restarts. Tom, if your Erlang process is causing your OS to page VM to/from disk, then all expectations of soft realtime performance will be thrown out the window. If the VM tries to do something simple like "char foo = *(some_pointer)", and if some_pointer points to a page that isn't resident in RAM, that thread will wait a *long* time before progress can be made again. Typically you've got 1 scheduler thread per CPU, but if your working set isn't resident in RAM, you'll quickly block all scheduler threads... ... and then when it comes time to answer a heartbeat, you won't do it in time, and you'll be killed because you're too !@#$! slow. If you're using Linux, crank the /proc/vm/*swappiness* (I forget the exact path) down to 0. Many kernels (RedHat comes to mind) use 60, which is not what you want a snappy server to do. If you can't blame your OS for moving your VM's pages to RAM, you'll have to blame yourself: use less data or buy more RAM. :-) -Scott From dima@REDACTED Sat Jun 26 00:46:51 2010 From: dima@REDACTED (Dmitry Vasiliev) Date: Sat, 26 Jun 2010 02:46:51 +0400 Subject: [erlang-questions] using catch - getting error In-Reply-To: References: Message-ID: <4C2531DB.8050202@hlabs.org> On 26.06.2010 2:16, Wes James wrote: > If the key exists, then put it in Val and return Val, if the key does > not exist, catch the error and set Val to 0. > > How should this be done? Consider to use proplists (http://www.erlang.org/doc/man/proplists.html) module for {Key, Value} lists. It seems proplists:get_value/3 do what you need. -- Dmitry Vasiliev http://hlabs.org http://twitter.com/hdima http://erlport.org From zabrane3@REDACTED Sat Jun 26 01:53:32 2010 From: zabrane3@REDACTED (zabrane Mikael) Date: Sat, 26 Jun 2010 01:53:32 +0200 Subject: [erlang-questions] +A attribute In-Reply-To: <859.1277505069@snookles.snookles.com> References: <859.1277505069@snookles.snookles.com> Message-ID: Thanks very much Scott. 2010/6/26 Scott Lystig Fritchie > zabrane Mikael wrote: > > mz> I'm also interested on that. Any advices guys? > > Guess how many outstanding file I/O requests you might have going at any > one time, then use that plus perhaps a few more. Or pick a number > 0 > and see how your app works with the same workload, with and without +A. > > +A won't help if the workload doesn't do file I/O or use a linked-in > driver that uses async threads. > > -Scott > -- Regards Zabrane From jeraymond@REDACTED Sun Jun 27 05:58:43 2010 From: jeraymond@REDACTED (Jeremy Raymond) Date: Sat, 26 Jun 2010 23:58:43 -0400 Subject: Managing Experiments Message-ID: I have a web application and need to manage functional 'experiments'. An experiment is some functionality that's new that we want test out with a subset of the application's users before rolling it out to everyone, basically A/B testing new features. I'm looking for a clean way to manage the code for experiments, in essence something equivalent to: case user_in_experiment(UserId, new_feature_x) of true -> % do experiment functionality for new feature 'x' false -> % do current functionality end And then once we're happy with new feature 'x' make it the default functionality. There may be several different experiments in the code at any given time. Possible ways of accomplishing this that I've thought of are: - case statements littered throughout the code - encapsulating the functionality in funs and somehow do a lookup and select the right one for the current user - encapsulating the functionality in custom behaviors and somehow do a lookup selecting the right one for the current user Basically I need to be able to encapsulate and dynamically swap out different bits of functionality throughout the application based upon who is the current user. Anyone done something similar to this or have any insights into how they might approach such a problem? -- Jeremy Raymond From gordon@REDACTED Sun Jun 27 11:53:30 2010 From: gordon@REDACTED (Gordon Guthrie) Date: Sun, 27 Jun 2010 10:53:30 +0100 Subject: [erlang-questions] Managing Experiments In-Reply-To: References: Message-ID: Jeremy Run the old and new functionality in parallel in the backend and do the switching in the GUI. So you would have module1.erl and module2.erl which are branched versions of each other with the same/similar interface, the same/similar supervision tree and the same/similar startup process. Each user either gets GUI1 which maps to module1 or GUI2 which maps to module 2 - this can be static hmtl/javascript switching or dynamic on some A/B parameter. The module that you use to switch web requests (out/1 in yaws or the mochi equivalent) then needs to switch based on request_type1 or request_type2 This will work fine in a development style web-app where there is no published API. For changes behind an API you will need to implement the switching in out/1 or the equivalent. Gordon On 27 June 2010 04:58, Jeremy Raymond wrote: > I have a web application and need to manage functional 'experiments'. An > experiment is some functionality that's new that we want test out with a > subset of the application's users before rolling it out to everyone, > basically A/B testing new features. I'm looking for a clean way to manage > the code for experiments, in essence something equivalent to: > > case user_in_experiment(UserId, new_feature_x) of > true -> > % do experiment functionality for new feature 'x' > false -> > % do current functionality > end > > And then once we're happy with new feature 'x' make it the default > functionality. There may be several different experiments in the code at > any > given time. Possible ways of accomplishing this that I've thought of are: > > - case statements littered throughout the code > - encapsulating the functionality in funs and somehow do a lookup and > select > the right one for the current user > - encapsulating the functionality in custom behaviors and somehow do a > lookup selecting the right one for the current user > > Basically I need to be able to encapsulate and dynamically swap out > different bits of functionality throughout the application based upon who > is > the current user. Anyone done something similar to this or have any > insights > into how they might approach such a problem? > > -- > Jeremy Raymond > -- Gordon Guthrie CEO hypernumbers http://hypernumbers.com t: hypernumbers +44 7776 251669 From jesper.louis.andersen@REDACTED Sun Jun 27 12:22:17 2010 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Sun, 27 Jun 2010 12:22:17 +0200 Subject: [erlang-questions] Managing Experiments In-Reply-To: References: Message-ID: On Sun, Jun 27, 2010 at 5:58 AM, Jeremy Raymond wrote: > case user_in_experiment(UserId, new_feature_x) of > ? true -> > ? ? ?% do experiment functionality for new feature 'x' > ? false -> > ? ? ?% do current functionality > end I'd do something like: ets:new(ab_test_user, [named_table, public]), NewFeature = fun() -> ... end, ets:insert(ab_test, {{UserId, new_feature_x}, NewFeature}), ... case ets:lookup(ab_test, {UserId, Feature}) of [] -> CallNormalFunctionality(); [{K, F}] -> F() end, ... That is, wrap up the functionality for the test-group into a function and store those usernames which should get treatment (the non-matching users are the control group). Once in place, you can avoid having to change the code anymore as it is now essentially a question of manipulating data (and loading new test functions). The only caveat is that I don't know what happens in the ERTS when you do this. How are the function closures stored? (shared?) and what happens when you hot-load new modules onto the system from which you drew the functions (i.e., can you upgrade your ab_test by hot-loading). -- J. From mail@REDACTED Sun Jun 27 14:09:08 2010 From: mail@REDACTED (Tim Fletcher) Date: Sun, 27 Jun 2010 05:09:08 -0700 (PDT) Subject: Managing Experiments In-Reply-To: References: Message-ID: <90b67b95-bc3f-4903-b703-126e15e206e2@g19g2000yqc.googlegroups.com> > Basically I need to be able to encapsulate and dynamically swap out > different bits of functionality throughout the application based upon > who is the current user. Anyone done something similar to this or have > any insights into how they might approach such a problem? A system for "enabling features for a subset of users" is more general than A/B testing. Here are some relevant slides: http://www.paulhammond.org/2010/06/trunk/ As with your example, the approach described basically amounts to branching within the application code using guard conditions. > - case statements littered throughout the code This is my preference, because it's simple. As the aforementioned slides quote: "There is one consumer of the software: you". Adding this test code is adding a feature that delivers value to you, so instead of litter just think of it as part of the application. If you want to "hot swap" the guard conditions without having to re- deploy your entire application then you could store the code for the guard functions external to the app (file system, mnesia, redis etc) and evaluate them on the fly. As for A/B testing specifically, it may be useful to look at existing frameworks for ideas: http://vanity.labnotes.org/ab_testing.html http://www.bingocardcreator.com/abingo/usage Hope that helps. Tim From ttom.kelly@REDACTED Sun Jun 27 18:14:55 2010 From: ttom.kelly@REDACTED (tom kelly) Date: Sun, 27 Jun 2010 18:14:55 +0200 Subject: [erlang-questions] heart restarting erlang node In-Reply-To: <1304.1277505431@snookles.snookles.com> References: <1304.1277505431@snookles.snookles.com> Message-ID: Hi Scott, Thanks for your very useful answers! We found some segmentation errors reported by the OS so we were starting to think that heart wasn't the problem after all. This is proving difficult to pin down as it's on a customers site and happens at very irregular intervals. For anyone else experiencing similar problems we'll inform the list if we find a definitive solution. //Tom. On Sat, Jun 26, 2010 at 12:37 AM, Scott Lystig Fritchie < fritchie@REDACTED> wrote: > tom kelly wrote: > > tk> We've found this post from Serge Aleynikov which we're > tk> investigating: > tk> > http://www.erlang.org/pipermail/erlang-questions/2006-December/024365.html > > tk> But I'm not yet sure it's the same issue. This can cause heart to > tk> restart our system but only after memory usage was sustained around > tk> 90% for 5-10 minutes which wasn't the case for all of our restarts. > > Tom, if your Erlang process is causing your OS to page VM to/from disk, > then all expectations of soft realtime performance will be thrown out > the window. If the VM tries to do something simple like "char foo = > *(some_pointer)", and if some_pointer points to a page that isn't > resident in RAM, that thread will wait a *long* time before progress can > be made again. Typically you've got 1 scheduler thread per CPU, but if > your working set isn't resident in RAM, you'll quickly block all > scheduler threads... > > ... and then when it comes time to answer a heartbeat, you won't do it > in time, and you'll be killed because you're too !@#$! slow. > > If you're using Linux, crank the /proc/vm/*swappiness* (I forget the > exact path) down to 0. Many kernels (RedHat comes to mind) use 60, > which is not what you want a snappy server to do. > > If you can't blame your OS for moving your VM's pages to RAM, you'll > have to blame yourself: use less data or buy more RAM. :-) > > -Scott > From rzezeski@REDACTED Sun Jun 27 20:37:48 2010 From: rzezeski@REDACTED (Ryan Zezeski) Date: Sun, 27 Jun 2010 14:37:48 -0400 Subject: supervised inets httpd process Message-ID: Hi everyone. I'm a newcomer to Erlang and have been reading through Programming Erlang for the past week. There is an application I want to build to replace a legacy webapp in my workplace. I will be replacing the bulk of this application with CouchDB/Erlang but I need a light web interface that wraps it to provide service to the legacy endpoints (URLs). As a first cut, I plan on using the inets application with a custom httpd callback module to service the API. I was curious, what is the best way to "embed" the httpd server in my application? That is, I'm building an OTP compliant application, and I want the httpd server to sit under my supervisor. My first attempt was to create a gen_server callback that called inets:start/1 and httpd:start/2 in the init/1 function, but I'm not sure this was the appropriate approach. My second approach was to start inets in the supervisor callback init/1, and then pass the httpd startup to the supervisor config like so: {inets, start, [httpd,[{port,7777}, ...}. I'm not sure either approach is the correct one. What I *think* I want is a supervised process that contains the httpd server. I want this to be a "permanent" process that is restarted when an error occurs. I peeked at the OTP source code a bit on github and noticed there is an httpd_manager which implements gen_server. Would this be more appropriate? Before anyone mentions them, I am aware of Yaws and Mochiweb, but for my proof of concept I want to stick with inets. I appreciate any help and I just want to say that Erlang has been an absolute joy so far! -Ryan From erlangy@REDACTED Mon Jun 28 01:33:36 2010 From: erlangy@REDACTED (Michael McDaniel) Date: Sun, 27 Jun 2010 16:33:36 -0700 Subject: [erlang-questions] supervised inets httpd process In-Reply-To: References: Message-ID: <20100627233335.GO30357@delora.autosys.us> On Sun, Jun 27, 2010 at 02:37:48PM -0400, Ryan Zezeski wrote: > Hi everyone. I'm a newcomer to Erlang and have been reading through > Programming Erlang for the past week. There is an application I want to > build to replace a legacy webapp in my workplace. I will be replacing the > bulk of this application with CouchDB/Erlang but I need a light web > interface that wraps it to provide service to the legacy endpoints (URLs). > > As a first cut, I plan on using the inets application with a custom httpd > callback module to service the API. I was curious, what is the best way to > "embed" the httpd server in my application? That is, I'm building an OTP > compliant application, and I want the httpd server to sit under my > supervisor. > > My first attempt was to create a gen_server callback that called > inets:start/1 and httpd:start/2 in the init/1 function, but I'm not sure > this was the appropriate approach. My second approach was to start inets in > the supervisor callback init/1, and then pass the httpd startup to the > supervisor config like so: {inets, start, [httpd,[{port,7777}, ...}. > > I'm not sure either approach is the correct one. What I *think* I want is a > supervised process that contains the httpd server. I want this to be a > "permanent" process that is restarted when an error occurs. I peeked at the > OTP source code a bit on github and noticed there is an httpd_manager which > implements gen_server. Would this be more appropriate? > > Before anyone mentions them, I am aware of Yaws and Mochiweb, but for my > proof of concept I want to stick with inets. > > I appreciate any help and I just want to say that Erlang has been an > absolute joy so far! > > -Ryan ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I start inets and httpd from my supervisor (in init/1). Not claiming this is the *best* way to do it, but seems to work fine. It might make more sense to start it from within one of the other processes that is started from the supervisor but, as mentioned, this seems to work fine (though I only use inets in my application to provide RSS feeds). See also Erlang documentation for inets and application regarding 'permanent'. inets:start(permanent) , inets:start(httpd, [{proplist_file, "priv/conf/httpd.conf"}]) , The above two lines are in src/edids_sup.erl at http://edids.org (you will have to login as 'anonymous' to see the 'Files' link). ~M -- Michael McDaniel Portland, Oregon, USA http://trip.autosys.us http://edids.org From paul.joseph.davis@REDACTED Mon Jun 28 08:12:29 2010 From: paul.joseph.davis@REDACTED (Paul Davis) Date: Mon, 28 Jun 2010 02:12:29 -0400 Subject: Turning on ASSERT's in OTP code. Message-ID: I've stumbled across a weird segfault when sending terms from a thread spawned by a NIF. Investigating this i followed a traceback to erts/emulator/beam/erl_alloc_util.c. Glancing at the code in erl_alloc_util.c I notice that the line before the crash is an assert. Checking the value in gdb shows that the assertion is violated. My first thought was to try and enable these asserts but I'm not sure where to look for docs on how to do such a thing. Looking through the code I see them looking for DEBUG to be defined yet nothing in ./configure's help suggests a flag to set. In the interest of trying things I tried CFLAGS="-DDEBUG" ./configure && CFLAGS="-DDEBUG" make but it dies with an error about pcre. Anyone have a pointer on where to look for getting these enabled? Here's a copy of the traceback if it helps anyone. The lines in erl_alloc_util.c starting at 598: ASSERT(crr->prev); crr->prev->next = crr->next; gdb shows that crr is valid and crr->prev is NULL. #0 0x08085e82 in unlink_carrier (allctr=0xa2dc140, blk=) at beam/erl_alloc_util.c:599 #1 destroy_carrier (allctr=0xa2dc140, blk=) at beam/erl_alloc_util.c:1615 #2 0x08087161 in do_erts_alcu_free (type=148, unused=0x8250b60, p=0xa2dd7f0) at beam/erl_alloc_util.c:2648 #3 erts_alcu_free_thr_pref (type=148, unused=0x8250b60, p=0xa2dd7f0) at beam/erl_alloc_util.c:2699 #4 0x081535da in erts_free (env=0xa2dd7f0) at beam/erl_alloc.h:210 #5 enif_free_env (env=0xa2dd7f0) at beam/erl_nif.c:256 #6 0x00e21218 in job_destroy (obj=0xa2dd7c0) at c_src/job.c:32 #7 0x00e21cda in queue_done (queue=0xa2dd718, item=0xa2dd7c0) at c_src/queue.c:184 #8 0x00e23849 in worker_exec (vm=0xa2a7d10) at c_src/worker.c:124 #9 0x00e2376d in worker_run (arg=0xa2dd628) at c_src/worker.c:85 #10 0x081d2a2c in thr_wrapper (vtwd=0xb64e5020) at common/ethread.c:480 #11 0x0068296e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 #12 0x00260a4e in clone () from /lib/tls/i686/cmov/libc.so.6 Thanks, Paul Davis From ingela@REDACTED Mon Jun 28 09:33:00 2010 From: ingela@REDACTED (Ingela Andin) Date: Mon, 28 Jun 2010 09:33:00 +0200 Subject: [erlang-questions] supervised inets httpd process In-Reply-To: References: Message-ID: Hi! 2010/6/27 Ryan Zezeski : > Hi everyone. ?I'm a newcomer to Erlang and have been reading through > Programming Erlang for the past week. ?There is an application I want to > build to replace a legacy webapp in my workplace. ?I will be replacing the > bulk of this application with CouchDB/Erlang but I need a light web > interface that wraps it to provide service to the legacy endpoints (URLs). > > As a first cut, I plan on using the inets application with a custom httpd > callback module to service the API. ?I was curious, what is the best way to > "embed" the httpd server in my application? ?That is, I'm building an OTP > compliant application, and I want the httpd server to sit under my > supervisor. > > My first attempt was to create a gen_server callback that called > inets:start/1 and httpd:start/2 in the init/1 function, but I'm not sure Note that httpd:start/2 is not a documented function in the latest version of inets. > this was the appropriate approach. ?My second approach was to start inets in > the supervisor callback init/1, and then pass the httpd startup to the > supervisor config like so: {inets, start, [httpd,[{port,7777}, ...}. By default the httpd processes is supervised by the inets applications supervisor. The "normal" way would be to make your application a user of the inets application and let it take care of the supervison for you. If you for some reanson want to make your own application the top supervisor of the httpd service you shold start it with the option stand_alone e.i. inets:start(httpd, ServiceConfig, stand_alone). This will in a sense make the calling process the top supervisor of the httpd service, and if this process is a OTP-supervisor it should work as expected. [...] Regards Ingela Erlang/OTP team, Ericsson AB From rapsey@REDACTED Mon Jun 28 09:41:02 2010 From: rapsey@REDACTED (Rapsey) Date: Mon, 28 Jun 2010 09:41:02 +0200 Subject: [erlang-questions] Turning on ASSERT's in OTP code. In-Reply-To: References: Message-ID: I'm using a NIF library that sends messages from a thread and have not seen such crashes. The environment gets invalidated after a send. Are you calling enif_clear_env or enif_free_env after enif_send? Sergej On Mon, Jun 28, 2010 at 8:12 AM, Paul Davis wrote: > I've stumbled across a weird segfault when sending terms from a thread > spawned by a NIF. Investigating this i followed a traceback to > erts/emulator/beam/erl_alloc_util.c. Glancing at the code in > erl_alloc_util.c I notice that the line before the crash is an assert. > Checking the value in gdb shows that the assertion is violated. My > first thought was to try and enable these asserts but I'm not sure > where to look for docs on how to do such a thing. Looking through the > code I see them looking for DEBUG to be defined yet nothing in > ./configure's help suggests a flag to set. > > In the interest of trying things I tried CFLAGS="-DDEBUG" ./configure > && CFLAGS="-DDEBUG" make but it dies with an error about pcre. > > Anyone have a pointer on where to look for getting these enabled? > > Here's a copy of the traceback if it helps anyone. The lines in > erl_alloc_util.c starting at 598: > > ASSERT(crr->prev); > crr->prev->next = crr->next; > > gdb shows that crr is valid and crr->prev is NULL. > > #0 0x08085e82 in unlink_carrier (allctr=0xa2dc140, blk= out>) > at beam/erl_alloc_util.c:599 > #1 destroy_carrier (allctr=0xa2dc140, blk=) > at beam/erl_alloc_util.c:1615 > #2 0x08087161 in do_erts_alcu_free (type=148, unused=0x8250b60, > p=0xa2dd7f0) > at beam/erl_alloc_util.c:2648 > #3 erts_alcu_free_thr_pref (type=148, unused=0x8250b60, p=0xa2dd7f0) > at beam/erl_alloc_util.c:2699 > #4 0x081535da in erts_free (env=0xa2dd7f0) at beam/erl_alloc.h:210 > #5 enif_free_env (env=0xa2dd7f0) at beam/erl_nif.c:256 > #6 0x00e21218 in job_destroy (obj=0xa2dd7c0) at c_src/job.c:32 > #7 0x00e21cda in queue_done (queue=0xa2dd718, item=0xa2dd7c0) > at c_src/queue.c:184 > #8 0x00e23849 in worker_exec (vm=0xa2a7d10) at c_src/worker.c:124 > #9 0x00e2376d in worker_run (arg=0xa2dd628) at c_src/worker.c:85 > #10 0x081d2a2c in thr_wrapper (vtwd=0xb64e5020) at common/ethread.c:480 > #11 0x0068296e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 > #12 0x00260a4e in clone () from /lib/tls/i686/cmov/libc.so.6 > > > Thanks, > Paul Davis > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From paul.joseph.davis@REDACTED Mon Jun 28 10:20:18 2010 From: paul.joseph.davis@REDACTED (Paul Joseph Davis) Date: Mon, 28 Jun 2010 04:20:18 -0400 Subject: [erlang-questions] Turning on ASSERT's in OTP code. In-Reply-To: References: Message-ID: Yeah, this is affecting a specific point in some tests I'm migrating. I haven't been able to narrow down what it is about this specific message that's causing an error but other messages are sent fine. My hope is that by turning on the asserts I can narrow down where exactly I'm going off the reservation. Paul Davis On Jun 28, 2010, at 3:41 AM, Rapsey wrote: > I'm using a NIF library that sends messages from a thread and have not seen such crashes. > The environment gets invalidated after a send. Are you calling enif_clear_env or enif_free_env after enif_send? > > > Sergej > > On Mon, Jun 28, 2010 at 8:12 AM, Paul Davis wrote: > I've stumbled across a weird segfault when sending terms from a thread > spawned by a NIF. Investigating this i followed a traceback to > erts/emulator/beam/erl_alloc_util.c. Glancing at the code in > erl_alloc_util.c I notice that the line before the crash is an assert. > Checking the value in gdb shows that the assertion is violated. My > first thought was to try and enable these asserts but I'm not sure > where to look for docs on how to do such a thing. Looking through the > code I see them looking for DEBUG to be defined yet nothing in > ./configure's help suggests a flag to set. > > In the interest of trying things I tried CFLAGS="-DDEBUG" ./configure > && CFLAGS="-DDEBUG" make but it dies with an error about pcre. > > Anyone have a pointer on where to look for getting these enabled? > > Here's a copy of the traceback if it helps anyone. The lines in > erl_alloc_util.c starting at 598: > > ASSERT(crr->prev); > crr->prev->next = crr->next; > > gdb shows that crr is valid and crr->prev is NULL. > > #0 0x08085e82 in unlink_carrier (allctr=0xa2dc140, blk=) > at beam/erl_alloc_util.c:599 > #1 destroy_carrier (allctr=0xa2dc140, blk=) > at beam/erl_alloc_util.c:1615 > #2 0x08087161 in do_erts_alcu_free (type=148, unused=0x8250b60, p=0xa2dd7f0) > at beam/erl_alloc_util.c:2648 > #3 erts_alcu_free_thr_pref (type=148, unused=0x8250b60, p=0xa2dd7f0) > at beam/erl_alloc_util.c:2699 > #4 0x081535da in erts_free (env=0xa2dd7f0) at beam/erl_alloc.h:210 > #5 enif_free_env (env=0xa2dd7f0) at beam/erl_nif.c:256 > #6 0x00e21218 in job_destroy (obj=0xa2dd7c0) at c_src/job.c:32 > #7 0x00e21cda in queue_done (queue=0xa2dd718, item=0xa2dd7c0) > at c_src/queue.c:184 > #8 0x00e23849 in worker_exec (vm=0xa2a7d10) at c_src/worker.c:124 > #9 0x00e2376d in worker_run (arg=0xa2dd628) at c_src/worker.c:85 > #10 0x081d2a2c in thr_wrapper (vtwd=0xb64e5020) at common/ethread.c:480 > #11 0x0068296e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 > #12 0x00260a4e in clone () from /lib/tls/i686/cmov/libc.so.6 > > > Thanks, > Paul Davis > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From sverker@REDACTED Mon Jun 28 11:22:18 2010 From: sverker@REDACTED (Sverker Eriksson) Date: Mon, 28 Jun 2010 11:22:18 +0200 Subject: [erlang-questions] Turning on ASSERT's in OTP code. In-Reply-To: References: Message-ID: <4C2869CA.1050902@erix.ericsson.se> A "debug" build will enable ASSERT's. From INSTALL.md: "How to Build a Debug Enabled Erlang RunTime System -------------------------------------------------- After completing all the normal building steps described above a debug enabled runtime system can be built. To do this you have to change directory to `$ERL_TOP/erts/emulator`. In this directory execute: $ make debug FLAVOR=$FLAVOR where `$FLAVOR` is either `plain` or `smp`. The flavor options will produce a beam.debug and beam.smp.debug executable respectively. The files are installed along side with the normal (opt) versions `beam.smp` and `beam`. To start the debug enabled runtime system execute: $ $ERL_TOP/bin/cerl -debug The debug enabled runtime system features lock violation checking, assert checking and various sanity checks to help a developer ensure correctness. Some of these features can be enabled on a normal beam using appropriate configure options. There are other types of runtime systems that can be built as well using the similar steps just described. $ make $TYPE FLAVOR=$FLAVOR where `$TYPE` is `opt`, `gcov`, `gprof`, `debug`, `valgrind`, or `lcnt`. These different beam types are useful for debugging and profiling purposes." /Sverker, Erlang/OTP Paul Joseph Davis wrote: > Yeah, this is affecting a specific point in some tests I'm migrating. I haven't been able to narrow down what it is about this specific message that's causing an error but other messages are sent fine. My hope is that by turning on the asserts I can narrow down where exactly I'm going off the reservation. > > Paul Davis > > On Jun 28, 2010, at 3:41 AM, Rapsey wrote: > > >> I'm using a NIF library that sends messages from a thread and have not seen such crashes. >> The environment gets invalidated after a send. Are you calling enif_clear_env or enif_free_env after enif_send? >> >> >> Sergej >> >> On Mon, Jun 28, 2010 at 8:12 AM, Paul Davis wrote: >> I've stumbled across a weird segfault when sending terms from a thread >> spawned by a NIF. Investigating this i followed a traceback to >> erts/emulator/beam/erl_alloc_util.c. Glancing at the code in >> erl_alloc_util.c I notice that the line before the crash is an assert. >> Checking the value in gdb shows that the assertion is violated. My >> first thought was to try and enable these asserts but I'm not sure >> where to look for docs on how to do such a thing. Looking through the >> code I see them looking for DEBUG to be defined yet nothing in >> ./configure's help suggests a flag to set. >> >> In the interest of trying things I tried CFLAGS="-DDEBUG" ./configure >> && CFLAGS="-DDEBUG" make but it dies with an error about pcre. >> >> Anyone have a pointer on where to look for getting these enabled? >> >> Here's a copy of the traceback if it helps anyone. The lines in >> erl_alloc_util.c starting at 598: >> >> ASSERT(crr->prev); >> crr->prev->next = crr->next; >> >> gdb shows that crr is valid and crr->prev is NULL. >> >> #0 0x08085e82 in unlink_carrier (allctr=0xa2dc140, blk=) >> at beam/erl_alloc_util.c:599 >> #1 destroy_carrier (allctr=0xa2dc140, blk=) >> at beam/erl_alloc_util.c:1615 >> #2 0x08087161 in do_erts_alcu_free (type=148, unused=0x8250b60, p=0xa2dd7f0) >> at beam/erl_alloc_util.c:2648 >> #3 erts_alcu_free_thr_pref (type=148, unused=0x8250b60, p=0xa2dd7f0) >> at beam/erl_alloc_util.c:2699 >> #4 0x081535da in erts_free (env=0xa2dd7f0) at beam/erl_alloc.h:210 >> #5 enif_free_env (env=0xa2dd7f0) at beam/erl_nif.c:256 >> #6 0x00e21218 in job_destroy (obj=0xa2dd7c0) at c_src/job.c:32 >> #7 0x00e21cda in queue_done (queue=0xa2dd718, item=0xa2dd7c0) >> at c_src/queue.c:184 >> #8 0x00e23849 in worker_exec (vm=0xa2a7d10) at c_src/worker.c:124 >> #9 0x00e2376d in worker_run (arg=0xa2dd628) at c_src/worker.c:85 >> #10 0x081d2a2c in thr_wrapper (vtwd=0xb64e5020) at common/ethread.c:480 >> #11 0x0068296e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 >> #12 0x00260a4e in clone () from /lib/tls/i686/cmov/libc.so.6 >> >> >> Thanks, >> Paul Davis >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> >> > > > From fdmanana@REDACTED Mon Jun 28 12:55:05 2010 From: fdmanana@REDACTED (Filipe David Manana) Date: Mon, 28 Jun 2010 11:55:05 +0100 Subject: EEP 18 (JSON BIFs) Message-ID: Hello, I've just seen the following EEP recently: http://www.erlang.org/eeps/eep-0018.html What happened to it? Got abandoned? cheers -- Filipe David Manana, fdmanana @ apache.org "Reasonable men adapt themselves to the world. Unreasonable men adapt the world to themselves. That's why all progress depends on unreasonable men." From kenneth.lundin@REDACTED Mon Jun 28 14:14:47 2010 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 28 Jun 2010 14:14:47 +0200 Subject: [erlang-questions] EEP 18 (JSON BIFs) In-Reply-To: References: Message-ID: Hi, Since we have introduced NIFs as a way to implement and dynamically load parts of the functions in a module in C there is no need to introduce new BIFs (Built In Functions) for encoding /decoding between Erlang terms and JSON. EEPs are suggestions regarding extensions of the language and standard libraries. And BIF's are mostly regarded as part of the language. Now we don't need a new BIF just because something is implemented in C (for efficiency reasons) and thus no EEP. The suggested functionality in EEP 18 is still very valid and we welcome the implementation of JSON library or module that we can include in the distribution or that is distributed separately. /Regards Kenneth , Erlang/OTP Ericsson On Mon, Jun 28, 2010 at 12:55 PM, Filipe David Manana wrote: > Hello, > > I've just seen the following EEP recently: > > http://www.erlang.org/eeps/eep-0018.html > > What happened to it? Got abandoned? > > cheers > > > -- > Filipe David Manana, > fdmanana @ apache.org > > "Reasonable men adapt themselves to the world. > Unreasonable men adapt the world to themselves. > That's why all progress depends on unreasonable men." > From rbhat@REDACTED Mon Jun 28 15:32:04 2010 From: rbhat@REDACTED (Rajesh Bhat) Date: Mon, 28 Jun 2010 08:32:04 -0500 Subject: [erlang-questions] Erlang - Question on memory usage reported In-Reply-To: <98440.1277503191@snookles.snookles.com> References: Message of "Wed, 16 Jun 2010 07:55:00 CDT." <6329B957BA5C514DBF5FBED87A88388204D2317B44@spswchi6mail1.peak6.net> <98440.1277503191@snookles.snookles.com> Message-ID: <6329B957BA5C514DBF5FBED87A88388204E30ED410@spswchi6mail1.peak6.net> Thank you. Yes, it is the release memory back to OS option that I am looking for. I have run garbage collector on the pid, however that did not do the trick. Thanks -- Rajesh Bhat. -----Original Message----- From: Scott Lystig Fritchie [mailto:fritchie@REDACTED] Sent: Friday, June 25, 2010 5:00 PM To: Rajesh Bhat Cc: 'erlang-questions@REDACTED' Subject: Re: [erlang-questions] Erlang - Question on memory usage reported Sorry for replying to a message a week and a half old... Rajesh Bhat wrote: rb> I am running an application that starts up with a memory footprint rb> of around ~725MB when started (Approx 9000 processes on rb> startup).. Application spawns processes as new requests are rb> processed and grows to about 50K processes and memory usage of 5.1GB rb> during the day. [...] rb> At the end of the day, a cleanup job reviews the process state and rb> kills the pids that are not required and cleans up the ets rb> table. [...] rb> [...] however running 'htop' on the system still indicates Erlang rb> beam process with a resident memory usage of around 5.1GB. Any rb> pointers that explains this behavior is greatly appreciated. Is rb> there a way to release the memory? Not easily, no. When a UNIX process calls free(), there's no guarantee that the memory free'd by that call will be returned to the OS now, later, or ever. It depends on how it's allocated. If the allocator used mmap(), then it can't munmap() the memory until (at least) all other chunks in the mmap()'ed region are also freed. If it's allocated using sbrk() or related, you can't move the break back down (to deallocate memory) if there are still live chunks of memory above the break. The Erlang VM uses its own set of allocators instead of using malloc directly, so they add another layer of when-to-release-to-the-OS that I can't comment directly on, sorry. -Scott ______________________________________________ See http://www.peak6.com/email_disclaimer.php for terms and conditions related to this email From comptekki@REDACTED Mon Jun 28 22:39:58 2010 From: comptekki@REDACTED (Wes James) Date: Mon, 28 Jun 2010 14:39:58 -0600 Subject: try/catch Message-ID: So in a previous post, it was mentioned that a variable in a try can not be used afterwards. How is this done then? Like this: do_query(Sp) -> {ok, Db} = pgsql:connect(?HOST, ?DB, ?USERNAME, ?PASSWORD), try {_,[{_,_,Res}]}=pgsql:squery(Db, Sp) catch throw:Term -> Term; exit:Reason -> {'EXIT',Reason}; error:Reason -> {'EXIT',{Reason,erlang:get_stacktrace()}} end, pgsql:terminate(Db), {Sp,""}. I want to call squery and return a value to Res, but if there is an error return nothing. {Sp. ""} was {Sp, Res} but doesn't work since Res is in the Try. thx, -wes From reachsaurabhnarula@REDACTED Mon Jun 28 22:46:19 2010 From: reachsaurabhnarula@REDACTED (Saurabh Narula) Date: Tue, 29 Jun 2010 02:16:19 +0530 Subject: ODBC SQL Param inserts only single item/record Message-ID: Hello Everyone, I am trying to insert records from my erlang program to database which supports ODBC connections, my sample program is give below - start_test() -> odbc:start(), {ok, Ref} = odbc:connect("DSN=myDB;Database=sqltest;UID=test;PWD=test", []), odbc:param_query(Ref,"INSERT INTO f1 (f1) VALUES(?)",[{{sql_varchar, 20},["test1", "test2"]}]), odbc:stop(). this program only inserts value "test1", however if i run it using sql query by forming query strings, everything just works fine. Any help would be deeply appreciated. Thank you everyone. Saurabh From allanwegan@REDACTED Mon Jun 28 23:08:45 2010 From: allanwegan@REDACTED (Allan Wegan) Date: Mon, 28 Jun 2010 23:08:45 +0200 Subject: [erlang-questions] try/catch In-Reply-To: References: Message-ID: <4C290F5D.9060100@allanwegan.de> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > So in a previous post, it was mentioned that a variable in a try can > not be used afterwards. How is this done then? Like this: > > do_query(Sp) -> > {ok, Db} = pgsql:connect(?HOST, ?DB, ?USERNAME, ?PASSWORD), > try {_,[{_,_,Res}]}=pgsql:squery(Db, Sp) > catch > throw:Term -> Term; > exit:Reason -> {'EXIT',Reason}; > error:Reason -> {'EXIT',{Reason,erlang:get_stacktrace()}} > end, > pgsql:terminate(Db), > {Sp,""}. > > I want to call squery and return a value to Res, but if there is an > error return nothing. {Sp. ""} was {Sp, Res} but doesn't work since > Res is in the Try. Maybe, the following is what you want: do_query(Sp) -> {ok, Db} = pgsql:connect(?HOST, ?DB, ?USERNAME, ?PASSWORD), Result = try {_,[{_,_,Res}]} = pgsql:squery(Db, Sp), {Sp, Res} catch _:_ -> 'undefined'; end, pgsql:terminate(Db), Result . - -- Allan Wegan Jabber: allanwegan@REDACTED ICQ: 209459114 Phone: +49 40 6732962 Sch?neberger Strasse 60, 22149 Hamburg, Germany -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (MingW32) iQEcBAEBAgAGBQJMKQ9dAAoJENm5axHh7AcxPMcIAL+/z/wTjIrQDSPNWaFnEBiw IE0JVnyQz04QfhQ9mJcpiKOdatImrTfshmAV8ocklzWgkTlp6GkYJIFdJBVdKnZC AbViKCviFDC01A1PMfdg8aSN9r5XYCEXHX+N1mZ4rB6Wr5Wrb10j4QLxQVZDkEZi KW1354BDU8bd7Llw35wtWM+Vip05hBhXTzTGO3KmreKtFBKH/y1PmKEVdetxxLeH bwRFU6XFfUiVHQ4uKHoDOtybi11AhzIb+ajiavDenWaXppXXEisfTlsZcUQc5Er9 SwyMBrcylNBSYysKAUbRpK67kZMyAIS/rX10PBkV9dGYAfaKejSwYhNGfgwACLk= =EHrJ -----END PGP SIGNATURE----- From comptekki@REDACTED Mon Jun 28 23:21:45 2010 From: comptekki@REDACTED (Wes James) Date: Mon, 28 Jun 2010 15:21:45 -0600 Subject: [erlang-questions] try/catch In-Reply-To: <4C290F5D.9060100@allanwegan.de> References: <4C290F5D.9060100@allanwegan.de> Message-ID: Thx. That worked. I didn't know try could return a value. I also need to remember that an expression is more than just a single line of code but can be several lines separated by a "," in erlang. -wes On Mon, Jun 28, 2010 at 3:08 PM, Allan Wegan wrote: > > Maybe, the following is what you want: > > do_query(Sp) -> > ? ? ? ?{ok, Db} = pgsql:connect(?HOST, ?DB, ?USERNAME, ?PASSWORD), > ? ? ? ?Result = try > ? ? ? ? ? ? ? ?{_,[{_,_,Res}]} = pgsql:squery(Db, Sp), > ? ? ? ? ? ? ? ?{Sp, Res} > ? ? ? ?catch > ? ? ? ? ? ? ? ?_:_ -> 'undefined'; > ? ? ? ?end, > ? ? ? ?pgsql:terminate(Db), > ? ? ? ?Result > . > From comptekki@REDACTED Mon Jun 28 23:24:09 2010 From: comptekki@REDACTED (Wes James) Date: Mon, 28 Jun 2010 15:24:09 -0600 Subject: [erlang-questions] try/catch In-Reply-To: References: Message-ID: Thx for responding. Allan had a similar response. -wes On Mon, Jun 28, 2010 at 3:12 PM, Brady McCary wrote: > Wes, > > do_query(Sp) -> > ? ?try > > ? ? ? ?{ok, Db} = pgsql:connect(?HOST, ?DB, ?USERNAME, ?PASSWORD), > ? ? ? ?{_,[{_,_,Res}]} = pgsql:squery(Db, Sp), > ? ? ? ?pgsql:terminate(Db), > ? ? ? ?{Sp, Res} > > ? ?catch > > ? ? ? ?throw:Term -> > ? ? ? ? ? ?Term; > > ? ? ? ? ?exit:Reason -> > ? ? ? ? ? ?{'EXIT',Reason}; > > ? ? ? ? ?error:Reason -> > ? ? ? ? ? ?{'EXIT',{Reason,erlang:get_stacktrace()}} > > ? ?end. > > Probably what you want. However, establishing/destorying a connection > for each query is probably inefficient and using try/catch is not the > usual erlang idiom of letting supervised processes die fast. > > Brady > > On Mon, Jun 28, 2010 at 3:39 PM, Wes James wrote: >> So in a previous post, it was mentioned that a variable in a try can >> not be used afterwards. ?How is this done then? ?Like this: >> >> do_query(Sp) -> >> ? ? ? ?{ok, Db} = pgsql:connect(?HOST, ?DB, ?USERNAME, ?PASSWORD), >> ? ? ? ?try {_,[{_,_,Res}]}=pgsql:squery(Db, Sp) >> ? ? ? ?catch >> ? ? ? ?throw:Term -> Term; >> ? ? ? ?exit:Reason -> {'EXIT',Reason}; >> ? ? ? ?error:Reason -> {'EXIT',{Reason,erlang:get_stacktrace()}} >> ? ? ? ?end, >> ? ? ? ?pgsql:terminate(Db), >> ? ? ? ?{Sp,""}. >> >> >> I want to call squery and return a value to Res, but if there is an >> error return nothing. ?{Sp. ""} was {Sp, Res} ?but doesn't work since >> Res is in the Try. >> >> thx, >> >> -wes >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> > From g@REDACTED Mon Jun 28 23:24:18 2010 From: g@REDACTED (Garrett Smith) Date: Mon, 28 Jun 2010 15:24:18 -0600 Subject: [erlang-questions] try/catch In-Reply-To: <4C290F5D.9060100@allanwegan.de> References: <4C290F5D.9060100@allanwegan.de> Message-ID: I tend to use try...of almost exclusively. IMO, something like this is much easier to understand (assuming I have the intent right): {ok, Db} = connect_db(), try pgsql:squery(Db, Sp) of {_,[{_,_,Res}]} -> {Sp, Res} catch _ -> undefined after pgsql:terminate(Db) end. The after body is always evaluated. On Mon, Jun 28, 2010 at 3:08 PM, Allan Wegan wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > >> So in a previous post, it was mentioned that a variable in a try can >> not be used afterwards. ?How is this done then? ?Like this: >> >> do_query(Sp) -> >> ? ? ? {ok, Db} = pgsql:connect(?HOST, ?DB, ?USERNAME, ?PASSWORD), >> ? ? ? try {_,[{_,_,Res}]}=pgsql:squery(Db, Sp) >> ? ? ? catch >> ? ? ? throw:Term -> Term; >> ? ? ? exit:Reason -> {'EXIT',Reason}; >> ? ? ? error:Reason -> {'EXIT',{Reason,erlang:get_stacktrace()}} >> ? ? ? end, >> ? ? ? pgsql:terminate(Db), >> ? ? ? {Sp,""}. >> >> I want to call squery and return a value to Res, but if there is an >> error return nothing. ?{Sp. ""} was {Sp, Res} ?but doesn't work since >> Res is in the Try. > > Maybe, the following is what you want: > > do_query(Sp) -> > ? ? ? ?{ok, Db} = pgsql:connect(?HOST, ?DB, ?USERNAME, ?PASSWORD), > ? ? ? ?Result = try > ? ? ? ? ? ? ? ?{_,[{_,_,Res}]} = pgsql:squery(Db, Sp), > ? ? ? ? ? ? ? ?{Sp, Res} > ? ? ? ?catch > ? ? ? ? ? ? ? ?_:_ -> 'undefined'; > ? ? ? ?end, > ? ? ? ?pgsql:terminate(Db), > ? ? ? ?Result > . > > > > - -- > Allan Wegan > Jabber: allanwegan@REDACTED > ICQ: ? ?209459114 > Phone: ?+49 40 6732962 > Sch?neberger Strasse 60, 22149 Hamburg, Germany > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.12 (MingW32) > > iQEcBAEBAgAGBQJMKQ9dAAoJENm5axHh7AcxPMcIAL+/z/wTjIrQDSPNWaFnEBiw > IE0JVnyQz04QfhQ9mJcpiKOdatImrTfshmAV8ocklzWgkTlp6GkYJIFdJBVdKnZC > AbViKCviFDC01A1PMfdg8aSN9r5XYCEXHX+N1mZ4rB6Wr5Wrb10j4QLxQVZDkEZi > KW1354BDU8bd7Llw35wtWM+Vip05hBhXTzTGO3KmreKtFBKH/y1PmKEVdetxxLeH > bwRFU6XFfUiVHQ4uKHoDOtybi11AhzIb+ajiavDenWaXppXXEisfTlsZcUQc5Er9 > SwyMBrcylNBSYysKAUbRpK67kZMyAIS/rX10PBkV9dGYAfaKejSwYhNGfgwACLk= > =EHrJ > -----END PGP SIGNATURE----- > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From dale@REDACTED Tue Jun 29 00:16:01 2010 From: dale@REDACTED (Dale Harvey) Date: Mon, 28 Jun 2010 23:16:01 +0100 Subject: New Release of erldocs Message-ID: Hey A few people have asked me about documenting their own libraries so thought I would post this to the list, I have just done a new release of http://erldocs.com/ as well as adding R14 its now easier for people to document their own libraries, the instructions are in the repository ( http://github.com/daleharvey/erldocs.com) and I have added an online version that includes some open source erlang libraries* @ http://erldocs.com/R14Aextra/mochiweb-read-only/mochijson.html?i=5&search=mochi Hope some people find it useful Cheers Dale * currently I have just added mochiweb and joes elib, if some requests are popular I will add them to the online docs. From rvirding@REDACTED Tue Jun 29 00:42:25 2010 From: rvirding@REDACTED (Robert Virding) Date: Tue, 29 Jun 2010 00:42:25 +0200 Subject: [erlang-questions] try/catch In-Reply-To: References: <4C290F5D.9060100@allanwegan.de> Message-ID: It's sometimes easy to forget that everything returns a value, usually something useful. Using try ... of as Garret suggested is a good anser to this problem. It also gives you better control of which errors are caught. Robert On 28 June 2010 23:21, Wes James wrote: > Thx. That worked. ?I didn't know try could return a value. ?I also > need to remember that an expression is more than just a single line of > code but can be several lines separated by a "," in erlang. > > -wes > > On Mon, Jun 28, 2010 at 3:08 PM, Allan Wegan wrote: > > >> >> Maybe, the following is what you want: >> >> do_query(Sp) -> >> ? ? ? ?{ok, Db} = pgsql:connect(?HOST, ?DB, ?USERNAME, ?PASSWORD), >> ? ? ? ?Result = try >> ? ? ? ? ? ? ? ?{_,[{_,_,Res}]} = pgsql:squery(Db, Sp), >> ? ? ? ? ? ? ? ?{Sp, Res} >> ? ? ? ?catch >> ? ? ? ? ? ? ? ?_:_ -> 'undefined'; >> ? ? ? ?end, >> ? ? ? ?pgsql:terminate(Db), >> ? ? ? ?Result >> . >> > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From zabrane3@REDACTED Tue Jun 29 02:00:36 2010 From: zabrane3@REDACTED (zabrane Mikael) Date: Tue, 29 Jun 2010 02:00:36 +0200 Subject: [erlang-questions] Reliable way to handle Java node crashs? In-Reply-To: References: Message-ID: Now, my Java node is restared after each crash ! But for one of my message data, I got this strange Erlang error: beam.smp(89316,0xb14d1000) malloc: *** mmap(size=730857472) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Could someone tell me what happens to the Erlang VM? Regards Zabrane From zabrane3@REDACTED Tue Jun 29 02:09:53 2010 From: zabrane3@REDACTED (zabrane Mikael) Date: Tue, 29 Jun 2010 02:09:53 +0200 Subject: [erlang-questions] Reliable way to handle Java node crashs? In-Reply-To: References: Message-ID: Trying to restart the same failing test, I got (maybe) a useful info: beam.smp(89316,0xb14d1000) malloc: *** mmap(size=730857472) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Crash dump was written to: erl_crash.dump eheap_alloc: Cannot allocate 583848200 bytes of memory (of type "heap"). Abort trap 2010/6/29 zabrane Mikael > Now, my Java node is restared after each crash ! > But for one of my message data, I got this strange Erlang error: > > beam.smp(89316,0xb14d1000) malloc: > *** mmap(size=730857472) failed (error code=12) > *** error: can't allocate region > *** set a breakpoint in malloc_error_break to debug > > Could someone tell me what happens to the Erlang VM? > > > Regards > Zabrane > -- Regards Zabrane From jeraymond@REDACTED Tue Jun 29 04:32:38 2010 From: jeraymond@REDACTED (Jeremy Raymond) Date: Mon, 28 Jun 2010 22:32:38 -0400 Subject: [erlang-questions] Re: Managing Experiments In-Reply-To: <90b67b95-bc3f-4903-b703-126e15e206e2@g19g2000yqc.googlegroups.com> References: <90b67b95-bc3f-4903-b703-126e15e206e2@g19g2000yqc.googlegroups.com> Message-ID: Thanks for the info everyone. This gives me some ideas on how to approach this. -- Jeremy Raymond On Sun, Jun 27, 2010 at 8:09 AM, Tim Fletcher wrote: > > Basically I need to be able to encapsulate and dynamically swap out > > different bits of functionality throughout the application based upon > > who is the current user. Anyone done something similar to this or have > > any insights into how they might approach such a problem? > > A system for "enabling features for a subset of users" is more general > than A/B testing. Here are some relevant slides: > > http://www.paulhammond.org/2010/06/trunk/ > > As with your example, the approach described basically amounts to > branching within the application code using guard conditions. > > > > - case statements littered throughout the code > > This is my preference, because it's simple. As the aforementioned > slides quote: "There is one consumer of the software: you". Adding > this test code is adding a feature that delivers value to you, so > instead of litter just think of it as part of the application. > > > If you want to "hot swap" the guard conditions without having to re- > deploy your entire application then you could store the code for the > guard functions external to the app (file system, mnesia, redis etc) > and evaluate them on the fly. > > > As for A/B testing specifically, it may be useful to look at existing > frameworks for ideas: > > http://vanity.labnotes.org/ab_testing.html > > http://www.bingocardcreator.com/abingo/usage > > > Hope that helps. > > Tim > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From sand.softnet1@REDACTED Tue Jun 29 06:53:27 2010 From: sand.softnet1@REDACTED (Sand T) Date: Tue, 29 Jun 2010 10:23:27 +0530 Subject: [erlang-questions] Compare XML string In-Reply-To: References: Message-ID: Any suggestions from the team? Regards, Sandeep > Hi Michael, > > I need to compare two XML string and the XML string attribute order, > value can be different as you pointed out in your explanation. The > comparison should give *false* only if the value of attribute is > different or some attribute is missing, It should not give *false* if > order of attribute is different. However, when I perform, > >> ? {Given, _} = xmerl_scan:file("Given.xml"), >> ? {Expected,_} = xmerl_scan:file("Expected.xml"), >> --then directly compare the resulting data structures in the obvious (?) >> way: >> ? Virtually_identical = (Given =:= Expected) > > it gives me *false* if the order of attribute is different. The two > example string that I used is > > S=" im=\"IM\" login=\"L\">Connected To Server". > > Exp = " code=\"100\" login=\"L\">Connected To Server". > > Regards, > Sandeep > > On Fri, Jun 25, 2010 at 8:56 PM, Michael Turner > wrote: >> I feel like I must be missing something in your question. ?Let's say that >> the Given XML is in a file Given.xml, the Expected in a file Expected.xml. >> ?Just read them in-- >> ??{Given, _} = xmerl_scan:file("Given.xml"), >> ??{Expected,_} =?xmerl_scan:file("Expected.xml"), >> --then directly compare the resulting data structures in the obvious (?) >> way: >> ??Virtually_identical = (Given =:= Expected) >> Of course, the two files could be different in certain inconsequential >> details, such as having have the same set of attributes in an XML element >> but in a different order, and/or having different tag formatting in >> whitespace. ?E.g., Expected.xml might literally have >> ?? >> while Given.xml had >> ??> ?? ? ? ?value = "1 cent" >> ?? ? ? ?id = me >> ??/> >> but the comparison above with Given with Expected (the resulting tree >> structures) would still yield true all other things being equal. ?Isn't that >> what you want, though? >> If you want to know the contents of the two files *AS STRINGS* are identical >> (regardless of whether they are XML, I suppose), why not just read them in >> (say as binaries) and compare them? >> -michael turner >> >> On Fri, Jun 25, 2010 at 3:43 PM, Sand T wrote: >>> >>> Hi, >>> >>> I need to compare two given XML string to ensure that the two strings >>> are identical or not at runtime. Does anyone have any idea on how to >>> do this in erlang? >>> >>> Following are some of the examples >>> Given String >>> >> code=\"102\">Authentication Successful ... >>> Exp String: >>> >> code=\"102\">Authentication Successful ... >>> >>> Eq 2: >>> Given String >>> >> code=\"102\">Authentication Successful ... >>> >> status=\"offline\" custom=\"Is offline\" group=\"Friends\" >>> blocked=\"no\"/> >>> >>> Expected: >>> Authentication >>> Successful ... >>> >> status=\"online\" custom=\"Is offline\" group=\"Friends\" >>> blocked=\"no\"/> >>> >>> Regards, >>> Sandeep >>> >>> ________________________________________________________________ >>> erlang-questions (at) erlang.org mailing list. >>> See http://www.erlang.org/faq.html >>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>> >> >> > From w.a.de.jong@REDACTED Tue Jun 29 08:53:33 2010 From: w.a.de.jong@REDACTED (Willem de Jong) Date: Tue, 29 Jun 2010 08:53:33 +0200 Subject: [erlang-questions] Compare XML string In-Reply-To: References: Message-ID: Hi Sandeep, If you have an XSD for the XML, then you can use erlsom:scan(). I believe that the output for two different XMLs with the same "meaning" will be identical. It will also help you to identify XML strings that are not correct (ie not in accordance with the XSD), and it may make the processing of the XML easier. You can find erlsom on sourceforge or on github ( http://github.com/willemdj/erlsom) Regards, Willem On Tue, Jun 29, 2010 at 6:53 AM, Sand T wrote: > Any suggestions from the team? > > Regards, > Sandeep > > > Hi Michael, > > > > I need to compare two XML string and the XML string attribute order, > > value can be different as you pointed out in your explanation. The > > comparison should give *false* only if the value of attribute is > > different or some attribute is missing, It should not give *false* if > > order of attribute is different. However, when I perform, > > > >> {Given, _} = xmerl_scan:file("Given.xml"), > >> {Expected,_} = xmerl_scan:file("Expected.xml"), > >> --then directly compare the resulting data structures in the obvious (?) > >> way: > >> Virtually_identical = (Given =:= Expected) > > > > it gives me *false* if the order of attribute is different. The two > > example string that I used is > > > > S=" > im=\"IM\" login=\"L\">Connected To Server". > > > > Exp = " > code=\"100\" login=\"L\">Connected To Server". > > > > Regards, > > Sandeep > > > > On Fri, Jun 25, 2010 at 8:56 PM, Michael Turner > > wrote: > >> I feel like I must be missing something in your question. Let's say > that > >> the Given XML is in a file Given.xml, the Expected in a file > Expected.xml. > >> Just read them in-- > >> {Given, _} = xmerl_scan:file("Given.xml"), > >> {Expected,_} = xmerl_scan:file("Expected.xml"), > >> --then directly compare the resulting data structures in the obvious (?) > >> way: > >> Virtually_identical = (Given =:= Expected) > >> Of course, the two files could be different in certain inconsequential > >> details, such as having have the same set of attributes in an XML > element > >> but in a different order, and/or having different tag formatting in > >> whitespace. E.g., Expected.xml might literally have > >> > >> while Given.xml had > >> >> value = "1 cent" > >> id = me > >> /> > >> but the comparison above with Given with Expected (the resulting tree > >> structures) would still yield true all other things being equal. Isn't > that > >> what you want, though? > >> If you want to know the contents of the two files *AS STRINGS* are > identical > >> (regardless of whether they are XML, I suppose), why not just read them > in > >> (say as binaries) and compare them? > >> -michael turner > >> > >> On Fri, Jun 25, 2010 at 3:43 PM, Sand T > wrote: > >>> > >>> Hi, > >>> > >>> I need to compare two given XML string to ensure that the two strings > >>> are identical or not at runtime. Does anyone have any idea on how to > >>> do this in erlang? > >>> > >>> Following are some of the examples > >>> Given String > >>> >>> code=\"102\">Authentication Successful ... > >>> Exp String: > >>> >>> code=\"102\">Authentication Successful ... > >>> > >>> Eq 2: > >>> Given String > >>> >>> code=\"102\">Authentication Successful ... > >>> >>> status=\"offline\" custom=\"Is offline\" group=\"Friends\" > >>> blocked=\"no\"/> > >>> > >>> Expected: > >>> Authentication > >>> Successful ... > >>> >>> status=\"online\" custom=\"Is offline\" group=\"Friends\" > >>> blocked=\"no\"/> > >>> > >>> Regards, > >>> Sandeep > >>> > >>> ________________________________________________________________ > >>> erlang-questions (at) erlang.org mailing list. > >>> See http://www.erlang.org/faq.html > >>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > >>> > >> > >> > > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From sand.softnet1@REDACTED Tue Jun 29 09:03:00 2010 From: sand.softnet1@REDACTED (Sand T) Date: Tue, 29 Jun 2010 12:33:00 +0530 Subject: [erlang-questions] Compare XML string In-Reply-To: References: Message-ID: Hi Willem, Thanks for the response. I am using erlsom but dont have XSD as I am getting all this XML as a part of server responses during runtime. All I need to do is compare the server response with the expected response and conclude whether the server response is exactly similar to the expected [XML] response. Expecting some quick response. Regards, Sandeep On Tue, Jun 29, 2010 at 12:23 PM, Willem de Jong wrote: > Hi Sandeep, > > If you have an XSD for the XML, then you can use erlsom:scan(). I believe > that the output for two different XMLs with the same "meaning" will be > identical. It will also help you to identify XML strings that are not > correct (ie not in accordance with the XSD), and it may make the processing > of the XML easier. > > You can find erlsom on sourceforge or on github > (http://github.com/willemdj/erlsom) > > Regards, > Willem > > > > On Tue, Jun 29, 2010 at 6:53 AM, Sand T wrote: >> >> Any suggestions from the team? >> >> Regards, >> Sandeep >> >> > Hi Michael, >> > >> > I need to compare two XML string and the XML string attribute order, >> > value can be different as you pointed out in your explanation. The >> > comparison should give *false* only if the value of attribute is >> > different or some attribute is missing, It should not give *false* if >> > order of attribute is different. However, when I perform, >> > >> >> ? {Given, _} = xmerl_scan:file("Given.xml"), >> >> ? {Expected,_} = xmerl_scan:file("Expected.xml"), >> >> --then directly compare the resulting data structures in the obvious >> >> (?) >> >> way: >> >> ? Virtually_identical = (Given =:= Expected) >> > >> > it gives me *false* if the order of attribute is different. The two >> > example string that I used is >> > >> > S="> > im=\"IM\" login=\"L\">Connected To Server". >> > >> > Exp = "> > code=\"100\" login=\"L\">Connected To Server". >> > >> > Regards, >> > Sandeep >> > >> > On Fri, Jun 25, 2010 at 8:56 PM, Michael Turner >> > wrote: >> >> I feel like I must be missing something in your question. ?Let's say >> >> that >> >> the Given XML is in a file Given.xml, the Expected in a file >> >> Expected.xml. >> >> ?Just read them in-- >> >> ??{Given, _} = xmerl_scan:file("Given.xml"), >> >> ??{Expected,_} =?xmerl_scan:file("Expected.xml"), >> >> --then directly compare the resulting data structures in the obvious >> >> (?) >> >> way: >> >> ??Virtually_identical = (Given =:= Expected) >> >> Of course, the two files could be different in certain inconsequential >> >> details, such as having have the same set of attributes in an XML >> >> element >> >> but in a different order, and/or having different tag formatting in >> >> whitespace. ?E.g., Expected.xml might literally have >> >> ?? >> >> while Given.xml had >> >> ??> >> ?? ? ? ?value = "1 cent" >> >> ?? ? ? ?id = me >> >> ??/> >> >> but the comparison above with Given with Expected (the resulting tree >> >> structures) would still yield true all other things being equal. ?Isn't >> >> that >> >> what you want, though? >> >> If you want to know the contents of the two files *AS STRINGS* are >> >> identical >> >> (regardless of whether they are XML, I suppose), why not just read them >> >> in >> >> (say as binaries) and compare them? >> >> -michael turner >> >> >> >> On Fri, Jun 25, 2010 at 3:43 PM, Sand T >> >> wrote: >> >>> >> >>> Hi, >> >>> >> >>> I need to compare two given XML string to ensure that the two strings >> >>> are identical or not at runtime. Does anyone have any idea on how to >> >>> do this in erlang? >> >>> >> >>> Following are some of the examples >> >>> Given String >> >>> > >>> code=\"102\">Authentication Successful ... >> >>> Exp String: >> >>> > >>> code=\"102\">Authentication Successful ... >> >>> >> >>> Eq 2: >> >>> Given String >> >>> > >>> code=\"102\">Authentication Successful ... >> >>> > >>> status=\"offline\" custom=\"Is offline\" group=\"Friends\" >> >>> blocked=\"no\"/> >> >>> >> >>> Expected: >> >>> Authentication >> >>> Successful ... >> >>> > >>> status=\"online\" custom=\"Is offline\" group=\"Friends\" >> >>> blocked=\"no\"/> >> >>> >> >>> Regards, >> >>> Sandeep >> >>> >> >>> ________________________________________________________________ >> >>> erlang-questions (at) erlang.org mailing list. >> >>> See http://www.erlang.org/faq.html >> >>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >>> >> >> >> >> >> > >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> > > From schramm.ingo@REDACTED Tue Jun 29 09:24:08 2010 From: schramm.ingo@REDACTED (ingo.schramm) Date: Tue, 29 Jun 2010 00:24:08 -0700 (PDT) Subject: Reliable way to handle Java node crashs? In-Reply-To: References: Message-ID: BTW, for a certain application I wrote an Erlang/Java app called "ej" abstracting all that stuff. An Erlang app maintains a Java node, restarts it etc. Messages are abstracted into one common format with an API. It's available here: http://github.com/nerlo/nerlo. I plan to distribute it separately from nerlo once it has been proven(!) to be rock solid and once it is documented. Cheers, Ingo On Jun 29, 2:09?am, zabrane Mikael wrote: > Trying to restart the same failing test, I got (maybe) a useful info: > > beam.smp(89316,0xb14d1000) malloc: > *** mmap(size=730857472) failed (error code=12) > *** error: can't allocate region > *** set a breakpoint in malloc_error_break to debug > > Crash dump was written to: erl_crash.dump > eheap_alloc: Cannot allocate 583848200 bytes of memory (of type "heap"). > > Abort trap > > 2010/6/29 zabrane Mikael > > > Now, my Java node is restared after each crash ! > > But for one of my message data, I got this strange Erlang error: > > > beam.smp(89316,0xb14d1000) malloc: > > *** mmap(size=730857472) failed (error code=12) > > *** error: can't allocate region > > *** set a breakpoint in malloc_error_break to debug > > > Could someone tell me what happens to the Erlang VM? > > > Regards > > Zabrane > > -- > Regards > Zabrane From sedrik@REDACTED Tue Jun 29 10:17:47 2010 From: sedrik@REDACTED (Fredrik Andersson) Date: Tue, 29 Jun 2010 10:17:47 +0200 Subject: Difference between erlang:send_after and timer:send_after? Message-ID: Hi all These two functions seems to be doing the exact same thing (sending a message after a certain amount of time) but I was wondering why they are both there. Should timer:send_after not be replacing erlang:send_after or am I missing something here? None of them seems to be deprecated, which is the preferred one to use? Sorry for the silly question. from the documentation concerning timer: send_after(Time, Pid, Message) -> {ok, TRef} | {error,Reason} send_after(Time, Message) -> {ok, TRef} | {error,Reason} * Time = integer() in Milliseconds * Pid = pid() | atom() * Message = term() * Result = {ok, TRef} | {error, Reason} send_after/3 Evaluates Pid ! Message after Time amount of time has elapsed. (Pid can also be an atom of a registered name.) Returns {ok, TRef}, or {error, Reason}. send_after/2 Same as send_after(Time, self(), Message). and the module erlang documentation: erlang:send_after(Time, Dest, Msg) -> TimerRef * Time = int() * 0 <= Time <= 4294967295 * Dest = pid() | RegName * LocalPid = pid() (of a process, alive or dead, on the local node) * Msg = term() * TimerRef = ref() Starts a timer which will send the message Msg to Dest after Time milliseconds. If Dest is an atom, it is supposed to be the name of a registered process. The process referred to by the name is looked up at the time of delivery. No error is given if the name does not refer to a process. If Dest is a pid, the timer will be automatically canceled if the process referred to by the pid is not alive, or when the process exits. This feature was introduced in erts version 5.4.11. Note that timers will not be automatically canceled when Dest is an atom. See also erlang:start_timer/3, erlang:cancel_timer/1, and erlang:read_timer/1. Failure: badarg if the arguments does not satisfy the requirements specified above. From mazen.harake@REDACTED Tue Jun 29 10:51:18 2010 From: mazen.harake@REDACTED (Mazen Harake) Date: Tue, 29 Jun 2010 11:51:18 +0300 Subject: [erlang-questions] Compare XML string In-Reply-To: References: Message-ID: <4C29B406.60602@erlang-solutions.com> "Exactly similar" :) Anyway; perhaps if you flatten the whole string and sort it. It should be the same. Maybe that is a good enough solution /Mazen On 29/06/2010 10:03, Sand T wrote: > exactly similar --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com From w.a.de.jong@REDACTED Tue Jun 29 13:20:58 2010 From: w.a.de.jong@REDACTED (Willem de Jong) Date: Tue, 29 Jun 2010 13:20:58 +0200 Subject: [erlang-questions] Compare XML string In-Reply-To: References: Message-ID: Hi, If you take a look at the erlsom source file erlsom_simpleform.erl, you could try replacing the line 156: lists:reverse(Acc); by: lists:sort(Acc); That way you can compare the results of erlsom:simple_form(Given) and erlsom:simple_form(Expected) (Note: I didn't test this..) Regards, Willem On Tue, Jun 29, 2010 at 9:03 AM, Sand T wrote: > Hi Willem, > > Thanks for the response. I am using erlsom but dont have XSD as I am > getting all this XML as a part of server responses during runtime. All > I need to do is compare the server response with the expected response > and conclude whether the server response is exactly similar to the > expected [XML] response. > > Expecting some quick response. > > Regards, > Sandeep > > On Tue, Jun 29, 2010 at 12:23 PM, Willem de Jong > wrote: > > Hi Sandeep, > > > > If you have an XSD for the XML, then you can use erlsom:scan(). I believe > > that the output for two different XMLs with the same "meaning" will be > > identical. It will also help you to identify XML strings that are not > > correct (ie not in accordance with the XSD), and it may make the > processing > > of the XML easier. > > > > You can find erlsom on sourceforge or on github > > (http://github.com/willemdj/erlsom) > > > > Regards, > > Willem > > > > > > > > On Tue, Jun 29, 2010 at 6:53 AM, Sand T wrote: > >> > >> Any suggestions from the team? > >> > >> Regards, > >> Sandeep > >> > >> > Hi Michael, > >> > > >> > I need to compare two XML string and the XML string attribute order, > >> > value can be different as you pointed out in your explanation. The > >> > comparison should give *false* only if the value of attribute is > >> > different or some attribute is missing, It should not give *false* if > >> > order of attribute is different. However, when I perform, > >> > > >> >> {Given, _} = xmerl_scan:file("Given.xml"), > >> >> {Expected,_} = xmerl_scan:file("Expected.xml"), > >> >> --then directly compare the resulting data structures in the obvious > >> >> (?) > >> >> way: > >> >> Virtually_identical = (Given =:= Expected) > >> > > >> > it gives me *false* if the order of attribute is different. The two > >> > example string that I used is > >> > > >> > S=" >> > im=\"IM\" login=\"L\">Connected To Server". > >> > > >> > Exp = " >> > code=\"100\" login=\"L\">Connected To Server". > >> > > >> > Regards, > >> > Sandeep > >> > > >> > On Fri, Jun 25, 2010 at 8:56 PM, Michael Turner > >> > wrote: > >> >> I feel like I must be missing something in your question. Let's say > >> >> that > >> >> the Given XML is in a file Given.xml, the Expected in a file > >> >> Expected.xml. > >> >> Just read them in-- > >> >> {Given, _} = xmerl_scan:file("Given.xml"), > >> >> {Expected,_} = xmerl_scan:file("Expected.xml"), > >> >> --then directly compare the resulting data structures in the obvious > >> >> (?) > >> >> way: > >> >> Virtually_identical = (Given =:= Expected) > >> >> Of course, the two files could be different in certain > inconsequential > >> >> details, such as having have the same set of attributes in an XML > >> >> element > >> >> but in a different order, and/or having different tag formatting in > >> >> whitespace. E.g., Expected.xml might literally have > >> >> > >> >> while Given.xml had > >> >> >> >> value = "1 cent" > >> >> id = me > >> >> /> > >> >> but the comparison above with Given with Expected (the resulting tree > >> >> structures) would still yield true all other things being equal. > Isn't > >> >> that > >> >> what you want, though? > >> >> If you want to know the contents of the two files *AS STRINGS* are > >> >> identical > >> >> (regardless of whether they are XML, I suppose), why not just read > them > >> >> in > >> >> (say as binaries) and compare them? > >> >> -michael turner > >> >> > >> >> On Fri, Jun 25, 2010 at 3:43 PM, Sand T > >> >> wrote: > >> >>> > >> >>> Hi, > >> >>> > >> >>> I need to compare two given XML string to ensure that the two > strings > >> >>> are identical or not at runtime. Does anyone have any idea on how to > >> >>> do this in erlang? > >> >>> > >> >>> Following are some of the examples > >> >>> Given String > >> >>> >> >>> code=\"102\">Authentication Successful ... > >> >>> Exp String: > >> >>> >> >>> code=\"102\">Authentication Successful ... > >> >>> > >> >>> Eq 2: > >> >>> Given String > >> >>> >> >>> code=\"102\">Authentication Successful ... > >> >>> >> >>> status=\"offline\" custom=\"Is offline\" group=\"Friends\" > >> >>> blocked=\"no\"/> > >> >>> > >> >>> Expected: > >> >>> Authentication > >> >>> Successful ... > >> >>> >> >>> status=\"online\" custom=\"Is offline\" group=\"Friends\" > >> >>> blocked=\"no\"/> > >> >>> > >> >>> Regards, > >> >>> Sandeep > >> >>> > >> >>> ________________________________________________________________ > >> >>> erlang-questions (at) erlang.org mailing list. > >> >>> See http://www.erlang.org/faq.html > >> >>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > >> >>> > >> >> > >> >> > >> > > >> > >> ________________________________________________________________ > >> erlang-questions (at) erlang.org mailing list. > >> See http://www.erlang.org/faq.html > >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > >> > > > > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From steven.charles.davis@REDACTED Tue Jun 29 13:32:23 2010 From: steven.charles.davis@REDACTED (Steve Davis) Date: Tue, 29 Jun 2010 04:32:23 -0700 (PDT) Subject: Compare XML string In-Reply-To: References: Message-ID: Am I under-thinking this if I say: case GivenString of ExpectedString -> ok; _ -> error end. ...or is the question really as simple as it sounds. /s On Jun 25, 1:43?am, Sand T wrote: > Hi, > > I need to compare two given XML string to ensure that the two strings > are identical or not at runtime. Does anyone have any idea on how to > do this in erlang? > > Following are some of the examples > Given String > code=\"102\">Authentication Successful ... > Exp String: > code=\"102\">Authentication Successful ... > > Eq 2: > Given String > code=\"102\">Authentication Successful ... > status=\"offline\" custom=\"Is offline\" group=\"Friends\" > blocked=\"no\"/> > > Expected: > Authentication > Successful ... > status=\"online\" custom=\"Is offline\" group=\"Friends\" > blocked=\"no\"/> > > Regards, > Sandeep > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > Seehttp://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscr...@REDACTED From rumata-estor@REDACTED Tue Jun 29 13:40:53 2010 From: rumata-estor@REDACTED (Dmitry Belyaev) Date: Tue, 29 Jun 2010 15:40:53 +0400 Subject: [erlang-questions] Re: Compare XML string In-Reply-To: References: Message-ID: <4C29DBC5.8080903@nm.ru> First of all, what does author want to compare: plain strings or xml documents? If documents (or parts of documents) then what about order of attributes and child elements? Does it matter? > code=\"102\">Authentication Successful ... >> Exp String: >> > code=\"102\">Authentication Successful ... >> >> Eq 2: >> Given String >> > code=\"102\">Authentication Successful ... >> > status=\"offline\" custom=\"Is offline\" group=\"Friends\" >> blocked=\"no\"/> >> >> Expected: >> Authentication >> Successful ... >> > status=\"online\" custom=\"Is offline\" group=\"Friends\" >> blocked=\"no\"/> >> >> Regards, >> Sandeep >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> Seehttp://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscr...@REDACTED >> > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > From zabrane3@REDACTED Tue Jun 29 14:18:14 2010 From: zabrane3@REDACTED (zabrane Mikael) Date: Tue, 29 Jun 2010 14:18:14 +0200 Subject: [erlang-questions] Re: Reliable way to handle Java node crashs? In-Reply-To: References: Message-ID: Hi guys, Please, could someone help me understand this memory heap alloc failure of the Erlang VM ;-) Regards Zabrane > On Jun 29, 2:09 am, zabrane Mikael wrote: >> > Trying to restart the same failing test, I got (maybe) a useful info: >> > >> > beam.smp(89316,0xb14d1000) malloc: >> > *** mmap(size=730857472) failed (error code=12) >> > *** error: can't allocate region >> > *** set a breakpoint in malloc_error_break to debug >> > >> > Crash dump was written to: erl_crash.dump >> > eheap_alloc: Cannot allocate 583848200 bytes of memory (of type "heap"). >> > >> > Abort trap >> > >> > 2010/6/29 zabrane Mikael >> > >> > > Now, my Java node is restared after each crash ! >> > > But for one of my message data, I got this strange Erlang error: >> > >> > > beam.smp(89316,0xb14d1000) malloc: >> > > *** mmap(size=730857472) failed (error code=12) >> > > *** error: can't allocate region >> > > *** set a breakpoint in malloc_error_break to debug >> > >> > > Could someone tell me what happens to the Erlang VM? >> > >> > > Regards >> > > Zabrane >> > >> > -- >> > Regards >> > Zabrane >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> > > > -- > Regards > Zabrane > -- Regards Zabrane From mikpe@REDACTED Tue Jun 29 15:00:56 2010 From: mikpe@REDACTED (Mikael Pettersson) Date: Tue, 29 Jun 2010 15:00:56 +0200 Subject: [erlang-questions] Re: Reliable way to handle Java node crashs? In-Reply-To: References: Message-ID: <19497.61064.200862.927855@pilspetsen.it.uu.se> zabrane Mikael writes: > Hi guys, > > Please, could someone help me understand this memory heap alloc failure of > the Erlang VM ;-) > > Regards > Zabrane > > > > On Jun 29, 2:09 am, zabrane Mikael wrote: > >> > Trying to restart the same failing test, I got (maybe) a useful info: > >> > > >> > beam.smp(89316,0xb14d1000) malloc: > >> > *** mmap(size=730857472) failed (error code=12) > >> > *** error: can't allocate region > >> > *** set a breakpoint in malloc_error_break to debug > >> > > >> > Crash dump was written to: erl_crash.dump > >> > eheap_alloc: Cannot allocate 583848200 bytes of memory (of type "heap"). > >> > > >> > Abort trap > >> > > >> > 2010/6/29 zabrane Mikael > >> > > >> > > Now, my Java node is restared after each crash ! > >> > > But for one of my message data, I got this strange Erlang error: > >> > > >> > > beam.smp(89316,0xb14d1000) malloc: > >> > > *** mmap(size=730857472) failed (error code=12) > >> > > *** error: can't allocate region > >> > > *** set a breakpoint in malloc_error_break to debug > >> > > >> > > Could someone tell me what happens to the Erlang VM? It's all there: the Erlang VM asked the OS for more memory, but the OS refused. Presumably you don't have enough RAM or swap in the machine. The 730M allocation is a tad big, but not unreasonable, so it's not necessarily a bug in the Erlang VM. If you need more help than this, post a self-contained test case. ps. please don't top-post From torben.lehoff@REDACTED Tue Jun 29 15:05:27 2010 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Tue, 29 Jun 2010 15:05:27 +0200 Subject: Broken links in the Erlang/OTP documentation for et Message-ID: Hi, If you have not started using the et (event tracer) tool yet please have a look at it. It is great. When I go to http://erlang.org/documentation/doc-5.7.5/lib/et-1.4/doc/html/users_guide.html and click on the tutorial followed by a click on either of the sections I get Forbidden You don't have permission to access /documentation/doc-5.7.5/lib/et-1.4/doc/html/.html on this server. Not that I mind rejection, but this is kind of annoying ;-) I can resort to my downloaded documentation, but the online one should be working too I think. Cheers, Torben -- http://www.linkedin.com/in/torbenhoffmann From ted.karmel@REDACTED Tue Jun 29 15:32:50 2010 From: ted.karmel@REDACTED (Ted Karmel) Date: Tue, 29 Jun 2010 15:32:50 +0200 Subject: Installing Module and Adding Path : Ibrowse Message-ID: Sorry for the noob question. I am trying to install the ibrowse erlang module ( http://wiki.github.com/cmullaparthi/ibrowse/ibrowse-api ). I created a directory separate from the erlang lib one ( i.e. usr/local/lib/erlang/lib ). I downloaded ibrowse to this folder and compiled ( make ) it successfully. I added this directory to the code path with the built in code module ( http://www.erlang.org/doc/man/code.html ). When I try using the ibrowse module from the erl command, it works when I am in the ibrowse directory and the ebin folder. However, whenever I am in another folder, I cannot call the ibrowse module. It is simply not recognized. Help. From dmercer@REDACTED Tue Jun 29 15:36:54 2010 From: dmercer@REDACTED (David Mercer) Date: Tue, 29 Jun 2010 08:36:54 -0500 Subject: [erlang-questions] try/catch In-Reply-To: References: <4C290F5D.9060100@allanwegan.de> Message-ID: <44A94C06ADB04828A2942E89ACAD9CD1@SSI.CORP> On Monday, June 28, 2010, Wes James wrote: > I also > need to remember that an expression is more than just a single line of > code but can be several lines separated by a "," in erlang. I was previously unaware of that, myself. I knew it could be done with the "begin" and "end" keywords, but not without. What, then, are the begin/end keywords for? Like Garrett, I usually use try...of to ensure I am catching errors only where I expect them. I don't like to catch errors. In fact, I usually use "try" for the "after" clause rather than the "catch"... Cheers, DBM From chandrashekhar.mullaparthi@REDACTED Tue Jun 29 17:12:12 2010 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Tue, 29 Jun 2010 16:12:12 +0100 Subject: [erlang-questions] Installing Module and Adding Path : Ibrowse In-Reply-To: References: Message-ID: On 29 June 2010 14:32, Ted Karmel wrote: > Sorry for the noob question. > > I am trying to install the ibrowse erlang module ( > http://wiki.github.com/cmullaparthi/ibrowse/ibrowse-api ). > > I created a directory separate from the erlang lib one ( i.e. > usr/local/lib/erlang/lib ). > > I downloaded ibrowse to this folder and compiled ( make ) it successfully. > > I added this directory to the code path with the built in code module > ( http://www.erlang.org/doc/man/code.html ). > > When I try using the ibrowse module from the erl command, it works > when I am in the ibrowse directory and the ebin folder. > > However, whenever I am in another folder, I cannot call the ibrowse > module. It is simply not recognized. > > Can you post a transcript of your shell commands? That might help diagnose the problem. cheers Chandru From paul.joseph.davis@REDACTED Tue Jun 29 17:21:50 2010 From: paul.joseph.davis@REDACTED (Paul Davis) Date: Tue, 29 Jun 2010 11:21:50 -0400 Subject: [erlang-questions] Turning on ASSERT's in OTP code. In-Reply-To: <4C2869CA.1050902@erix.ericsson.se> References: <4C2869CA.1050902@erix.ericsson.se> Message-ID: On Mon, Jun 28, 2010 at 5:22 AM, Sverker Eriksson wrote: > A "debug" build will enable ASSERT's. > > From INSTALL.md: > > "How to Build a Debug Enabled Erlang RunTime System > -------------------------------------------------- > > After completing all the normal building steps described above a debug > enabled runtime system can be built. To do this you have to change > directory to `$ERL_TOP/erts/emulator`. > > In this directory execute: > > ? $ make debug FLAVOR=$FLAVOR > > where `$FLAVOR` is either `plain` or `smp`. The flavor options will > produce a beam.debug and beam.smp.debug executable respectively. The > files are installed along side with the normal (opt) versions `beam.smp` > and `beam`. > > To start the debug enabled runtime system execute: > > ? $ $ERL_TOP/bin/cerl -debug > > The debug enabled runtime system features lock violation checking, > assert checking and various sanity checks to help a developer ensure > correctness. Some of these features can be enabled on a normal beam > using appropriate configure options. > > There are other types of runtime systems that can be built as well > using the similar steps just described. > > ? $ make $TYPE FLAVOR=$FLAVOR > > where `$TYPE` is `opt`, `gcov`, `gprof`, `debug`, `valgrind`, or `lcnt`. > These different beam types are useful for debugging and profiling > purposes." > > /Sverker, Erlang/OTP > > > > Paul Joseph Davis wrote: >> >> Yeah, this is affecting a specific point in some tests I'm migrating. I >> haven't been able to narrow down what it is about this specific message >> that's causing an error but other messages are sent fine. My hope is that by >> turning on the asserts I can narrow down where exactly I'm going off the >> reservation. >> Paul Davis >> >> On Jun 28, 2010, at 3:41 AM, Rapsey wrote: >> >> >>> >>> I'm using a NIF library that sends messages from a thread and have not >>> seen such crashes. The environment gets invalidated after a send. Are you >>> calling enif_clear_env or enif_free_env after enif_send? >>> >>> Sergej >>> >>> On Mon, Jun 28, 2010 at 8:12 AM, Paul Davis >>> wrote: >>> I've stumbled across a weird segfault when sending terms from a thread >>> spawned by a NIF. Investigating this i followed a traceback to >>> erts/emulator/beam/erl_alloc_util.c. Glancing at the code in >>> erl_alloc_util.c I notice that the line before the crash is an assert. >>> Checking the value in gdb shows that the assertion is violated. My >>> first thought was to try and enable these asserts but I'm not sure >>> where to look for docs on how to do such a thing. Looking through the >>> code I see them looking for DEBUG to be defined yet nothing in >>> ./configure's help suggests a flag to set. >>> >>> In the interest of trying things I tried CFLAGS="-DDEBUG" ./configure >>> && CFLAGS="-DDEBUG" make but it dies with an error about pcre. >>> >>> Anyone have a pointer on where to look for getting these enabled? >>> >>> Here's a copy of the traceback if it helps anyone. The lines in >>> erl_alloc_util.c starting at 598: >>> >>> ? ASSERT(crr->prev); >>> ? crr->prev->next = crr->next; >>> >>> gdb shows that crr is valid and crr->prev is NULL. >>> >>> #0 ?0x08085e82 in unlink_carrier (allctr=0xa2dc140, blk=>> out>) >>> ? at beam/erl_alloc_util.c:599 >>> #1 ?destroy_carrier (allctr=0xa2dc140, blk=) >>> ? at beam/erl_alloc_util.c:1615 >>> #2 ?0x08087161 in do_erts_alcu_free (type=148, unused=0x8250b60, >>> p=0xa2dd7f0) >>> ? at beam/erl_alloc_util.c:2648 >>> #3 ?erts_alcu_free_thr_pref (type=148, unused=0x8250b60, p=0xa2dd7f0) >>> ? at beam/erl_alloc_util.c:2699 >>> #4 ?0x081535da in erts_free (env=0xa2dd7f0) at beam/erl_alloc.h:210 >>> #5 ?enif_free_env (env=0xa2dd7f0) at beam/erl_nif.c:256 >>> #6 ?0x00e21218 in job_destroy (obj=0xa2dd7c0) at c_src/job.c:32 >>> #7 ?0x00e21cda in queue_done (queue=0xa2dd718, item=0xa2dd7c0) >>> ? at c_src/queue.c:184 >>> #8 ?0x00e23849 in worker_exec (vm=0xa2a7d10) at c_src/worker.c:124 >>> #9 ?0x00e2376d in worker_run (arg=0xa2dd628) at c_src/worker.c:85 >>> #10 0x081d2a2c in thr_wrapper (vtwd=0xb64e5020) at common/ethread.c:480 >>> #11 0x0068296e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0 >>> #12 0x00260a4e in clone () from /lib/tls/i686/cmov/libc.so.6 >>> >>> >>> Thanks, >>> Paul Davis >>> >>> ________________________________________________________________ >>> erlang-questions (at) erlang.org mailing list. >>> See http://www.erlang.org/faq.html >>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >>> >>> >>> >> >> >> > > Thanks for everyone's input. I managed to get the debug version built last night and tested with my code. Unfortunately I've managed to completely remove any trace of the bug. I've run it through valgrind as well as with duma to try and track down any memory issues to no avail. There was an issue with building the valgrind version of the emulator though. Linking failed with an error about a missing definition for something like "erts_fpu_interrupt". I can't remember the exact third part of the function name. If I figure that out tonight I'll send a report. Thanks, Paul Davis From kiszl@REDACTED Tue Jun 29 17:48:54 2010 From: kiszl@REDACTED (Zoltan Lajos Kis) Date: Tue, 29 Jun 2010 17:48:54 +0200 Subject: [erlang-questions] try/catch In-Reply-To: <44A94C06ADB04828A2942E89ACAD9CD1@SSI.CORP> References: <4C290F5D.9060100@allanwegan.de> <44A94C06ADB04828A2942E89ACAD9CD1@SSI.CORP> Message-ID: <4C2A15E6.7070704@tmit.bme.hu> An example for begin-end is having multiple expressions in list comprehension: [io:format("~p~n", [N]), N || N <- [1,2,3,4]]. % syntax error [begin io:format("~p~n", [N]), N end || N <- [1,2,3,4]]. % OK Zoltan. On 6/29/2010 3:36 PM, David Mercer wrote: > On Monday, June 28, 2010, Wes James wrote: > > >> I also >> need to remember that an expression is more than just a single line of >> code but can be several lines separated by a "," in erlang. >> > I was previously unaware of that, myself. I knew it could be done with the > "begin" and "end" keywords, but not without. What, then, are the begin/end > keywords for? > > Like Garrett, I usually use try...of to ensure I am catching errors only > where I expect them. I don't like to catch errors. In fact, I usually use > "try" for the "after" clause rather than the "catch"... > > Cheers, > > DBM > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From info@REDACTED Tue Jun 29 19:22:01 2010 From: info@REDACTED (info) Date: Tue, 29 Jun 2010 19:22:01 +0200 Subject: binary expression with fixed and variable fields Message-ID: <201006291922003122229@its3.ch> Hi all, I have a string composed of several fixed and variable fields. I would like to parse this string as binary expression. I checked the example with an IP datagram (the variable fields are to the end ...): <> If the size3 of the field3 is variable,how to parse the string ? <> but after ? If a field is empty, how to detect it ? If a char (e.g comma) is between each field, is it always possible to use the binary syntax ? Does exist a general approach in Erlang ? John From gonzalo@REDACTED Tue Jun 29 21:44:44 2010 From: gonzalo@REDACTED (Gonzalo) Date: Tue, 29 Jun 2010 21:44:44 +0200 Subject: two simple escript questions Message-ID: Hi all, I have two questions regarding the following simple erlang script: #!/opt/local/bin/escript main(_) -> {ok, Name} = io:read("What's your name?\n> "), io:format("Hello ~s!~n", [Name]). Execution: Denver:Erlang gonzalo$ ./hello What's your name? > gonzalo. Hello gonzalo! It works for a simple atom. 1. I would like to modify this script so I could type anything. Examples: gonzalo, jean paul, Gonzalo, Jean Paul, etc. 2. It seems that io:read() expects an expression ending with a dot (.) Is it possible to avoid this? Just pressing enter should work. Thanks for your tips. Gonzalo. From holger@REDACTED Tue Jun 29 23:07:05 2010 From: holger@REDACTED (Holger =?iso-8859-1?Q?Wei=DF?=) Date: Tue, 29 Jun 2010 23:07:05 +0200 Subject: Reliability of open_port's exit_status option Message-ID: <20100629210705.GA2673708@CIS.FU-Berlin.DE> The documentation on erlang:open_port/2 says: "If the port program closes its stdout without exiting, the exit_status option will not work." What exactly does that mean? Is the manual simply telling me that the status won't be reported before the port process actually exited (which seems a little too obvious) or is there anything else that could happen (such as the status not being reported even if the port process eventually exits)? Holger From comptekki@REDACTED Tue Jun 29 23:21:12 2010 From: comptekki@REDACTED (Wes James) Date: Tue, 29 Jun 2010 15:21:12 -0600 Subject: try catch scope Message-ID: What is the scope of try/catch. I changed the code: has_query(A) -> case length(yaws_api:parse_query(A)) of 0 -> false; _ -> true end. to this has_query(A) -> try case length(yaws_api:parse_query(A)) of 0 -> false; _ -> true end catch _ -> false end. because if a user puts in an invalid character in the URL it crashes parse_query and I want the app to continue without erroring out in the browser. Is this because of the level of the error? For instance if you have the url http://localhost/app?var1=foo1%var2=foo2 in parse_query it tries to do a list_to_integer of "va" with var2 based on how it parses the args list and you can't do that since "va" doesn't produce a valid integer. Would the try need to be at the level of the list_to_integer call? thx, -wes From prikrutil@REDACTED Tue Jun 29 23:46:07 2010 From: prikrutil@REDACTED (Sergey Samokhin) Date: Wed, 30 Jun 2010 01:46:07 +0400 Subject: [erlang-questions] try catch scope In-Reply-To: References: Message-ID: > has_query(A) -> > ? ? ? ?try > ? ? ? ? ? ? ? ?case length(yaws_api:parse_query(A)) of > ? ? ? ? ? ? ? ? ? ? ? ?0 ?-> false; > ? ? ? ? ? ? ? ? ? ? ? ?_ -> true > ? ? ? ? ? ? ? ?end > ? ? ? ?catch > ? ? ? ? ? ? ? ?_ -> false > ? ? ? ?end. For this function to catch exceptions of all possible types (error, exit and throw) you need to use "_:_" pattern instead of just "_" (which will catch only 'throw' exceptions): has_query(A) -> try case length(yaws_api:parse_query(A)) of 0 -> false; _ -> true end catch _:_ -> false % <----- Here "_" has been replaced by "_:_" end. -- Sergey Samokhin From jesper.louis.andersen@REDACTED Tue Jun 29 23:53:04 2010 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Tue, 29 Jun 2010 23:53:04 +0200 Subject: [erlang-questions] try catch scope In-Reply-To: References: Message-ID: On Tue, Jun 29, 2010 at 11:21 PM, Wes James wrote: > What is the scope of try/catch. > has_query(A) -> > ? ? ? ?try > ? ? ? ? ? ? ? ?case length(yaws_api:parse_query(A)) of [...] > because if a user puts in an invalid character in the URL it crashes > parse_query and I want the app to continue without erroring out in the > browser. > > Is this because of the level of the error? Yes (is my guess), see http://www.erlang.org/doc/reference_manual/expressions.html#id2276021 on the try..catch construction. Since you omit the class, it is defaulted to 'throw'. I would personally regard that as an error in the interface of parse_query. My solution would be something akin to safe_parse_query(A) -> try Q = yaws_api:parse_query(A), {ok, Q} catch error:_ -> no_parse % You should really narrow down the class and the error Reason to the right type here. I may be wrong. end. which transforms the function into a variant which is safer: has_query(A) -> case yaws_api:parse_query(A) of no_parse -> false; {ok, Q} when length(Q) == 0 -> false; {ok, Q} -> true end. alternatively, no_parse can be an empty list, if you so want. (Caveat: I only wrote the code and did not test it). -- J. From comptekki@REDACTED Wed Jun 30 00:17:02 2010 From: comptekki@REDACTED (Wes James) Date: Tue, 29 Jun 2010 16:17:02 -0600 Subject: [erlang-questions] try catch scope In-Reply-To: References: Message-ID: Thank you Sergey and Jesper for your responses. I went back and looked at: http://www.erlang.org/doc/reference_manual/expressions.html#id2275780 and http://www.erlang.org/doc/reference_manual/errors.html to see how _:_ works. There is no mention of this on these pages. Is _:_ the same as {_,_}? Is there a doc on what _:_ is? thx, again, -wes On Tue, Jun 29, 2010 at 3:46 PM, Sergey Samokhin wrote: >> has_query(A) -> >> ? ? ? ?try >> ? ? ? ? ? ? ? ?case length(yaws_api:parse_query(A)) of >> ? ? ? ? ? ? ? ? ? ? ? ?0 ?-> false; >> ? ? ? ? ? ? ? ? ? ? ? ?_ -> true >> ? ? ? ? ? ? ? ?end >> ? ? ? ?catch >> ? ? ? ? ? ? ? ?_ -> false >> ? ? ? ?end. > > For this function to catch exceptions of all possible types (error, > exit and throw) you need to use "_:_" pattern instead of just "_" > (which will catch only 'throw' exceptions): > > has_query(A) -> > ? ? ? try > ? ? ? ? ? ? ? case length(yaws_api:parse_query(A)) of > ? ? ? ? ? ? ? ? ? ? ? 0 ?-> false; > ? ? ? ? ? ? ? ? ? ? ? _ -> true > ? ? ? ? ? ? ? end > ? ? ? catch > ? ? ? ? ? ? ? _:_ -> false % <----- Here "_" has been replaced by "_:_" > ? ? ? end. > > -- > Sergey Samokhin > From rvirding@REDACTED Wed Jun 30 01:35:45 2010 From: rvirding@REDACTED (Robert Virding) Date: Wed, 30 Jun 2010 01:35:45 +0200 Subject: [erlang-questions] try catch scope In-Reply-To: References: Message-ID: No _:_ is *NOT* the same as {_,_}. It is a special pattern which can only be used in the catch part of a try. There you can give [Class1:]ExceptionPattern1 as a pattern to match which class of exception to match and also which exception. Writing _:_ here means that you match all classes and all exceptions, i.e. you catch everything. Calling throw an exception is not really correct in my opinion as it doesn't really signify an error but is a non-local return. At least that is how it was intended to be used. Try might actually be too powerful. Robert On 30 June 2010 00:17, Wes James wrote: > Thank you Sergey and Jesper for your responses. I went back and looked at: > > http://www.erlang.org/doc/reference_manual/expressions.html#id2275780 > and > http://www.erlang.org/doc/reference_manual/errors.html > > to see how _:_ works. ?There is no mention of this on these pages. ?Is > _:_ the same as {_,_}? ?Is there a doc on what _:_ is? > > thx, again, > > -wes > > On Tue, Jun 29, 2010 at 3:46 PM, Sergey Samokhin wrote: >>> has_query(A) -> >>> ? ? ? ?try >>> ? ? ? ? ? ? ? ?case length(yaws_api:parse_query(A)) of >>> ? ? ? ? ? ? ? ? ? ? ? ?0 ?-> false; >>> ? ? ? ? ? ? ? ? ? ? ? ?_ -> true >>> ? ? ? ? ? ? ? ?end >>> ? ? ? ?catch >>> ? ? ? ? ? ? ? ?_ -> false >>> ? ? ? ?end. >> >> For this function to catch exceptions of all possible types (error, >> exit and throw) you need to use "_:_" pattern instead of just "_" >> (which will catch only 'throw' exceptions): >> >> has_query(A) -> >> ? ? ? try >> ? ? ? ? ? ? ? case length(yaws_api:parse_query(A)) of >> ? ? ? ? ? ? ? ? ? ? ? 0 ?-> false; >> ? ? ? ? ? ? ? ? ? ? ? _ -> true >> ? ? ? ? ? ? ? end >> ? ? ? catch >> ? ? ? ? ? ? ? _:_ -> false % <----- Here "_" has been replaced by "_:_" >> ? ? ? end. >> >> -- >> Sergey Samokhin >> > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From bernie@REDACTED Wed Jun 30 01:36:21 2010 From: bernie@REDACTED (Bernard Duggan) Date: Wed, 30 Jun 2010 09:36:21 +1000 Subject: [erlang-questions] Difference between erlang:send_after and timer:send_after? In-Reply-To: References: Message-ID: <4C2A8375.20804@m5net.com> On 29/06/10 18:17, Fredrik Andersson wrote: > These two functions seems to be doing the exact same thing (sending a > message after a certain amount of time) but I was wondering why they > are both there. Should timer:send_after not be replacing > erlang:send_after or am I missing something here? Yep - you're missing the bit in the efficiency guide that explains the difference :) http://www.erlang.org/doc/efficiency_guide/commoncaveats.html#id2262042 If anything, the timer: version should be removed but no doubt that would break people's code :) B From sand.softnet1@REDACTED Wed Jun 30 05:47:36 2010 From: sand.softnet1@REDACTED (Sand T) Date: Wed, 30 Jun 2010 09:17:36 +0530 Subject: [erlang-questions] Re: Compare XML string In-Reply-To: <4C29DBC5.8080903@nm.ru> References: <4C29DBC5.8080903@nm.ru> Message-ID: Yes, both are identical. I need to compare xml strings/documents ~Sand On Tue, Jun 29, 2010 at 5:10 PM, Dmitry Belyaev wrote: > First of all, what does author want to compare: plain strings or xml > documents? > > If documents (or parts of documents) then what about order of attributes and > child elements? Does it matter? > > > >> code=\"102\">Authentication Successful ... >>> Exp String: >>> >> code=\"102\">Authentication Successful ... >>> >>> Eq 2: >>> Given String >>> >> code=\"102\">Authentication Successful ... >>> >> status=\"offline\" custom=\"Is offline\" group=\"Friends\" >>> blocked=\"no\"/> >>> >>> Expected: >>> Authentication >>> Successful ... >>> >> status=\"online\" custom=\"Is offline\" group=\"Friends\" >>> blocked=\"no\"/> >>> >>> Regards, >>> Sandeep >>> >>> ________________________________________________________________ >>> erlang-questions (at) erlang.org mailing list. >>> Seehttp://www.erlang.org/faq.html >>> To unsubscribe; mailto:erlang-questions-unsubscr...@REDACTED >>> >> >> ________________________________________________________________ >> erlang-questions (at) erlang.org mailing list. >> See http://www.erlang.org/faq.html >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED >> >> >> > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From erlangy@REDACTED Wed Jun 30 05:55:39 2010 From: erlangy@REDACTED (Michael McDaniel) Date: Tue, 29 Jun 2010 20:55:39 -0700 Subject: [erlang-questions] Re: Compare XML string In-Reply-To: References: <4C29DBC5.8080903@nm.ru> Message-ID: <20100630035539.GF30357@delora.autosys.us> On Wed, Jun 30, 2010 at 09:17:36AM +0530, Sand T wrote: > Yes, both are identical. I need to compare xml strings/documents > > ~Sand > > On Tue, Jun 29, 2010 at 5:10 PM, Dmitry Belyaev wrote: > > First of all, what does author want to compare: plain strings or xml > > documents? > > > > If documents (or parts of documents) then what about order of attributes and > > child elements? Does it matter? > > > > > > >>> code=\"102\">Authentication Successful ... > >>> Exp String: > >>> >>> code=\"102\">Authentication Successful ... > >>> > >>> Eq 2: > >>> Given String > >>> >>> code=\"102\">Authentication Successful ... > >>> >>> status=\"offline\" custom=\"Is offline\" group=\"Friends\" > >>> blocked=\"no\"/> > >>> > >>> Expected: > >>> Authentication > >>> Successful ... > >>> >>> status=\"online\" custom=\"Is offline\" group=\"Friends\" > >>> blocked=\"no\"/> > >>> > >>> Regards, > >>> Sandeep > >>> ________________________________________________________________ truly *identical* ? as in "a" = "a" is identical and "a" = "a " is not identical ? if so, try XML_one = XML_two of XML_one -> true catch _:_ -> false end ~Michael From sand.softnet1@REDACTED Wed Jun 30 06:11:33 2010 From: sand.softnet1@REDACTED (Sand T) Date: Wed, 30 Jun 2010 09:41:33 +0530 Subject: [erlang-questions] Re: Compare XML string In-Reply-To: <20100630035539.GF30357@delora.autosys.us> References: <4C29DBC5.8080903@nm.ru> <20100630035539.GF30357@delora.autosys.us> Message-ID: Hi, Thanks a lot for the team suggestion, I use erlsom with XSD and it works well. The tree generated for following XML are identical and and >> > > >>> code=\"102\">Authentication Successful ... >> >>> Exp String: >> >>> > >>> code=\"102\">Authentication Successful ... >> >>> >> >>> Eq 2: >> >>> Given String >> >>> > >>> code=\"102\">Authentication Successful ... >> >>> > >>> status=\"offline\" custom=\"Is offline\" group=\"Friends\" >> >>> blocked=\"no\"/> >> >>> >> >>> Expected: >> >>> Authentication >> >>> Successful ... >> >>> > >>> status=\"online\" custom=\"Is offline\" group=\"Friends\" >> >>> blocked=\"no\"/> >> >>> >> >>> Regards, >> >>> Sandeep >> >>> > ________________________________________________________________ > > > ?truly *identical* ? > ?as in "a" = "a" is identical and "a" = "a " is not identical ? > > > ?if so, > > > ? try XML_one = XML_two of > ? ? ?XML_one ? ? ? -> true > ? ? ?catch _:_ ? ? -> false > ? end > > > ~Michael > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From attila.r.nohl@REDACTED Wed Jun 30 08:39:39 2010 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Wed, 30 Jun 2010 08:39:39 +0200 Subject: [erlang-questions] Difference between erlang:send_after and timer:send_after? In-Reply-To: <4C2A8375.20804@m5net.com> References: <4C2A8375.20804@m5net.com> Message-ID: 2010/6/30, Bernard Duggan : > On 29/06/10 18:17, Fredrik Andersson wrote: >> These two functions seems to be doing the exact same thing (sending a >> message after a certain amount of time) but I was wondering why they >> are both there. Should timer:send_after not be replacing >> erlang:send_after or am I missing something here? > Yep - you're missing the bit in the efficiency guide that explains the > difference :) > http://www.erlang.org/doc/efficiency_guide/commoncaveats.html#id2262042 > > If anything, the timer: version should be removed but no doubt that > would break people's code :) The usual procedure is to give a "deprecated" warning for a release and two, then remove it... On the other hand code used to compile under R13B doesn't compile under R14A, so breakage already happens. From sedrik@REDACTED Wed Jun 30 08:45:51 2010 From: sedrik@REDACTED (Fredrik Andersson) Date: Wed, 30 Jun 2010 08:45:51 +0200 Subject: [erlang-questions] Difference between erlang:send_after and timer:send_after? In-Reply-To: References: <4C2A8375.20804@m5net.com> Message-ID: On Wed, Jun 30, 2010 at 8:39 AM, Attila Rajmund Nohl wrote: > 2010/6/30, Bernard Duggan : >> On 29/06/10 18:17, Fredrik Andersson wrote: >>> These two functions seems to be doing the exact same thing (sending a >>> message after a certain amount of time) but I was wondering why they >>> are both there. Should timer:send_after not be replacing >>> erlang:send_after or am I missing something here? >> Yep - you're missing the bit in the efficiency guide that explains the >> difference :) >> http://www.erlang.org/doc/efficiency_guide/commoncaveats.html#id2262042 >> >> If anything, the timer: version should be removed but no doubt that >> would break people's code :) > > The usual procedure is to give a "deprecated" warning for a release > and two, then remove it... On the other hand code used to compile > under R13B doesn't compile under R14A, so breakage already happens. Yeah but why has this not happend yet? I have talked some with Ulf Wiger now and understand why they both exist but not why timer:send_after has not been deprecated yet. Currently I see no reason to use timer:send_after. What are your opinions on this matter? Currently it seems to cause more confusion than useage. > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From krab@REDACTED Wed Jun 30 10:02:35 2010 From: krab@REDACTED (Kresten Krab Thorup) Date: Wed, 30 Jun 2010 10:02:35 +0200 Subject: Stack space used by "body-recursive calls". Message-ID: One of my challenges in Erjang is that list comprehensions end up chewing stack space. And today I got a glimpse of hope reading this: According to http://www.erlang.org/doc/efficiency_guide/myths.html In R12B and later releases, there is an optimization that will in many cases reduces the number of words used on the stack in body-recursive calls, so that a body-recursive list function and tail-recursive function that calls lists:reverse/1<../man/lists.html#reverse-1> at the end will use exactly the same amount of memory. lists:map/2, lists:filter/2, list comprehensions, and many other recursive functions now use the same amount of space as their tail-recursive equivalents. Can someone tell me, what exactly is the optimization that was done in R12B? It must be something in the runtime system that recognizes these conditions and does something smart; I'd love to be able to be equally smart. Kresten Krab Thorup, Trifork From magnus@REDACTED Wed Jun 30 13:53:30 2010 From: magnus@REDACTED (Magnus Henoch) Date: Wed, 30 Jun 2010 12:53:30 +0100 Subject: try catch scope In-Reply-To: (Wes James's message of "Tue, 29 Jun 2010 15:21:12 -0600") References: Message-ID: <848w5wybwl.fsf@linux-b2a3.site> Wes James writes: > has_query(A) -> > case length(yaws_api:parse_query(A)) of > 0 -> false; > _ -> true > end. A separate note about the code: you should avoid "case length(Foo)" when possible, since length/1 needs to traverse the entire list. Just comparing the result to the empty list is probably faster: case yaws_api:parse_query(A) of [] -> false; _ -> true end. And this can be simplified further: yaws_api:parse_query(A) /= []. (There is a difference between my two examples and yours: your code will crash with badarg if the result is not a proper list, while mine will just return false.) -- Magnus Henoch, magnus@REDACTED Erlang Solutions http://www.erlang-solutions.com/ From comptekki@REDACTED Wed Jun 30 15:33:39 2010 From: comptekki@REDACTED (Wes James) Date: Wed, 30 Jun 2010 07:33:39 -0600 Subject: [erlang-questions] Re: try catch scope In-Reply-To: <848w5wybwl.fsf@linux-b2a3.site> References: <848w5wybwl.fsf@linux-b2a3.site> Message-ID: Mangus, Thanks! This is much better! has_query(A) -> try yaws_api:parse_query(A) /= [] catch _:_ -> false end. -wes On Wed, Jun 30, 2010 at 5:53 AM, Magnus Henoch wrote: > Wes James writes: > >> has_query(A) -> >> ? ? ? ? ? ? ? case length(yaws_api:parse_query(A)) of >> ? ? ? ? ? ? ? ? ? ? ? 0 ?-> false; >> ? ? ? ? ? ? ? ? ? ? ? _ -> true >> ? ? ? ? ? ? ? end. > > A separate note about the code: you should avoid "case length(Foo)" when > possible, since length/1 needs to traverse the entire list. ?Just > comparing the result to the empty list is probably faster: > > case yaws_api:parse_query(A) of > ? ?[] -> false; > ? ?_ -> true > end. > > And this can be simplified further: > > yaws_api:parse_query(A) /= []. > > (There is a difference between my two examples and yours: your code will > crash with badarg if the result is not a proper list, while mine will > just return false.) > > -- > Magnus Henoch, magnus@REDACTED > Erlang Solutions > http://www.erlang-solutions.com/ > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > From raimo+erlang-questions@REDACTED Wed Jun 30 16:17:31 2010 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 30 Jun 2010 16:17:31 +0200 Subject: [erlang-questions] Re: try catch scope In-Reply-To: References: <848w5wybwl.fsf@linux-b2a3.site> Message-ID: <20100630141731.GA12774@erix.ericsson.se> On Wed, Jun 30, 2010 at 07:33:39AM -0600, Wes James wrote: > Mangus, > > Thanks! This is much better! > > has_query(A) -> > try > yaws_api:parse_query(A) /= [] > catch > _:_ -> false > end. > > -wes This might be even clearer (separating the right and wrong cases): has_query(A) -> try yaws_api:parse_query(A) of [] -> false; _ -> true % Were you supposed to return true for this case? catch error:_ -> false % Only cathes runtime errors, not exit/1. end. > > On Wed, Jun 30, 2010 at 5:53 AM, Magnus Henoch > wrote: > > Wes James writes: > > > >> has_query(A) -> > >> ? ? ? ? ? ? ? case length(yaws_api:parse_query(A)) of > >> ? ? ? ? ? ? ? ? ? ? ? 0 ?-> false; > >> ? ? ? ? ? ? ? ? ? ? ? _ -> true > >> ? ? ? ? ? ? ? end. > > > > A separate note about the code: you should avoid "case length(Foo)" when > > possible, since length/1 needs to traverse the entire list. ?Just > > comparing the result to the empty list is probably faster: > > > > case yaws_api:parse_query(A) of > > ? ?[] -> false; > > ? ?_ -> true > > end. > > > > And this can be simplified further: > > > > yaws_api:parse_query(A) /= []. > > > > (There is a difference between my two examples and yours: your code will > > crash with badarg if the result is not a proper list, while mine will > > just return false.) > > > > -- > > Magnus Henoch, magnus@REDACTED > > Erlang Solutions > > http://www.erlang-solutions.com/ > > > > ________________________________________________________________ > > erlang-questions (at) erlang.org mailing list. > > See http://www.erlang.org/faq.html > > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > > > > > > ________________________________________________________________ > erlang-questions (at) erlang.org mailing list. > See http://www.erlang.org/faq.html > To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED > -- / Raimo Niskanen, Erlang/OTP, Ericsson AB