From jeffm@REDACTED Wed Apr 1 08:57:30 2009 From: jeffm@REDACTED (jm) Date: Wed, 01 Apr 2009 17:57:30 +1100 Subject: [erlang-questions] Managing the order of rows in mnesia Message-ID: <49D3105A.6050306@ghostgun.com> What is a good way to track the order of rows in a mnesia database? What I have is a set of records which need to be processed in a set order as these define a set of rules to be obeyed. It's an ACL. Further, rules may be inserted or delete. I've thought of having an order field which is an integer, but this causes problems with guessing a good integer value. This lead to the idea of have parent and child pointers which would be easier to mantain. Is there a better that I've missed? Also, along the same lines is there an efficient search algorithm which doesn't involve visting every row until a match is found or the end of the table is reached? To make it a little more concrete this is roughly what I'm thinking, -define(entry, { id, %% unique identifier parent, %% id of parent row child, %% id of child row a, %% first field to be matched against b, %% second field to be matched against action %% action to be returned }). Example table ('*' denotes wildcard, using integers where ref() values would be used in id, parent, and child columns) id parent child a b action 15 top 1 denise '*' deny 1 15 2 alice car allow 2 1 5 alice motorbike deny 5 2 11 bob car deny 11 5 6 '*' car allow 6 11 bottom '*' motorbike allow example searches and results {alice, car} -> allow {carol, car} -> allow {alice, motorbike} -> deny {carol, motorbike} -> allow {carol, yacht} -> undefined {denise, car} -> deny Thoughts? Jeff. From raimo+erlang-questions@REDACTED Wed Apr 1 11:24:19 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 1 Apr 2009 11:24:19 +0200 Subject: [erlang-questions] IPv6 In-Reply-To: <200903271622.n2RGMPQm071931@pluto.hedeland.org> References: <200903271622.n2RGMPQm071931@pluto.hedeland.org> Message-ID: <20090401092419.GA11196@erix.ericsson.se> On Fri, Mar 27, 2009 at 05:22:25PM +0100, Per Hedeland wrote: > Hi, > > Is there some good reason for gen_tcp/gen_udp not auto-recognizing an Not really. But as you see for gen_tcp:connect below, the inet6 option is currently required there even for an IPv6 address tuple. These are corners we have not smoothed yet. It can be argued that the tuple size alone is not sufficient to determine the address class. After all a 4-tuple can be interpreted as a IPv4-compatible IPv6 address if you really want. And the DUH! error 'nxdomain' that is returned for all "other" errors should also be improved. I will see what I can do. > 8-tuple as an IPv6 address? gen_tcp:listen/2 and gen_udp:open/2 don't > even fail if you give them one w/o explicit 'inet6' option, but (OS > stack permitting) interprets "the first 4 bytes" as an IPv4 address - > shocking behaviour for an Erlang module! Oops! We will fix this. > > Erlang R13A (erts-5.7) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false] > Eshell V5.7 (abort with ^G) > 1> gen_tcp:listen(1234, [{ip,{1,43981,4660,0,0,0,0,5}}]). > {ok,#Port<0.439>} > 2> gen_udp:open(1234, [{ip,{1,43981,4660,0,0,0,0,5}}]). > {ok,#Port<0.449>} > > $ netstat -an | grep 1234 > tcp 0 0 0.1.171.205:1234 0.0.0.0:* LISTEN > udp 0 0 0.1.171.205:1234 0.0.0.0:* > > 'inet' may be a reasonable default (though it isn't actually documented > as such as far as I can see), but blindly "applying" it in the face of > obvious evidence to the contrary can't be right. gen_tcp:connect/3 and > gen_udp:send/4 also have "interesting" behaviour: > > 4> gen_tcp:connect({1,43981,4660,0,0,0,0,5}, 1234, []). > {error,nxdomain} > 5> gen_udp:send(S, {1,43981,4660,0,0,0,0,5}, 1234, <<"hello">>). > {error,nxdomain} Perhaps these should be 'badarg' exceptions since the 'inet6' option is missing... > > Yeah, I can imagine that the name server had trouble finding that > "domain"... (no, it didn't actually try a DNS lookup). > > --Per Hedeland > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From jlprasantha@REDACTED Wed Apr 1 11:39:15 2009 From: jlprasantha@REDACTED (prasantha kumara) Date: Wed, 1 Apr 2009 15:09:15 +0530 Subject: [erlang-questions] send a http response Message-ID: hi all! i am dealing with http request and response using erlang.i could send a http request from the java and i get it in erlang.now i have to send a response to that request using erlang to the java servlet. can anybody let me know any hint or any document to solve this matter.iesending a response to the servlet using erlang regards -------------- next part -------------- An HTML attachment was scrubbed... URL: From sreenivasan.sreeramu@REDACTED Wed Apr 1 12:30:23 2009 From: sreenivasan.sreeramu@REDACTED (Sreenivasan K) Date: Wed, 1 Apr 2009 10:30:23 +0000 Subject: [erlang-questions] Problem with xmerl - xml parsing Message-ID: Hi, \n problem in xml file . This is my xml file (test.xml) This is my erlang file test_parse.erl -module(test_parse). -compile(export_all). start()-> Data=xmerl_scan:file("test.xml",[{encoding,"utf-8"}]), io:format("~p~n",[Data]). this is the output i got when i run the program >test_parse:start(). Out put is the xmlElement recort and for the string in xml file it is parsing as "one two three" but this i had not expected i experted \n in between one ,two and three. . And one more point i cant put \n inside the string if i put \n in between the strings it parser and displays as "\\n" i need only one \n is there is any way to put \n inside the string . From tmadankumar@REDACTED Wed Apr 1 13:01:31 2009 From: tmadankumar@REDACTED (madan kumar) Date: Wed, 1 Apr 2009 16:31:31 +0530 Subject: [erlang-questions] gen-event Message-ID: what is the need of gen-event , allready we have gen server,gen-fsm send some examples using gen-event. -- Tallapalem Madan Kumar, Pyro Networks Pvt. Ltd., Hyderabad. -------------- next part -------------- An HTML attachment was scrubbed... URL: From fmilicchio@REDACTED Wed Apr 1 10:00:24 2009 From: fmilicchio@REDACTED (Franco Milicchio) Date: Wed, 01 Apr 2009 10:00:24 +0200 Subject: [erlang-questions] State of the Union: FFI Message-ID: <2812B7B9-6B8C-4CDE-A966-96624AF61625@me.com> Dear all, Is there someone that knowns the inner working of FFI standardization? I am trying to use it, but it's really not a piece of cake when I must remain with older versions of Erlang/OTP. By the way, is there someone I can talk with regarding FFI? (in production, of course!) Thanks! PS. I know this is a recurring topic, but I didn't find any post newer than six month, so... this is just a reminder :) -- Franco Milicchio DIA - Dept. of Computer Science and Engineering University Roma Tre http://plm.dia.uniroma3.it/milicchio/ -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available URL: From steven.charles.davis@REDACTED Wed Apr 1 13:19:03 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 1 Apr 2009 04:19:03 -0700 (PDT) Subject: [erlang-questions] send a http response In-Reply-To: References: Message-ID: <3e76d5cd-72ec-44a1-8a5d-2c58117e7db0@o6g2000yql.googlegroups.com> Hi prasantha, We'd probably need to know what web server you are using. e.g. is it inets, yaws, mochiweb or some home-cooked socket server? Each would have a different API to create the HTTP response you desire... /s On Apr 1, 4:39?am, prasantha kumara wrote: > hi all! > i am dealing with http request and response using erlang.i could send a http > request from the java and i get it in erlang.now i have to send a response > to that request using erlang to the java servlet. > > can anybody let me know any hint or any document to solve this > matter.iesending a response to the servlet using erlang > > regards > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From steven.charles.davis@REDACTED Wed Apr 1 13:20:20 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 1 Apr 2009 04:20:20 -0700 (PDT) Subject: [erlang-questions] gen-event In-Reply-To: References: Message-ID: <1b0a2430-a35c-4f3f-8dc5-e674bdc83162@j39g2000yqn.googlegroups.com> The classic example would be a "logger" application. On Apr 1, 6:01?am, madan kumar wrote: > what is the need of ?gen-event , allready we have gen server,gen-fsm send > some examples ?using gen-event. > -- > Tallapalem Madan Kumar, > Pyro Networks Pvt. Ltd., > Hyderabad. > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From bbmaj7@REDACTED Wed Apr 1 13:39:07 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Wed, 1 Apr 2009 04:39:07 -0700 (PDT) Subject: [erlang-questions] send a http response In-Reply-To: References: Message-ID: <137570.77540.qm@web65514.mail.ac4.yahoo.com> > i am dealing with http request and response using erlang.i could > send a http request from the java and i get it in erlang.now i > have to send a response to that request using erlang to the java > servlet. Maybe have a look at the erlang httpd module. Consider using one of the erlang webserver implementations eg. YAWS. Enjoy a better web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. From bbmaj7@REDACTED Wed Apr 1 13:43:12 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Wed, 1 Apr 2009 04:43:12 -0700 (PDT) Subject: [erlang-questions] Problem with xmerl - xml parsing In-Reply-To: References: Message-ID: <964513.19873.qm@web65511.mail.ac4.yahoo.com> ----- Original Message ---- > \n problem in xml file . ... > this is the output i got when i run the program > > >test_parse:start(). > Out put is the xmlElement recort and for the string in xml file it is > parsing as "one two three" but this i had not expected i > experted \n in between one ,two and three. . And one more point i cant > put \n inside the string if i put \n in between the strings it parser > and displays as "\\n" i need only one \n is there is any way to put \n > inside the string . Erlang is not python. Have a look at iolib if you want to construct complex strings. Enjoy a safer web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. From tuscland@REDACTED Wed Apr 1 14:12:53 2009 From: tuscland@REDACTED (Camille Troillard) Date: Wed, 1 Apr 2009 14:12:53 +0200 Subject: [erlang-questions] IPC bus for Erlang? Message-ID: Hi, I would like to build a desktop application in which user interface and core process (Erlang) would be separated. I also need it to be as much portable as possible. The idea would be to base the user interface on WebKit so it can be easily customized, and a lot of people know how to build web interfaces already. The different solutions I have found so far: - use Mochiweb/Erlycomet on the Erlang side, and dojo/cometd (aka "Ajax server side push"). - Pros: very generic, based on JSON, runs in any browser - Cons: not efficient at all, can't build a real desktop application. - D-Bus : - Pros: Cross-platform, supported by Qt and there is also javascript bindings (named JSCoreBus ). - Cons: the Erlang implementationseems a bit old / not maintained. - Leverage Erlang built-in communications system and make the WebKit a C erlang port itself. - Pros: Almost no work no the Erlang node side. - Cons: no WebKit plugin for setting up an Erlang port in Javascript exists yet. Not as generic as the two other options. I have ruled out the first idea (Erlycomet), because of the poor performance I got for the initial tests ; this is really something for the web, not the desktop. D-Bus seems alright, but is perhaps overkill, and lacks support? So, I am seriously considering the third option, for its simplicity. Do you have other suggestions for a IPC bus that would make the link between Erlang and Webkit? I would also be happy to learn about your experiences on creating desktop applications with Erlang. Best, Camille -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Wed Apr 1 14:27:32 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 1 Apr 2009 05:27:32 -0700 (PDT) Subject: [erlang-questions] Problem with xmerl - xml parsing In-Reply-To: References: Message-ID: HI Sreenivasan, Perhaps the biggest issue here is that, in XML, space preservation is only defined for the element values/content, not for attributes. It may help to review the XML specs particularly the definition of attribute values, and then you'll understand that erlang's xmerl is, in fact, working correctly. regs, Steve On Apr 1, 5:30?am, Sreenivasan K wrote: > Hi, > \n problem in xml file . > > This is my xml file (test.xml) > > > > > > This is my erlang file test_parse.erl > > -module(test_parse). > -compile(export_all). > > start()-> > ? ? Data=xmerl_scan:file("test.xml",[{encoding,"utf-8"}]), > ? ? io:format("~p~n",[Data]). > > this is the output i got when i run the program > > >test_parse:start(). > > Out put is the xmlElement recort and for the string in xml file it is > parsing as "one ? ?two ? ? three" but this i had not expected i > experted \n in between one ,two and three. . And one more point i cant > put \n inside the string if i put \n in between the strings it parser > and displays as "\\n" i need only one \n is there is any way to put \n > inside the string . > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From bbmaj7@REDACTED Wed Apr 1 13:28:43 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Wed, 1 Apr 2009 04:28:43 -0700 (PDT) Subject: [erlang-questions] tokenize function In-Reply-To: <200903311137038798567@bluewin.ch> References: <200903311137038798567@bluewin.ch> Message-ID: <801068.58967.qm@web65513.mail.ac4.yahoo.com> > Hi, > I read in one erlang program the following statement: > Tokens=tokenize(Rest) > Does tokenize an erlang function or a user function ? > I didn't find documentation on it. I suppose that this function extracts > segments from a bit stream. Maybe a wrapper around string:tokens/2. See the string module. It is unlikely to be an erlang built-in or part of an OTP module as it does not define token separators and is therefore not general enough to be widely useful. Enjoy a safer web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. From sreenivasan.sreeramu@REDACTED Wed Apr 1 14:37:35 2009 From: sreenivasan.sreeramu@REDACTED (Sreenivasan K) Date: Wed, 1 Apr 2009 12:37:35 +0000 Subject: [erlang-questions] Problem with xmerl - xml parsing In-Reply-To: <964513.19873.qm@web65511.mail.ac4.yahoo.com> References: <964513.19873.qm@web65511.mail.ac4.yahoo.com> Message-ID: On 4/1/09, Richard Andrews wrote: > > > > > > ----- Original Message ---- >> \n problem in xml file . > ... >> this is the output i got when i run the program >> >> >test_parse:start(). >> Out put is the xmlElement recort and for the string in xml file it is >> parsing as "one two three" but this i had not expected i >> experted \n in between one ,two and three. . And one more point i cant >> put \n inside the string if i put \n in between the strings it parser >> and displays as "\\n" i need only one \n is there is any way to put \n >> inside the string . > > Erlang is not python. > Have a look at iolib if you want to construct complex strings. > > > Enjoy a safer web experience. Upgrade to the new Internet Explorer 8 > optimised for Yahoo!7. Get it now. > thanks for your quick replay with same xml file i tryed with >file:read_file("test.xml"). By using this function i am getting \r\n in between one,two and three . . . Same output is not coming when i use xmerl no \r\n is coming in between one,two and three . . . ??? From mihai@REDACTED Wed Apr 1 15:15:41 2009 From: mihai@REDACTED (Mihai Balea) Date: Wed, 1 Apr 2009 09:15:41 -0400 Subject: [erlang-questions] gen-event In-Reply-To: <1b0a2430-a35c-4f3f-8dc5-e674bdc83162@j39g2000yqn.googlegroups.com> References: <1b0a2430-a35c-4f3f-8dc5-e674bdc83162@j39g2000yqn.googlegroups.com> Message-ID: <716A1565-EA9B-427F-B453-80F50720A322@hates.ms> On Apr 1, 2009, at 7:20 AM, Steve Davis wrote: > The classic example would be a "logger" application. > > On Apr 1, 6:01 am, madan kumar wrote: >> what is the need of gen-event , allready we have gen server,gen- >> fsm send >> some examples using gen-event. >> -- The standard error_logger that comes with OTP is, in fact, based on gen_event. Generally speaking, you would use gen_event when you have an "event source" and a variable number of "monitors/handlers/listeners". There is some overlap in the gen_even/fsm/server family of behaviours. You could transform one into another by just ignoring parts of existing functionality and writing up the missing bits. Mihai From bqt@REDACTED Wed Apr 1 15:34:27 2009 From: bqt@REDACTED (Johnny Billquist) Date: Wed, 01 Apr 2009 15:34:27 +0200 Subject: [erlang-questions] Why is it necessary to "double-escape" [ characters in regular expressions? In-Reply-To: <837618.69848.qm@web65504.mail.ac4.yahoo.com> References: <837618.69848.qm@web65504.mail.ac4.yahoo.com> Message-ID: <49D36D63.8090708@softjar.se> I'm not sure I would call it "escaping", since [] in a regular expression actually have a meaning. They express a range of valid chars. However, the characters inside [] are interpreted/parsed in another way than outside of them, which cause a [ inside to be accepted literally. ] is a little ugly in that it must be the first character in the range specified inside a [], otherwise it won't work. (So you could say [abc[] to match any of a,b,c or [, but you couldn't say [abc]], you would have to write it as []abc]). Using \ to excape brackets seems to vary between different implementations of regexps that I look at. As for the orginial question, others have already pointed it out, but in order to get a \ in the actual string you create, you need to put a double \ in the literal. And that's escaping. :-) Johnny Richard Andrews wrote: > IIRC the way to escape [ in regular expressions is [[] not \[. > Similarly []] not \]. > > Never tried with erlang re application though. > > ------------------------------------------------------------------------ > *From:* David Mitchell > *To:* erlang-questions Questions > *Sent:* Monday, 30 March, 2009 2:19:28 PM > *Subject:* [erlang-questions] Why is it necessary to "double-escape" [ > characters in regular expressions? > > Hello group, > > Running 5.6.5 under Windows... > > I've got a bunch of code that's "almost but not quite syntactically > correct" XML, and I'm trying to convert it to valid XML. Part of this > process involves removing some invalid CDATA tags. > > My code fragment: > re:replace("abc123", " is giving me "exception error: bad argument in function re:replace/4. > > Trial and error shows that removing the escaped [ characters: > re:replace("abc123 works as expected, but it's obviously not what I want. > > However, "double-escaping" the [ characters (by adding a second \ prior > to the [ character) does exactly what I want: > re:replace("abc123 [{return, list}]) > returns "abc123 < abc123", which is the result I'm after. > > In this context, I guess it's conceivable that the [ character can be > misinterpreted in two distinct ways in a regular expression: > - it could denote the start of an Erlang list > - it could denote the start of a character grouping within a regular > expression > However, I didn't expect that "double escaping" it would be the solution > to my problem. > > Is this expected behaviour, or some sort of anomaly? In any case, > sending this email to the mailing list should help out the next person > who falls into this trap, but who can use Google to track down the > solution... > > Regards > > David Mitchell > > ------------------------------------------------------------------------ > Enjoy a better web experience. Upgrade to the new Internet Explorer 8 > optimised for Yahoo!7. Get it now. > . > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Johnny Billquist || "I'm on a bus || on a psychedelic trip email: bqt@REDACTED || Reading murder books pdp is alive! || tryin' to stay hip" - B. Idol From bengt.kleberg@REDACTED Wed Apr 1 16:12:12 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 01 Apr 2009 16:12:12 +0200 Subject: [erlang-questions] Where can I use gen_server? In-Reply-To: References: Message-ID: <1238595132.19996.11.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, If you start a gen_server with start_link() it will take its clients with it. If you start with start() the clients will remain. bengt On Mon, 2009-03-30 at 19:29 -0700, ryeguy wrote: > I'm making a game server, and I just can't see where I would want to > use a gen_server. I'm not set on using one, but I don't want to skimp > on using one where it would make it easier to program this app. > > What I have per node is this: I have 1 process accepting new > connections, which spawns a new process for each new client. For each > packet that comes in, a new process is spawned to handle it and then > it sends the result back to the listening process and terminates. > > It sounds like a good candidate for gen_server, but per the docs it > seems you want to use them when there is some shared resource that you > want to manage, and I don't see one. If I gave each client their own > gen_server, it wouldn't be good because if an erroneous packet was > sent that caused an exception, it would terminate their connection and > any other packets being processed for this client (since a gen_server > takes all of its spawned processes down with it, right?). > > Is there any advantage to using gen_server in my situation? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From icfp.publicity@REDACTED Wed Apr 1 17:33:13 2009 From: icfp.publicity@REDACTED (Matthew Fluet (ICFP Publicity Chair)) Date: Wed, 1 Apr 2009 10:33:13 -0500 Subject: [erlang-questions] DEFUN09: Call for Talks & Tutorials (co-located w/ ICFP09) Message-ID: <53ff55480904010833n30e33362xaf17aedba49fa2db@mail.gmail.com> Call for Talks and Tutorials ACM SIGPLAN 2009 Developer Tracks on Functional Programming http://www.defun2009.info/ Edinburgh, Scotland, September 3 and 5, 2009 The workshop will be held in conjunction with ICFP 2009 http://www.cs.nott.ac.uk/~gmh/icfp09.html Important dates Proposal Deadline: June 5, 2009, 0:00 UTC Notification: June 19, 2009 DEFUN 2009 invites functional programmers and researchers who know how to solve problems with functional progamming to give talks and lead tutorials at the The ICFP Developer Tracks. We want to know about your favorite programming techniques, powerful libraries, and engineering approaches you've used that the world should know about and apply to other projects. We want to know how to be productive using functional programming, write better code, and avoid common pitfalls. We invite proposals for presentations in the following categories. Lightning talks 5- to 10-minute talks that introduce exciting and promising research or techniques that may be in progress or not yet ready for widespread use, but that offer a glimpse into the near future of real world functional programming. Examples: * Clustered high performance computing in a functional language * Making advanced type systems more accessible to working programmers * How and why we're infiltrating category theory info industry How-to talks 45-minute "how-to" talks that provide specific information on how to solve specific problems using functional programming. These talks focus on concrete examples, but provide useful information for developers working on different projects or in different contexts. Examples: * "How I use Haskell for oilfield simulations." * "How I replaced /sbin/init by a Scheme program." * "How I hooked up my home appliances to an Erlang control system." * "How I got an SML program to drive my BMW." General language tutorials Half-day general language tutorials for specific functional languages, given by recognized experts for the respective languages. Technology tutorials Half-day tutorials on techniques, technologies, or solving specific problems in functional programming. Examples: * How to make the best use of specific FP programming techniques * How to inject FP into a development team used to more conventional technologies * How to connect FP to existing libraries / frameworks / platforms * How to deliver high-performance systems with FP * How to deliver high-reliability systems with FP Remember that your audience will include computing professionals who are not academics and who may not already be experts on functional programming. Presenters of tutorials will receive free registration to CUFP 2009. Submission guidelines Submit a proposal of 150 words or less for either a 45-minute talk with a short Q&A session at the end, or a 300-word-or-less proposal for a 3-hour tutorial, where you present your material, but also give participants a chance to practice it on their own laptops. Some advice: * Give it a simple and straightforward title or name; avoid fancy titles or puns that would make it harder for attendees to figure out what you'll be talking about. * Clearly identify the level of the talk: What knowledge should people have when they come to the presentation or tutorial? * Explain why people will want to attend: o Is the language or library useful for a wide range of attendees? o Is the pitfall you're identifying common enough that a wide range of attendees is likely to encounter it? * Explain what benefits attendees are expected to take home to their own projects. * For a tutorial, explain how you want to structure the time, and what you expect to have attendees to do on their laptops. List what software you'll expect attendees to have installed prior to coming. Submit your proposal in plain text electronically to defun-2009-submissions@REDACTED by the beginning of Friday, June 5 2009, Universal Coordinated Time. Organizers * Yaron Minsky (Jane Street Capital) * Ulf Wiger (Erlang Training and Consulting) * Mike Sperber - co-chair (DeinProgramm) * Bryan O'Sullivan - co-chair (Linden Lab) From exta7@REDACTED Wed Apr 1 18:56:02 2009 From: exta7@REDACTED (Zvi) Date: Wed, 1 Apr 2009 09:56:02 -0700 (PDT) Subject: [erlang-questions] State of the Union: FFI In-Reply-To: <2812B7B9-6B8C-4CDE-A966-96624AF61625@me.com> References: <2812B7B9-6B8C-4CDE-A966-96624AF61625@me.com> Message-ID: <22831017.post@talk.nabble.com> I propose to not wait for standardization, and port it ourselves to R13A. It's a crucial feature for my application. Even if later I will need to port all my code to linked-in driver, ffi allows me to work right now and rapid prototyping just can't be achieved with linked-in drivers. There are several people interested. I even may pay some symbolic sum to speed things up. BR, Zvi Franco Milicchio-4 wrote: > > Dear all, > > Is there someone that knowns the inner working of FFI standardization? > I am trying to use it, but it's really not a piece of cake when I must > remain with older versions of Erlang/OTP. > > By the way, is there someone I can talk with regarding FFI? (in > production, of course!) > > Thanks! > > > PS. I know this is a recurring topic, but I didn't find any post newer > than six month, so... this is just a reminder :) > > -- > Franco Milicchio > > DIA - Dept. of Computer Science and Engineering > University Roma Tre > http://plm.dia.uniroma3.it/milicchio/ > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://www.nabble.com/State-of-the-Union%3A-FFI-tp22824174p22831017.html Sent from the Erlang Questions mailing list archive at Nabble.com. From bengt.kleberg@REDACTED Wed Apr 1 13:16:39 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 01 Apr 2009 13:16:39 +0200 Subject: [erlang-questions] gen-event In-Reply-To: References: Message-ID: <1238584599.19996.6.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, Have you read http://www.erlang.org/doc/man/gen_event.html ? bengt On Wed, 2009-04-01 at 16:31 +0530, madan kumar wrote: > > what is the need of gen-event , allready we have gen server,gen-fsm > send some examples using gen-event. > -- > Tallapalem Madan Kumar, > Pyro Networks Pvt. Ltd., > Hyderabad. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From raould@REDACTED Wed Apr 1 19:49:34 2009 From: raould@REDACTED (Raoul Duke) Date: Wed, 1 Apr 2009 10:49:34 -0700 Subject: [erlang-questions] McErlang first public release In-Reply-To: <49D21C84.6080701@fi.upm.es> References: <49D21C84.6080701@fi.upm.es> Message-ID: <91a2ba3e0904011049g7768f18ata96eed090a843f29@mail.gmail.com> > Please take a look at https://babel.ls.fi.upm.es/trac/McErlang/ try the > tool and send us your questions, comments, bug reports, etc. www.cs.chalmers.se/~hanssv/doc/icfp07-McErlang.pdf very cool! i think concurrency/distribution clearly needs model checking to develop 'correct' systems (as opposed to ones that 'just' handle failure dynamically). hope to get some free time (ha ha!) to try this all out. sincerely. From rec@REDACTED Wed Apr 1 19:54:31 2009 From: rec@REDACTED (Roger Critchlow) Date: Wed, 1 Apr 2009 11:54:31 -0600 Subject: [erlang-questions] problem running escript upon linux startup In-Reply-To: <4537c3580903311250l1a8ccd79i99f0e87eac01755a@mail.gmail.com> References: <4537c3580903311250l1a8ccd79i99f0e87eac01755a@mail.gmail.com> Message-ID: <66d1c98f0904011054n1b4bbe38h652a99f60bf7fff@mail.gmail.com> I believe that the %%! -env setting in the script takes place too late to satisfy the erlang runtime. If the script is being launched from another script, inside /etc/rc.local, then try this: HOME=/root path-to-escript or this: env HOME=/root path-to-escript which do the same thing, launch the command with the HOME environment set to /root -- rec -- On Tue, Mar 31, 2009 at 1:50 PM, Kris Prieb wrote: > Hello list, > > The following escript fails when run upon linux (ubuntu) startup: > > #!/usr/bin/escript > %% -*- erlang -*- > %%! -env HOME /root > main(_) -> file:write_file("/root/simple_start_output", "bunch of text"). > > The program should create a file called "simple_start_output," under > the root directory, but no such file appears when I log into the > system. > A look at /var/logsyslog/ reveals a "erlexec: HOME must be set" > message resulting from the execution of the script. ?The strange thing > is that the script works fine when I run it after logging in. > > I've tried variations of the script such as: > > 1. using "/root" instead of /root when setting the HOME environment > variable in the 3rd line of the script > 2. excluding the 3rd line of the script entirely > 3. using "/usr/bin/env escript" instead of calling "/usr/bin/escript" > > All scripts result in the same error, ?"erlexec: HOME must be set," > when run at startup. ?However, they all work when run after logging > in. ?Does anyone have an idea of how to get an escript to run at > startup?? ?Any thoughts would be greatly appreciated. ?Thanks! > > Kris Prieb > > (I should also mention that I am actually running the script at the > launch of an Amazon EC2 virtual server, not on a machine that is > physically in front of me. ?Not sure if that matters one way or > another.) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From bookwyrm@REDACTED Wed Apr 1 20:00:45 2009 From: bookwyrm@REDACTED (Kim) Date: Wed, 1 Apr 2009 11:00:45 -0700 Subject: [erlang-questions] Developing in Erlang for customer support Message-ID: <20090401180044.GA39471@solluna.org> Good day -- I am starting to learn Erlang in order to stretch my marketability in the current job market, and to see if it could be applicable at work (if I can convince people of that.) I was wondering if there were any guidelines on writing Erlang programs with respect to providing customer support in the field. Ideally, what I am looking for is an integrated testing/logging framework such that log files could be parsed by the test framework to drive code simulations. (i.e. customer reports bug, sends log, log is run through the framework to generate test simulation of bug, rather than having to spend time reading a log and manually writing tests.) Probably more an integrated testing/telemetry framework than a testing/logging one. I can find much talk about unit testing, regression testing, etc., and occasionally some on program logging, monitoring, statistics, and so forth, but I'm just wondering if anyone has tried to tie them all together. State machine-based frameworks coupled with functional programming strike me as a potentially good candidate for developing such a framework for, so it would seem that Erlang would be a good choice, but I'm still mulling the design issues in my head. (i.e. just like mandating unit tests, requiring the logging be able to be fed back into the unit tests.) Hopefully I am making sense here. If this sort of integrated framework already exists in some form, then I would appreciate a pointer towards it. This would help me explain the benefits of looking at using Erlang at work. (Basically, I want to not spend so much time reading log files. Er, I mean, improve customer support by being able to (have someone else) automatically analyze and simulate their situations in the field. One of the major customer support issues I seem to be running into is that the customers prefer to run with minimal logging -- bug happens, no information is captured, ask customer to turn on logging, repeat, etc. -- I'd rather the customer run with minimal telemtry, get the telemetry, turn that into a test simulation, and run the simulation with maximum debugging.) Thank you, Kim -- Kim bookwyrm@REDACTED http://solluna.org/ "Nothing in the world is more dangerous than a sincere ignorance and conscientious stupidity" - Martin Luther King, Jr. From watson.timothy@REDACTED Thu Apr 2 00:41:46 2009 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 1 Apr 2009 23:41:46 +0100 Subject: [erlang-questions] erlang-questions Digest, Vol 23, Issue 3 In-Reply-To: References: Message-ID: > > I propose to not wait for standardization, and port it ourselves to > R13A. > It's a crucial feature for my application. Even if later I will need > to port > all my code to linked-in driver, ffi allows me to work right now and > rapid > prototyping just can't be achieved with linked-in drivers. +1 But it would be *really* nice if this got in to a 'standard' release - sooner the better. From kris_prieb@REDACTED Thu Apr 2 00:55:00 2009 From: kris_prieb@REDACTED (Kris Prieb) Date: Wed, 1 Apr 2009 17:55:00 -0500 Subject: [erlang-questions] problem running escript upon linux startup In-Reply-To: <66d1c98f0904011054n1b4bbe38h652a99f60bf7fff@mail.gmail.com> References: <4537c3580903311250l1a8ccd79i99f0e87eac01755a@mail.gmail.com> <66d1c98f0904011054n1b4bbe38h652a99f60bf7fff@mail.gmail.com> Message-ID: <4537c3580904011555kc44eb4djfb294af6129b0d23@mail.gmail.com> Thanks! I will try that. Kris Prieb On Wed, Apr 1, 2009 at 12:54 PM, Roger Critchlow wrote: > I believe that the %%! -env setting in the script takes place too late > to satisfy the erlang runtime. > > If the script is being launched from another script, inside > /etc/rc.local, then try this: > > HOME=/root path-to-escript > > or this: > > env HOME=/root path-to-escript > > which do the same thing, launch the command with the HOME environment > set to /root > > -- rec -- > > On Tue, Mar 31, 2009 at 1:50 PM, Kris Prieb wrote: >> Hello list, >> >> The following escript fails when run upon linux (ubuntu) startup: >> >> #!/usr/bin/escript >> %% -*- erlang -*- >> %%! -env HOME /root >> main(_) -> file:write_file("/root/simple_start_output", "bunch of text"). >> >> The program should create a file called "simple_start_output," under >> the root directory, but no such file appears when I log into the >> system. >> A look at /var/logsyslog/ reveals a "erlexec: HOME must be set" >> message resulting from the execution of the script. ?The strange thing >> is that the script works fine when I run it after logging in. >> >> I've tried variations of the script such as: >> >> 1. using "/root" instead of /root when setting the HOME environment >> variable in the 3rd line of the script >> 2. excluding the 3rd line of the script entirely >> 3. using "/usr/bin/env escript" instead of calling "/usr/bin/escript" >> >> All scripts result in the same error, ?"erlexec: HOME must be set," >> when run at startup. ?However, they all work when run after logging >> in. ?Does anyone have an idea of how to get an escript to run at >> startup?? ?Any thoughts would be greatly appreciated. ?Thanks! >> >> Kris Prieb >> >> (I should also mention that I am actually running the script at the >> launch of an Amazon EC2 virtual server, not on a machine that is >> physically in front of me. ?Not sure if that matters one way or >> another.) >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From carnildo@REDACTED Thu Apr 2 03:47:35 2009 From: carnildo@REDACTED (Mark Wagner) Date: Wed, 1 Apr 2009 18:47:35 -0700 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <31117710.95821238081411376.JavaMail.root@zimbra> References: <4ecde87b0903260804p6272c65ft2a62729789be790f@mail.gmail.com> <31117710.95821238081411376.JavaMail.root@zimbra> Message-ID: <31073ef90904011847s109287c7h668e7c3bc1099171@mail.gmail.com> On Thu, Mar 26, 2009 at 08:30, Adam Lindberg wrote: > ----- "Jon Gretar Borgthorsson" wrote: >> Or you can focus on ADA and program the Space Shuttle. >> >> Pick. > > I'd love to get bug reports from space. Trust me: you won't get any. The Space Shuttle's flight-control systems are some of the most bug-free code on the planet. -- Mark From carnildo@REDACTED Thu Apr 2 03:53:36 2009 From: carnildo@REDACTED (Mark Wagner) Date: Wed, 1 Apr 2009 18:53:36 -0700 Subject: [erlang-questions] how much time required to pass messages. In-Reply-To: References: <49CF5200.1080702@codimi.de> Message-ID: <31073ef90904011853w138ff164rdfd537d38fc291d7@mail.gmail.com> Because the timer resolution is too small. What does tokenring:tokenring(120000,1). produce? -- Mark 2009/3/30 Vikrant : > even if timer resolution is the reason why we don't see the change in time, > question remains same. why the change in time scales with M(number of > messages) and NOT with N (number of processes + number of messages)! > > 2009/3/29 Carsten Schultz >> >> Vikrant schrieb: >> > >> > 26> tokenring:tokenring(10000,1). >> > Time required to pass message 10000 times=3.00000 (4.40000) microsecond >> > .ok >> > 27> tokenring:tokenring(20000,1). >> > Time required to pass message 20000 times=3.00000 (4.65000) microsecond >> > .ok >> > 28> tokenring:tokenring(30000,1). >> > Time required to pass message 30000 times=3.33333 (4.63333) microsecond >> > .ok >> > >> > (time in bracket is system time and time outside bracket is user time in >> > microseconds.) >> > >> > This is surprising to me! I expected that time required to pass token >> > along N processes should be proportional to N! >> >> My guess here is that the resultion of the timer is 1/3. ?So your >> results are 9, 9, 10. ?Considering that these are rounded and that your >> function will have a constant term, these numbers are just to small to >> allow you to deduce much about your runtime function. ?Change the second >> parameter into, say, 1000000 in all cases and see what happens. >> >> -- >> Carsten Schultz (2:38, 33:47) >> http://carsten.codimi.de/ >> PGP/GPG key on the pgp.net key servers, >> fingerprint on my home page. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From josh@REDACTED Thu Apr 2 04:18:30 2009 From: josh@REDACTED (Josh Goldberg) Date: Wed, 1 Apr 2009 19:18:30 -0700 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <31073ef90904011847s109287c7h668e7c3bc1099171@mail.gmail.com> References: <4ecde87b0903260804p6272c65ft2a62729789be790f@mail.gmail.com> <31117710.95821238081411376.JavaMail.root@zimbra> <31073ef90904011847s109287c7h668e7c3bc1099171@mail.gmail.com> Message-ID: <4c7f9e8d0904011918g25ee982k2538df628ab0a27a@mail.gmail.com> pun intended? On Wed, Apr 1, 2009 at 6:47 PM, Mark Wagner wrote: > On Thu, Mar 26, 2009 at 08:30, Adam Lindberg > wrote: > > ----- "Jon Gretar Borgthorsson" wrote: > >> Or you can focus on ADA and program the Space Shuttle. > >> > >> Pick. > > > > I'd love to get bug reports from space. > > Trust me: you won't get any. The Space Shuttle's flight-control > systems are some of the most bug-free code on the planet. > > -- > Mark > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryeguy1@REDACTED Thu Apr 2 04:34:44 2009 From: ryeguy1@REDACTED (ryeguy) Date: Wed, 1 Apr 2009 19:34:44 -0700 (PDT) Subject: [erlang-questions] Where can I use gen_server? In-Reply-To: <1238595132.19996.11.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> References: <1238595132.19996.11.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Message-ID: Well why doesn't this work then? start() -> gen_server:start({global, ?MODULE}, ?MODULE, [], []). stop() -> gen_server:call({global, ?MODULE}, stop). test() -> gen_server:cast({global, ?MODULE}, test). test2() -> gen_server:cast({global, ?MODULE}, test2). init([]) ->process_flag(trap_exit, true), {ok, 0}. handle_cast(test, State) -> timer:sleep(3000), io:format("asdasd"), {noreply, State}; handle_cast(test2, State) -> timer:sleep(3000), 3=4, %%% deliberate error {noreply, State}. handle_call(stop, _From, State) -> {stop, normal, stopped, State}; handle_call(test2, _From, State) -> 3=4, {noreply, State}. handle_info(_Info, State) -> {noreply, State}. terminate(_Reason, _State) -> ok. code_change(_OldVsn, State, _Extra) -> {ok, State}. When I call test2() then call test(), test2 (obviously) crashes, but test() appears to be terminated too. On Apr 1, 10:12?am, Bengt Kleberg wrote: > Greetings, > > If you start a gen_server with start_link() it will take its clients > with it. If you start with start() the clients will remain. > > bengt > > > > On Mon, 2009-03-30 at 19:29 -0700, ryeguy wrote: > > I'm making a game server, and I just can't see where I would want to > > use a gen_server. I'm not set on using one, but I don't want to skimp > > on using one where it would make it easier to program this app. > > > What I have per node is this: I have 1 process accepting new > > connections, which spawns a new process for each new client. For each > > packet that comes in, a new process is spawned to handle it and then > > it sends the result back to the listening process and terminates. > > > It sounds like a good candidate for gen_server, but per the docs it > > seems you want to use them when there is some shared resource that you > > want to manage, and I don't see one. If I gave each client their own > > gen_server, it wouldn't be good because if an erroneous packet was > > sent that caused an exception, it would terminate their connection and > > any other packets being processed for this client (since a gen_server > > takes all of its spawned processes down with it, right?). > > > Is there any advantage to using gen_server in my situation? > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From bbmaj7@REDACTED Thu Apr 2 04:47:43 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Wed, 1 Apr 2009 19:47:43 -0700 (PDT) Subject: [erlang-questions] RPC from linkedin driver In-Reply-To: <722837.22586.qm@web31810.mail.mud.yahoo.com> References: <722837.22586.qm@web31810.mail.mud.yahoo.com> Message-ID: <764605.24484.qm@web65503.mail.ac4.yahoo.com> > I am currently working on developing a linkedin driver (c language) for XML > parser (xmerl is too slow). This is a SAX parser is given the following input: > > 1. XML to be parsed > 2. Call back functions (MFA) for start of node, end of node and for text > elements > > I found C APIs to do RPC calls from c-node (ei_rpc). This require ei_cnode and > fd parameters. That means I need to run the port as a c-node. > > Is it possible to do RPC from linkedin driver without converting linkedin driver > as a c-node? I *think* erl_driver describes what you want to know but I find your description/question somewhat confusing. Enjoy a better web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. From bbmaj7@REDACTED Thu Apr 2 04:25:14 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Wed, 1 Apr 2009 19:25:14 -0700 (PDT) Subject: [erlang-questions] IPC bus for Erlang? In-Reply-To: References: Message-ID: <387853.38888.qm@web65505.mail.ac4.yahoo.com> > The different solutions I have found so far: > * use Mochiweb/Erlycomet on the Erlang side, and dojo/cometd > (aka "Ajax server side push"). > * D-Bus: > * Leverage Erlang built-in communications system and make the > WebKit a C erlang port itself. > > as the two other options. > I have ruled out the first idea (Erlycomet), because of the poor > performance I got for the initial tests ; this is really something > for the web, not the desktop. D-Bus seems alright, but is perhaps > overkill, and lacks support? So, I am seriously considering the > third option, for its simplicity. I have recently been involved in a project where the UI was provided by YAWS utilising prototype.js for an Ajax based system. It works well on LAN or across slow links but was a lot of work. XmlHttpRequest can greatly reduce the amount of data required to dynamically render a page. Browser support with javascript becomes an issue. We had to choose to support just one browser to make this workable. You probably don't want the UI program to be a port as this implies that the erlang node is starting the UI program. If you were going to go in this direction then a standard SSL connection from UI to server is more appropriate IMO. You can still exchange erlang terms (eg. use erl_interface and erlang:term_to_binary) as the messages in the TCP stream if that is a good way to move the data. -- Rich Enjoy a better web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. From bbmaj7@REDACTED Thu Apr 2 04:39:01 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Wed, 1 Apr 2009 19:39:01 -0700 (PDT) Subject: [erlang-questions] Developing in Erlang for customer support In-Reply-To: <20090401180044.GA39471@solluna.org> References: <20090401180044.GA39471@solluna.org> Message-ID: <601579.47160.qm@web65507.mail.ac4.yahoo.com> > Ideally, what I am looking for is an integrated testing/logging > framework such that log files could be parsed by the test framework > to drive code simulations. (i.e. customer reports bug, sends log, > log is run through the framework to generate test simulation of bug, > rather than having to spend time reading a log and manually writing > tests.) Probably more an integrated testing/telemetry framework > than a testing/logging one. The message tracing facilities of erlang:trace() using the {trace,Process} option might be a good place to start looking. By using this, all messages specified for capture into or out of the specified processes will be copied out to the tracer process which might log them to disk. The new Internet Explorer 8 optimised for Yahoo!7: Faster, Safer, Easier. From vikrant.patil@REDACTED Thu Apr 2 06:19:11 2009 From: vikrant.patil@REDACTED (Vikrant) Date: Thu, 2 Apr 2009 09:49:11 +0530 Subject: [erlang-questions] how much time required to pass messages. In-Reply-To: References: <49CF5200.1080702@codimi.de> Message-ID: Thanks Per, for pointing out the typo! and you all right on time resolution side. After correcting the problem pointed above, it turns out that, time taken to pass message is indeed very small and it is less than timer resolution (on my machine it is coming out to be average of 0.6 microseconds per message). very impressive :) it does it very fast! Now next stuff I wonder, will the time required to pass message depends on what is being passed through message? guess is that it should. Because on process boundaries the data is copied.... copying will take time which will depend on the data itself. I will experiment on it further.... thanks all! (Vikrant) 2009/4/2 Per Gustafsson > It's because you are dividing the measured time by N. Otherwise sending > messages in Erlang would be very fast indeed (less than a clock cycle). > > Per > > 2009/3/31 Vikrant > >> even if timer resolution is the reason why we don't see the change in >> time, question remains same. why the change in time scales with M(number of >> messages) and NOT with N (number of processes + number of messages)! >> >> 2009/3/29 Carsten Schultz >> >>> Vikrant schrieb: >>> > >>> > 26> tokenring:tokenring(10000,1). >>> > Time required to pass message 10000 times=3.00000 (4.40000) microsecond >>> > .ok >>> > 27> tokenring:tokenring(20000,1). >>> > Time required to pass message 20000 times=3.00000 (4.65000) microsecond >>> > .ok >>> > 28> tokenring:tokenring(30000,1). >>> > Time required to pass message 30000 times=3.33333 (4.63333) microsecond >>> > .ok >>> > >>> > (time in bracket is system time and time outside bracket is user time >>> in >>> > microseconds.) >>> > >>> > This is surprising to me! I expected that time required to pass token >>> > along N processes should be proportional to N! >>> >>> My guess here is that the resultion of the timer is 1/3. So your >>> results are 9, 9, 10. Considering that these are rounded and that your >>> function will have a constant term, these numbers are just to small to >>> allow you to deduce much about your runtime function. Change the second >>> parameter into, say, 1000000 in all cases and see what happens. >>> >>> -- >>> Carsten Schultz (2:38, 33:47) >>> http://carsten.codimi.de/ >>> PGP/GPG key on the pgp.net key >>> servers, >>> fingerprint on my home page. >>> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Thu Apr 2 09:00:45 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 02 Apr 2009 09:00:45 +0200 Subject: [erlang-questions] Where can I use gen_server? In-Reply-To: References: <1238595132.19996.11.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Message-ID: <1238655645.19996.20.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, It is not obvious to me how you use the gen_server below. You are registering it as global, but I understood your explanation below as if you wanted a separate gen_server for each client. Is the idea to have one gen_server, or one per client? bengt On Wed, 2009-04-01 at 19:34 -0700, ryeguy wrote: > Well why doesn't this work then? > > start() -> gen_server:start({global, ?MODULE}, ?MODULE, > [], []). > stop() -> gen_server:call({global, ?MODULE}, stop). > test() -> gen_server:cast({global, ?MODULE}, test). > test2() -> gen_server:cast({global, ?MODULE}, test2). > > init([]) ->process_flag(trap_exit, true), > {ok, 0}. > > handle_cast(test, State) -> > timer:sleep(3000), > io:format("asdasd"), > {noreply, State}; > handle_cast(test2, State) -> > timer:sleep(3000), > 3=4, %%% deliberate error > {noreply, State}. > > handle_call(stop, _From, State) -> > {stop, normal, stopped, State}; > handle_call(test2, _From, State) -> > 3=4, > {noreply, State}. > > handle_info(_Info, State) -> > {noreply, State}. > > terminate(_Reason, _State) -> > ok. > > code_change(_OldVsn, State, _Extra) -> > {ok, State}. > > When I call test2() then call test(), test2 (obviously) crashes, but > test() appears to be terminated too. > > On Apr 1, 10:12 am, Bengt Kleberg wrote: > > Greetings, > > > > If you start a gen_server with start_link() it will take its clients > > with it. If you start with start() the clients will remain. > > > > bengt > > > > > > > > On Mon, 2009-03-30 at 19:29 -0700, ryeguy wrote: > > > I'm making a game server, and I just can't see where I would want to > > > use a gen_server. I'm not set on using one, but I don't want to skimp > > > on using one where it would make it easier to program this app. > > > > > What I have per node is this: I have 1 process accepting new > > > connections, which spawns a new process for each new client. For each > > > packet that comes in, a new process is spawned to handle it and then > > > it sends the result back to the listening process and terminates. > > > > > It sounds like a good candidate for gen_server, but per the docs it > > > seems you want to use them when there is some shared resource that you > > > want to manage, and I don't see one. If I gave each client their own > > > gen_server, it wouldn't be good because if an erroneous packet was > > > sent that caused an exception, it would terminate their connection and > > > any other packets being processed for this client (since a gen_server > > > takes all of its spawned processes down with it, right?). > > > > > Is there any advantage to using gen_server in my situation? > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questi...@REDACTED > > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From yogishb@REDACTED Thu Apr 2 10:14:43 2009 From: yogishb@REDACTED (Yogish Baliga) Date: Thu, 2 Apr 2009 01:14:43 -0700 (PDT) Subject: [erlang-questions] Error while installing new release Message-ID: <112284.56862.qm@web31811.mail.mud.yahoo.com> Hello all, I have done all the steps required to release an application. release_handler:unpack_release("2") worked fine. It create lib/erlang/releases/2 directory and files within it. 3 files are create in the directory. start.boot, relup and myapp-2.rel While installing the release (release_handler:install_release("2")), I am getting the error {error,{enoent,"/usr/local/lib/erlang/releases/R12B/relup"}} Any clue on how to solve this? Thanx, -- baliga "The quality of programmers is a decreasing function of the density of GOTO statements in the programs they produce." - Edsger W. Dijkstra http://dudefrommangalore.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Apr 2 10:30:08 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 02 Apr 2009 10:30:08 +0200 Subject: [erlang-questions] sorting rules regarding bit strings Message-ID: <49D47790.2050107@erlang-consulting.com> Maybe I'm just unusually dense today, but what are the sorting properties of bit strings? 5> lists:sort([<<1:1>>,<<1:2>>,<<1:3>>,<<1:4>>, <<1:5>>,<<1:6>>,<<1:7>>,<<1:8>>, <<2:2>>, <<2:3>>,<<2:4>>,<<1>>, <<16>>, <<128>>, <<255>>]). [<<1>>, <<1>>, <<1:7>>, <<1:6>>, <<1:5>>, <<1:4>>, <<16>>, <<1:3>>, <<2:4>>, <<1:2>>, <<2:3>>, <<1:1>>, <<2:2>>, <<128>>, <<"?">>] Well, I think I can see the pattern, but is this really what one wants? BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From per@REDACTED Thu Apr 2 10:55:50 2009 From: per@REDACTED (Per Hedeland) Date: Thu, 2 Apr 2009 10:55:50 +0200 (CEST) Subject: [erlang-questions] IPv6 In-Reply-To: <20090401092419.GA11196@erix.ericsson.se> Message-ID: <200904020855.n328toGE005421@pluto.hedeland.org> Raimo Niskanen wrote: > >On Fri, Mar 27, 2009 at 05:22:25PM +0100, Per Hedeland wrote: >> Hi, >> >> Is there some good reason for gen_tcp/gen_udp not auto-recognizing an > >Not really. But as you see for gen_tcp:connect below, the inet6 >option is currently required there even for an IPv6 address tuple. >These are corners we have not smoothed yet. Thanks, that's good enough for me - I was mainly contemplating whether I should (again) modify the OTP code or sprinkle 'size(Addr) == 8' guards over our own (and the "old" ssh, which doesn't seem to honour an 'inet6' option) - I'll go for the former then. >It can be argued that the tuple size alone is not >sufficient to determine the address class. After all >a 4-tuple can be interpreted as a IPv4-compatible >IPv6 address if you really want. Good point I guess - so, 4-tuple + 'inet' or no option would mean IPv4 (as today), 4-tuple + 'inet6' could mean v4-in-v6, and you could even have 8-tuple + 'inet' set up a tunnel if you want:-) - I'm really only interested in the 8-tuple + no option case, which I think is just plain broken today. For Your Inspiration:-), below is a modified version of the patches I sent earlier, which now fix only this case, and in addition don't override a user-set inet_db module (for "all" the people that use that feature:-) (actually I thought about using it to fix my problem, but since it would mean having to use a bunch of undocumented prim_inet functions, it's really the worst option). Thanks! --Per --------------- --- otp_src_R13A/lib/kernel/src/gen_tcp.erl.ORIG 2009-03-12 13:19:00.000000000 +0100 +++ otp_src_R13A/lib/kernel/src/gen_tcp.erl 2009-04-02 10:03:34.000000000 +0200 @@ -46,7 +46,7 @@ end. connect1(Address,Port,Opts,Timer) -> - Mod = mod(Opts), + Mod = mod(Opts, Address), case Mod:getaddrs(Address,Timer) of {ok,IPs} -> case Mod:getserv(Port) of @@ -73,7 +73,7 @@ %% Listen on a tcp port %% listen(Port, Opts) -> - Mod = mod(Opts), + Mod = mod(Opts, undefined), case Mod:getserv(Port) of {ok,TP} -> Mod:listen(TP, Opts); @@ -173,20 +173,28 @@ %% Create a port/socket from a file descriptor %% fdopen(Fd, Opts) -> - Mod = mod(Opts), + Mod = mod(Opts, undefined), Mod:fdopen(Fd, Opts). -%% Get the tcp_module -mod() -> inet_db:tcp_module(). +%% Get the tcp_module, but IPv6 address overrides default IPv4 +mod(Address) -> + case inet_db:tcp_module() of + inet_tcp when is_tuple(Address), size(Address) =:= 8 -> + inet6_tcp; + Mod -> + Mod + end. %% Get the tcp_module, but option tcp_module|inet|inet6 overrides -mod([{tcp_module,Mod}|_]) -> +mod([{tcp_module,Mod}|_], _Address) -> Mod; -mod([inet|_]) -> +mod([inet|_], _Address) -> inet_tcp; -mod([inet6|_]) -> +mod([inet6|_], _Address) -> inet6_tcp; -mod([_|Opts]) -> - mod(Opts); -mod([]) -> - mod(). +mod([{ip, Address}|Opts], undefined) -> + mod(Opts, Address); +mod([_|Opts], Address) -> + mod(Opts, Address); +mod([], Address) -> + mod(Address). --- otp_src_R13A/lib/kernel/src/gen_udp.erl.ORIG 2009-03-12 13:19:00.000000000 +0100 +++ otp_src_R13A/lib/kernel/src/gen_udp.erl 2009-04-02 10:03:37.000000000 +0200 @@ -29,7 +29,7 @@ open(Port, []). open(Port, Opts) -> - Mod = mod(Opts), + Mod = mod(Opts, undefined), {ok,UP} = Mod:getserv(Port), Mod:open(UP, Opts). @@ -97,21 +97,29 @@ %% Create a port/socket from a file descriptor %% fdopen(Fd, Opts) -> - Mod = mod(), + Mod = mod(Opts, undefined), Mod:fdopen(Fd, Opts). -%% Get the udp_module -mod() -> inet_db:udp_module(). +%% Get the udp_module, but IPv6 address overrides default IPv4 +mod(Address) -> + case inet_db:udp_module() of + inet_udp when is_tuple(Address), size(Address) =:= 8 -> + inet6_udp; + Mod -> + Mod + end. -%% Get the udp_module, but option udp_module|inet|inet6 overrides -mod([{udp_module,Mod}|_]) -> +%% Get the udp_module, but option tcp_module|inet|inet6 overrides +mod([{udp_module,Mod}|_], _Address) -> Mod; -mod([inet|_]) -> +mod([inet|_], _Address) -> inet_udp; -mod([inet6|_]) -> +mod([inet6|_], _Address) -> inet6_udp; -mod([_|Opts]) -> - mod(Opts); -mod([]) -> - mod(). +mod([{ip, Address}|Opts], undefined) -> + mod(Opts, Address); +mod([_|Opts], Address) -> + mod(Opts, Address); +mod([], Address) -> + mod(Address). From tuscland@REDACTED Thu Apr 2 12:00:14 2009 From: tuscland@REDACTED (Camille Troillard) Date: Thu, 2 Apr 2009 12:00:14 +0200 Subject: [erlang-questions] IPC bus for Erlang? In-Reply-To: <387853.38888.qm@web65505.mail.ac4.yahoo.com> References: <387853.38888.qm@web65505.mail.ac4.yahoo.com> Message-ID: Hello Richard, On Thu, Apr 2, 2009 at 4:25 AM, Richard Andrews wrote: > > I have recently been involved in a project where the UI was provided by > YAWS utilising prototype.js for an Ajax based system. It works well on LAN > or across slow links but was a lot of work. XmlHttpRequest can greatly > reduce the amount of data required to dynamically render a page. Browser > support with javascript becomes an issue. We had to choose to support just > one browser to make this workable. > Alright, I chose WebKit for the same reason. You probably don't want the UI program to be a port as this implies that the > erlang node is starting the UI program. > Good point. I was wondering, in the case the server node is registered, isn't the C port able to send data without being launched from the server? Maybe there's a security concern. If you were going to go in this direction then a standard SSL connection > from UI to server is more appropriate IMO. You can still exchange erlang > terms (eg. use erl_interface and erlang:term_to_binary) as the messages in > the TCP stream if that is a good way to move the data. > Ah, using the ei interface to encode/decode data without going into writing a C port, right? Thanks. Best, Cam -------------- next part -------------- An HTML attachment was scrubbed... URL: From pguyot@REDACTED Thu Apr 2 12:18:54 2009 From: pguyot@REDACTED (Paul Guyot) Date: Thu, 2 Apr 2009 12:18:54 +0200 Subject: [erlang-questions] Error while installing new release In-Reply-To: References: Message-ID: <0EEE7FF4-0A25-4408-970B-9F43E84780D6@kallisys.net> > Date: Thu, 2 Apr 2009 01:14:43 -0700 (PDT) > From: Yogish Baliga > Subject: [erlang-questions] Error while installing new release > To: Erlang Questions > Message-ID: <112284.56862.qm@REDACTED> > > Hello all, > > I have done all the steps required to release an application. > release_handler:unpack_release("2") worked fine. It create lib/ > erlang/releases/2 directory and files within it. 3 files are create > in the directory. > start.boot, relup and myapp-2.rel > > While installing the release (release_handler:install_release("2")), > I am getting the error > > {error,{enoent,"/usr/local/lib/erlang/releases/R12B/relup"}} > > Any clue on how to solve this? Each release must be defined as a successor of the previously installed release. However, this does not make much sense for the first release, which seems to be what release "2" is on your system. From what I understand, you need to directly unpack the tarball somewhere (without release_handler:unpack_release/1), which will be your new OTP_ROOT. You need to call release_handler:create_RELEASES/4 using the old OTP_ROOT in order to bootstrap your system and create the RELEASES file in the new OTP_ROOT. You will also need to create the scripts in OTP_ROOT/bin manually, by copying those from OTP_ROOT/ erts-*/bin/ and fixing paths. Here is our Makefile's target to do this (on a MacOS X system where OTP is installed in /opt/local/bin/erlang): > TARBALL=target/${RELEASE_NAME}.tar.gz > > # Target to create the otp root (non-upgrade case). > ${OTP_ROOT}: ${TARBALL} > # Create the directory. > mkdir ${OTP_ROOT} > # Untar the tarball. > cd ${OTP_ROOT} && tar xzf ../${TARBALL} && cd .. > # Create the scripts > mkdir ${OTP_ROOT}/bin > @for file in ${OTP_ROOT}/erts-*/bin/*.src src/main/scripts/*.src ; > do \ > basename=`basename $$file`; \ > destfile=`echo $$basename | sed -e "s,.src,,g"`; \ > sed -e "s,%FINAL_ROOTDIR%,${DEST_DIR},g" < $$file > ${OTP_ROOT}/ > bin/$$destfile; \ > chmod ugo+rx ${OTP_ROOT}/bin/$$destfile; \ > done > # Create the RELEASES file. > erl -eval 'release_handler:create_RELEASES("${DEST_DIR}", "$ > {OTP_ROOT}/releases/${RELEASE_NAME}.rel"), erlang:halt().' -noshell > # Copy start.boot to be able to use erl directly. > cp /opt/local/lib/erlang/bin/start.boot "${OTP_ROOT}/bin/" Each subsequent release is installed with the release_handler:unpack_release/1, release_handler:install_release/1, release_handler:make_permanent/1 dance. Paul From gamoto@REDACTED Thu Apr 2 12:03:38 2009 From: gamoto@REDACTED (Gamoto) Date: Thu, 2 Apr 2009 12:03:38 +0200 Subject: [erlang-questions] variable unbound Message-ID: <200904021203383175654@bluewin.ch> What is wrong in this function ? I receive the following error: variable 'S' is unbound ! I also receive two warnings: File is unused, S is unused. This process can receive two messages: one file to open and one message to write Pid ! {open,"filetoopen.txt"} Pid ! {data, Message} log_message()-> receive {open,File} -> case file:open("File", [append]) of {ok,S} -> log_message(); {error,Reason} -> io:format( "~s~n",[Reason]) end; {data,Data} -> io:format(S,"~s~n",[Data]), log_message() end. From gamoto@REDACTED Thu Apr 2 12:10:32 2009 From: gamoto@REDACTED (Gamoto) Date: Thu, 2 Apr 2009 12:10:32 +0200 Subject: [erlang-questions] process: messages from various sources Message-ID: <200904021210317690795@bluewin.ch> Is this possible for one process to receive messages from two sources whose one of these is a socket ? Example my_process(Socket)-> receive {tcp,Socket,Bin}-> %equivalent to gen_tcp:recv(Socket,0) ???? ... %handle Bin my_process(Socket); %loop {msg,Message} -> %from another process ... %handle Message i.e gen_send(Socket,Message) my_process(Socket); %loop end. From harveyd@REDACTED Thu Apr 2 13:04:19 2009 From: harveyd@REDACTED (Dale Harvey) Date: Thu, 2 Apr 2009 12:04:19 +0100 Subject: [erlang-questions] process: messages from various sources In-Reply-To: <200904021210317690795@bluewin.ch> References: <200904021210317690795@bluewin.ch> Message-ID: Yes, you just need to make sure the socket is opened in active mode, or set it to active after inet:setopts(Socket, [{active, once}]), 2009/4/2 Gamoto > Is this possible for one process to receive messages from two sources whose > one of these is a socket ? > > Example > > my_process(Socket)-> > receive > {tcp,Socket,Bin}-> %equivalent to > gen_tcp:recv(Socket,0) ???? > ... %handle Bin > my_process(Socket); %loop > {msg,Message} -> %from another process > ... %handle Message > i.e gen_send(Socket,Message) > my_process(Socket); %loop > end. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar@REDACTED Thu Apr 2 13:17:46 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Thu, 02 Apr 2009 12:17:46 +0100 Subject: [erlang-questions] Ok, now then? Message-ID: <49D49EDA.9010803@erlang-consulting.com> SPF? -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From oscar@REDACTED Thu Apr 2 13:20:39 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Thu, 02 Apr 2009 12:20:39 +0100 Subject: [erlang-questions] Ok, now then? In-Reply-To: <49D49EDA.9010803@erlang-consulting.com> References: <49D49EDA.9010803@erlang-consulting.com> Message-ID: <49D49F87.5010307@erlang-consulting.com> Sorry about this noise, it wasn't supposed to go here.... Oscar Hellstr?m wrote: > SPF? > > Cheers -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From bengt.kleberg@REDACTED Thu Apr 2 13:20:36 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 02 Apr 2009 13:20:36 +0200 Subject: [erlang-questions] variable unbound In-Reply-To: <200904021203383175654@bluewin.ch> References: <200904021203383175654@bluewin.ch> Message-ID: <1238671236.19996.47.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, The compiler finds that you have not used the File variable. Instead you open the string constant "File". Neither do you use the S variable from the case statement (with file:open/2). The unbound S is the one in io:format/2. It does not have a value. bengt On Thu, 2009-04-02 at 12:03 +0200, Gamoto wrote: > What is wrong in this function ? I receive the following error: variable 'S' is unbound ! > I also receive two warnings: File is unused, S is unused. > This process can receive two messages: one file to open and one message to write > > Pid ! {open,"filetoopen.txt"} > > Pid ! {data, Message} > > log_message()-> > receive > {open,File} -> case file:open("File", [append]) of > {ok,S} -> log_message(); > {error,Reason} -> io:format( "~s~n",[Reason]) > end; > {data,Data} -> io:format(S,"~s~n",[Data]), > log_message() > end. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From rvirding@REDACTED Thu Apr 2 13:15:26 2009 From: rvirding@REDACTED (Robert Virding) Date: Thu, 2 Apr 2009 13:15:26 +0200 Subject: [erlang-questions] variable unbound In-Reply-To: <200904021203383175654@bluewin.ch> References: <200904021203383175654@bluewin.ch> Message-ID: <3dbc6d1c0904020415u209d7d5eie956c88e2f95e62@mail.gmail.com> 2009/4/2 Gamoto > What is wrong in this function ? I receive the following error: variable > 'S' is unbound ! > I also receive two warnings: File is unused, S is unused. > This process can receive two messages: one file to open and one message to > write > > Pid ! {open,"filetoopen.txt"} > > Pid ! {data, Message} > > log_message()-> > receive > {open,File} -> case file:open("File", [append]) of > {ok,S} -> > log_message(); > {error,Reason} -> io:format( > "~s~n",[Reason]) > end; > {data,Data} -> io:format(S,"~s~n",[Data]), > log_message() > end. - The variable File is defined in the message {file,File} you recieve but is never used, you open the file "File". - The variable S is defined when you receive the {open,File} message, but you wish to use it when you receive the {data,Data} message where it is not defined. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From harveyd@REDACTED Thu Apr 2 13:31:50 2009 From: harveyd@REDACTED (Dale Harvey) Date: Thu, 2 Apr 2009 12:31:50 +0100 Subject: [erlang-questions] variable unbound In-Reply-To: <3dbc6d1c0904020415u209d7d5eie956c88e2f95e62@mail.gmail.com> References: <200904021203383175654@bluewin.ch> <3dbc6d1c0904020415u209d7d5eie956c88e2f95e62@mail.gmail.com> Message-ID: log_message(File)-> receive {open,File} -> case file:open("File", [append]) of {ok,FileD} -> log_message(FileD); {error,Reason} -> io:format( "~s~n",[Reason]) end; {data,Data} -> case File of not_open -> exit(oops_file_not_open); Else -> io:format(File,"~s~n",[Data]), log_message(File) end end. is closer to what you are wanting, variable only have scope within a function call, this isnt a closure, to keep a variable in scope you pass it into the next call of the function. 2009/4/2 Robert Virding > 2009/4/2 Gamoto > >> What is wrong in this function ? I receive the following error: variable >> 'S' is unbound ! >> I also receive two warnings: File is unused, S is unused. >> This process can receive two messages: one file to open and one message to >> write >> >> Pid ! {open,"filetoopen.txt"} >> >> Pid ! {data, Message} >> >> log_message()-> >> receive >> {open,File} -> case file:open("File", [append]) of >> {ok,S} -> >> log_message(); >> {error,Reason} -> io:format( >> "~s~n",[Reason]) >> end; >> {data,Data} -> io:format(S,"~s~n",[Data]), >> log_message() >> end. > > > - The variable File is defined in the message {file,File} you recieve but > is never used, you open the file "File". > > - The variable S is defined when you receive the {open,File} message, but > you wish to use it when you receive the {data,Data} message where it is not > defined. > > Robert > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Thu Apr 2 13:51:40 2009 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 02 Apr 2009 13:51:40 +0200 Subject: [erlang-questions] Simon P.J.'s Impl. of Func. Lang. now as a free book Message-ID: <49D4A6CC.6050403@it.uu.se> http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ /Richard From rvirding@REDACTED Thu Apr 2 14:02:37 2009 From: rvirding@REDACTED (Robert Virding) Date: Thu, 2 Apr 2009 14:02:37 +0200 Subject: [erlang-questions] Simon P.J.'s Impl. of Func. Lang. now as a free book In-Reply-To: <49D4A6CC.6050403@it.uu.se> References: <49D4A6CC.6050403@it.uu.se> Message-ID: <3dbc6d1c0904020502r5c2f983jfbc7baec25d609a3@mail.gmail.com> Wow, fantastic! This is truly a book well worth reading. Robert 2009/4/2 Richard Carlsson > > http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ > > /Richard > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Thu Apr 2 14:06:25 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Thu, 2 Apr 2009 05:06:25 -0700 (PDT) Subject: [erlang-questions] IPC bus for Erlang? In-Reply-To: References: Message-ID: <542cb051-6391-437e-b5e9-10366d5c683f@z1g2000yqn.googlegroups.com> Hi Camille, I've been working on a library that does much of what you describe. It wraps for the cross-platform GUI library 'wx' that appeared in R13A release of Erlang/OTP. This interface runs the UI as a separate process (a gen_server), it allows you to specify the application GUI in XML which makes it very easy to design/modify/update. It allows you to pass in a callback module to use for the UI issued commands. So it's pretty close to your design target. The problem is that I only started development of this library less than a month ago, it's as yet unfinished, and as yet badly documented as it's a work in rapid progress. However you may wish to keep an eye on: http://github.com/komone/gx I'm hoping to have a documented and tagged stable release of this within a month (to coincide with the stable release of Erlang/OTP R13B from Ericsson). Regards, Steve On Apr 1, 7:12?am, Camille Troillard wrote: > Hi, > I would like to build a desktop application in which user interface and core > process (Erlang) would be separated. ?I also need it to be as much portable > as possible. ?The idea would be to base the user interface on WebKit so it > can be easily customized, and a lot of people know how to build web > interfaces already. > > The different solutions I have found so far: > > ? ?- use Mochiweb/Erlycomet on the > ? ?Erlang side, and dojo/cometd (aka "Ajax server > ? ?side push"). > ? ? ? - Pros: very generic, based on JSON, runs in any browser > ? ? ? - Cons: not efficient at all, can't build a real desktop > application. > ? ?- D-Bus > ? ?: > ? ? ? - Pros: Cross-platform, supported by Qt and there is also javascript > ? ? ? bindings > ? ? ? ?(named JSCoreBus > ? ? ? ). > ? ? ? - Cons: the Erlang > implementationseems a > bit old / not maintained. > ? ?- Leverage Erlang built-in communications system and make the WebKit a C > ? ?erlang port itself. > ? ? ? - Pros: Almost no work no the Erlang node side. > ? ? ? - Cons: no WebKit plugin for setting up an Erlang port in > ? ? ? Javascript exists yet. Not as generic as the two other options. > > I have ruled out the first idea (Erlycomet), because of the poor performance > I got for the initial tests ; this is really something for the web, not the > desktop. ?D-Bus seems alright, but is perhaps overkill, and lacks support? > ?So, I am seriously considering the third option, for its simplicity. > > Do you have other suggestions for a IPC bus that would make the link between > Erlang and Webkit? > I would also be happy to learn about your experiences on creating desktop > applications with Erlang. > > Best, > Camille > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From saleyn@REDACTED Thu Apr 2 14:07:15 2009 From: saleyn@REDACTED (Serge Aleynikov) Date: Thu, 02 Apr 2009 08:07:15 -0400 Subject: [erlang-questions] State of the Union: FFI In-Reply-To: <22831017.post@talk.nabble.com> References: <2812B7B9-6B8C-4CDE-A966-96624AF61625@me.com> <22831017.post@talk.nabble.com> Message-ID: <49D4AA73.8060300@gmail.com> That would be good. I also would like to express keen interest in pushing this EEP forward in the queue so that the OTP team would consider its inclusion in the distribution. This EEP has been sitting out there for a while and if there is a reason why it's not being processed, please let us know. Though driver-based C interop API is fast, it does incur around 20-30us overhead for a function call in the current implementation (though I last benchmarked it in R11B-5), whereas an FFI-based approach can be made more optimal (at the cost of potential loss of robustness, yet often that is an acceptable sacrifice for the sake of performance gain when bridging Erlang to other C/C++ libraries). Serge Zvi wrote: > I propose to not wait for standardization, and port it ourselves to R13A. > It's a crucial feature for my application. Even if later I will need to port > all my code to linked-in driver, ffi allows me to work right now and rapid > prototyping just can't be achieved with linked-in drivers. > There are several people interested. > I even may pay some symbolic sum to speed things up. > > BR, > Zvi > > > Franco Milicchio-4 wrote: >> Dear all, >> >> Is there someone that knowns the inner working of FFI standardization? >> I am trying to use it, but it's really not a piece of cake when I must >> remain with older versions of Erlang/OTP. >> >> By the way, is there someone I can talk with regarding FFI? (in >> production, of course!) >> >> Thanks! >> >> >> PS. I know this is a recurring topic, but I didn't find any post newer >> than six month, so... this is just a reminder :) >> >> -- >> Franco Milicchio >> >> DIA - Dept. of Computer Science and Engineering >> University Roma Tre >> http://plm.dia.uniroma3.it/milicchio/ >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From gamoto@REDACTED Thu Apr 2 14:57:34 2009 From: gamoto@REDACTED (Gamoto) Date: Thu, 2 Apr 2009 14:57:34 +0200 Subject: [erlang-questions] variable unbound References: <200904021203383175654@bluewin.ch>, <3dbc6d1c0904020415u209d7d5eie956c88e2f95e62@mail.gmail.com> Message-ID: <200904021457340519636@bluewin.ch> I don't understand. After the reception of the filename the variable S is defined ! I could understand a run-time error if I send a message before to send the filename !! 2009/4/2 Gamoto What is wrong in this function ? I receive the following error: variable 'S' is unbound ! I also receive two warnings: File is unused, S is unused. This process can receive two messages: one file to open and one message to write Pid ! {open,"filetoopen.txt"} Pid ! {data, Message} log_message()-> receive {open,File} -> case file:open("File", [append]) of {ok,S} -> log_message(); {error,Reason} -> io:format( "~s~n",[Reason]) end; {data,Data} -> io:format(S,"~s~n",[Data]), log_message() end. - The variable File is defined in the message {file,File} you recieve but is never used, you open the file "File". - The variable S is defined when you receive the {open,File} message, but you wish to use it when you receive the {data,Data} message where it is not defined. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Thu Apr 2 15:01:58 2009 From: dmercer@REDACTED (David Mercer) Date: Thu, 2 Apr 2009 08:01:58 -0500 Subject: [erlang-questions] sorting rules regarding bit strings In-Reply-To: <49D47790.2050107@erlang-consulting.com> References: <49D47790.2050107@erlang-consulting.com> Message-ID: <232998D1E5334E9DBF067888B1D97DCE@SSI.CORP> On April 02, 2009, Ulf Wiger wrote: > Maybe I'm just unusually dense today, but what are > the sorting properties of bit strings? . . . > Well, I think I can see the pattern, but is this really > what one wants? The sort order seems right to me. When I write out the bit patterns it might make it clear: > [<<1>>, 00000001 > <<1>>, 00000001 > <<1:7>>, 0000001 > <<1:6>>, 000001 > <<1:5>>, 00001 > <<1:4>>, 0001 > <<16>>, 00010000 > <<1:3>>, 001 > <<2:4>>, 0010 > <<1:2>>, 01 > <<2:3>>, 010 > <<1:1>>, 1 > <<2:2>>, 10 > <<128>>, 10000000 > <<"?">>] 11111111 Sorting is done bit-by-bit, with end-of-bitstring < 0 < 1. Or am I just weird, thinking that that is intuitive? David Mercer From thomasl_erlang@REDACTED Thu Apr 2 14:37:53 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 2 Apr 2009 05:37:53 -0700 (PDT) Subject: [erlang-questions] Simon P.J.'s Impl. of Func. Lang. now as a free book In-Reply-To: <49D4A6CC.6050403@it.uu.se> References: <49D4A6CC.6050403@it.uu.se> Message-ID: <16988.13374.qm@web111403.mail.gq1.yahoo.com> ----- Original Message ---- > From: Richard Carlsson > To: erlang-questions > Sent: Thursday, April 2, 2009 1:51:40 PM > Subject: [erlang-questions] Simon P.J.'s Impl. of Func. Lang. now as a free book > > http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ That's a great book, I read it forwards and backwards during a long trip abroad; it was, I guess, my gateway drug for programming language implementation. It predates Haskell and a lot of bells and whistles that came afterwards, but it gives you a good idea of how things are done, as well as how to think about these things. Here's another, slightly more modern one by the very same: http://research.microsoft.com/en-us/um/people/simonpj/papers/pj-lester-book/ Maybe someone should translate that one to Haskell as a 2nd edition. Best, Thomas From harveyd@REDACTED Thu Apr 2 15:08:07 2009 From: harveyd@REDACTED (Dale Harvey) Date: Thu, 2 Apr 2009 14:08:07 +0100 Subject: [erlang-questions] variable unbound In-Reply-To: <200904021457340519636@bluewin.ch> References: <200904021203383175654@bluewin.ch> <3dbc6d1c0904020415u209d7d5eie956c88e2f95e62@mail.gmail.com> <200904021457340519636@bluewin.ch> Message-ID: S is defined in the context of that function call, you then do log_message(), and in the new function call S does not exist, it needs to be passed in 2009/4/2 Gamoto > I don't understand. After the reception of the filename the variable S is > defined ! > I could understand a run-time error if I send a message before to send the > filename !! > > 2009/4/2 Gamoto > >> What is wrong in this function ? I receive the following error: variable >> 'S' is unbound ! >> I also receive two warnings: File is unused, S is unused. >> This process can receive two messages: one file to open and one message to >> write >> >> Pid ! {open,"filetoopen.txt"} >> >> Pid ! {data, Message} >> >> log_message()-> >> receive >> {open,File} -> case file:open("File", [append]) of >> {ok,S} -> >> log_message(); >> {error,Reason} -> io:format( >> "~s~n",[Reason]) >> end; >> {data,Data} -> io:format(S,"~s~n",[Data]), >> log_message() >> end. > > > - The variable File is defined in the message {file,File} you recieve but > is never used, you open the file "File". > > - The variable S is defined when you receive the {open,File} message, but > you wish to use it when you receive the {data,Data} message where it is not > defined. > > Robert > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew@REDACTED Thu Apr 2 15:15:18 2009 From: andrew@REDACTED (Andrew Thompson) Date: Thu, 2 Apr 2009 09:15:18 -0400 Subject: [erlang-questions] ANSI escape sequences in the erlang shell Message-ID: <20090402131517.GB16582@hijacked.us> Is there a reason the erlang shell is making my attempts to print ANSI escape sequences (specifically the color codes) fail? I've tried io:format with both \e, inlining the ctrl-esc manually (using ctrl-v in vim) and using \033 (the ASCII octal code for the escape). None of these get me color in the shell, I just see the ^[[31m or whatever. It was my impression that the terminal caught those sequences and converted them to color codes - what is the shell doing to the control sequences that's preventing them from working? Oh, while writing this email I found this: http://erlang.org/pipermail/erlang-questions/2008-June/036005.html which explains that the shell is escaping the sequences and making them show as plain text. Is there any chance of getting part of this patch merged, at least enough to let the shell not escape the escape character? Andrew From richardc@REDACTED Thu Apr 2 15:24:10 2009 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 02 Apr 2009 15:24:10 +0200 Subject: [erlang-questions] variable unbound In-Reply-To: <200904021457340519636@bluewin.ch> References: <200904021203383175654@bluewin.ch>, <3dbc6d1c0904020415u209d7d5eie956c88e2f95e62@mail.gmail.com> <200904021457340519636@bluewin.ch> Message-ID: <49D4BC7A.8020909@it.uu.se> Gamoto wrote: > I don't understand. After the reception of the filename the variable S is defined ! > I could understand a run-time error if I send a message before to send the filename !! > > 2009/4/2 Gamoto > > What is wrong in this function ? I receive the following error: variable 'S' is unbound ! > I also receive two warnings: File is unused, S is unused. > This process can receive two messages: one file to open and one message to write > > Pid ! {open,"filetoopen.txt"} > > Pid ! {data, Message} > > log_message()-> > receive > {open,File} -> case file:open("File", [append]) of ^^^^^^^ don't put File inside quotes > {ok,S} -> log_message(); ^ this S is not used > {error,Reason} -> io:format( "~s~n",[Reason]) > end; > {data,Data} -> io:format(S, "~s~n", [Data]), ^^ S is not bound to anything here > log_message() > end. /Richard From vances@REDACTED Thu Apr 2 15:25:49 2009 From: vances@REDACTED (Vance Shipley) Date: Thu, 2 Apr 2009 09:25:49 -0400 Subject: [erlang-questions] ANSI escape sequences in the erlang shell In-Reply-To: <20090402131517.GB16582@hijacked.us> References: <20090402131517.GB16582@hijacked.us> Message-ID: <20090402132548.GH195@h216-235-12-174.host.egate.net> +1 here. I quite recently was dissapointed to find I couldn't add colour. On Thu, Apr 02, 2009 at 09:15:18AM -0400, Andrew Thompson wrote: } Is there any chance of getting part of this patch merged, } at least enough to let the shell not escape the escape character? From ext@REDACTED Thu Apr 2 15:36:39 2009 From: ext@REDACTED (David Sveningsson) Date: Thu, 02 Apr 2009 15:36:39 +0200 Subject: [erlang-questions] ANSI escape sequences in the erlang shell In-Reply-To: <20090402131517.GB16582@hijacked.us> References: <20090402131517.GB16582@hijacked.us> Message-ID: <49D4BF67.6010103@sidvind.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andrew Thompson wrote: > Is there a reason the erlang shell is making my attempts to print ANSI > escape sequences (specifically the color codes) fail? I've tried > io:format with both \e, inlining the ctrl-esc manually (using > ctrl-v in vim) and using \033 (the ASCII octal code for the escape). > None of these get me color in the shell, I just see the ^[[31m or > whatever. > > It was my impression that the terminal caught those sequences and > converted them to color codes - what is the shell doing to the control > sequences that's preventing them from working? It is at least working for me when I'm using -noshell and -run. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAknUv2cACgkQ6pa1H/H5pqWHuwCdEPBp3jv2XTDu/Q1MR0/WPQKw W/sAoJ85S9jwKlcBg6KEFRbE0LdmANgm =2Mia -----END PGP SIGNATURE----- From gamoto@REDACTED Thu Apr 2 15:38:22 2009 From: gamoto@REDACTED (Gamoto) Date: Thu, 2 Apr 2009 15:38:22 +0200 Subject: [erlang-questions] variable unbound References: <200904021203383175654@bluewin.ch>, <3dbc6d1c0904020415u209d7d5eie956c88e2f95e62@mail.gmail.com>, Message-ID: <200904021538215783611@bluewin.ch> Are you sure this code is correct ? lines 1 and 16: log_message(FileD) line 4: open(File, ...) But I am newbie ... then correct me if I am wrong ... log_message(File)-> receive {open,File} -> case file:open("File", [append]) of {ok,FileD} -> log_message(FileD); {error,Reason} -> io:format( "~s~n",[Reason]) end; {data,Data} -> case File of not_open -> exit(oops_file_not_open); Else -> io:format(File,"~s~n",[Data]), log_message(File) end end. is closer to what you are wanting, variable only have scope within a function call, this isnt a closure, to keep a variable in scope you pass it into the next call of the function. 2009/4/2 Robert Virding 2009/4/2 Gamoto What is wrong in this function ? I receive the following error: variable 'S' is unbound ! I also receive two warnings: File is unused, S is unused. This process can receive two messages: one file to open and one message to write Pid ! {open,"filetoopen.txt"} Pid ! {data, Message} log_message()-> receive {open,File} -> case file:open("File", [append]) of {ok,S} -> log_message(); {error,Reason} -> io:format( "~s~n",[Reason]) end; {data,Data} -> io:format(S,"~s~n",[Data]), log_message() end. - The variable File is defined in the message {file,File} you recieve but is never used, you open the file "File". - The variable S is defined when you receive the {open,File} message, but you wish to use it when you receive the {data,Data} message where it is not defined. Robert _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From gamoto@REDACTED Thu Apr 2 15:14:35 2009 From: gamoto@REDACTED (Gamoto) Date: Thu, 2 Apr 2009 15:14:35 +0200 Subject: [erlang-questions] process: messages from various sources References: <200904021210317690795@bluewin.ch>, Message-ID: <200904021514353976140@bluewin.ch> After what ? where should I add your line ? Yes, you just need to make sure the socket is opened in active mode, or set it to active after inet:setopts(Socket, [{active, once}]), 2009/4/2 Gamoto Is this possible for one process to receive messages from two sources whose one of these is a socket ? Example my_process(Socket)-> receive {tcp,Socket,Bin}-> %equivalent to gen_tcp:recv(Socket,0) ???? ... %handle Bin my_process(Socket); %loop {msg,Message} -> %from another process ... %handle Message i.e gen_send(Socket,Message) my_process(Socket); %loop end. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From harveyd@REDACTED Thu Apr 2 16:21:19 2009 From: harveyd@REDACTED (Dale Harvey) Date: Thu, 2 Apr 2009 15:21:19 +0100 Subject: [erlang-questions] variable unbound In-Reply-To: <200904021538215783611@bluewin.ch> References: <200904021203383175654@bluewin.ch> <3dbc6d1c0904020415u209d7d5eie956c88e2f95e62@mail.gmail.com> <200904021538215783611@bluewin.ch> Message-ID: Sorry yes one or 2 bugs because I just typed it in the email, this version works log_message(File)-> receive {open,Path} -> case file:open(Path, [append]) of {ok,F} -> log_message(F); {error,Reason} -> io:format( "~s~n",[Reason]) end; {data,Data} -> case File of not_open -> exit(oops_file_not_open); _Else -> io:format(File,"~s~n",[Data]), log_message(File) end end 1>Pid = spawn(fun() -> yourmodule:log_message(not_open) end, 2>Pid ! {open, "/path/to/file.txt"}. 3>Pid ! {data, "some string"}. 2009/4/2 Gamoto > Are you sure this code is correct ? > lines 1 and 16: log_message(FileD) > line 4: open(File, ...) > > But I am newbie ... then correct me if I am wrong ... > > log_message(File)-> > receive > {open,File} -> > case file:open("File", [append]) of > {ok,FileD} -> > log_message(FileD); > {error,Reason} -> > io:format( "~s~n",[Reason]) > end; > {data,Data} -> > case File of > not_open -> > exit(oops_file_not_open); > Else -> > io:format(File,"~s~n",[Data]), > log_message(File) > end > end. > > is closer to what you are wanting, variable only have scope > within a function call, this isnt a closure, to keep a variable > in scope you pass it into the next call of the function. > > 2009/4/2 Robert Virding > >> 2009/4/2 Gamoto >> >>> What is wrong in this function ? I receive the following error: variable >>> 'S' is unbound ! >>> I also receive two warnings: File is unused, S is unused. >>> This process can receive two messages: one file to open and one message >>> to write >>> >>> Pid ! {open,"filetoopen.txt"} >>> >>> Pid ! {data, Message} >>> >>> log_message()-> >>> receive >>> {open,File} -> case file:open("File", [append]) of >>> {ok,S} -> >>> log_message(); >>> {error,Reason} -> io:format( >>> "~s~n",[Reason]) >>> end; >>> {data,Data} -> io:format(S,"~s~n",[Data]), >>> log_message() >>> end. >> >> >> - The variable File is defined in the message {file,File} you recieve but >> is never used, you open the file "File". >> >> - The variable S is defined when you receive the {open,File} message, but >> you wish to use it when you receive the {data,Data} message where it is not >> defined. >> >> Robert >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Apr 2 16:36:29 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 02 Apr 2009 16:36:29 +0200 Subject: [erlang-questions] sorting rules regarding bit strings In-Reply-To: <232998D1E5334E9DBF067888B1D97DCE@SSI.CORP> References: <49D47790.2050107@erlang-consulting.com> <232998D1E5334E9DBF067888B1D97DCE@SSI.CORP> Message-ID: <49D4CD6D.6060906@erlang-consulting.com> David Mercer wrote: > On April 02, 2009, Ulf Wiger wrote: > >> Maybe I'm just unusually dense today, but what are >> the sorting properties of bit strings? > . . . >> Well, I think I can see the pattern, but is this really >> what one wants? > > The sort order seems right to me. When I write out the bit > patterns it might make it clear: > ... Sure, and it's also consistent with how larger "words" are sorted: 1> lists:sort([<<1:64>>,<<1:32>>,<<2:64>>]). [<<0,0,0,0,0,0,0,1>>, <<0,0,0,0,0,0,0,2>>, <<0,0,0,1>>] > Sorting is done bit-by-bit, with end-of-bitstring < 0 < 1. > > Or am I just weird, thinking that that is intuitive? I guess the main problem is that the way bitstrings are pretty-printed gives the wrong visual cues, as regards sorting. <<1:1>> reads as the number one, and not necessarily as "the most significant bit", whereas larger words, as above give visual cues that explain the ordering (just think of each element as a byte, and is sorts just like a string.) BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From kenneth.lundin@REDACTED Thu Apr 2 16:55:43 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 2 Apr 2009 16:55:43 +0200 Subject: [erlang-questions] RPC from linkedin driver In-Reply-To: <722837.22586.qm@web31810.mail.mud.yahoo.com> References: <722837.22586.qm@web31810.mail.mud.yahoo.com> Message-ID: We are working on significant performance improvements and new API's for XMERL. The new XMERL will be at least 4 times faster than the current version. The base for this is a completely new SAX parser that you also can use directly with new API's. The memory consumption will also be significantly reduced. /Kenneth Erlang/OTP Ericsson On Tue, Mar 31, 2009 at 8:13 PM, Yogish Baliga wrote: > > I am currently working on developing a linkedin driver (c language) for XML parser (xmerl is too slow). This is a SAX parser is given the following input: > > 1. XML to be parsed > 2. Call back functions (MFA) for start of node, end of node and for text elements > > I found C APIs to do RPC calls from c-node (ei_rpc). This require ei_cnode and fd parameters. That means I need to run the port as a c-node. > > Is it possible to do RPC from linkedin driver without converting linkedin driver as a c-node? > > Thanx, > -- baliga > > > "The quality of programmers is a decreasing function of the density of GOTO statements in the programs they produce." - Edsger W. Dijkstra > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From andrew@REDACTED Thu Apr 2 16:59:16 2009 From: andrew@REDACTED (Andrew Thompson) Date: Thu, 2 Apr 2009 10:59:16 -0400 Subject: [erlang-questions] ANSI escape sequences in the erlang shell In-Reply-To: <49D4BF67.6010103@sidvind.com> References: <20090402131517.GB16582@hijacked.us> <49D4BF67.6010103@sidvind.com> Message-ID: <20090402145915.GD16582@hijacked.us> On Thu, Apr 02, 2009 at 03:36:39PM +0200, David Sveningsson wrote: > It is at least working for me when I'm using -noshell and -run. > Yes, something like erl -noshell -eval 'io:format("\e[31mhi\e[0m").' works, but it's nice to have the interactive shell at the same time. And it looks like a pretty trivial fix (in the message linked in the original post; I think it's just the stuff in the patch that specialcases ASCII code 27). I haven't actually tested that though. Andrew From michael@REDACTED Thu Apr 2 15:29:40 2009 From: michael@REDACTED (Michael Smith) Date: Thu, 2 Apr 2009 13:29:40 +0000 (UTC) Subject: [erlang-questions] =?utf-8?q?Parent_crashes_when_child_crashes_in?= =?utf-8?q?_ssl=3Assl=5Faccept?= Message-ID: Hi, I'm an Erlang newbie, maintaining an absolutely tiny Erlang program -- it's essentially an SSL wrapper around a C program using open_port. I'm updating from R11B to R12B-5 and I noticed ssl:accept/2 is deprecated, so I'm switching to ssl:transport_accept in the parent followed by ssl:ssl_accept in the child after proc_lib:spawn. Normally, if I have a crash in the child, that particular connection drops and the parent keeps listening. But if ssl:ssl_accept throws an error due to timeout or garbage on the socket, my child crashes and then my parent stops listening. I get two crash reports, one for my child and one for gen_server:call/1. It's strange because I'm not referencing gen_server anywhere in my code. I tried playing with the trap_exit flag, but it didn't seem to help. The crash reports are below, followed by a short test program. Any hints would be appreciated. =CRASH REPORT==== 2-Apr-2009::09:19:51 === crasher: pid: <0.55.0> registered_name: [] exception error: no match of right hand side value {error,esslerrssl} in function ssl_crashme:serve_client/1 initial call: ssl_crashme:serve_client/1 ancestors: [<0.46.0>,<0.1.0>] messages: [] links: [] dictionary: [] trap_exit: false status: running heap_size: 233 stack_size: 23 reductions: 92 neighbours: =CRASH REPORT==== 2-Apr-2009::09:19:51 === crasher: pid: <0.46.0> registered_name: [] exception exit: {normal, {gen_server,call, [<0.54.0>, {release_msgs,<0.46.0>,<0.55.0>}, infinity]}} in function gen_server:call/3 in call from ssl_crashme:server_loop/1 initial call: ssl_crashme:server_loop/1 ancestors: [<0.1.0>] messages: [] links: [<0.45.0>] dictionary: [] trap_exit: false status: running heap_size: 377 stack_size: 23 reductions: 337 neighbours: -module(ssl_crashme). -export([start/0, server_loop/1, serve_client/1]). start() -> application:start(sasl), application:start(ssl), {ok, ListenSocket} = ssl:listen(5050, [list, {certfile, "./cert/host.cert"}, {keyfile, "./cert/host.key"}, {verify, 0}, {depth, 0}, {active, false}]), {A,B,C} = now(), ssl:seed(<>), Pid = proc_lib:spawn(?MODULE, server_loop, [ListenSocket]), ssl:controlling_process(ListenSocket, Pid), io:format("server listening to requests~n"). server_loop(ListenSocket) -> case ssl:transport_accept(ListenSocket, 3000) of {error, timeout} -> ?MODULE:server_loop(ListenSocket); {ok, Socket} -> io:format("server got connection, spawning process~n"), Pid = proc_lib:spawn(?MODULE, serve_client, [Socket]), ssl:controlling_process(Socket, Pid), ?MODULE:server_loop(ListenSocket); _ -> %% lets try again for all other errors ?MODULE:server_loop(ListenSocket) end. serve_client(Socket) -> ok = ssl:ssl_accept(Socket, 15000), {ok, Str} = ssl:recv(Socket, 0, 15000), io:format("got string: ~s~n", [Str]), ok = ssl:send(Socket, "thanks"). Thanks, Mike From ryeguy1@REDACTED Thu Apr 2 17:12:01 2009 From: ryeguy1@REDACTED (ryeguy) Date: Thu, 2 Apr 2009 08:12:01 -0700 (PDT) Subject: [erlang-questions] Where can I use gen_server? In-Reply-To: <1238655645.19996.20.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> References: <1238595132.19996.11.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <1238655645.19996.20.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Message-ID: <1c7c9d5b-0901-4c97-ba0c-f93c765983db@g19g2000yql.googlegroups.com> Yeah sorry that's just test code mostly. I DO want one per client, I would actually globally register each as {player, <<"username">>}. I'm just trying to get this working first. On Apr 2, 3:00?am, Bengt Kleberg wrote: > Greetings, > > It is not obvious to me how you use the gen_server below. You are > registering it as global, but I understood your explanation below as if > you wanted a separate gen_server for each client. > Is the idea to have one gen_server, or one per client? > > bengt > > > > On Wed, 2009-04-01 at 19:34 -0700, ryeguy wrote: > > Well why doesn't this work then? > > > start() ? ? ? ? ? ? ? -> gen_server:start({global, ?MODULE}, ?MODULE, > > [], []). > > stop() ? ? ? ? ? ? ? ?-> gen_server:call({global, ?MODULE}, stop). > > test() ? ? ? ? ? ? ? ?-> gen_server:cast({global, ?MODULE}, test). > > test2() ? ? ? ? ? ? ? ?-> gen_server:cast({global, ?MODULE}, test2). > > > init([]) ->process_flag(trap_exit, true), > > ? ? {ok, 0}. > > > handle_cast(test, State) -> > > ? ?timer:sleep(3000), > > ? ?io:format("asdasd"), > > ? ?{noreply, State}; > > handle_cast(test2, State) -> > > ? ?timer:sleep(3000), > > ? ?3=4, ? ? ? ? ? ? ? ? %%% deliberate error > > ? ?{noreply, State}. > > > handle_call(stop, _From, State) -> > > ? ? {stop, normal, stopped, State}; > > handle_call(test2, _From, State) -> > > ? ?3=4, > > ? ? {noreply, State}. > > > handle_info(_Info, State) -> > > ? ? {noreply, State}. > > > terminate(_Reason, _State) -> > > ? ? ok. > > > code_change(_OldVsn, State, _Extra) -> > > ? ? {ok, State}. > > > When I call test2() then call test(), test2 (obviously) crashes, but > > test() appears to be terminated too. > > > On Apr 1, 10:12 am, Bengt Kleberg wrote: > > > Greetings, > > > > If you start a gen_server with start_link() it will take its clients > > > with it. If you start with start() the clients will remain. > > > > bengt > > > > On Mon, 2009-03-30 at 19:29 -0700, ryeguy wrote: > > > > I'm making a game server, and I just can't see where I would want to > > > > use a gen_server. I'm not set on using one, but I don't want to skimp > > > > on using one where it would make it easier to program this app. > > > > > What I have per node is this: I have 1 process accepting new > > > > connections, which spawns a new process for each new client. For each > > > > packet that comes in, a new process is spawned to handle it and then > > > > it sends the result back to the listening process and terminates. > > > > > It sounds like a good candidate for gen_server, but per the docs it > > > > seems you want to use them when there is some shared resource that you > > > > want to manage, and I don't see one. If I gave each client their own > > > > gen_server, it wouldn't be good because if an erroneous packet was > > > > sent that caused an exception, it would terminate their connection and > > > > any other packets being processed for this client (since a gen_server > > > > takes all of its spawned processes down with it, right?). > > > > > Is there any advantage to using gen_server in my situation? > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questi...@REDACTED > > > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From attila.r.nohl@REDACTED Thu Apr 2 18:03:19 2009 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Thu, 2 Apr 2009 18:03:19 +0200 Subject: [erlang-questions] Version-dependent compiling? Message-ID: <401d3ba30904020903g58420408vb9142645ea712d62@mail.gmail.com> Hello! Is there a way to test for the OTP version during compile time? For example the possible return values of the pwdfun callback in an ssh server are true, {true, Handle} or {false, Str} in OTP R11B-5 (even if it's not documented) and true or false in OTP R13A. For a while I'd like to compile and use the same code with both OTP versions - is it possible to do easily? I'd like to avoid modifying the Makefiles, but I'm willing to introduce some -ifdefs. From gamoto@REDACTED Thu Apr 2 18:15:21 2009 From: gamoto@REDACTED (Gamoto) Date: Thu, 2 Apr 2009 18:15:21 +0200 Subject: [erlang-questions] process: messages from various sources References: <200904021418.n32EIjRc001291@mail.pharos-avantgard.com> Message-ID: <200904021815206403674@bluewin.ch> OK, like this ?: {ok, Listen} = gen_tcp:listen(Port,[binary, {packet, 0}, {active, once}, {reuseaddr, true}] ), ... my_process(Socket)-> receive {tcp,Socket,Bin}-> handle_Bin, inet:setopts(Socket, [{active, once}]), my_process(Socket); {msg,Message} -> handle Message, my_process(Socket); end. >Sure, however, you need to make a call to inet:setops/2 only if you receive >a message from socket (hence, do not need to do it if you receive {msg, >Message}. >The second observation is matter of style -- I personally wouldn't use macro >to declare options, as it hides what is actually used, and you would need to >browse the code, or even go to another file yo find out what's going on. > >-----Original Message----- >From: Gamoto [mailto:gamoto@REDACTED] >Sent: 02 April 2009 03:29 PM >To: Valentin Micic >Subject: Re: RE: [erlang-questions] process: messages from various sources > >Thank you for your explanations. Does this code better and correct ? the >gen_tcp:recv function is unuseful in my case, isn't it ? > >-define(TCP_OPTIONS,[binary, {packet, 0}, {active, once}, {reuseaddr, >true}]). > >{ok, Listen} = gen_tcp:listen(Port, ?TCP_OPTIONS), >... > > >my_process(Socket)-> > receive > {tcp,Socket,Bin}-> handle_Bin, > inet:setopts(Socket, [{active, once}]), > my_process(Socket); > > {msg,Message} -> handle_Message, > inet:setopts(Socket, [{active, once}]), > my_process(Socket); > end. > > >>Absolutely! >>However, you must ensure that socket is in a right mode to achieve that. In >>other words, you can use gen_tcp:recv, or receive it as a message depending >>on how "active" parameter is set during the socket creation (or using >>inet:setopts/2 function. Thus: >> >>{active, false} indicate that socket will be used using gen_tcp:recv/2 >>function >> >>{active, true} indicates that socket will send all messages to process' >>message queue (where it may be retrieved using receive...end construct. >> >>{active, false} indicates that socket will send only one message to message >>queue, and the rest shall be kept in socket's (kernel) buffer. In order to >>trigger sending of the next message, inet:setopts/2 with another {active, >>onece}. >> >>BR. >> >>V. >> >>-----Original Message----- >>From: erlang-questions-bounces@REDACTED >>[mailto:erlang-questions-bounces@REDACTED] On Behalf Of Gamoto >>Sent: 02 April 2009 12:11 PM >>To: erlang-questions >>Subject: [erlang-questions] process: messages from various sources >> >>Is this possible for one process to receive messages from two sources whose >>one of these is a socket ? >> >>Example >> >>my_process(Socket)-> >> receive >> {tcp,Socket,Bin}-> %equivalent to >>gen_tcp:recv(Socket,0) ???? >> ... %handle Bin >> my_process(Socket); %loop >> {msg,Message} -> %from another process >> ... %handle Message >>i.e gen_send(Socket,Message) >> my_process(Socket); %loop >> end. >> >>_______________________________________________ >>erlang-questions mailing list >>erlang-questions@REDACTED >>http://www.erlang.org/mailman/listinfo/erlang-questions >> > From thomasmallen@REDACTED Thu Apr 2 20:04:57 2009 From: thomasmallen@REDACTED (Thomas Allen) Date: Thu, 2 Apr 2009 14:04:57 -0400 Subject: [erlang-questions] Self-referencing anonymous functions? Message-ID: <87b18a720904021104s1a30207ei855fe6f3316e742b@mail.gmail.com> Hi all, I'm just getting going with Erlang (using Armstrong's book) and I ran into anonymous functions. I tried translating the shop:cost and shop:total functions, but I cannot translate the latter because it refers to itself. How would I rewrite this to not throw errors? Total = fun ([{What, N}|T]) -> Cost(What) * N + Total(T); % Clearly, "Total" won't fly here ([]) -> 0 end. Thanks, Thomas From steven.charles.davis@REDACTED Thu Apr 2 20:19:03 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Thu, 2 Apr 2009 11:19:03 -0700 (PDT) Subject: [erlang-questions] Version-dependent compiling? In-Reply-To: <401d3ba30904020903g58420408vb9142645ea712d62@mail.gmail.com> References: <401d3ba30904020903g58420408vb9142645ea712d62@mail.gmail.com> Message-ID: <3ba4993d-f82f-4b48-afe8-c140d43ec48b@e15g2000vbe.googlegroups.com> Would one of erlang:system_info(version). % i.e. the erts version erlang:system_info(otp_release). ...help? On Apr 2, 11:03?am, Attila Rajmund Nohl wrote: > Hello! > > Is there a way to test for the OTP version during compile time? For > example the possible return values of the pwdfun callback in an ssh > server are true, {true, Handle} or {false, Str} in OTP R11B-5 (even if > it's not documented) and true or false in OTP R13A. For a while I'd > like to compile and use the same code with both OTP versions - is it > possible to do easily? I'd like to avoid modifying the Makefiles, but > I'm willing to introduce some -ifdefs. > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From erlang@REDACTED Thu Apr 2 20:19:17 2009 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 2 Apr 2009 20:19:17 +0200 Subject: [erlang-questions] Self-referencing anonymous functions? In-Reply-To: <87b18a720904021104s1a30207ei855fe6f3316e742b@mail.gmail.com> References: <87b18a720904021104s1a30207ei855fe6f3316e742b@mail.gmail.com> Message-ID: <9b08084c0904021119p17ccbf24xc2ef035958aa430d@mail.gmail.com> 1> Cost = fun(F, [{N,C}|T]) -> N*C + F(F, T);(_,[])-> 0 end. #Fun 2> Cost(Cost, [{2,3},{4,5}]). Now you know why the book didn't have any examples of this :-) /Joe On Thu, Apr 2, 2009 at 8:04 PM, Thomas Allen wrote: > Hi all, > > I'm just getting going with Erlang (using Armstrong's book) and I ran > into anonymous functions. I tried translating the shop:cost and > shop:total functions, but I cannot translate the latter because it > refers to itself. How would I rewrite this to not throw errors? > > Total = fun ([{What, N}|T]) -> > ? ? ? ?Cost(What) * N + Total(T); % Clearly, "Total" won't fly here > ? ?([]) -> 0 > end. > > Thanks, > Thomas > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From richardc@REDACTED Thu Apr 2 20:48:06 2009 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 02 Apr 2009 20:48:06 +0200 Subject: [erlang-questions] Self-referencing anonymous functions? In-Reply-To: <87b18a720904021104s1a30207ei855fe6f3316e742b@mail.gmail.com> References: <87b18a720904021104s1a30207ei855fe6f3316e742b@mail.gmail.com> Message-ID: <49D50866.9090507@it.uu.se> Thomas Allen wrote: > I'm just getting going with Erlang (using Armstrong's book) and I ran > into anonymous functions. I tried translating the shop:cost and > shop:total functions, but I cannot translate the latter because it > refers to itself. How would I rewrite this to not throw errors? > > Total = fun ([{What, N}|T]) -> > Cost(What) * N + Total(T); % Clearly, "Total" won't fly here > ([]) -> 0 > end. You have to make it a parameter of the function, and then keep passing it the reference to itself, like this: Total = fun ([{What, N}|T], ThisFunction) -> Cost(What) * N + ThisFunction(T, ThisFunction); ([], ThisFunction) -> 0 end, Sum = Total(SomeList, Total) you can wrap the initial call in another fun, like this: MyTotal = fun (List) -> Total(List, Total) end, Sum = MyTotal(SomeList) /Richard From kris_prieb@REDACTED Thu Apr 2 21:18:59 2009 From: kris_prieb@REDACTED (Kris Prieb) Date: Thu, 2 Apr 2009 14:18:59 -0500 Subject: [erlang-questions] problem running escript upon linux startup In-Reply-To: <4537c3580904011555kc44eb4djfb294af6129b0d23@mail.gmail.com> References: <4537c3580903311250l1a8ccd79i99f0e87eac01755a@mail.gmail.com> <66d1c98f0904011054n1b4bbe38h652a99f60bf7fff@mail.gmail.com> <4537c3580904011555kc44eb4djfb294af6129b0d23@mail.gmail.com> Message-ID: <4537c3580904021218g638d437bp4c665ebb292e96b7@mail.gmail.com> Yup that did the trick. Thanks again. Kris Prieb On Wed, Apr 1, 2009 at 5:55 PM, Kris Prieb wrote: > Thanks! ?I will try that. > > Kris Prieb > > On Wed, Apr 1, 2009 at 12:54 PM, Roger Critchlow wrote: >> I believe that the %%! -env setting in the script takes place too late >> to satisfy the erlang runtime. >> >> If the script is being launched from another script, inside >> /etc/rc.local, then try this: >> >> HOME=/root path-to-escript >> >> or this: >> >> env HOME=/root path-to-escript >> >> which do the same thing, launch the command with the HOME environment >> set to /root >> >> -- rec -- >> >> On Tue, Mar 31, 2009 at 1:50 PM, Kris Prieb wrote: >>> Hello list, >>> >>> The following escript fails when run upon linux (ubuntu) startup: >>> >>> #!/usr/bin/escript >>> %% -*- erlang -*- >>> %%! -env HOME /root >>> main(_) -> file:write_file("/root/simple_start_output", "bunch of text"). >>> >>> The program should create a file called "simple_start_output," under >>> the root directory, but no such file appears when I log into the >>> system. >>> A look at /var/logsyslog/ reveals a "erlexec: HOME must be set" >>> message resulting from the execution of the script. ?The strange thing >>> is that the script works fine when I run it after logging in. >>> >>> I've tried variations of the script such as: >>> >>> 1. using "/root" instead of /root when setting the HOME environment >>> variable in the 3rd line of the script >>> 2. excluding the 3rd line of the script entirely >>> 3. using "/usr/bin/env escript" instead of calling "/usr/bin/escript" >>> >>> All scripts result in the same error, ?"erlexec: HOME must be set," >>> when run at startup. ?However, they all work when run after logging >>> in. ?Does anyone have an idea of how to get an escript to run at >>> startup?? ?Any thoughts would be greatly appreciated. ?Thanks! >>> >>> Kris Prieb >>> >>> (I should also mention that I am actually running the script at the >>> launch of an Amazon EC2 virtual server, not on a machine that is >>> physically in front of me. ?Not sure if that matters one way or >>> another.) >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> > From rapsey@REDACTED Thu Apr 2 21:45:39 2009 From: rapsey@REDACTED (Rapsey) Date: Thu, 2 Apr 2009 21:45:39 +0200 Subject: [erlang-questions] getting file descriptor from socket Message-ID: <97619b170904021245h43654fdby9518f570cb15e55d@mail.gmail.com> Is it possible to get the file descriptor from a socket? The point is to use it in a linked in driver. thank you, Sergej -------------- next part -------------- An HTML attachment was scrubbed... URL: From vinoski@REDACTED Thu Apr 2 22:04:24 2009 From: vinoski@REDACTED (Steve Vinoski) Date: Thu, 2 Apr 2009 16:04:24 -0400 Subject: [erlang-questions] getting file descriptor from socket In-Reply-To: <97619b170904021245h43654fdby9518f570cb15e55d@mail.gmail.com> References: <97619b170904021245h43654fdby9518f570cb15e55d@mail.gmail.com> Message-ID: <65b2728e0904021304o35ce94efjeb5b0307bb108bae@mail.gmail.com> On 4/2/09, Rapsey wrote: > Is it possible to get the file descriptor from a socket? The point is to use > it in a linked in driver. prim_inet:getfd/1, assuming it succeeds it returns {ok, Fd} Undocumented, so use it at your own risk. --steve From contact@REDACTED Thu Apr 2 21:34:49 2009 From: contact@REDACTED (contact@REDACTED) Date: Thu, 02 Apr 2009 21:34:49 +0200 Subject: [erlang-questions] List Comprehensions permutation Message-ID: <1238700889.7516.5.camel@localhost.localdomain> Hi all, I recently bought the book "Programming Erlang" by Joe Armstrong and I have a little problem of comprehension about the logical of an algorithm. Here is the sample from the book : perms([]) -> [[]]; perms(L) -> [[H|T] || H <- L, T <- perms(L--[H])]. I would like to know why we return [[]] and not [] ? I have try some tests : 6> [[H|T] || H <- [1], T <- []]. [] 7> [[H|T] || H <- [1], T <- [[]]]. [[1]] For me it's not logical, in my brain its should be something like : 8> [1|[]]. [1] 9> [1|[[]]]. [1,[]] (all the sample are paste from erlang shell). Someone can "light" me about this ? Thanks in advance. From tuscland@REDACTED Thu Apr 2 23:05:22 2009 From: tuscland@REDACTED (Camille Troillard) Date: Thu, 2 Apr 2009 23:05:22 +0200 Subject: [erlang-questions] IPC bus for Erlang? In-Reply-To: <542cb051-6391-437e-b5e9-10366d5c683f@z1g2000yqn.googlegroups.com> References: <542cb051-6391-437e-b5e9-10366d5c683f@z1g2000yqn.googlegroups.com> Message-ID: Hi Steve, On Thu, Apr 2, 2009 at 2:06 PM, Steve Davis wrote: > > I've been working on a library that does much of what you describe. It > wraps for the cross-platform GUI library 'wx' that appeared in R13A > release of Erlang/OTP. Yes, I have tested that on Windows and it worked well. However, on Mac OS X it compiles but I get : Erlang R13A (erts-5.7) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7 (abort with ^G) 1> sudoku:start(). <0.34.0> 2> =ERROR REPORT==== 2-Apr-2009::22:06:50 === WX Failed loading "wxe_driver"@"/usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0" ** exception error: {load_driver,"dlopen(/usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0/wxe_driver.so, 2): Symbol not found: __ZN10wxGLCanvas20MacVisibilityChangedEv\n Referenced from: /usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0/wxe_driver.so\n Expected in: flat namespace\n"} in function wxe_server:start/0 in call from wx:new/0 in call from sudoku_gui:new/1 in call from timer:tc/3 in call from sudoku:tc/3 in call from sudoku:init/1 I didn't find the origin of this problem. However, I searched and found the symbol was defined in the wxWidgets library included with Mac OS X (libwx_macud_gl-2.8.0.1.1.dylib). Why the library is not dynamically loaded is a mystery to me. This interface runs the UI as a separate process (a gen_server), it > allows you to specify the application GUI in XML which makes it very > easy to design/modify/update. It allows you to pass in a callback > module to use for the UI issued commands. So it's pretty close to your > design target. It looks very interesting. However, my application will need to use a widespread format, so any user that has basic skill in HTML can write simple extensions. The problem is that I only started development of this library less > than a month ago, it's as yet unfinished, and as yet badly documented > as it's a work in rapid progress. > > However you may wish to keep an eye on: > > http://github.com/komone/gx I am interested in anything that touches close of far GUI and Erlang. I will have a look, thanks! Best, Cam -------------- next part -------------- An HTML attachment was scrubbed... URL: From rob.charlton@REDACTED Thu Apr 2 22:28:53 2009 From: rob.charlton@REDACTED (Rob Charlton) Date: Thu, 02 Apr 2009 21:28:53 +0100 Subject: [erlang-questions] Self-referencing anonymous functions? In-Reply-To: <87b18a720904021104s1a30207ei855fe6f3316e742b@mail.gmail.com> References: <87b18a720904021104s1a30207ei855fe6f3316e742b@mail.gmail.com> Message-ID: <49D52005.80909@savageminds.com> Perhaps a step too far, but it's fun (no pun intended): you could also use the Y-combinator: 1> Y = fun(M) -> 1> G = fun (F) -> M(fun(A) -> (F(F))(A) end) end, 1> G(G) end. #Fun Then define Total using a surrounding function-that-takes-a-function: 2> Total2 = fun(F) -> fun([{N,C}|T]) -> N*C + F(T);([])-> 0 end end. #Fun Then your actual Total function can be used by: 3> (Y(Total2))([{2,3},{4,1},{9,7}]). 73 Or you can then define Total by: 4> Total = Y(Total2). #Fun and use it: 5> Total([{2,3},{4,1},{9,7}]). 73 See: http://bc.tech.coop/blog/070611.html if you're interested in this. Cheers Rob Thomas Allen wrote: > Hi all, > > I'm just getting going with Erlang (using Armstrong's book) and I ran > into anonymous functions. I tried translating the shop:cost and > shop:total functions, but I cannot translate the latter because it > refers to itself. How would I rewrite this to not throw errors? > > Total = fun ([{What, N}|T]) -> > Cost(What) * N + Total(T); % Clearly, "Total" won't fly here > ([]) -> 0 > end. > > Thanks, > Thomas > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Rob Charlton Savage Minds Ltd +44 20 79210521 rob.charlton@REDACTED skype: chocolatetpot www.savageminds.com From ossareh@REDACTED Thu Apr 2 23:44:50 2009 From: ossareh@REDACTED (Michael Ossareh) Date: Thu, 2 Apr 2009 14:44:50 -0700 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <4c7f9e8d0904011918g25ee982k2538df628ab0a27a@mail.gmail.com> References: <4ecde87b0903260804p6272c65ft2a62729789be790f@mail.gmail.com> <31117710.95821238081411376.JavaMail.root@zimbra> <31073ef90904011847s109287c7h668e7c3bc1099171@mail.gmail.com> <4c7f9e8d0904011918g25ee982k2538df628ab0a27a@mail.gmail.com> Message-ID: 2009/4/1 Josh Goldberg : > pun intended? I hope so - cos that was very funny :) > > On Wed, Apr 1, 2009 at 6:47 PM, Mark Wagner wrote: >> >> On Thu, Mar 26, 2009 at 08:30, Adam Lindberg >> wrote: >> > ----- "Jon Gretar Borgthorsson" wrote: >> >> Or you can focus on ADA and program the Space Shuttle. >> >> >> >> Pick. >> > >> > I'd love to get bug reports from space. >> >> Trust me: you won't get any. ?The Space Shuttle's flight-control >> systems are some of the most bug-free code on the planet. >> >> -- >> Mark >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- god loves atheists, Fact: http://www.mrwiggleslovesyou.com/comics/rehab477.jpg From ok@REDACTED Fri Apr 3 00:42:02 2009 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 3 Apr 2009 11:42:02 +1300 Subject: [erlang-questions] List Comprehensions permutation In-Reply-To: <1238700889.7516.5.camel@localhost.localdomain> References: <1238700889.7516.5.camel@localhost.localdomain> Message-ID: On 3 Apr 2009, at 8:34 am, contact@REDACTED wrote: > Hi all, > > I recently bought the book "Programming Erlang" by Joe Armstrong and I > have a little problem of comprehension about the logical of an > algorithm. > > Here is the sample from the book : > > perms([]) -> [[]]; > perms(L) -> > [[H|T] || H <- L, T <- perms(L--[H])]. > > I would like to know why we return [[]] and not [] ? Because it simply isn't true that there are no permutations of the empty list. perms(L) returns a list of all the permutations of L. There is ONE permutation of the empty list, namely []. So perms([]) returns a list containing that one permutation, [[]]. > I have try some tests : > > 6> [[H|T] || H <- [1], T <- []]. > [] > 7> [[H|T] || H <- [1], T <- [[]]]. > [[1]] > > For me it's not logical, > in my brain its should be something like : > > 8> [1|[]]. > [1] [1|[]] is indeed [1]. But perms([1]) is supposed to return a LIST OF PERMUTATIONS, not a single permutation. So perms([1]) should return [[1]], just as perms([1,2]) should return [[1,2],[2,1]] or something like that. From adam.kocoloski@REDACTED Fri Apr 3 01:06:58 2009 From: adam.kocoloski@REDACTED (Adam Kocoloski) Date: Thu, 2 Apr 2009 19:06:58 -0400 Subject: [erlang-questions] question on 'EXIT' messages delivered to exit-trapping gen_servers Message-ID: <2CEC647C-1D19-41E3-91E8-4F40618DC1EF@gmail.com> Hi Erlangers, I've been doing a little hacking on CouchDB and running into some behavior that I don't understand. We have a standalone gen_server (let's call it A) that traps exits and was started by another gen_server (B) using start_link. B does not trap exits, and is linked to some other process C. Now we have the following sequence of events: * exit(C, kill) * B exits immediately with Reason killed * A calls terminate with Reason killed That last line surprised me. I was expecting to receive {'EXIT', B, killed} in A's mailbox, and in fact I had written a handle_info to process all 'EXIT' messages, but none arrived. I checked that trap_exit is still true in A's terminate. {trap_exit, true} clearly has some effect, as without it terminate isn't even called. I tried changing the exit signal to some other atom, but I still get the same basic results (just with goodbye_cruel_world instead of kill/ killed in the Reasons). I'm stumped. Regards, Adam From chandrashekhar.mullaparthi@REDACTED Fri Apr 3 01:29:22 2009 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Fri, 3 Apr 2009 00:29:22 +0100 Subject: [erlang-questions] question on 'EXIT' messages delivered to exit-trapping gen_servers In-Reply-To: <2CEC647C-1D19-41E3-91E8-4F40618DC1EF@gmail.com> References: <2CEC647C-1D19-41E3-91E8-4F40618DC1EF@gmail.com> Message-ID: Hi Adam, It looks like if a gen_server process was spawned using proc_lib:spawn and an EXIT signal is received indicating that the Parent process has died, the terminate() function is called! The documentation should probably clarify this. Here is the extract from gen_server.erl in R11B-5 loop(Parent, Name, State, Mod, Time, Debug) -> Msg = receive Input -> Input after Time -> timeout end, case Msg of {system, From, Req} -> sys:handle_system_msg(Req, From, Parent, ?MODULE, Debug, [Name, State, Mod, Time]); {'EXIT', Parent, Reason} -> terminate(Reason, Name, Msg, Mod, State, Debug); _Msg when Debug =:= [] -> handle_msg(Msg, Parent, Name, State, Mod, Time); _Msg -> Debug1 = sys:handle_debug(Debug, {?MODULE, print_event}, Name, {in, Msg}), handle_msg(Msg, Parent, Name, State, Mod, Time, Debug1) end. cheers Chandru 2009/4/3 Adam Kocoloski > Hi Erlangers, I've been doing a little hacking on CouchDB and running > into some behavior that I don't understand. We have a standalone > gen_server (let's call it A) that traps exits and was started by > another gen_server (B) using start_link. B does not trap exits, and > is linked to some other process C. Now we have the following sequence > of events: > > * exit(C, kill) > * B exits immediately with Reason killed > * A calls terminate with Reason killed > > That last line surprised me. I was expecting to receive {'EXIT', B, > killed} in A's mailbox, and in fact I had written a handle_info to > process all 'EXIT' messages, but none arrived. I checked that > trap_exit is still true in A's terminate. {trap_exit, true} clearly > has some effect, as without it terminate isn't even called. > > I tried changing the exit signal to some other atom, but I still get > the same basic results (just with goodbye_cruel_world instead of kill/ > killed in the Reasons). I'm stumped. Regards, Adam > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nesrait@REDACTED Fri Apr 3 03:35:59 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Fri, 3 Apr 2009 02:35:59 +0100 Subject: [erlang-questions] how much time required to pass messages. In-Reply-To: References: <49CF5200.1080702@codimi.de> Message-ID: <523869a70904021835n69abc196ve7d63af718c9652a@mail.gmail.com> Hi Vikrant! :) Now next stuff I wonder, will the time required to pass message depends on > what is being passed through message? guess is that it should. Because on > process boundaries the data is copied.... copying will take time which will > depend on the data itself. > I don't really know what happens while sending messages (cue for more experienced folks ;)) but I remember recently reading (*checking mail...*) here: http://erlang.org/pipermail/erlang-questions/2009-March/042714.html): > Large heap binaries are always reference counted; this has nothing to > do with the hybrid memory architecture. But it's only for binaries. > > What the hybrid system does is keep a separate, shared heap for all > data that has been passed as messages. On the first send, the data is > copied from the sender to the shared area, and from then on, it will > be shared by all processes. > > So that might explain the message passing speed (on a single node). Cheers, Davide :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam.kocoloski@REDACTED Fri Apr 3 04:07:36 2009 From: adam.kocoloski@REDACTED (Adam Kocoloski) Date: Thu, 2 Apr 2009 22:07:36 -0400 Subject: [erlang-questions] question on 'EXIT' messages delivered to exit-trapping gen_servers In-Reply-To: References: <2CEC647C-1D19-41E3-91E8-4F40618DC1EF@gmail.com> Message-ID: <23F584D6-E71C-4B8F-BDC6-ADC8DD86C664@gmail.com> Aha, glad to know I wasn't going crazy. Thanks Chandru! Adam On Apr 2, 2009, at 7:29 PM, Chandru wrote: > Hi Adam, > > It looks like if a gen_server process was spawned using > proc_lib:spawn and an EXIT signal is received indicating that the > Parent process has died, the terminate() function is called! > > The documentation should probably clarify this. > > Here is the extract from gen_server.erl in R11B-5 > > loop(Parent, Name, State, Mod, Time, Debug) -> > Msg = receive > Input -> > Input > after Time -> > timeout > end, > case Msg of > {system, From, Req} -> > sys:handle_system_msg(Req, From, Parent, ?MODULE, Debug, > [Name, State, Mod, Time]); > {'EXIT', Parent, Reason} -> > terminate(Reason, Name, Msg, Mod, State, Debug); > _Msg when Debug =:= [] -> > handle_msg(Msg, Parent, Name, State, Mod, Time); > _Msg -> > Debug1 = sys:handle_debug(Debug, {?MODULE, print_event}, > Name, {in, Msg}), > handle_msg(Msg, Parent, Name, State, Mod, Time, Debug1) > end. > > cheers > Chandru > > > 2009/4/3 Adam Kocoloski > Hi Erlangers, I've been doing a little hacking on CouchDB and running > into some behavior that I don't understand. We have a standalone > gen_server (let's call it A) that traps exits and was started by > another gen_server (B) using start_link. B does not trap exits, and > is linked to some other process C. Now we have the following sequence > of events: > > * exit(C, kill) > * B exits immediately with Reason killed > * A calls terminate with Reason killed > > That last line surprised me. I was expecting to receive {'EXIT', B, > killed} in A's mailbox, and in fact I had written a handle_info to > process all 'EXIT' messages, but none arrived. I checked that > trap_exit is still true in A's terminate. {trap_exit, true} clearly > has some effect, as without it terminate isn't even called. > > I tried changing the exit signal to some other atom, but I still get > the same basic results (just with goodbye_cruel_world instead of kill/ > killed in the Reasons). I'm stumped. Regards, Adam > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From yogishb@REDACTED Fri Apr 3 04:12:17 2009 From: yogishb@REDACTED (Yogish Baliga) Date: Thu, 2 Apr 2009 19:12:17 -0700 (PDT) Subject: [erlang-questions] lists:flatmap tail recursive? Message-ID: <738666.41332.qm@web31810.mail.mud.yahoo.com> Here is a code snippet from lists module. flatmap(F, [Hd|Tail]) -> F(Hd) ++ flatmap(F, Tail); flatmap(F, []) when is_function(F, 1) -> []. I was wondering if it is tail recursive? -- baliga "The quality of programmers is a decreasing function of the density of GOTO statements in the programs they produce." - Edsger W. Dijkstra http://dudefrommangalore.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Fri Apr 3 04:30:53 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Thu, 2 Apr 2009 19:30:53 -0700 Subject: [erlang-questions] lists:flatmap tail recursive? In-Reply-To: <738666.41332.qm@web31810.mail.mud.yahoo.com> References: <738666.41332.qm@web31810.mail.mud.yahoo.com> Message-ID: 2009/4/2 Yogish Baliga : > Here is a code snippet from lists module. > > flatmap(F, [Hd|Tail]) -> > ??? F(Hd) ++ flatmap(F, Tail); > flatmap(F, []) when is_function(F, 1) -> []. > > I was wondering if it is tail recursive? No, it's equivalent to flatmap(F, [Hd|Tail]) -> erlang:'++'(F(Hd), flatmap(F, Tail)); flatmap(F, []) when is_function(F, 1) -> []. From nesrait@REDACTED Fri Apr 3 06:22:16 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Fri, 3 Apr 2009 05:22:16 +0100 Subject: [erlang-questions] McErlang first public release In-Reply-To: <91a2ba3e0904011049g7768f18ata96eed090a843f29@mail.gmail.com> References: <49D21C84.6080701@fi.upm.es> <91a2ba3e0904011049g7768f18ata96eed090a843f29@mail.gmail.com> Message-ID: <523869a70904022122k479e4979id5b85b1be6c6e088@mail.gmail.com> On Wed, Apr 1, 2009 at 6:49 PM, Raoul Duke wrote: > > Please take a look at https://babel.ls.fi.upm.es/trac/McErlang/ try the > > tool and send us your questions, comments, bug reports, etc. > > www.cs.chalmers.se/~hanssv/doc/icfp07-McErlang.pdf > > very cool! i think concurrency/distribution clearly needs model > checking to develop 'correct' systems (as opposed to ones that 'just' > handle failure dynamically). hope to get some free time (ha ha!) to > try this all out. I just read the tutorials and presentations on the site and I *have* to say I really admire the work you've done with McErlang! Congrats! :) >From what I can tell, the best way to get an overview of McErlang (without wasting too much of that ethereal free time :)) is this presentation: https://babel.ls.fi.upm.es/trac/McErlang/attachment/wiki/talks/costDec2008.pdf . I think this sums it up quite nicely: [McErlang]"An alternative implementation of Erlang for testing!" (writting this got me hungry...) /Davide :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From dgud@REDACTED Fri Apr 3 07:58:19 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Fri, 03 Apr 2009 07:58:19 +0200 Subject: [erlang-questions] IPC bus for Erlang? In-Reply-To: References: <542cb051-6391-437e-b5e9-10366d5c683f@z1g2000yqn.googlegroups.com> Message-ID: <49D5A57B.9090105@erix.ericsson.se> On Mac OS X you will need to compile and install wxWidgets by yourself, before compiling erlang. The wxWidgets libs that are included with Mac OS X Leopard is old and is missing some things I require, (e.g. wxStyledTextCtrl which provides erlang syntax highlighting). See compiling instructions here: http://apps.sourceforge.net/mediawiki/wxerlang/index.php?title=Getting_Started /Dan Camille Troillard wrote: > Hi Steve, > > > On Thu, Apr 2, 2009 at 2:06 PM, Steve Davis > > > wrote: > > > I've been working on a library that does much of what you describe. It > wraps for the cross-platform GUI library 'wx' that appeared in R13A > release of Erlang/OTP. > > > Yes, I have tested that on Windows and it worked well. > However, on Mac OS X it compiles but I get : > > Erlang R13A (erts-5.7) [source] [smp:2:2] [rq:2] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.7 (abort with ^G) > 1> sudoku:start(). > <0.34.0> > 2> > =ERROR REPORT==== 2-Apr-2009::22:06:50 === > WX Failed loading "wxe_driver"@"/usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0" > ** exception error: {load_driver,"dlopen(/usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0/wxe_driver.so, 2): Symbol not found: __ZN10wxGLCanvas20MacVisibilityChangedEv\n Referenced from: /usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0/wxe_driver.so\n Expected in: flat namespace\n"} > in function wxe_server:start/0 > in call from wx:new/0 > in call from sudoku_gui:new/1 > in call from timer:tc/3 > in call from sudoku:tc/3 > in call from sudoku:init/1 > > I didn't find the origin of this problem. > However, I searched and found the symbol was defined in the wxWidgets > library included with Mac OS X (libwx_macud_gl-2.8.0.1.1.dylib). Why > the library is not dynamically loaded is a mystery to me. > > > > This interface runs the UI as a separate process (a gen_server), it > allows you to specify the application GUI in XML which makes it very > easy to design/modify/update. It allows you to pass in a callback > module to use for the UI issued commands. So it's pretty close to your > design target. > > > It looks very interesting. > However, my application will need to use a widespread format, so any > user that has basic skill in HTML can write simple extensions. > > > The problem is that I only started development of this library less > than a month ago, it's as yet unfinished, and as yet badly documented > as it's a work in rapid progress. > > However you may wish to keep an eye on: > > http://github.com/komone/gx > > > I am interested in anything that touches close of far GUI and Erlang. > I will have a look, thanks! > > > > Best, > Cam > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From bengt.kleberg@REDACTED Fri Apr 3 08:05:10 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 03 Apr 2009 08:05:10 +0200 Subject: [erlang-questions] process: messages from various sources In-Reply-To: <200904021815206403674@bluewin.ch> References: <200904021418.n32EIjRc001291@mail.pharos-avantgard.com> <200904021815206403674@bluewin.ch> Message-ID: <1238738710.19365.37.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, Just to make sure: The socket returned from listen/2 can only be used in calls to accept/1,2. The socket you get from accept() is the one you should use in my_process/1 below. Also, please consider adding {tcp_closed, Socket} and {tcp_error, Socket, Reason} to your receive. bengt On Thu, 2009-04-02 at 18:15 +0200, Gamoto wrote: > OK, like this ?: > {ok, Listen} = gen_tcp:listen(Port,[binary, {packet, 0}, {active, once}, {reuseaddr, true}] ), > ... > > > my_process(Socket)-> > receive > {tcp,Socket,Bin}-> handle_Bin, > inet:setopts(Socket, [{active, once}]), > my_process(Socket); > > {msg,Message} -> handle Message, > my_process(Socket); > end. > > > >Sure, however, you need to make a call to inet:setops/2 only if you receive > >a message from socket (hence, do not need to do it if you receive {msg, > >Message}. > >The second observation is matter of style -- I personally wouldn't use macro > >to declare options, as it hides what is actually used, and you would need to > >browse the code, or even go to another file yo find out what's going on. > > > >-----Original Message----- > >From: Gamoto [mailto:gamoto@REDACTED] > >Sent: 02 April 2009 03:29 PM > >To: Valentin Micic > >Subject: Re: RE: [erlang-questions] process: messages from various sources > > > >Thank you for your explanations. Does this code better and correct ? the > >gen_tcp:recv function is unuseful in my case, isn't it ? > > > >-define(TCP_OPTIONS,[binary, {packet, 0}, {active, once}, {reuseaddr, > >true}]). > > > >{ok, Listen} = gen_tcp:listen(Port, ?TCP_OPTIONS), > >... > > > > > >my_process(Socket)-> > > receive > > {tcp,Socket,Bin}-> handle_Bin, > > inet:setopts(Socket, [{active, once}]), > > my_process(Socket); > > > > {msg,Message} -> handle_Message, > > inet:setopts(Socket, [{active, once}]), > > my_process(Socket); > > end. > > > > > >>Absolutely! > >>However, you must ensure that socket is in a right mode to achieve that. In > >>other words, you can use gen_tcp:recv, or receive it as a message depending > >>on how "active" parameter is set during the socket creation (or using > >>inet:setopts/2 function. Thus: > >> > >>{active, false} indicate that socket will be used using gen_tcp:recv/2 > >>function > >> > >>{active, true} indicates that socket will send all messages to process' > >>message queue (where it may be retrieved using receive...end construct. > >> > >>{active, false} indicates that socket will send only one message to message > >>queue, and the rest shall be kept in socket's (kernel) buffer. In order to > >>trigger sending of the next message, inet:setopts/2 with another {active, > >>onece}. > >> > >>BR. > >> > >>V. > >> > >>-----Original Message----- > >>From: erlang-questions-bounces@REDACTED > >>[mailto:erlang-questions-bounces@REDACTED] On Behalf Of Gamoto > >>Sent: 02 April 2009 12:11 PM > >>To: erlang-questions > >>Subject: [erlang-questions] process: messages from various sources > >> > >>Is this possible for one process to receive messages from two sources whose > >>one of these is a socket ? > >> > >>Example > >> > >>my_process(Socket)-> > >> receive > >> {tcp,Socket,Bin}-> %equivalent to > >>gen_tcp:recv(Socket,0) ???? > >> ... %handle Bin > >> my_process(Socket); %loop > >> {msg,Message} -> %from another process > >> ... %handle Message > >>i.e gen_send(Socket,Message) > >> my_process(Socket); %loop > >> end. > >> > >>_______________________________________________ > >>erlang-questions mailing list > >>erlang-questions@REDACTED > >>http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From bengt.kleberg@REDACTED Fri Apr 3 08:09:11 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 03 Apr 2009 08:09:11 +0200 Subject: [erlang-questions] Where can I use gen_server? In-Reply-To: <1c7c9d5b-0901-4c97-ba0c-f93c765983db@g19g2000yql.googlegroups.com> References: <1238595132.19996.11.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <1238655645.19996.20.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <1c7c9d5b-0901-4c97-ba0c-f93c765983db@g19g2000yql.googlegroups.com> Message-ID: <1238738951.19365.41.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> OK, you have one globally registered server that pretends to an instance of (the future) fleet of servers. How do you call this one server? From one process or many? bengt On Thu, 2009-04-02 at 08:12 -0700, ryeguy wrote: > Yeah sorry that's just test code mostly. I DO want one per client, I > would actually globally register each as {player, <<"username">>}. I'm > just trying to get this working first. > > On Apr 2, 3:00 am, Bengt Kleberg wrote: > > Greetings, > > > > It is not obvious to me how you use the gen_server below. You are > > registering it as global, but I understood your explanation below as if > > you wanted a separate gen_server for each client. > > Is the idea to have one gen_server, or one per client? > > > > bengt > > > > > > > > On Wed, 2009-04-01 at 19:34 -0700, ryeguy wrote: > > > Well why doesn't this work then? > > > > > start() -> gen_server:start({global, ?MODULE}, ?MODULE, > > > [], []). > > > stop() -> gen_server:call({global, ?MODULE}, stop). > > > test() -> gen_server:cast({global, ?MODULE}, test). > > > test2() -> gen_server:cast({global, ?MODULE}, test2). > > > > > init([]) ->process_flag(trap_exit, true), > > > {ok, 0}. > > > > > handle_cast(test, State) -> > > > timer:sleep(3000), > > > io:format("asdasd"), > > > {noreply, State}; > > > handle_cast(test2, State) -> > > > timer:sleep(3000), > > > 3=4, %%% deliberate error > > > {noreply, State}. > > > > > handle_call(stop, _From, State) -> > > > {stop, normal, stopped, State}; > > > handle_call(test2, _From, State) -> > > > 3=4, > > > {noreply, State}. > > > > > handle_info(_Info, State) -> > > > {noreply, State}. > > > > > terminate(_Reason, _State) -> > > > ok. > > > > > code_change(_OldVsn, State, _Extra) -> > > > {ok, State}. > > > > > When I call test2() then call test(), test2 (obviously) crashes, but > > > test() appears to be terminated too. > > > > > On Apr 1, 10:12 am, Bengt Kleberg wrote: > > > > Greetings, > > > > > > If you start a gen_server with start_link() it will take its clients > > > > with it. If you start with start() the clients will remain. > > > > > > bengt > > > > > > On Mon, 2009-03-30 at 19:29 -0700, ryeguy wrote: > > > > > I'm making a game server, and I just can't see where I would want to > > > > > use a gen_server. I'm not set on using one, but I don't want to skimp > > > > > on using one where it would make it easier to program this app. > > > > > > > What I have per node is this: I have 1 process accepting new > > > > > connections, which spawns a new process for each new client. For each > > > > > packet that comes in, a new process is spawned to handle it and then > > > > > it sends the result back to the listening process and terminates. > > > > > > > It sounds like a good candidate for gen_server, but per the docs it > > > > > seems you want to use them when there is some shared resource that you > > > > > want to manage, and I don't see one. If I gave each client their own > > > > > gen_server, it wouldn't be good because if an erroneous packet was > > > > > sent that caused an exception, it would terminate their connection and > > > > > any other packets being processed for this client (since a gen_server > > > > > takes all of its spawned processes down with it, right?). > > > > > > > Is there any advantage to using gen_server in my situation? > > > > > _______________________________________________ > > > > > erlang-questions mailing list > > > > > erlang-questi...@REDACTED > > > > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questi...@REDACTED > > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From w.a.de.jong@REDACTED Fri Apr 3 08:12:20 2009 From: w.a.de.jong@REDACTED (Willem de Jong) Date: Fri, 3 Apr 2009 08:12:20 +0200 Subject: [erlang-questions] RPC from linkedin driver In-Reply-To: References: <722837.22586.qm@web31810.mail.mud.yahoo.com> Message-ID: <407d9ef80904022312ob31f1camd9dc1e54044a998e@mail.gmail.com> In the mean time, you could try the sax parser that comes with erlsom. It is significantly faster than xmerl, uses little memory and it has an easy to use sax API. You can read the documentation here: http://erlsom.sourceforge.net or download the software here: http://sourceforge.net/projects/erlsom/ Regards, Willem On Thu, Apr 2, 2009 at 4:55 PM, Kenneth Lundin wrote: > We are working on significant performance improvements and new API's for > XMERL. > > The new XMERL will be at least 4 times faster than the current > version. The base for this is a completely new > SAX parser that you also can use directly with new API's. > > The memory consumption will also be significantly reduced. > > /Kenneth Erlang/OTP Ericsson > > On Tue, Mar 31, 2009 at 8:13 PM, Yogish Baliga wrote: > > > > I am currently working on developing a linkedin driver (c language) for > XML parser (xmerl is too slow). This is a SAX parser is given the following > input: > > > > 1. XML to be parsed > > 2. Call back functions (MFA) for start of node, end of node and for text > elements > > > > I found C APIs to do RPC calls from c-node (ei_rpc). This require > ei_cnode and fd parameters. That means I need to run the port as a c-node. > > > > Is it possible to do RPC from linkedin driver without converting linkedin > driver as a c-node? > > > > Thanx, > > -- baliga > > > > > > "The quality of programmers is a decreasing function of the density of > GOTO statements in the programs they produce." - Edsger W. Dijkstra > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pguyot@REDACTED Fri Apr 3 09:50:47 2009 From: pguyot@REDACTED (Paul Guyot) Date: Fri, 3 Apr 2009 09:50:47 +0200 Subject: [erlang-questions] escript and tail recursion Message-ID: Hello, I've just noticed that tail recursive functions in interpreted escript scripts are not tail recursive at all. Here is a sample script : > tail_r() -> > io:format("~p~n", [element(2, process_info(self(), stack_size))]), > tail_r(). > > main([]) -> > tail_r(). The function is tail-recursive if -mode(compile) is used. Is it a known limitation of escript? (this is R12B). If so, shouldn't it be mentioned in the escript documentation? Paul From ofer.affias@REDACTED Fri Apr 3 10:40:13 2009 From: ofer.affias@REDACTED (vim) Date: Fri, 3 Apr 2009 01:40:13 -0700 (PDT) Subject: [erlang-questions] atomicity when using more than one database Message-ID: <0113bdc5-0175-4b7b-b240-33107f1c398e@v19g2000yqn.googlegroups.com> i am looking for some advice on how to implement an application which use a mnesia database. the app i am working on, is relying on a central database. the app issue synchronous commands into this database, which preform all kinds of tasks. the access to this database should be optimal, since i need it to have real time performance on the average scenario. on the other hand, the app need to supply more information (services) which some of it is sitting on the central database, this extra information have no real time demands, and can be requested asynchronously. i fear that the need for those services will hurt the app requirements, if i will implement it by accessing the central database directly. i thought of several solutions, at first i thought that each write to the central database can send a message to another process with all the info to be written. this way i can actually duplicate the info i need on another mirror database, and i can access it for my services. the problem with this solution is that the action above is not atomic. there can be a scenario in which those database can get out of sync. another solution i thought of, is to wrap all the mnesia transaction to the core database with more writes to the mirror database for the services. this way i can guaranty atomicity. the problem here is that if i need more mirror databases with all kinds of information, it is kind of ugly to recode those transaction each time and add more code each time. not to mention a bigger issue: i can get into speed problem in my core, if the mirror writes (which are wrapped on the same mnesia transaction to ensure atomicity) will slow the main process down, causing my app to preform bad and failing to supply the real time demands i have. any ideas? thanks, vim. From masse@REDACTED Fri Apr 3 11:17:36 2009 From: masse@REDACTED (mats cronqvist) Date: Fri, 03 Apr 2009 11:17:36 +0200 Subject: [erlang-questions] RPC from linkedin driver In-Reply-To: <407d9ef80904022312ob31f1camd9dc1e54044a998e@mail.gmail.com> (Willem de Jong's message of "Fri\, 3 Apr 2009 08\:12\:20 +0200") References: <722837.22586.qm@web31810.mail.mud.yahoo.com> <407d9ef80904022312ob31f1camd9dc1e54044a998e@mail.gmail.com> Message-ID: <87vdpmksen.fsf@sterlett.hq.kred> Willem de Jong writes: > In the mean time, you could try the sax parser that comes with erlsom. It is > significantly faster than xmerl, uses little memory and it has an easy to use > sax API. +1. I use it every day and it's excellent. From chandrashekhar.mullaparthi@REDACTED Fri Apr 3 11:23:37 2009 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Fri, 3 Apr 2009 10:23:37 +0100 Subject: [erlang-questions] RPC from linkedin driver In-Reply-To: <407d9ef80904022312ob31f1camd9dc1e54044a998e@mail.gmail.com> References: <722837.22586.qm@web31810.mail.mud.yahoo.com> <407d9ef80904022312ob31f1camd9dc1e54044a998e@mail.gmail.com> Message-ID: 2009/4/3 Willem de Jong > In the mean time, you could try the sax parser that comes with erlsom. It > is significantly faster than xmerl, uses little memory and it has an easy to > use sax API. > > You can read the documentation here: > http://erlsom.sourceforge.net > > or download the software here: > http://sourceforge.net/projects/erlsom/ > > Yes - I highly recommend this. Works very well. cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From smiler@REDACTED Fri Apr 3 10:45:33 2009 From: smiler@REDACTED (Christian Axelsson) Date: Fri, 03 Apr 2009 10:45:33 +0200 Subject: [erlang-questions] Self-referencing anonymous functions? In-Reply-To: <9b08084c0904021119p17ccbf24xc2ef035958aa430d@mail.gmail.com> References: <87b18a720904021104s1a30207ei855fe6f3316e742b@mail.gmail.com> <9b08084c0904021119p17ccbf24xc2ef035958aa430d@mail.gmail.com> Message-ID: <49D5CCAD.9000504@lanil.mine.nu> Joe Armstrong wrote: > 1> Cost = fun(F, [{N,C}|T]) -> N*C + F(F, T);(_,[])-> 0 end. > #Fun > 2> Cost(Cost, [{2,3},{4,5}]). > > Now you know why the book didn't have any examples of this :-) I've noticed that aswell :) Would it be a bad idea to introduce a keyword for self referencing anonymous functions? /Christian > /Joe > > > On Thu, Apr 2, 2009 at 8:04 PM, Thomas Allen wrote: >> Hi all, >> >> I'm just getting going with Erlang (using Armstrong's book) and I ran >> into anonymous functions. I tried translating the shop:cost and >> shop:total functions, but I cannot translate the latter because it >> refers to itself. How would I rewrite this to not throw errors? >> >> Total = fun ([{What, N}|T]) -> >> Cost(What) * N + Total(T); % Clearly, "Total" won't fly here >> ([]) -> 0 >> end. >> >> Thanks, >> Thomas >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions> Now you know why the book didn't have any examples of this :-) > > > /Joe > From gamoto@REDACTED Fri Apr 3 11:40:57 2009 From: gamoto@REDACTED (Gamoto) Date: Fri, 3 Apr 2009 11:40:57 +0200 Subject: [erlang-questions] accept part of a server Message-ID: <200904031140573691220@bluewin.ch> I saw two approaches for the accept part of a server: Approach 1: do_accept(LS)-> case gen_tcp:accept(LS) of {ok,S}->spawn(...handle(S)...), do_accept(LS); Other-> ... end. Approach 2): do_accept(LS)-> case gen_tcp:accept(LS) of {ok,S}-> spawn(...do_accept(LS) ...), handle(S); Other-> ... end. What is the better approach and the criteria for chosing (crash, supervision, ...) ? From gamoto@REDACTED Fri Apr 3 11:35:28 2009 From: gamoto@REDACTED (Gamoto) Date: Fri, 3 Apr 2009 11:35:28 +0200 Subject: [erlang-questions] variable unbound References: <200904021203383175654@bluewin.ch>, <3dbc6d1c0904020415u209d7d5eie956c88e2f95e62@mail.gmail.com>, <200904021457340519636@bluewin.ch>, <42C4C484-3B66-4F59-90AF-AA1D71880D09@cs.otago.ac.nz> Message-ID: <200904031135281244167@bluewin.ch> I thought that the scope was the function and not the branch ! I must learnt more on Erlang !! Thanks > >On 3 Apr 2009, at 1:57 am, Gamoto wrote: > >> I don't understand. After the reception of the filename the variable >> S is defined ! > >*IN THAT BRANCH*. > >It's defined in one branch of the 'receive', >but used in the other, where it is _not_ defined. > From gamoto@REDACTED Fri Apr 3 12:14:25 2009 From: gamoto@REDACTED (Gamoto) Date: Fri, 3 Apr 2009 12:14:25 +0200 Subject: [erlang-questions] segments of variable length Message-ID: <200904031214221225101@bluewin.ch> I receive from several machines messages and I would like to extract data. My first approach was: handler(Data)-> case Data of <> etc... My problem is that some segment have a fixed length (header, Status) and some others a variable length (Time <= 6 bytes, UnitID <= 8 bytes). My approach is bad. I thought to do: Segments = string:tokens(Data,",") This separates the segments but I don't have their name (header,unitid,time,status) ! Could you advice me a better approach. My goal is to check each segment and make actions according to their values. From chsu79@REDACTED Fri Apr 3 12:39:05 2009 From: chsu79@REDACTED (Christian) Date: Fri, 3 Apr 2009 12:39:05 +0200 Subject: [erlang-questions] Self-referencing anonymous functions? In-Reply-To: <49D5CCAD.9000504@lanil.mine.nu> References: <87b18a720904021104s1a30207ei855fe6f3316e742b@mail.gmail.com> <9b08084c0904021119p17ccbf24xc2ef035958aa430d@mail.gmail.com> <49D5CCAD.9000504@lanil.mine.nu> Message-ID: On Fri, Apr 3, 2009 at 10:45, Christian Axelsson wrote: > Joe Armstrong wrote: >> 1> Cost = fun(F, [{N,C}|T]) -> N*C + F(F, T);(_,[])-> 0 end. >> #Fun >> 2> Cost(Cost, [{2,3},{4,5}]). >> >> Now you know why the book didn't have any examples of this :-) > > I've noticed that aswell :) > Would it be a bad idea to introduce a keyword for self referencing > anonymous functions? That discussion has been had several times on this list. I think nothing is done because those that are capable of doing it don't feel that it is important. The shell is just used for basic inspection and evaluation, not for building systems. Get distel to compile into real modules if you want more interactive development. If you want recusion in real modules you can define a named function. Giving non-trivial things a name is generally a good thing. It makes it much easier to talk about. Anyway. Introducing a magical keyword that refers to the surrounding closure would be a bad thing anyway. First for introducing yet another keyword. Secondly because it is only referring to one surrounding fun when erlang allow funs to return funs that return funs, and so on. The better approach would be to add an optional name that is scoped to the fun-body. This way you can have multiple nested funs and they can refer to the outer funs or itself, and the programmer can give them meaningful names. From tuscland@REDACTED Fri Apr 3 12:42:40 2009 From: tuscland@REDACTED (Camille Troillard) Date: Fri, 3 Apr 2009 12:42:40 +0200 Subject: [erlang-questions] IPC bus for Erlang? In-Reply-To: <49D5A57B.9090105@erix.ericsson.se> References: <542cb051-6391-437e-b5e9-10366d5c683f@z1g2000yqn.googlegroups.com> <49D5A57B.9090105@erix.ericsson.se> Message-ID: Hi Dan, OK, I understand: I have actually tried to build wxWidgets *after*installing Erlang. I found some details to be a bit confusing: When Erlang is built, there is no warning about a deprecated or absent version of wxWidgets. For me it's like everything was ready to go. Having found that it was not the case, I have tried to follow wxerlang instructions. So, in the wxerlang build instruction it is said that the wxWidgets build should be static. Because the wxerlang driver has been built successfully and that it need a dynamic library, it didn't occurred to me that building wxWidgets and Erlang in the right order would solve the problem. Anyway, thanks for letting me know this. I think it would be great if the build instructions could reflect that*, or if by default Erland is not built with wxWidgets support unless a correct static library is found. Best Regards, Cam (*) that is, tell the user that on Mac OS X the wxWidgets system library will not be used, and that a fresh build must be made before building Erlang. On Fri, Apr 3, 2009 at 7:58 AM, Dan Gudmundsson wrote: > On Mac OS X you will need to compile and install wxWidgets by yourself, > before compiling erlang. The wxWidgets libs that are included with Mac OS X > Leopard is old and is missing some things I require, (e.g. wxStyledTextCtrl > which provides erlang syntax highlighting). > > See compiling instructions here: > > http://apps.sourceforge.net/mediawiki/wxerlang/index.php?title=Getting_Started > > /Dan > > Camille Troillard wrote: > >> Hi Steve, >> >> >> >> On Thu, Apr 2, 2009 at 2:06 PM, Steve Davis < >> steven.charles.davis@REDACTED > >> wrote: >> >> >> I've been working on a library that does much of what you describe. It >> wraps for the cross-platform GUI library 'wx' that appeared in R13A >> release of Erlang/OTP. >> >> >> Yes, I have tested that on Windows and it worked well. >> However, on Mac OS X it compiles but I get : >> >> Erlang R13A (erts-5.7) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] >> [kernel-poll:false] >> >> Eshell V5.7 (abort with ^G) >> 1> sudoku:start(). >> <0.34.0> >> 2> =ERROR REPORT==== 2-Apr-2009::22:06:50 === >> WX Failed loading >> "wxe_driver"@"/usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0" >> ** exception error: >> {load_driver,"dlopen(/usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0/wxe_driver.so, >> 2): Symbol not found: __ZN10wxGLCanvas20MacVisibilityChangedEv\n Referenced >> from: >> /usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0/wxe_driver.so\n >> Expected in: flat namespace\n"} >> in function wxe_server:start/0 >> in call from wx:new/0 >> in call from sudoku_gui:new/1 >> in call from timer:tc/3 >> in call from sudoku:tc/3 >> in call from sudoku:init/1 >> >> I didn't find the origin of this problem. >> However, I searched and found the symbol was defined in the wxWidgets >> library included with Mac OS X (libwx_macud_gl-2.8.0.1.1.dylib). Why the >> library is not dynamically loaded is a mystery to me. >> >> >> >> This interface runs the UI as a separate process (a gen_server), it >> allows you to specify the application GUI in XML which makes it very >> easy to design/modify/update. It allows you to pass in a callback >> module to use for the UI issued commands. So it's pretty close to your >> design target. >> >> >> It looks very interesting. >> However, my application will need to use a widespread format, so any user >> that has basic skill in HTML can write simple extensions. >> >> >> The problem is that I only started development of this library less >> than a month ago, it's as yet unfinished, and as yet badly documented >> as it's a work in rapid progress. >> >> However you may wish to keep an eye on: >> >> http://github.com/komone/gx >> >> >> I am interested in anything that touches close of far GUI and Erlang. >> I will have a look, thanks! >> >> >> >> Best, >> Cam >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From smiler@REDACTED Fri Apr 3 13:00:35 2009 From: smiler@REDACTED (Christian Axelsson) Date: Fri, 03 Apr 2009 13:00:35 +0200 Subject: [erlang-questions] Self-referencing anonymous functions? In-Reply-To: References: <87b18a720904021104s1a30207ei855fe6f3316e742b@mail.gmail.com> <9b08084c0904021119p17ccbf24xc2ef035958aa430d@mail.gmail.com> <49D5CCAD.9000504@lanil.mine.nu> Message-ID: <49D5EC53.9080103@lanil.mine.nu> Christian wrote: > On Fri, Apr 3, 2009 at 10:45, Christian Axelsson wrote: >> Joe Armstrong wrote: >>> 1> Cost = fun(F, [{N,C}|T]) -> N*C + F(F, T);(_,[])-> 0 end. >>> #Fun >>> 2> Cost(Cost, [{2,3},{4,5}]). >>> >>> Now you know why the book didn't have any examples of this :-) >> I've noticed that aswell :) >> Would it be a bad idea to introduce a keyword for self referencing >> anonymous functions? > > That discussion has been had several times on this list. I think > nothing is done because those that are capable of doing it don't feel > that it is important. The shell is just used for basic inspection and > evaluation, not for building systems. Get distel to compile into real > modules if you want more interactive development. If you want recusion > in real modules you can define a named function. Giving non-trivial > things a name is generally a good thing. It makes it much easier to > talk about. > > Anyway. > > Introducing a magical keyword that refers to the surrounding closure > would be a bad thing anyway. First for introducing yet another > keyword. Secondly because it is only referring to one surrounding fun > when erlang allow funs to return funs that return funs, and so on. True that. > The better approach would be to add an optional name that is scoped to > the fun-body. This way you can have multiple nested funs and they can > refer to the outer funs or itself, and the programmer can give them > meaningful names. This would allowed for scoped funs, much like the 'let'-keyword in ML, thats something I've been missing a bit in Erlang. Although it's not really that much of a hurdle :) /Christian From bbmaj7@REDACTED Fri Apr 3 13:17:15 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Fri, 3 Apr 2009 04:17:15 -0700 (PDT) Subject: [erlang-questions] segments of variable length In-Reply-To: <200904031214221225101@bluewin.ch> References: <200904031214221225101@bluewin.ch> Message-ID: <919007.46366.qm@web65515.mail.ac4.yahoo.com> > I receive from several machines messages and I would like to extract data. > My first approach was: > > handler(Data)-> > case Data of > <> > etc... > > My problem is that some segment have a fixed length (header, Status) and some > others a variable length (Time <= 6 bytes, UnitID <= 8 bytes). > My approach is bad. I thought to do: Segments = string:tokens(Data,",") > This separates the segments but I don't have their name > (header,unitid,time,status) ! > Could you advice me a better approach. My goal is to check each segment and make > actions according to their values. You need to define a message format such that the required information is present to determine how to parse the rest of the message. This isn't really an erlang-specific problem but erlang is very good at supporting this. As an example you could use erlang:term_to_binary() and binary_to_term() for the message encoding on the wire. binary_to_term() might fail if the message is incomplete. This is where the {packet, N} inet options for connect/listen come in, eg. {packet,2} will only return complete messages; the length header is added automatically on send and stripped on receive so you only need to do, eg. gen_tcp:send( Sock, term_to_binary( MessageTerm ) ) and if you receive {tcp, Sock, Data}, then it is safe to call MessageTerm = binary_to_term(Data) Check out the inet module documentation. There are lots of useful options. Hope that is useful -- Rich The new Internet Explorer 8 optimised for Yahoo!7: Faster, Safer, Easier. From tuscland@REDACTED Fri Apr 3 13:24:39 2009 From: tuscland@REDACTED (Camille Troillard) Date: Fri, 3 Apr 2009 13:24:39 +0200 Subject: [erlang-questions] IPC bus for Erlang? In-Reply-To: References: <542cb051-6391-437e-b5e9-10366d5c683f@z1g2000yqn.googlegroups.com> <49D5A57B.9090105@erix.ericsson.se> Message-ID: Dan, Just two more things: 1. It appears on Mac OS X Leopard that it is needed to instruction the wxerlang configure script to use the newly installed wxWidgets library, like this: cd wx ./configure --with-wxconfig=/usr/local/lib/wx-config/mac-unicode-release-static-2.8 2. in wxerlang, "make install" fails with the following error: olibrius:wx camille$ sudo make install Password: escript ./install.es @libdir@ escript: exception error: undefined function 'escript__install.io':format/2 in function 'escript__install.es__1238__757603__565159':main/1 in call from escript:run/2 in call from escript:start/1 in call from init:start_it/1 in call from init:start_em/1 make: *** [install] Error 127 Sorry, I am not proficient enough in escript to be able to fix that. I am using Erlang OTP R13A. Cheers, Cam On Fri, Apr 3, 2009 at 12:42 PM, Camille Troillard wrote: > Hi Dan, > OK, I understand: I have actually tried to build wxWidgets *after*installing Erlang. > I found some details to be a bit confusing: > > When Erlang is built, there is no warning about a deprecated or absent > version of wxWidgets. For me it's like everything was ready to go. Having > found that it was not the case, I have tried to follow wxerlang > instructions. > > So, in the wxerlang build instruction it is said that the wxWidgets build > should be static. Because the wxerlang driver has been built successfully > and that it need a dynamic library, it didn't occurred to me that building > wxWidgets and Erlang in the right order would solve the problem. > > Anyway, thanks for letting me know this. I think it would be great if the > build instructions could reflect that*, or if by default Erland is not built > with wxWidgets support unless a correct static library is found. > > > Best Regards, > Cam > > (*) that is, tell the user that on Mac OS X the wxWidgets system library > will not be used, and that a fresh build must be made before building > Erlang. > > > > On Fri, Apr 3, 2009 at 7:58 AM, Dan Gudmundsson wrote: > >> On Mac OS X you will need to compile and install wxWidgets by yourself, >> before compiling erlang. The wxWidgets libs that are included with Mac OS X >> Leopard is old and is missing some things I require, (e.g. wxStyledTextCtrl >> which provides erlang syntax highlighting). >> >> See compiling instructions here: >> >> http://apps.sourceforge.net/mediawiki/wxerlang/index.php?title=Getting_Started >> >> /Dan >> >> Camille Troillard wrote: >> >>> Hi Steve, >>> >>> >>> >>> On Thu, Apr 2, 2009 at 2:06 PM, Steve Davis < >>> steven.charles.davis@REDACTED > >>> wrote: >>> >>> >>> I've been working on a library that does much of what you describe. It >>> wraps for the cross-platform GUI library 'wx' that appeared in R13A >>> release of Erlang/OTP. >>> >>> >>> Yes, I have tested that on Windows and it worked well. >>> However, on Mac OS X it compiles but I get : >>> >>> Erlang R13A (erts-5.7) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] >>> [kernel-poll:false] >>> >>> Eshell V5.7 (abort with ^G) >>> 1> sudoku:start(). >>> <0.34.0> >>> 2> =ERROR REPORT==== 2-Apr-2009::22:06:50 === >>> WX Failed loading >>> "wxe_driver"@"/usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0" >>> ** exception error: >>> {load_driver,"dlopen(/usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0/wxe_driver.so, >>> 2): Symbol not found: __ZN10wxGLCanvas20MacVisibilityChangedEv\n Referenced >>> from: >>> /usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0/wxe_driver.so\n >>> Expected in: flat namespace\n"} >>> in function wxe_server:start/0 >>> in call from wx:new/0 >>> in call from sudoku_gui:new/1 >>> in call from timer:tc/3 >>> in call from sudoku:tc/3 >>> in call from sudoku:init/1 >>> >>> I didn't find the origin of this problem. >>> However, I searched and found the symbol was defined in the wxWidgets >>> library included with Mac OS X (libwx_macud_gl-2.8.0.1.1.dylib). Why the >>> library is not dynamically loaded is a mystery to me. >>> >>> >>> >>> This interface runs the UI as a separate process (a gen_server), it >>> allows you to specify the application GUI in XML which makes it very >>> easy to design/modify/update. It allows you to pass in a callback >>> module to use for the UI issued commands. So it's pretty close to your >>> design target. >>> >>> >>> It looks very interesting. >>> However, my application will need to use a widespread format, so any user >>> that has basic skill in HTML can write simple extensions. >>> >>> >>> The problem is that I only started development of this library less >>> than a month ago, it's as yet unfinished, and as yet badly documented >>> as it's a work in rapid progress. >>> >>> However you may wish to keep an eye on: >>> >>> http://github.com/komone/gx >>> >>> >>> I am interested in anything that touches close of far GUI and Erlang. >>> I will have a look, thanks! >>> >>> >>> >>> Best, >>> Cam >>> >>> >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Fri Apr 3 13:32:45 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 03 Apr 2009 13:32:45 +0200 Subject: [erlang-questions] accept part of a server In-Reply-To: <200904031140573691220@bluewin.ch> References: <200904031140573691220@bluewin.ch> Message-ID: <1238758365.4604.5.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, If you do 1), and want to use an active socket, you will have to assign a new controlling process Pid to S. If you do 2) the right process is already in control. LS is not a problem, since the accept call does not have to be issued from the socket owner process. Read http://erlang.org/doc/man/gen_tcp.html for more information. bengt On Fri, 2009-04-03 at 11:40 +0200, Gamoto wrote: > I saw two approaches for the accept part of a server: > > Approach 1: > do_accept(LS)-> > case gen_tcp:accept(LS) of > {ok,S}->spawn(...handle(S)...), > do_accept(LS); > Other-> ... > end. > > Approach 2): > do_accept(LS)-> > case gen_tcp:accept(LS) of > {ok,S}-> spawn(...do_accept(LS) ...), > handle(S); > Other-> ... > end. > > What is the better approach and the criteria for chosing (crash, supervision, ...) ? > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From tobbe@REDACTED Fri Apr 3 14:14:41 2009 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Fri, 03 Apr 2009 14:14:41 +0200 Subject: [erlang-questions] RPC from linkedin driver References: <722837.22586.qm@web31810.mail.mud.yahoo.com> Message-ID: <87ab6yhr2m.fsf@sej.hq.kred> Kenneth Lundin writes: > We are working on significant performance improvements and new API's for > XMERL. Hm...talking about xmerl. It seems like xmerl's xsd functionality doesn't like when you break out, e.g a complexType declaration from where it is referred to. So validating this: With: is fine, but with this: I get: {error,[{[],xmerl_xsd, {reference_undeclared,simpleType, {simpleType,{tLabel,[],[]}}}}]} ? Tobbe > > The new XMERL will be at least 4 times faster than the current > version. The base for this is a completely new > SAX parser that you also can use directly with new API's. > > The memory consumption will also be significantly reduced. > > /Kenneth Erlang/OTP Ericsson > > On Tue, Mar 31, 2009 at 8:13 PM, Yogish Baliga wrote: >> >> I am currently working on developing a linkedin driver (c language) for XML parser (xmerl is too slow). This is a SAX parser is given the following input: >> >> 1. XML to be parsed >> 2. Call back functions (MFA) for start of node, end of node and for text elements >> >> I found C APIs to do RPC calls from c-node (ei_rpc). This require ei_cnode and fd parameters. That means I need to run the port as a c-node. >> >> Is it possible to do RPC from linkedin driver without converting linkedin driver as a c-node? >> >> Thanx, >> -- baliga >> >> >> "The quality of programmers is a decreasing function of the density of GOTO statements in the programs they produce." - Edsger W. Dijkstra >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> -- KREDITOR EUROPE AB S:t Eriksgatan 117 SE-113 43 Stockholm, Sweden Tel: +46(0)8-120 120 00 Fax: +46(0)8-120 120 99 Email: torbjorn.tornkvist@REDACTED Web: www.kreditor.se From dgud@REDACTED Fri Apr 3 14:29:07 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Fri, 03 Apr 2009 14:29:07 +0200 Subject: [erlang-questions] IPC bus for Erlang? In-Reply-To: References: <542cb051-6391-437e-b5e9-10366d5c683f@z1g2000yqn.googlegroups.com> <49D5A57B.9090105@erix.ericsson.se> Message-ID: <49D60113.2090100@erix.ericsson.se> I tried to add configure test for the mac leopard libs, but I obviously failed. My configure skills are rather limited. After you have built and installed wxwidgets. Add the install dir to the path, i.e. so that wx-config is found in the path unpack a freash r13a erlang, run ./configure && make && make install for the complete erlang package. The separate install script in wx library was intended for standalone wxErlang-releases before it was included in the erlang distribution. I have some more work to do.. Thanks. /Dan Camille Troillard wrote: > Dan, > > Just two more things: > > 1. It appears on Mac OS X Leopard that it is needed to instruction the > wxerlang configure script to use the newly installed wxWidgets library, > like this: > > cd wx > ./configure > --with-wxconfig=/usr/local/lib/wx-config/mac-unicode-release-static-2.8 > > 2. in wxerlang, "make install" fails with the following error: > > olibrius:wx camille$ sudo make install > Password: > escript ./install.es @libdir@ > escript: exception error: undefined function 'escript__install.io > ':format/2 > in function 'escript__install.es__1238__757603__565159':main/1 > in call from escript:run/2 > in call from escript:start/1 > in call from init:start_it/1 > in call from init:start_em/1 > make: *** [install] Error 127 > > Sorry, I am not proficient enough in escript to be able to fix that. > I am using Erlang OTP R13A. > > Cheers, > Cam > > > > On Fri, Apr 3, 2009 at 12:42 PM, Camille Troillard > wrote: > > Hi Dan, > > OK, I understand: I have actually tried to build wxWidgets /after/ > installing Erlang. > I found some details to be a bit confusing: > > When Erlang is built, there is no warning about a deprecated or > absent version of wxWidgets. For me it's like everything was ready > to go. Having found that it was not the case, I have tried to > follow wxerlang instructions. > > So, in the wxerlang build instruction it is said that the wxWidgets > build should be static. Because the wxerlang driver has been built > successfully and that it need a dynamic library, it didn't occurred > to me that building wxWidgets and Erlang in the right order would > solve the problem. > > Anyway, thanks for letting me know this. I think it would be great > if the build instructions could reflect that*, or if by default > Erland is not built with wxWidgets support unless a correct static > library is found. > > > Best Regards, > Cam > > (*) that is, tell the user that on Mac OS X the wxWidgets system > library will not be used, and that a fresh build must be made before > building Erlang. > > > > On Fri, Apr 3, 2009 at 7:58 AM, Dan Gudmundsson > > wrote: > > On Mac OS X you will need to compile and install wxWidgets by > yourself, before compiling erlang. The wxWidgets libs that are > included with Mac OS X Leopard is old and is missing some things > I require, (e.g. wxStyledTextCtrl which provides erlang syntax > highlighting). > > See compiling instructions here: > http://apps.sourceforge.net/mediawiki/wxerlang/index.php?title=Getting_Started > > /Dan > > Camille Troillard wrote: > > Hi Steve, > > > > On Thu, Apr 2, 2009 at 2:06 PM, Steve Davis > > >> wrote: > > > I've been working on a library that does much of what you > describe. It > wraps for the cross-platform GUI library 'wx' that > appeared in R13A > release of Erlang/OTP. > > > Yes, I have tested that on Windows and it worked well. > However, on Mac OS X it compiles but I get : > > Erlang R13A (erts-5.7) [source] [smp:2:2] [rq:2] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7 (abort with ^G) > 1> sudoku:start(). > <0.34.0> > 2> =ERROR REPORT==== 2-Apr-2009::22:06:50 === > WX Failed loading > "wxe_driver"@"/usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0" > ** exception error: > {load_driver,"dlopen(/usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0/wxe_driver.so, > 2): Symbol not found: > __ZN10wxGLCanvas20MacVisibilityChangedEv\n Referenced from: > /usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0/wxe_driver.so\n > Expected in: flat namespace\n"} > in function wxe_server:start/0 > in call from wx:new/0 > in call from sudoku_gui:new/1 > in call from timer:tc/3 > in call from sudoku:tc/3 > in call from sudoku:init/1 > > I didn't find the origin of this problem. > However, I searched and found the symbol was defined in the > wxWidgets library included with Mac OS X > (libwx_macud_gl-2.8.0.1.1.dylib). Why the library is not > dynamically loaded is a mystery to me. > > > > This interface runs the UI as a separate process (a > gen_server), it > allows you to specify the application GUI in XML which > makes it very > easy to design/modify/update. It allows you to pass in a > callback > module to use for the UI issued commands. So it's pretty > close to your > design target. > > > It looks very interesting. > However, my application will need to use a widespread > format, so any user that has basic skill in HTML can write > simple extensions. > > > The problem is that I only started development of this > library less > than a month ago, it's as yet unfinished, and as yet > badly documented > as it's a work in rapid progress. > > However you may wish to keep an eye on: > > http://github.com/komone/gx > > > I am interested in anything that touches close of far GUI > and Erlang. > I will have a look, thanks! > > > > Best, > Cam > > > ------------------------------------------------------------------------ > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From kunthar@REDACTED Fri Apr 3 14:49:51 2009 From: kunthar@REDACTED (Kunthar) Date: Fri, 3 Apr 2009 15:49:51 +0300 Subject: [erlang-questions] Math pow Message-ID: <9a09ca9a0904030549i5dcabeeawfc3aafff7985bcc0@mail.gmail.com> New shell R13A: > random:uniform(math:pow(2, 48)). ** exception error: no function clause matching random:uniform(281474976710656.0) Old shell R12B: > random:uniform(math:pow(2, 48)). 44982915740374 Any comments? From hasan.veldstra@REDACTED Fri Apr 3 14:58:59 2009 From: hasan.veldstra@REDACTED (Hasan Veldstra) Date: Fri, 3 Apr 2009 13:58:59 +0100 Subject: [erlang-questions] Math pow In-Reply-To: <9a09ca9a0904030549i5dcabeeawfc3aafff7985bcc0@mail.gmail.com> References: <9a09ca9a0904030549i5dcabeeawfc3aafff7985bcc0@mail.gmail.com> Message-ID: <9C899215-0F67-449E-B9DF-581122E732D3@gmail.com> On 3 Apr 2009, at 13:49PM, Kunthar wrote: > New shell R13A: >> random:uniform(math:pow(2, 48)). > ** exception error: no function clause matching > random:uniform(281474976710656.0) > > Old shell R12B: >> random:uniform(math:pow(2, 48)). > 44982915740374 > > Any comments? A guess ? random:uniform does not accept floats anymore? /Hasan From bertil.karlsson@REDACTED Fri Apr 3 15:06:29 2009 From: bertil.karlsson@REDACTED (Bertil Karlsson) Date: Fri, 03 Apr 2009 15:06:29 +0200 Subject: [erlang-questions] RPC from linkedin driver In-Reply-To: <87ab6yhr2m.fsf@sej.hq.kred> References: <722837.22586.qm@web31810.mail.mud.yahoo.com> <87ab6yhr2m.fsf@sej.hq.kred> Message-ID: <49D609D5.2090107@ericsson.com> Works fine for me. Maybe I didn't got your failed case exactly. I changed namespaces. My examples (with your content) below. mytest2.xsd mytest3.xsd and 1> {E,_}=xmerl_scan:string("",[]). 2> {ok,S2} = xmerl_xsd:process_schema("mytest2.xsd"). 3> xmerl_xsd:validate(E,S2). 4> {ok,S3} = xmerl_xsd:process_schema("mytest3.xsd"). 5> xmerl_xsd:validate(E,S3). all working as expected. /Bertil Torbjorn Tornkvist wrote: > Kenneth Lundin writes: > > >> We are working on significant performance improvements and new API's for >> XMERL. >> > > Hm...talking about xmerl. It seems like xmerl's xsd functionality > doesn't like when you break out, e.g a complexType declaration from > where it is referred to. > > So validating this: > > With: > > > > > > > > is fine, but with this: > > > > > > > > I get: > > {error,[{[],xmerl_xsd, > {reference_undeclared,simpleType, > {simpleType,{tLabel,[],[]}}}}]} > > > ? Tobbe > > > >> The new XMERL will be at least 4 times faster than the current >> version. The base for this is a completely new >> SAX parser that you also can use directly with new API's. >> >> The memory consumption will also be significantly reduced. >> >> /Kenneth Erlang/OTP Ericsson >> >> On Tue, Mar 31, 2009 at 8:13 PM, Yogish Baliga wrote: >> >>> I am currently working on developing a linkedin driver (c language) for XML parser (xmerl is too slow). This is a SAX parser is given the following input: >>> >>> 1. XML to be parsed >>> 2. Call back functions (MFA) for start of node, end of node and for text elements >>> >>> I found C APIs to do RPC calls from c-node (ei_rpc). This require ei_cnode and fd parameters. That means I need to run the port as a c-node. >>> >>> Is it possible to do RPC from linkedin driver without converting linkedin driver as a c-node? >>> >>> Thanx, >>> -- baliga >>> >>> >>> "The quality of programmers is a decreasing function of the density of GOTO statements in the programs they produce." - Edsger W. Dijkstra >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >>> > > From gamoto@REDACTED Fri Apr 3 15:12:32 2009 From: gamoto@REDACTED (Gamoto) Date: Fri, 3 Apr 2009 15:12:32 +0200 Subject: [erlang-questions] segments of variable length References: <200904031214221225101@bluewin.ch>, <919007.46366.qm@web65515.mail.ac4.yahoo.com> Message-ID: <200904031512319296028@bluewin.ch> May I understand like this ? handler(Data) -> case binary_to_term(Data) of {Header,UnitID,Time,Status} -> case Status of {1} -> ... etc... case UnitID of {1234} -> ... erc... > > >> I receive from several machines messages and I would like to extract data. >> My first approach was: >> >> handler(Data)-> >> case Data of >> <> >> etc... >> >> My problem is that some segment have a fixed length (header, Status) and some >> others a variable length (Time <= 6 bytes, UnitID <= 8 bytes). >> My approach is bad. I thought to do: Segments = string:tokens(Data,",") >> This separates the segments but I don't have their name >> (header,unitid,time,status) ! >> Could you advice me a better approach. My goal is to check each segment and make >> actions according to their values. > >You need to define a message format such that the required information is present to determine how to parse the rest of the message. This isn't really an erlang-specific problem but erlang is very good at supporting this. > >As an example you could use erlang:term_to_binary() and binary_to_term() for the message encoding on the wire. binary_to_term() might fail if the message is incomplete. This is where the {packet, N} inet options for connect/listen come in, eg. {packet,2} will only return complete messages; the length header is added automatically on send and stripped on receive so you only need to do, eg. > >gen_tcp:send( Sock, term_to_binary( MessageTerm ) ) > >and if you receive {tcp, Sock, Data}, then it is safe to call > >MessageTerm = binary_to_term(Data) > >Check out the inet module documentation. There are lots of useful options. > >Hope that is useful > >-- > Rich > > > The new Internet Explorer 8 optimised for Yahoo!7: Faster, Safer, Easier. From ext@REDACTED Fri Apr 3 15:29:58 2009 From: ext@REDACTED (David Sveningsson) Date: Fri, 03 Apr 2009 15:29:58 +0200 Subject: [erlang-questions] Math pow In-Reply-To: <9C899215-0F67-449E-B9DF-581122E732D3@gmail.com> References: <9a09ca9a0904030549i5dcabeeawfc3aafff7985bcc0@mail.gmail.com> <9C899215-0F67-449E-B9DF-581122E732D3@gmail.com> Message-ID: <49D60F56.4080604@sidvind.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hasan Veldstra wrote: > On 3 Apr 2009, at 13:49PM, Kunthar wrote: > >> New shell R13A: >>> random:uniform(math:pow(2, 48)). >> ** exception error: no function clause matching >> random:uniform(281474976710656.0) >> >> Old shell R12B: >>> random:uniform(math:pow(2, 48)). >> 44982915740374 >> >> Any comments? > > A guess ? random:uniform does not accept floats anymore? Correct, it doesn't accept floats any more, but strangely enough still truncates the input: - -spec uniform(pos_integer()) -> pos_integer(). uniform(N) when is_integer(N), N >= 1 -> trunc(uniform() * N) + 1. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAknWD1YACgkQ6pa1H/H5pqXKiACg2xBUP0/AHVgUq3voHCY6Wzhn Km8AoIF8GqFNzbCLHwCZnzFBLctv46mT =34PM -----END PGP SIGNATURE----- From vychodil.hynek@REDACTED Fri Apr 3 15:33:40 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 3 Apr 2009 15:33:40 +0200 Subject: [erlang-questions] Math pow In-Reply-To: <9a09ca9a0904030549i5dcabeeawfc3aafff7985bcc0@mail.gmail.com> References: <9a09ca9a0904030549i5dcabeeawfc3aafff7985bcc0@mail.gmail.com> Message-ID: <4d08db370904030633k2920567m978a5b430d5c033c@mail.gmail.com> try random:uniform(1 bsl 48) instead. On Fri, Apr 3, 2009 at 2:49 PM, Kunthar wrote: > New shell R13A: > > random:uniform(math:pow(2, 48)). > ** exception error: no function clause matching > random:uniform(281474976710656.0) > > Old shell R12B: > > random:uniform(math:pow(2, 48)). > 44982915740374 > > Any comments? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tuscland@REDACTED Fri Apr 3 17:34:34 2009 From: tuscland@REDACTED (Camille Troillard) Date: Fri, 3 Apr 2009 17:34:34 +0200 Subject: [erlang-questions] Building wxerlang [Was: IPC bus for Erlang?] Message-ID: Hello Dan, I think I am getting close to having wxerlang running on Mac OS X. However, there is a last problem in wxerlang building process you should know about. In the OTP R13A release notes, it is recommended for Darwin (Mac OS X) users to build Erlang with --enable-darwin64bits option. That doesn't work, "./configure --enable-hipe" worked fine on OS X and wxerlang is now working on my system, thanks. Best, Cam On Fri, Apr 3, 2009 at 2:29 PM, Dan Gudmundsson wrote: > I tried to add configure test for the mac leopard libs, but I obviously > failed. > My configure skills are rather limited. > > After you have built and installed wxwidgets. > Add the install dir to the path, i.e. so that wx-config is found in the > path > > unpack a freash r13a erlang, > run ./configure && make && make install for the complete erlang package. > > The separate install script in wx library was intended for standalone > wxErlang-releases > before it was included in the erlang distribution. I have some more work to > do.. > Thanks. > > /Dan > > Camille Troillard wrote: > >> Dan, >> >> Just two more things: >> >> 1. It appears on Mac OS X Leopard that it is needed to instruction the >> wxerlang configure script to use the newly installed wxWidgets library, like >> this: >> >> cd wx >> ./configure >> --with-wxconfig=/usr/local/lib/wx-config/mac-unicode-release-static-2.8 >> >> 2. in wxerlang, "make install" fails with the following error: >> >> olibrius:wx camille$ sudo make install >> Password: >> escript ./install.es @libdir@ >> escript: exception error: undefined function 'escript__install.io < >> http://escript__install.io>':format/2 >> in function 'escript__install.es__1238__757603__565159':main/1 >> in call from escript:run/2 >> in call from escript:start/1 >> in call from init:start_it/1 >> in call from init:start_em/1 >> make: *** [install] Error 127 >> >> Sorry, I am not proficient enough in escript to be able to fix that. >> I am using Erlang OTP R13A. >> >> Cheers, >> Cam >> >> >> >> On Fri, Apr 3, 2009 at 12:42 PM, Camille Troillard > tuscland@REDACTED>> wrote: >> >> Hi Dan, >> >> OK, I understand: I have actually tried to build wxWidgets /after/ >> installing Erlang. >> I found some details to be a bit confusing: >> >> When Erlang is built, there is no warning about a deprecated or >> absent version of wxWidgets. For me it's like everything was ready >> to go. Having found that it was not the case, I have tried to >> follow wxerlang instructions. >> >> So, in the wxerlang build instruction it is said that the wxWidgets >> build should be static. Because the wxerlang driver has been built >> successfully and that it need a dynamic library, it didn't occurred >> to me that building wxWidgets and Erlang in the right order would >> solve the problem. >> >> Anyway, thanks for letting me know this. I think it would be great >> if the build instructions could reflect that*, or if by default >> Erland is not built with wxWidgets support unless a correct static >> library is found. >> >> >> Best Regards, >> Cam >> >> (*) that is, tell the user that on Mac OS X the wxWidgets system >> library will not be used, and that a fresh build must be made before >> building Erlang. >> >> >> >> On Fri, Apr 3, 2009 at 7:58 AM, Dan Gudmundsson >> > wrote: >> >> On Mac OS X you will need to compile and install wxWidgets by >> yourself, before compiling erlang. The wxWidgets libs that are >> included with Mac OS X Leopard is old and is missing some things >> I require, (e.g. wxStyledTextCtrl which provides erlang syntax >> highlighting). >> >> See compiling instructions here: >> >> http://apps.sourceforge.net/mediawiki/wxerlang/index.php?title=Getting_Started >> >> /Dan >> >> Camille Troillard wrote: >> >> Hi Steve, >> >> >> >> On Thu, Apr 2, 2009 at 2:06 PM, Steve Davis >> > >> > >> wrote: >> >> >> I've been working on a library that does much of what you >> describe. It >> wraps for the cross-platform GUI library 'wx' that >> appeared in R13A >> release of Erlang/OTP. >> >> >> Yes, I have tested that on Windows and it worked well. >> However, on Mac OS X it compiles but I get : >> >> Erlang R13A (erts-5.7) [source] [smp:2:2] [rq:2] >> [async-threads:0] [hipe] [kernel-poll:false] >> >> Eshell V5.7 (abort with ^G) >> 1> sudoku:start(). >> <0.34.0> >> 2> =ERROR REPORT==== 2-Apr-2009::22:06:50 === >> WX Failed loading >> >> "wxe_driver"@"/usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0" >> ** exception error: >> >> {load_driver,"dlopen(/usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0/wxe_driver.so, >> 2): Symbol not found: >> __ZN10wxGLCanvas20MacVisibilityChangedEv\n Referenced from: >> >> /usr/local/lib/erlang/lib/wx-0.98/priv/i386-apple-darwin9.6.0/wxe_driver.so\n >> Expected in: flat namespace\n"} >> in function wxe_server:start/0 >> in call from wx:new/0 >> in call from sudoku_gui:new/1 >> in call from timer:tc/3 >> in call from sudoku:tc/3 >> in call from sudoku:init/1 >> >> I didn't find the origin of this problem. >> However, I searched and found the symbol was defined in the >> wxWidgets library included with Mac OS X >> (libwx_macud_gl-2.8.0.1.1.dylib). Why the library is not >> dynamically loaded is a mystery to me. >> >> >> >> This interface runs the UI as a separate process (a >> gen_server), it >> allows you to specify the application GUI in XML which >> makes it very >> easy to design/modify/update. It allows you to pass in a >> callback >> module to use for the UI issued commands. So it's pretty >> close to your >> design target. >> >> >> It looks very interesting. >> However, my application will need to use a widespread >> format, so any user that has basic skill in HTML can write >> simple extensions. >> >> >> The problem is that I only started development of this >> library less >> than a month ago, it's as yet unfinished, and as yet >> badly documented >> as it's a work in rapid progress. >> >> However you may wish to keep an eye on: >> >> http://github.com/komone/gx >> >> >> I am interested in anything that touches close of far GUI >> and Erlang. >> I will have a look, thanks! >> >> >> >> Best, >> Cam >> >> >> >> ------------------------------------------------------------------------ >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED > erlang-questions@REDACTED> >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryeguy1@REDACTED Fri Apr 3 17:52:21 2009 From: ryeguy1@REDACTED (ryeguy) Date: Fri, 3 Apr 2009 08:52:21 -0700 (PDT) Subject: [erlang-questions] Where can I use gen_server? In-Reply-To: <1238738951.19365.41.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> References: <1238595132.19996.11.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <1238655645.19996.20.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <1c7c9d5b-0901-4c97-ba0c-f93c765983db@g19g2000yql.googlegroups.com> <1238738951.19365.41.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Message-ID: <61bf23ee-d6b3-43cf-accd-03ec272e68be@j39g2000yqn.googlegroups.com> It's going to be from multiple processes, but right now I'm just doing it from the shell to get it working. All I'm trying to do is find out why all requests are taken down with the gen_server when it crashes? If it does this, then what is the difference between start and start_link? On Apr 3, 2:09?am, Bengt Kleberg wrote: > OK, you have one globally registered server that pretends to an instance > of (the future) fleet of servers. > > How do you call this one server? From one process or many? > > bengt > > > > On Thu, 2009-04-02 at 08:12 -0700, ryeguy wrote: > > Yeah sorry that's just test code mostly. I DO want one per client, ?I > > would actually globally register each as {player, <<"username">>}. I'm > > just trying to get this working first. > > > On Apr 2, 3:00 am, Bengt Kleberg wrote: > > > Greetings, > > > > It is not obvious to me how you use the gen_server below. You are > > > registering it as global, but I understood your explanation below as if > > > you wanted a separate gen_server for each client. > > > Is the idea to have one gen_server, or one per client? > > > > bengt > > > > On Wed, 2009-04-01 at 19:34 -0700, ryeguy wrote: > > > > Well why doesn't this work then? > > > > > start() ? ? ? ? ? ? ? -> gen_server:start({global, ?MODULE}, ?MODULE, > > > > [], []). > > > > stop() ? ? ? ? ? ? ? ?-> gen_server:call({global, ?MODULE}, stop). > > > > test() ? ? ? ? ? ? ? ?-> gen_server:cast({global, ?MODULE}, test). > > > > test2() ? ? ? ? ? ? ? ?-> gen_server:cast({global, ?MODULE}, test2). > > > > > init([]) ->process_flag(trap_exit, true), > > > > ? ? {ok, 0}. > > > > > handle_cast(test, State) -> > > > > ? ?timer:sleep(3000), > > > > ? ?io:format("asdasd"), > > > > ? ?{noreply, State}; > > > > handle_cast(test2, State) -> > > > > ? ?timer:sleep(3000), > > > > ? ?3=4, ? ? ? ? ? ? ? ? %%% deliberate error > > > > ? ?{noreply, State}. > > > > > handle_call(stop, _From, State) -> > > > > ? ? {stop, normal, stopped, State}; > > > > handle_call(test2, _From, State) -> > > > > ? ?3=4, > > > > ? ? {noreply, State}. > > > > > handle_info(_Info, State) -> > > > > ? ? {noreply, State}. > > > > > terminate(_Reason, _State) -> > > > > ? ? ok. > > > > > code_change(_OldVsn, State, _Extra) -> > > > > ? ? {ok, State}. > > > > > When I call test2() then call test(), test2 (obviously) crashes, but > > > > test() appears to be terminated too. > > > > > On Apr 1, 10:12 am, Bengt Kleberg wrote: > > > > > Greetings, > > > > > > If you start a gen_server with start_link() it will take its clients > > > > > with it. If you start with start() the clients will remain. > > > > > > bengt > > > > > > On Mon, 2009-03-30 at 19:29 -0700, ryeguy wrote: > > > > > > I'm making a game server, and I just can't see where I would want to > > > > > > use a gen_server. I'm not set on using one, but I don't want to skimp > > > > > > on using one where it would make it easier to program this app. > > > > > > > What I have per node is this: I have 1 process accepting new > > > > > > connections, which spawns a new process for each new client. For each > > > > > > packet that comes in, a new process is spawned to handle it and then > > > > > > it sends the result back to the listening process and terminates. > > > > > > > It sounds like a good candidate for gen_server, but per the docs it > > > > > > seems you want to use them when there is some shared resource that you > > > > > > want to manage, and I don't see one. If I gave each client their own > > > > > > gen_server, it wouldn't be good because if an erroneous packet was > > > > > > sent that caused an exception, it would terminate their connection and > > > > > > any other packets being processed for this client (since a gen_server > > > > > > takes all of its spawned processes down with it, right?). > > > > > > > Is there any advantage to using gen_server in my situation? > > > > > > _______________________________________________ > > > > > > erlang-questions mailing list > > > > > > erlang-questi...@REDACTED > > > > > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > _______________________________________________ > > > > > erlang-questions mailing list > > > > > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questi...@REDACTED > > > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From raould@REDACTED Fri Apr 3 18:00:54 2009 From: raould@REDACTED (Raoul Duke) Date: Fri, 3 Apr 2009 09:00:54 -0700 Subject: [erlang-questions] local vs. distributed differences? Message-ID: <91a2ba3e0904030900q11754d0eq186eb3f0a7a5a7c@mail.gmail.com> hi, reading the McErlang stuff, i learned that message delivery order is only guaranteed when things aren't distributed. (looking around on the net, it i've heard that it is further only when you have multiple messages going from the same sender to the same receiver.) so it sounds like taking a multi-actor local system and then trying to scale out by moving to a bigger distributed system could turn up some interesting "bugs". what are people's experience with this? (and, as an aside, could the Erlang system be hacked to enforce ordering even in a distributed setup? would that ever be useful, or just silly?) thank you. From gamoto@REDACTED Fri Apr 3 18:07:45 2009 From: gamoto@REDACTED (Gamoto) Date: Fri, 3 Apr 2009 18:07:45 +0200 Subject: [erlang-questions] accept - server Message-ID: <200904031807453831370@bluewin.ch> I saw two approaches for the accept part of a server: Approach 1) do_accept(LS)-> case gen_tcp:accept(LS) of {ok,S}->spawn(...handle(S)...), do_accept(LS); Other-> ... end. Approach 2) do_accept(LS)-> case gen_tcp:accept(LS) of {ok,S}-> spawn(...do_accept(LS) ...), handle(S); Other-> ... end. The gen_tcp documentation doesn't explain what is the better approach according criteria (crash of one instance of handle, supervision, etc.) What is your experience ? From gamoto@REDACTED Fri Apr 3 18:13:06 2009 From: gamoto@REDACTED (Gamoto) Date: Fri, 3 Apr 2009 18:13:06 +0200 Subject: [erlang-questions] segments of variable length References: <200904031214221225101@bluewin.ch>, <919007.46366.qm@web65515.mail.ac4.yahoo.com> Message-ID: <200904031813061430718@bluewin.ch> -module(aa). -define(X,<<131,107,0,18,36,65,86,82,77,67,44,49,50,51,52,44,49,53,49,55,51,54>>). -export([start/0]). start()-> case binary_to_term(?X) of {<>}-> io:format("Header = ~s~n",[H]), io:format("Unit ID = ~s~n",[U]), io:format("Time = ~s~n",[T]) end. This gives me an error. I was waiting for Header = $AVRMC Unit ID = 1234 Time = 151736 The most important for me is to obtain H,U and T > > >> I receive from several machines messages and I would like to extract data. >> My first approach was: >> >> handler(Data)-> >> case Data of >> <> >> etc... >> >> My problem is that some segment have a fixed length (header, Status) and some >> others a variable length (Time <= 6 bytes, UnitID <= 8 bytes). >> My approach is bad. I thought to do: Segments = string:tokens(Data,",") >> This separates the segments but I don't have their name >> (header,unitid,time,status) ! >> Could you advice me a better approach. My goal is to check each segment and make >> actions according to their values. > >You need to define a message format such that the required information is present to determine how to parse the rest of the message. This isn't really an erlang-specific problem but erlang is very good at supporting this. > >As an example you could use erlang:term_to_binary() and binary_to_term() for the message encoding on the wire. binary_to_term() might fail if the message is incomplete. This is where the {packet, N} inet options for connect/listen come in, eg. {packet,2} will only return complete messages; the length header is added automatically on send and stripped on receive so you only need to do, eg. > >gen_tcp:send( Sock, term_to_binary( MessageTerm ) ) > >and if you receive {tcp, Sock, Data}, then it is safe to call > >MessageTerm = binary_to_term(Data) > >Check out the inet module documentation. There are lots of useful options. > >Hope that is useful > >-- > Rich > > > The new Internet Explorer 8 optimised for Yahoo!7: Faster, Safer, Easier. From ulf.wiger@REDACTED Fri Apr 3 18:29:56 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Fri, 03 Apr 2009 18:29:56 +0200 Subject: [erlang-questions] local vs. distributed differences? In-Reply-To: <91a2ba3e0904030900q11754d0eq186eb3f0a7a5a7c@mail.gmail.com> References: <91a2ba3e0904030900q11754d0eq186eb3f0a7a5a7c@mail.gmail.com> Message-ID: <49D63984.3080207@erlang-consulting.com> Raoul Duke wrote: > hi, > > reading the McErlang stuff, i learned that message delivery order is > only guaranteed when things aren't distributed. (looking around on the > net, it i've heard that it is further only when you have multiple > messages going from the same sender to the same receiver.) > > so it sounds like taking a multi-actor local system and then trying to > scale out by moving to a bigger distributed system could turn up some > interesting "bugs". what are people's experience with this? > > (and, as an aside, could the Erlang system be hacked to enforce > ordering even in a distributed setup? would that ever be useful, or > just silly?) > > thank you. I think you can assume that Erlang /does/ guarantee ordering in distributed systems. The case when it doesn't can be eliminated using the same techniques as when guarding against partitioned network scenarios. As long as the link stays up between two nodes, the ordering is guaranteed. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From fess-erlang@REDACTED Fri Apr 3 18:48:33 2009 From: fess-erlang@REDACTED (fess) Date: Fri, 3 Apr 2009 09:48:33 -0700 Subject: [erlang-questions] Where can I use gen_server? In-Reply-To: <61bf23ee-d6b3-43cf-accd-03ec272e68be@j39g2000yqn.googlegroups.com> References: <1238595132.19996.11.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <1238655645.19996.20.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <1c7c9d5b-0901-4c97-ba0c-f93c765983db@g19g2000yql.googlegroups.com> <1238738951.19365.41.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <61bf23ee-d6b3-43cf-accd-03ec272e68be@j39g2000yqn.googlegroups.com> Message-ID: <9778D54C-0020-47E1-AAC7-B542ED17E8DB@fess.org> You are starting one gen_server, that itself responds to the messages sent via gen_server cast/call in serial, so if it crashes it will no longer get to any of the other things in it's message queue. I think you probably want to spawn a new process in your handle_cast, [ which is what your first email mentioned you wanted the server to do, handle connections then spawn a process to handle them. ] right now, you call test2() the server handles that message and crashes. there is no longer a server to handle the message sent by test(), messages sent to non existent processes silently go into the void. [ not to mention that gen_server:cast always returns ok. ] if you change the handle_cast(test, ... to: handle_cast(test, State) -> spawn( fun () -> timer:sleep(3000), io:format("asdasd") end ), {noreply, State}; and leave test2() alone so that it crashes the gen_server, then your test() casts will cause the gen_server to spawn a new proc to sleep and won't be effected by a gen_server crash. then you can call start(), test(), test2() which should get your io:format through. [ unless io:format goes somewhere else, then you can call io:format/3 but I usually just use error_logger:error_report/1 ] ie, server starts, gets a test message and spawns a proc to sleep and io:format, then gets a test2 message and crashes, the spawned proc continues because it's not linked to the parent and later does it's io:format. I think maybe that answers what your asking. if not, ask again. :) You should definitely use gen_server, or you'll probably end up approximating it. It's one of those things that's trivial once you got what it's doing. someone also posted gen_serv I think that reduced the amount of boilerplate you have to write. hope that helps. --fess On Apr 3, 2009, at 8:52 AM, ryeguy wrote: > All I'm trying to do is find out > why all requests are taken down with the gen_server when it crashes? On Apr 1, 2009, at 7:34 PM, ryeguy wrote: > Well why doesn't this work then? > > start() -> gen_server:start({global, ?MODULE}, ?MODULE, > [], []). > stop() -> gen_server:call({global, ?MODULE}, stop). > test() -> gen_server:cast({global, ?MODULE}, test). > test2() -> gen_server:cast({global, ?MODULE}, test2). > > init([]) ->process_flag(trap_exit, true), > {ok, 0}. > > handle_cast(test, State) -> > timer:sleep(3000), > io:format("asdasd"), > {noreply, State}; > handle_cast(test2, State) -> > timer:sleep(3000), > 3=4, %%% deliberate error > {noreply, State}. > > handle_call(stop, _From, State) -> > {stop, normal, stopped, State}; > handle_call(test2, _From, State) -> > 3=4, > {noreply, State}. > > handle_info(_Info, State) -> > {noreply, State}. > > terminate(_Reason, _State) -> > ok. > > code_change(_OldVsn, State, _Extra) -> > {ok, State}. > > When I call test2() then call test(), test2 (obviously) crashes, but > test() appears to be terminated too. --fess From mihai@REDACTED Fri Apr 3 18:51:39 2009 From: mihai@REDACTED (Mihai Balea) Date: Fri, 3 Apr 2009 12:51:39 -0400 Subject: [erlang-questions] local vs. distributed differences? In-Reply-To: <91a2ba3e0904030900q11754d0eq186eb3f0a7a5a7c@mail.gmail.com> References: <91a2ba3e0904030900q11754d0eq186eb3f0a7a5a7c@mail.gmail.com> Message-ID: On Apr 3, 2009, at 12:00 PM, Raoul Duke wrote: > hi, > > reading the McErlang stuff, i learned that message delivery order is > only guaranteed when things aren't distributed. (looking around on the > net, it i've heard that it is further only when you have multiple > messages going from the same sender to the same receiver.) > > so it sounds like taking a multi-actor local system and then trying to > scale out by moving to a bigger distributed system could turn up some > interesting "bugs". what are people's experience with this? > > (and, as an aside, could the Erlang system be hacked to enforce > ordering even in a distributed setup? would that ever be useful, or > just silly?) Here's my understanding: Let's say P1 sends M1 and then M2 to P2. Regardless of whether P1 and P2 run on different nodes, if P2 receives both messages, they are guaranteed to arrive in the order they were sent. Now let's say P1 sends M1 to P2 and M2 to P3. In this case, arrival order is not guaranteed, even when P1 and P2 are on the same node. Same goes for two processes sending messages to the same destination. Mihai From ryeguy1@REDACTED Fri Apr 3 21:34:53 2009 From: ryeguy1@REDACTED (ryeguy) Date: Fri, 3 Apr 2009 12:34:53 -0700 (PDT) Subject: [erlang-questions] Couple of questions about mnesia locking Message-ID: <18e85b62-ca61-475e-8260-4ec5080aa568@r37g2000yqn.googlegroups.com> If I wanted to check if a username is in use before registering an account like this: F=fun()-> case is_username_available(User) of %% does a mnesia:read to see if there is a record with that username false -> throw(username_in_use); true -> mnesia:write(User) end, mnesia:transaction(F). Don't I have a potential race condition here? Since there is no record to lock because it doesn't exist, how can mnesia guarantee another process isn't also going to write that same Username to the database? If I'm doing this wrong, what's the right way? A table lock (eww)? My second question is regarding a quote from the mnesia manual: "Write locks are normally acquired on all nodes where a replica of the table resides (and is active). Read locks are acquired on one node (the local one if a local replica exists). " What does it mean read locks are acquired on one node? What would happen when a table is distributed? Wouldn't that defeat the purpose? From ahmed.nawras@REDACTED Fri Apr 3 22:38:31 2009 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Sat, 4 Apr 2009 00:38:31 +0400 Subject: [erlang-questions] gen-event In-Reply-To: <1238584599.19996.6.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> References: <1238584599.19996.6.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Message-ID: I think gen_event is useful when you need multiple handlers for messages. Think of it as publish/subscribe pattern in other languages where gen_event handlers are basically subscribers. The classical example is a logger, error_logger being the erlang/OTP implementation. The same is used with log4erl. Regards, Ahmed On Wed, Apr 1, 2009 at 3:16 PM, Bengt Kleberg wrote: > Greetings, > > Have you read http://www.erlang.org/doc/man/gen_event.html ? > > > bengt > > On Wed, 2009-04-01 at 16:31 +0530, madan kumar wrote: >> >> what is the need of ?gen-event , allready we have gen server,gen-fsm >> send some examples ?using gen-event. >> -- >> Tallapalem Madan Kumar, >> Pyro Networks Pvt. Ltd., >> Hyderabad. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From steven.charles.davis@REDACTED Sat Apr 4 00:46:33 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Fri, 3 Apr 2009 15:46:33 -0700 (PDT) Subject: [erlang-questions] segments of variable length In-Reply-To: <200904031813061430718@bluewin.ch> References: <200904031214221225101@bluewin.ch>, <919007.46366.qm@web65515.mail.ac4.yahoo.com> <200904031813061430718@bluewin.ch> Message-ID: <8fb10e5f-fc16-42c9-92a4-cd55dc28bb90@y9g2000yqg.googlegroups.com> You were originally on the right track, but look back to the original implementation you had and ask yourself this question: --- When does the UnitID field _end_ and Time field _begin_? If you, as a human being looking at the binary, cannot be sure, then you cannot expect your program to determine that, hence... ...the two variable binary fields are "indeterminate" You need to find a way to flag where one ends and the next begins in the binary encoding. :) On Apr 3, 11:13?am, "Gamoto" wrote: > -module(aa). > -define(X,<<131,107,0,18,36,65,86,82,77,67,44,49,50,51,52,44,49,53,49,55,51 ,54>>). > -export([start/0]). > > start()-> > ? ?case binary_to_term(?X) of > ? ? ? ? ? ? {<>}-> > ? ? ? ? ? ? ?io:format("Header = ~s~n",[H]), > ? ? ? ? ? ? ?io:format("Unit ID = ~s~n",[U]), > ? ? ? ? ? ? ?io:format("Time = ~s~n",[T]) > ? ? ? ? end. > > This gives me an error. > I was waiting for > Header = $AVRMC > Unit ID = 1234 > Time = ?151736 > > The most important for me is to obtain H,U and T > > > > > > > > >> I receive from several machines messages and I would like to extract data. > >> My first approach was: > > >> handler(Data)-> > >> ? ? case Data of > >> ? ? ? ? <> > >> ? ? ? ? etc... > > >> My problem is that some segment have a fixed length (header, Status) and some > >> others a variable length (Time <= 6 bytes, UnitID <= 8 bytes). > >> My approach is bad. I thought to do: ? ? ?Segments = string:tokens(Data,",") > >> This separates the segments but I don't have their name > >> (header,unitid,time,status) ! > >> Could you advice me a better approach. My goal is to check each segment and make > >> actions according to their values. > > >You need to define a message format such that the required information is present to determine how to parse the rest of the message. This isn't really an erlang-specific problem but erlang is very good at supporting this. > > >As an example you could use erlang:term_to_binary() and binary_to_term() for the message encoding on the wire. binary_to_term() might fail if the message is incomplete. This is where the {packet, N} inet options for connect/listen come in, eg. {packet,2} will only return complete messages; the length header is added automatically on send and stripped on receive so you only need to do, eg. > > >gen_tcp:send( Sock, term_to_binary( MessageTerm ) ) > > >and if you receive {tcp, Sock, Data}, then it is safe to call > > >MessageTerm = binary_to_term(Data) > > >Check out the inet module documentation. There are lots of useful options. > > >Hope that is useful > > >-- > > ?Rich > > > ? ? ?The new Internet Explorer 8 optimised for Yahoo!7: Faster, Safer, Easier. > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From steven.charles.davis@REDACTED Sat Apr 4 13:06:45 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 4 Apr 2009 04:06:45 -0700 (PDT) Subject: [erlang-questions] Storing funs in term files Message-ID: Given that: 1> A = {echo, fun(X) -> X end}. {echo,#Fun} I have a scenario where it would be useful to store funs in term files, for example: % contents of the term file {echo, fun(X) -> X end}. 2>{ok, B} = file:consult("fun.term"). ** exception error: no match of right hand side value {error,{2,erl_parse,"bad term"}} Note that although the term file contents *passes the syntax checker*, the parser declares this to be a bad term. Is there a way to achieve this? If not, it seems odd to me that funs should be "second class citizens" in term files. Thanks! From bbmaj7@REDACTED Sat Apr 4 13:31:26 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Sat, 4 Apr 2009 04:31:26 -0700 (PDT) Subject: [erlang-questions] Couple of questions about mnesia locking In-Reply-To: <18e85b62-ca61-475e-8260-4ec5080aa568@r37g2000yqn.googlegroups.com> References: <18e85b62-ca61-475e-8260-4ec5080aa568@r37g2000yqn.googlegroups.com> Message-ID: <393375.16569.qm@web65508.mail.ac4.yahoo.com> > If I wanted to check if a username is in use before registering an > account like this: > > F=fun()-> > case is_username_available(User) of %% does a mnesia:read to see if > there is a record with that username > false -> throw(username_in_use); > true -> mnesia:write(User) > end, > > mnesia:transaction(F). > > Don't I have a potential race condition here? Since there is no record > to lock because it doesn't exist, how can mnesia guarantee another > process isn't also going to write that same Username to the database? > If I'm doing this wrong, what's the right way? A table lock (eww)? You could use a gatekeeper - a singleton process on only one node which is allowed to create usernames. Creators make a request to the gatekeeper which serialises the requests and therefore prevents the race. The problem then shifts to process registration consistency and takeover in the case of the gatekeeper failure. Sharding/splitting the gatekeeper responsibility by eg. username first letter would quarantine the damage from a gatekeeper failure. > My second question is regarding a quote from the mnesia manual: > "Write locks are normally acquired on all nodes where a replica of the > table resides (and is active). Read locks are acquired on one node > (the local one if a local replica exists). " > > What does it mean read locks are acquired on one node? What would > happen when a table is distributed? Wouldn't that defeat the purpose? A read lock on any node prevents a write lock from being acquired on that item. A write lock must be acquired on *all* nodes so it is sufficient to take a read lock on any one node to block a write lock from being acquired. -- Rich Enjoy a safer web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. From bbmaj7@REDACTED Sat Apr 4 12:52:13 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Sat, 4 Apr 2009 03:52:13 -0700 (PDT) Subject: [erlang-questions] segments of variable length In-Reply-To: <200904031813061430718@bluewin.ch> References: <200904031214221225101@bluewin.ch>, <919007.46366.qm@web65515.mail.ac4.yahoo.com> <200904031813061430718@bluewin.ch> Message-ID: <450909.33504.qm@web65516.mail.ac4.yahoo.com> > -module(aa). > -define(X,<<131,107,0,18,36,65,86,82,77,67,44,49,50,51,52,44,49,53,49,55,51,54>>). > -export([start/0]). > > start()-> > case binary_to_term(?X) of > {<>}-> > io:format("Header = ~s~n",[H]), > io:format("Unit ID = ~s~n",[U]), > io:format("Time = ~s~n",[T]) > end. > > This gives me an error. > I was waiting for > Header = $AVRMC > Unit ID = 1234 > Time = 151736 As a first experiment I would suggest something like the following (have not tested that this compiles) %% Simulate sending side X = term_to_binary( {myTag, H, U, T} ), %% Receiving side case binary_to_term(X) of {myTag, H, U, T} -> process_myTag( H, U, T ); _ -> error end. Enjoy a better web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. From gamoto@REDACTED Sat Apr 4 14:03:37 2009 From: gamoto@REDACTED (Gamoto) Date: Sat, 4 Apr 2009 14:03:37 +0200 Subject: [erlang-questions] segments of variable length References: <200904031214221225101@bluewin.ch>, <919007.46366.qm@web65515.mail.ac4.yahoo.com>, <200904031813061430718@bluewin.ch>, Message-ID: <200904041403365435127@bluewin.ch> Thank you Per. That was the good solution. I understood my faults now ... John hat is because you are sending the following binary encoded term: "$AVRMC,1234,151736" and you are matching that to {<>} and a string does not match a one-tuple with a three byte binary as only element. what you want is probably something like this: -module(aa). -define(X,<<131,107,0,18,36,65,86,82,77,67,44,49,50,51,52,44,49,53,49,55,51,54>>). -export([start/0]). start() -> case string:tokens(binary_to_term(?X), ",") of [H,U,T] -> io:format("Header = ~s~n",[H]), io:format("Unit ID = ~s~n",[U]), io:format("Time = ~s~n",[T]) end. The question is if the wire protocol isn't given this is not the easiest way to have two Erlang nodes talk. It would be far easier to say that the nodes should be sending binary encoded three-tuples to each other then you'd have something like this: -module(ab). -define(X, term_to_binary({"$AVRMC", 1234, 151736})). -export([start/0]). start() -> case binary_to_term(?X) of {H,U,T} -> io:format("Header = ~s~n",[H]), io:format("Unit ID = ~p~n",[U]), io:format("Time = ~p~n",[T]) end. Note that in this case Unit ID and Time would be numbers rather than strings. None of the code above has actually been tested so it might not compile. Per 2009/4/3 Gamoto -module(aa). -define(X,<<131,107,0,18,36,65,86,82,77,67,44,49,50,51,52,44,49,53,49,55,51,54>>). -export([start/0]). start()-> case binary_to_term(?X) of {<>}-> io:format("Header = ~s~n",[H]), io:format("Unit ID = ~s~n",[U]), io:format("Time = ~s~n",[T]) end. This gives me an error. I was waiting for Header = $AVRMC Unit ID = 1234 Time = 151736 The most important for me is to obtain H,U and T > > >> I receive from several machines messages and I would like to extract data. >> My first approach was: >> >> handler(Data)-> >> case Data of >> <> >> etc... >> >> My problem is that some segment have a fixed length (header, Status) and some >> others a variable length (Time <= 6 bytes, UnitID <= 8 bytes). >> My approach is bad. I thought to do: Segments = string:tokens(Data,",") >> This separates the segments but I don't have their name >> (header,unitid,time,status) ! >> Could you advice me a better approach. My goal is to check each segment and make >> actions according to their values. > >You need to define a message format such that the required information is present to determine how to parse the rest of the message. This isn't really an erlang-specific problem but erlang is very good at supporting this. > >As an example you could use erlang:term_to_binary() and binary_to_term() for the message encoding on the wire. binary_to_term() might fail if the message is incomplete. This is where the {packet, N} inet options for connect/listen come in, eg. {packet,2} will only return complete messages; the length header is added automatically on send and stripped on receive so you only need to do, eg. > >gen_tcp:send( Sock, term_to_binary( MessageTerm ) ) > >and if you receive {tcp, Sock, Data}, then it is safe to call > >MessageTerm = binary_to_term(Data) > >Check out the inet module documentation. There are lots of useful options. > >Hope that is useful > >-- > Rich > > > The new Internet Explorer 8 optimised for Yahoo!7: Faster, Safer, Easier. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From bbmaj7@REDACTED Sat Apr 4 14:04:50 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Sat, 4 Apr 2009 05:04:50 -0700 (PDT) Subject: [erlang-questions] local vs. distributed differences? In-Reply-To: <91a2ba3e0904030900q11754d0eq186eb3f0a7a5a7c@mail.gmail.com> References: <91a2ba3e0904030900q11754d0eq186eb3f0a7a5a7c@mail.gmail.com> Message-ID: <358062.43636.qm@web65501.mail.ac4.yahoo.com> > reading the McErlang stuff, i learned that message delivery order is > only guaranteed when things aren't distributed. (looking around on the > net, it i've heard that it is further only when you have multiple > messages going from the same sender to the same receiver.) > > so it sounds like taking a multi-actor local system and then trying to > scale out by moving to a bigger distributed system could turn up some > interesting "bugs". what are people's experience with this? In my experience order of delivery *is* guaranteed between any *two* processes. You can consider the vaguaries of network propagation time as being similar to unpredictable scheduling of processes. The same problem exists within a single node. eg. given processes A, B and C where A sends two messages to C and B sends one messages to C - the messages at C may be ordered: A1,A2,B1 or B1,A1,A2 or A1,B1,A2 depending on the relative scheduling of A and B. But A2 will always be after A1 in the mailbox. Same is true between nodes except that some messages may not be delivered at all. Yahoo!7 recommends that you update your browser to the new Internet Explorer 8.Get it now. From gamoto@REDACTED Sat Apr 4 14:38:16 2009 From: gamoto@REDACTED (Gamoto) Date: Sat, 4 Apr 2009 14:38:16 +0200 Subject: [erlang-questions] No timeout on connect Message-ID: <200904041438162228321@bluewin.ch> What is wrong in this code ? When I run it, without a listening server, after a few second, I have a timeout error !! infinity parameter is not correctly defined ? John -module(client). -export([start/0,wait/1]). start()-> case gen_tcp:connect("localhost",1688,[binary, {packet, 0}],infinity) of {ok,Socket}-> io:format("Socket established~n"), loop(Socket); {error,Reason} -> io:format("Error ! ~s~n",[Reason]) end. loop(Socket)-> gen_tcp:send(Socket,"1234"), wait(4000), loop(Socket). wait(Timeout)-> receive after Timeout-> 0 end. From zambal@REDACTED Sat Apr 4 15:26:40 2009 From: zambal@REDACTED (zambal) Date: Sat, 4 Apr 2009 06:26:40 -0700 (PDT) Subject: [erlang-questions] segments of variable length In-Reply-To: <200904041403365435127@bluewin.ch> References: <200904031214221225101@bluewin.ch>, <919007.46366.qm@web65515.mail.ac4.yahoo.com>, <200904031813061430718@bluewin.ch>, <200904041403365435127@bluewin.ch> Message-ID: On 4 apr, 14:03, "Gamoto" wrote: > > start()-> > ? case binary_to_term(?X) of > ? ? ? ? ? ?{<>}-> > ? ? ? ? ? ? io:format("Header = ~s~n",[H]), > ? ? ? ? ? ? io:format("Unit ID = ~s~n",[U]), > ? ? ? ? ? ? io:format("Time = ~s~n",[T]) > ? ? ? ?end. > > This gives me an error. > I was waiting for > Header = $AVRMC > Unit ID = 1234 > Time = ?151736 > > The most important for me is to obtain H,U and T If the data you're trying to recieve is send like this: term_to_binary( {$AVRMC, 1234, 151736} ) then your case statement should look like this: case binary_to_term(?X) of {H,U,T}-> io:format("Header = ~s~n",[H]), io:format("Unit ID = ~s~n",[U]), io:format("Time = ~s~n",[T]) end. (note the absence of the '<<' and '>>' operators in the match pattern) --- vincent From corticalcomputer@REDACTED Sat Apr 4 18:32:28 2009 From: corticalcomputer@REDACTED (G.S.) Date: Sat, 4 Apr 2009 09:32:28 -0700 Subject: [erlang-questions] Erlang and Larrabee CPU Message-ID: <2a67d3ff0904040932u3fc1a2a6r8555d8f8bc856dc8@mail.gmail.com> Hello everyone, Does the Erlang community know by any chance whether Erlang will run on the Larrabbee cpu, and will be able to utilize all the cores properly, compile...? Larrabee is MIMD as you guys know, and so would be perfect for Erlang. Regards, -Gene -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryeguy1@REDACTED Sat Apr 4 19:54:44 2009 From: ryeguy1@REDACTED (ryeguy) Date: Sat, 4 Apr 2009 10:54:44 -0700 (PDT) Subject: [erlang-questions] Couple of questions about mnesia locking In-Reply-To: <393375.16569.qm@web65508.mail.ac4.yahoo.com> References: <18e85b62-ca61-475e-8260-4ec5080aa568@r37g2000yqn.googlegroups.com> <393375.16569.qm@web65508.mail.ac4.yahoo.com> Message-ID: <2beddffc-c2cf-4238-8676-61399b9aeb79@k2g2000yql.googlegroups.com> Hmm..well what if we had a transaction where we add to a bank account balance. You obviously read the balance then increment it. If NodeA and NodeB both have replicas of the table containing the balance, couldn't this happen: NodeA reads balance of 5 NodeB reads balance of 5 NodeA writes balance of 10 NodeB writes balance of 15 Since there is no read lock on each node? I'm assuming it would work like this because, if I understand correctly, the locks are acquired AS the transaction processes, and not the second the transaction fun is executed, right? In this situation, is the solution to simply just grab a write lock on the record when reading it? This poses another question: how do you acquire a write lock on a record when you do an index read? On Apr 4, 7:31?am, Richard Andrews wrote: > > If I wanted to check if a username is in use before registering an > > account like this: > > > F=fun()-> > > case is_username_available(User) of ? ?%% does a mnesia:read to see if > > there is a record with that username > > ? ? false -> throw(username_in_use); > > ? ? true -> mnesia:write(User) > > end, > > > mnesia:transaction(F). > > > Don't I have a potential race condition here? Since there is no record > > to lock because it doesn't exist, how can mnesia guarantee another > > process isn't also going to write that same Username to the database? > > If I'm doing this wrong, what's the right way? A table lock (eww)? > > You could use a gatekeeper - a singleton process on only one node which is allowed to create usernames. Creators make a request to the gatekeeper which serialises the requests and therefore prevents the race. The problem then shifts to process registration consistency and takeover in the case of the gatekeeper failure. > > Sharding/splitting the gatekeeper responsibility by eg. username first letter would quarantine the damage from a gatekeeper failure. > > > My second question is regarding a quote from the mnesia manual: > > "Write locks are normally acquired on all nodes where a replica of the > > table resides (and is active). Read locks are acquired on one node > > (the local one if a local replica exists). " > > > What does it mean read locks are acquired on one node? What would > > happen when a table is distributed? Wouldn't that defeat the purpose? > > A read lock on any node prevents a write lock from being acquired on that item. > A write lock must be acquired on *all* nodes so it is sufficient to take a read lock on any one node to block a write lock from being acquired. > > -- > ? Rich > > ? ? ? Enjoy a safer web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From vychodil.hynek@REDACTED Sat Apr 4 21:59:11 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Sat, 4 Apr 2009 21:59:11 +0200 Subject: [erlang-questions] Couple of questions about mnesia locking In-Reply-To: <2beddffc-c2cf-4238-8676-61399b9aeb79@k2g2000yql.googlegroups.com> References: <18e85b62-ca61-475e-8260-4ec5080aa568@r37g2000yqn.googlegroups.com> <393375.16569.qm@web65508.mail.ac4.yahoo.com> <2beddffc-c2cf-4238-8676-61399b9aeb79@k2g2000yql.googlegroups.com> Message-ID: <4d08db370904041259g6f87a0e0qb426f6d5ea1947ff@mail.gmail.com> Write operation will require aquiring write lock, obviously. On Sat, Apr 4, 2009 at 7:54 PM, ryeguy wrote: > Hmm..well what if we had a transaction where we add to a bank account > balance. You obviously read the balance then increment it. > > If NodeA and NodeB both have replicas of the table containing the > balance, couldn't this happen: > > NodeA reads balance of 5 > NodeB reads balance of 5 > NodeA writes balance of 10 > NodeB writes balance of 15 > > Since there is no read lock on each node? I'm assuming it would work > like this because, if I understand correctly, the locks are acquired > AS the transaction processes, and not the second the transaction fun > is executed, right? > > In this situation, is the solution to simply just grab a write lock on > the record when reading it? > This poses another question: how do you acquire a write lock on a > record when you do an index read? > > On Apr 4, 7:31 am, Richard Andrews wrote: > > > If I wanted to check if a username is in use before registering an > > > account like this: > > > > > F=fun()-> > > > case is_username_available(User) of %% does a mnesia:read to see if > > > there is a record with that username > > > false -> throw(username_in_use); > > > true -> mnesia:write(User) > > > end, > > > > > mnesia:transaction(F). > > > > > Don't I have a potential race condition here? Since there is no record > > > to lock because it doesn't exist, how can mnesia guarantee another > > > process isn't also going to write that same Username to the database? > > > If I'm doing this wrong, what's the right way? A table lock (eww)? > > > > You could use a gatekeeper - a singleton process on only one node which > is allowed to create usernames. Creators make a request to the gatekeeper > which serialises the requests and therefore prevents the race. The problem > then shifts to process registration consistency and takeover in the case of > the gatekeeper failure. > > > > Sharding/splitting the gatekeeper responsibility by eg. username first > letter would quarantine the damage from a gatekeeper failure. > > > > > My second question is regarding a quote from the mnesia manual: > > > "Write locks are normally acquired on all nodes where a replica of the > > > table resides (and is active). Read locks are acquired on one node > > > (the local one if a local replica exists). " > > > > > What does it mean read locks are acquired on one node? What would > > > happen when a table is distributed? Wouldn't that defeat the purpose? > > > > A read lock on any node prevents a write lock from being acquired on that > item. > > A write lock must be acquired on *all* nodes so it is sufficient to take > a read lock on any one node to block a write lock from being acquired. > > > > -- > > Rich > > > > Enjoy a safer web experience. Upgrade to the new Internet Explorer > 8 optimised for Yahoo!7. Get it now. > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED:// > www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryeguy1@REDACTED Sat Apr 4 22:14:12 2009 From: ryeguy1@REDACTED (Ryan Lepidi) Date: Sat, 4 Apr 2009 16:14:12 -0400 Subject: [erlang-questions] Couple of questions about mnesia locking In-Reply-To: <4d08db370904041259g6f87a0e0qb426f6d5ea1947ff@mail.gmail.com> References: <18e85b62-ca61-475e-8260-4ec5080aa568@r37g2000yqn.googlegroups.com> <393375.16569.qm@web65508.mail.ac4.yahoo.com> <2beddffc-c2cf-4238-8676-61399b9aeb79@k2g2000yql.googlegroups.com> <4d08db370904041259g6f87a0e0qb426f6d5ea1947ff@mail.gmail.com> Message-ID: I know a write lock would eventually be acquired, but aren't locks acquired AS the functions in the transaction are called? Like wouldn't it do this: NodeA reads balance of 5; gets read lock on record NodeB reads balance of 5; gets read lock on record NodeA writes balance of 10; gets write lock on record NodeB writes balance of 15; gets write lock on record ^ Obviously this would be bad Or does mnesia read the entire transaction first and then apply all of the locks before doing any of the actions? I don't think this is the case because then functions such as mnesia:wread would be necessary. On Sat, Apr 4, 2009 at 3:59 PM, Hynek Vychodil wrote: > Write operation will require aquiring write lock, obviously. > > On Sat, Apr 4, 2009 at 7:54 PM, ryeguy wrote: > >> Hmm..well what if we had a transaction where we add to a bank account >> balance. You obviously read the balance then increment it. >> >> If NodeA and NodeB both have replicas of the table containing the >> balance, couldn't this happen: >> >> NodeA reads balance of 5 >> NodeB reads balance of 5 >> NodeA writes balance of 10 >> NodeB writes balance of 15 >> >> Since there is no read lock on each node? I'm assuming it would work >> like this because, if I understand correctly, the locks are acquired >> AS the transaction processes, and not the second the transaction fun >> is executed, right? >> >> In this situation, is the solution to simply just grab a write lock on >> the record when reading it? >> This poses another question: how do you acquire a write lock on a >> record when you do an index read? >> >> On Apr 4, 7:31 am, Richard Andrews wrote: >> > > If I wanted to check if a username is in use before registering an >> > > account like this: >> > >> > > F=fun()-> >> > > case is_username_available(User) of %% does a mnesia:read to see if >> > > there is a record with that username >> > > false -> throw(username_in_use); >> > > true -> mnesia:write(User) >> > > end, >> > >> > > mnesia:transaction(F). >> > >> > > Don't I have a potential race condition here? Since there is no record >> > > to lock because it doesn't exist, how can mnesia guarantee another >> > > process isn't also going to write that same Username to the database? >> > > If I'm doing this wrong, what's the right way? A table lock (eww)? >> > >> > You could use a gatekeeper - a singleton process on only one node which >> is allowed to create usernames. Creators make a request to the gatekeeper >> which serialises the requests and therefore prevents the race. The problem >> then shifts to process registration consistency and takeover in the case of >> the gatekeeper failure. >> > >> > Sharding/splitting the gatekeeper responsibility by eg. username first >> letter would quarantine the damage from a gatekeeper failure. >> > >> > > My second question is regarding a quote from the mnesia manual: >> > > "Write locks are normally acquired on all nodes where a replica of the >> > > table resides (and is active). Read locks are acquired on one node >> > > (the local one if a local replica exists). " >> > >> > > What does it mean read locks are acquired on one node? What would >> > > happen when a table is distributed? Wouldn't that defeat the purpose? >> > >> > A read lock on any node prevents a write lock from being acquired on >> that item. >> > A write lock must be acquired on *all* nodes so it is sufficient to take >> a read lock on any one node to block a write lock from being acquired. >> > >> > -- >> > Rich >> > >> > Enjoy a safer web experience. Upgrade to the new Internet Explorer >> 8 optimised for Yahoo!7. Get it now. >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questi...@REDACTED:// >> www.erlang.org/mailman/listinfo/erlang-questions >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryeguy1@REDACTED Sat Apr 4 22:16:20 2009 From: ryeguy1@REDACTED (Ryan Lepidi) Date: Sat, 4 Apr 2009 16:16:20 -0400 Subject: [erlang-questions] Couple of questions about mnesia locking In-Reply-To: References: <18e85b62-ca61-475e-8260-4ec5080aa568@r37g2000yqn.googlegroups.com> <393375.16569.qm@web65508.mail.ac4.yahoo.com> <2beddffc-c2cf-4238-8676-61399b9aeb79@k2g2000yql.googlegroups.com> <4d08db370904041259g6f87a0e0qb426f6d5ea1947ff@mail.gmail.com> Message-ID: I meant to say unnecessary* On Sat, Apr 4, 2009 at 4:14 PM, Ryan Lepidi wrote: > I know a write lock would eventually be acquired, but aren't locks acquired > AS the functions in the transaction are called? Like wouldn't it do this: > > NodeA reads balance of 5; gets read lock on record > NodeB reads balance of 5; gets read lock on record > NodeA writes balance of 10; gets write lock on record > NodeB writes balance of 15; gets write lock on record > ^ Obviously this would be bad > > Or does mnesia read the entire transaction first and then apply all of the > locks before doing any of the actions? I don't think this is the case > because then functions such as mnesia:wread would be necessary. > > > On Sat, Apr 4, 2009 at 3:59 PM, Hynek Vychodil wrote: > >> Write operation will require aquiring write lock, obviously. >> >> On Sat, Apr 4, 2009 at 7:54 PM, ryeguy wrote: >> >>> Hmm..well what if we had a transaction where we add to a bank account >>> balance. You obviously read the balance then increment it. >>> >>> If NodeA and NodeB both have replicas of the table containing the >>> balance, couldn't this happen: >>> >>> NodeA reads balance of 5 >>> NodeB reads balance of 5 >>> NodeA writes balance of 10 >>> NodeB writes balance of 15 >>> >>> Since there is no read lock on each node? I'm assuming it would work >>> like this because, if I understand correctly, the locks are acquired >>> AS the transaction processes, and not the second the transaction fun >>> is executed, right? >>> >>> In this situation, is the solution to simply just grab a write lock on >>> the record when reading it? >>> This poses another question: how do you acquire a write lock on a >>> record when you do an index read? >>> >>> On Apr 4, 7:31 am, Richard Andrews wrote: >>> > > If I wanted to check if a username is in use before registering an >>> > > account like this: >>> > >>> > > F=fun()-> >>> > > case is_username_available(User) of %% does a mnesia:read to see >>> if >>> > > there is a record with that username >>> > > false -> throw(username_in_use); >>> > > true -> mnesia:write(User) >>> > > end, >>> > >>> > > mnesia:transaction(F). >>> > >>> > > Don't I have a potential race condition here? Since there is no >>> record >>> > > to lock because it doesn't exist, how can mnesia guarantee another >>> > > process isn't also going to write that same Username to the database? >>> > > If I'm doing this wrong, what's the right way? A table lock (eww)? >>> > >>> > You could use a gatekeeper - a singleton process on only one node which >>> is allowed to create usernames. Creators make a request to the gatekeeper >>> which serialises the requests and therefore prevents the race. The problem >>> then shifts to process registration consistency and takeover in the case of >>> the gatekeeper failure. >>> > >>> > Sharding/splitting the gatekeeper responsibility by eg. username first >>> letter would quarantine the damage from a gatekeeper failure. >>> > >>> > > My second question is regarding a quote from the mnesia manual: >>> > > "Write locks are normally acquired on all nodes where a replica of >>> the >>> > > table resides (and is active). Read locks are acquired on one node >>> > > (the local one if a local replica exists). " >>> > >>> > > What does it mean read locks are acquired on one node? What would >>> > > happen when a table is distributed? Wouldn't that defeat the purpose? >>> > >>> > A read lock on any node prevents a write lock from being acquired on >>> that item. >>> > A write lock must be acquired on *all* nodes so it is sufficient to >>> take a read lock on any one node to block a write lock from being acquired. >>> > >>> > -- >>> > Rich >>> > >>> > Enjoy a safer web experience. Upgrade to the new Internet >>> Explorer 8 optimised for Yahoo!7. Get it now. >>> > _______________________________________________ >>> > erlang-questions mailing list >>> > erlang-questi...@REDACTED:// >>> www.erlang.org/mailman/listinfo/erlang-questions >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> >> -- >> --Hynek (Pichi) Vychodil >> >> Analyze your data in minutes. Share your insights instantly. Thrill your >> boss. Be a data hero! >> Try Good Data now for free: www.gooddata.com >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Sat Apr 4 22:52:06 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Sat, 4 Apr 2009 22:52:06 +0200 Subject: [erlang-questions] Couple of questions about mnesia locking In-Reply-To: References: <18e85b62-ca61-475e-8260-4ec5080aa568@r37g2000yqn.googlegroups.com> <393375.16569.qm@web65508.mail.ac4.yahoo.com> <2beddffc-c2cf-4238-8676-61399b9aeb79@k2g2000yql.googlegroups.com> <4d08db370904041259g6f87a0e0qb426f6d5ea1947ff@mail.gmail.com> Message-ID: <4d08db370904041352g11f411a5x7e9a900af3d4630a@mail.gmail.com> mnesia uses optimistic locking. When NodeB's write is called than transaction fails and is restarted. This is why mneasia transaction should not contain side-effects. See mnesia manual for details. On Sat, Apr 4, 2009 at 10:14 PM, Ryan Lepidi wrote: > I know a write lock would eventually be acquired, but aren't locks acquired > AS the functions in the transaction are called? Like wouldn't it do this: > > NodeA reads balance of 5; gets read lock on record > NodeB reads balance of 5; gets read lock on record > NodeA writes balance of 10; gets write lock on record > NodeB writes balance of 15; gets write lock on record > ^ Obviously this would be bad > > Or does mnesia read the entire transaction first and then apply all of the > locks before doing any of the actions? I don't think this is the case > because then functions such as mnesia:wread would be necessary. > > > On Sat, Apr 4, 2009 at 3:59 PM, Hynek Vychodil wrote: > >> Write operation will require aquiring write lock, obviously. >> >> On Sat, Apr 4, 2009 at 7:54 PM, ryeguy wrote: >> >>> Hmm..well what if we had a transaction where we add to a bank account >>> balance. You obviously read the balance then increment it. >>> >>> If NodeA and NodeB both have replicas of the table containing the >>> balance, couldn't this happen: >>> >>> NodeA reads balance of 5 >>> NodeB reads balance of 5 >>> NodeA writes balance of 10 >>> NodeB writes balance of 15 >>> >>> Since there is no read lock on each node? I'm assuming it would work >>> like this because, if I understand correctly, the locks are acquired >>> AS the transaction processes, and not the second the transaction fun >>> is executed, right? >>> >>> In this situation, is the solution to simply just grab a write lock on >>> the record when reading it? >>> This poses another question: how do you acquire a write lock on a >>> record when you do an index read? >>> >>> On Apr 4, 7:31 am, Richard Andrews wrote: >>> > > If I wanted to check if a username is in use before registering an >>> > > account like this: >>> > >>> > > F=fun()-> >>> > > case is_username_available(User) of %% does a mnesia:read to see >>> if >>> > > there is a record with that username >>> > > false -> throw(username_in_use); >>> > > true -> mnesia:write(User) >>> > > end, >>> > >>> > > mnesia:transaction(F). >>> > >>> > > Don't I have a potential race condition here? Since there is no >>> record >>> > > to lock because it doesn't exist, how can mnesia guarantee another >>> > > process isn't also going to write that same Username to the database? >>> > > If I'm doing this wrong, what's the right way? A table lock (eww)? >>> > >>> > You could use a gatekeeper - a singleton process on only one node which >>> is allowed to create usernames. Creators make a request to the gatekeeper >>> which serialises the requests and therefore prevents the race. The problem >>> then shifts to process registration consistency and takeover in the case of >>> the gatekeeper failure. >>> > >>> > Sharding/splitting the gatekeeper responsibility by eg. username first >>> letter would quarantine the damage from a gatekeeper failure. >>> > >>> > > My second question is regarding a quote from the mnesia manual: >>> > > "Write locks are normally acquired on all nodes where a replica of >>> the >>> > > table resides (and is active). Read locks are acquired on one node >>> > > (the local one if a local replica exists). " >>> > >>> > > What does it mean read locks are acquired on one node? What would >>> > > happen when a table is distributed? Wouldn't that defeat the purpose? >>> > >>> > A read lock on any node prevents a write lock from being acquired on >>> that item. >>> > A write lock must be acquired on *all* nodes so it is sufficient to >>> take a read lock on any one node to block a write lock from being acquired. >>> > >>> > -- >>> > Rich >>> > >>> > Enjoy a safer web experience. Upgrade to the new Internet >>> Explorer 8 optimised for Yahoo!7. Get it now. >>> > _______________________________________________ >>> > erlang-questions mailing list >>> > erlang-questi...@REDACTED:// >>> www.erlang.org/mailman/listinfo/erlang-questions >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> >> -- >> --Hynek (Pichi) Vychodil >> >> Analyze your data in minutes. Share your insights instantly. Thrill your >> boss. Be a data hero! >> Try Good Data now for free: www.gooddata.com >> > > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Sat Apr 4 22:53:51 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Sat, 4 Apr 2009 22:53:51 +0200 Subject: [erlang-questions] Erlang and Larrabee CPU In-Reply-To: <2a67d3ff0904040932u3fc1a2a6r8555d8f8bc856dc8@mail.gmail.com> References: <2a67d3ff0904040932u3fc1a2a6r8555d8f8bc856dc8@mail.gmail.com> Message-ID: The Erlang VM needs an operating system to run on. Is there any OS that runs on the Larrabee? I have never heard of anyone running Erlang on the Larrabee and we have for sure never tried it and I don't really understand why that would be very interesting. Erlang can utilize a CPU with many general purpose cores or maybe act as a controller running still running on geneal purpose cores but administering jobs to be run on other special purpose cores. The extra instructions available on Larrabee is nothing the current Erlang VM can make benefit of. /Kenneth Erlang/OTP, Ericsson On Sat, Apr 4, 2009 at 6:32 PM, G.S. wrote: > Hello everyone, > > Does the Erlang community know by any chance whether Erlang will run on the > Larrabbee cpu, and will be able to utilize all the cores properly, > compile...? > Larrabee is MIMD as you guys know, and so would be perfect for Erlang. > > Regards, > -Gene > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From corticalcomputer@REDACTED Sat Apr 4 23:04:31 2009 From: corticalcomputer@REDACTED (G.S.) Date: Sat, 4 Apr 2009 14:04:31 -0700 Subject: [erlang-questions] Erlang and Larrabee CPU In-Reply-To: References: <2a67d3ff0904040932u3fc1a2a6r8555d8f8bc856dc8@mail.gmail.com> Message-ID: <2a67d3ff0904041404y3ea8c3dfl1fd45192ef7adab3@mail.gmail.com> The fact that Larrabee has 64 general purpose (relatively speaking) Cores, and one can utilize them for processing is a benefit in itself. It's much more general than the Nvidia's Tesla, and unlike cell architecture, all Cores are the same. After all, this is what Erlang is all about, concurrent high throughput computing. On Sat, Apr 4, 2009 at 1:53 PM, Kenneth Lundin wrote: > The Erlang VM needs an operating system to run on. > Is there any OS that runs on the Larrabee? > > I have never heard of anyone running Erlang on the Larrabee and we > have for sure never tried it and I don't really > understand why that would be very interesting. > > Erlang can utilize a CPU with many general purpose cores or maybe act > as a controller running still running on geneal purpose cores but > administering jobs to be run on other special purpose cores. > The extra instructions available on Larrabee is nothing the current > Erlang VM can make benefit of. > > /Kenneth Erlang/OTP, Ericsson > > On Sat, Apr 4, 2009 at 6:32 PM, G.S. wrote: > > Hello everyone, > > > > Does the Erlang community know by any chance whether Erlang will run on > the > > Larrabbee cpu, and will be able to utilize all the cores properly, > > compile...? > > Larrabee is MIMD as you guys know, and so would be perfect for Erlang. > > > > Regards, > > -Gene > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Sun Apr 5 00:20:26 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Sat, 4 Apr 2009 15:20:26 -0700 Subject: [erlang-questions] Storing funs in term files In-Reply-To: References: Message-ID: On Sat, Apr 4, 2009 at 4:06 AM, Steve Davis wrote: > 2>{ok, B} = file:consult("fun.term"). > ** exception error: no match of right hand side value > ? ? ? ? ? ? ? ? ? ?{error,{2,erl_parse,"bad term"}} Try using file:script. From corticalcomputer@REDACTED Sun Apr 5 00:54:02 2009 From: corticalcomputer@REDACTED (G.S.) Date: Sat, 4 Apr 2009 15:54:02 -0700 Subject: [erlang-questions] Erlang and Larrabee CPU In-Reply-To: References: <2a67d3ff0904040932u3fc1a2a6r8555d8f8bc856dc8@mail.gmail.com> <2a67d3ff0904041404y3ea8c3dfl1fd45192ef7adab3@mail.gmail.com> Message-ID: <2a67d3ff0904041554n41864463jef8d13ffbe7b4213@mail.gmail.com> Those are good points Tim, I've also came over the following while reading up on Larrabee: "A different version of Larrabee might sit in motherboard CPU sockets using QuickPath , but Intel has not yet announced plans for this" The following article http://arstechnica.com/hardware/news/2007/06/clearing-up-the-confusion-over-intels-larrabee-part-ii.ars also aludes to the possible future works of something like larrabee running directly in a CPU socket. By the way, at the end the mentioned "Gesher" cpu is currently known as "Sandy Bridges" (6-8 core, should be released this or next year). In any case, I just think that Erlang has a lot of potential for some hardcore computing (I primarily use it for computationally intensive projects on quad cores, and it's been working very well), and that we have not yet utilized Tesla and similar potential "processing force multipliers" is sad since Erlang can really scale on those easier than other languages. On Sat, Apr 4, 2009 at 3:23 PM, Timothy Baldridge wrote: > Right, although at launch, the Larrabee will be unable to run Erlang. > IIRC, at launch Larrabee will require a program running in the CPU to > hand it the instructions to run. This basically means that the Erlang > VM would have to be rewritten to support Larrabee. As Larrabee does > not support interrupts, and other hardware communication instructions, > Erlang would have to make sure that all OS processes are kept in the > conventional CPU cores, while the Larrabee is only handed the > processes that only manipulate memory. On top of that, Larabee > implementions will most likely not have direct access to the main CPU > memory, so any process data would need to be transported to the GPU > memory. > > Not impossible, but it still won't work out of the box. > > Timothy > > > On Sat, Apr 4, 2009 at 4:04 PM, G.S. wrote: > > The fact that Larrabee has 64 general purpose (relatively speaking) > Cores, > > and one can utilize them for processing is a benefit in itself. It's much > > more general than the Nvidia's Tesla, and unlike cell architecture, all > > Cores are the same. > > After all, this is what Erlang is all about, concurrent high throughput > > computing. > > > > > > On Sat, Apr 4, 2009 at 1:53 PM, Kenneth Lundin > > > wrote: > >> > >> The Erlang VM needs an operating system to run on. > >> Is there any OS that runs on the Larrabee? > >> > >> I have never heard of anyone running Erlang on the Larrabee and we > >> have for sure never tried it and I don't really > >> understand why that would be very interesting. > >> > >> Erlang can utilize a CPU with many general purpose cores or maybe act > >> as a controller running still running on geneal purpose cores but > >> administering jobs to be run on other special purpose cores. > >> The extra instructions available on Larrabee is nothing the current > >> Erlang VM can make benefit of. > >> > >> /Kenneth Erlang/OTP, Ericsson > >> > >> On Sat, Apr 4, 2009 at 6:32 PM, G.S. > wrote: > >> > Hello everyone, > >> > > >> > Does the Erlang community know by any chance whether Erlang will run > on > >> > the > >> > Larrabbee cpu, and will be able to utilize all the cores properly, > >> > compile...? > >> > Larrabee is MIMD as you guys know, and so would be perfect for Erlang. > >> > > >> > Regards, > >> > -Gene > >> > > >> > _______________________________________________ > >> > erlang-questions mailing list > >> > erlang-questions@REDACTED > >> > http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > ?One of the main causes of the fall of the Roman Empire was > that?lacking zero?they had no way to indicate successful termination > of their C programs.? > (Robert Firth) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Sun Apr 5 01:14:27 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 04 Apr 2009 18:14:27 -0500 Subject: [erlang-questions] Storing funs in term files In-Reply-To: References: Message-ID: <49D7E9D3.6050605@gmail.com> Hi Matthew, Succinct, and exactly what I was searching for! Many thanks. BR, /s Matthew Dempsky wrote: > On Sat, Apr 4, 2009 at 4:06 AM, Steve Davis > wrote: >> 2>{ok, B} = file:consult("fun.term"). >> ** exception error: no match of right hand side value >> {error,{2,erl_parse,"bad term"}} > > Try using file:script. > From yogishb@REDACTED Sun Apr 5 02:07:25 2009 From: yogishb@REDACTED (Yogish Baliga) Date: Sat, 4 Apr 2009 17:07:25 -0700 (PDT) Subject: [erlang-questions] Error while installing new release Message-ID: <11578.10042.qm@web31801.mail.mud.yahoo.com> Thanx for the all replies. Apparently I had a wrong understanding of Erlang. In the process of creating the release file and upgrading the existing modules while the system is running, I discovered that Erlang in not Python or Perl. My understanding of Erlang was that whatever I installed as a default erlang release is like a perl or python interpreter. But I came to know that what I installed itself is a release of Erlang. I can pick & choose the applications I want in the final release and create a release of my own distribution like doing a Linux distribution with only the required components. In my case I need only kernel, stdlib, inets, ibrowse, compiler and my own applications for the final release. I am posting this just in case if members here are not aware of it. Cheers, -- baliga "The quality of programmers is a decreasing function of the density of GOTO statements in the programs they produce." - Edsger W. Dijkstra http://dudefrommangalore.blogspot.com/ ________________________________ From: Yogish Baliga To: Erlang Questions Sent: Thursday, April 2, 2009 1:14:43 AM Subject: Error while installing new release Hello all, I have done all the steps required to release an application. release_handler:unpack_release("2") worked fine. It create lib/erlang/releases/2 directory and files within it. 3 files are create in the directory. start.boot, relup and myapp-2.rel While installing the release (release_handler:install_release("2")), I am getting the error {error,{enoent,"/usr/local/lib/erlang/releases/R12B/relup"}} Any clue on how to solve this? Thanx, -- baliga "The quality of programmers is a decreasing function of the density of GOTO statements in the programs they produce." - Edsger W. Dijkstra http://dudefrommangalore.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From bernie@REDACTED Sun Apr 5 06:15:09 2009 From: bernie@REDACTED (Bernard Duggan) Date: Sun, 05 Apr 2009 14:15:09 +1000 Subject: [erlang-questions] No timeout on connect In-Reply-To: <200904041438162228321@bluewin.ch> References: <200904041438162228321@bluewin.ch> Message-ID: <49D8304D.5060305@m5net.com> Gamoto wrote: > What is wrong in this code ? When I run it, without a listening server, after a few second, I have a timeout error !! > infinity parameter is not correctly defined ? Which OS and Erlang release are you using? When I try that on R12B-5 for both Linux and Windows it returns quickly as well, but the Reason is 'econnrefused' which is what I'd expect to see when there's no server there. The timeout parameter is how long the connection attempt will wait for a response of any kind, be it success, refusal or some other kind of failure. Setting it to 'infinity' (the default, by the way, so you don't need to explicitly set it) doesn't mean that it will keep retrying a failed connection indefinitely. Cheers, Bernard From ulf.wiger@REDACTED Sun Apr 5 08:54:50 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sun, 05 Apr 2009 08:54:50 +0200 Subject: [erlang-questions] Storing funs in term files In-Reply-To: References: Message-ID: <49D855BA.4050601@erlang-consulting.com> I once wrote a small module that would find a given fun and fetch its abstract representation (provided the module was compiled with debug info). Given the following brilliant program: -module(m). -export([f/2]). f(N, X) -> if N==1; N==2 -> element(N, {fun() -> X + 1 end, fun() -> X - 1 end}); N == 3 -> fun(Y) -> X + Y end end. Eshell V5.6.5 (abort with ^G) 1> m:f(1,17). #Fun 2> extract:f(v(2)). {'fun',10, {clauses,[{clause,10,[],[], [{op,11,'+',{var,11,'X'},{integer,11,1}}]}]}} If this approach suits you, I can send you the code. BR, Ulf W Steve Davis wrote: > Given that: > 1> A = {echo, fun(X) -> X end}. > {echo,#Fun} > > I have a scenario where it would be useful to store funs in term > files, for example: > > % contents of the term file > {echo, fun(X) -> X end}. > > 2>{ok, B} = file:consult("fun.term"). > ** exception error: no match of right hand side value > {error,{2,erl_parse,"bad term"}} > > Note that although the term file contents *passes the syntax checker*, > the parser declares this to be a bad term. > > Is there a way to achieve this? If not, it seems odd to me that funs > should be "second class citizens" in term files. > > Thanks! > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From ulf.wiger@REDACTED Sun Apr 5 09:27:50 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sun, 05 Apr 2009 09:27:50 +0200 Subject: [erlang-questions] Couple of questions about mnesia locking In-Reply-To: <4d08db370904041352g11f411a5x7e9a900af3d4630a@mail.gmail.com> References: <18e85b62-ca61-475e-8260-4ec5080aa568@r37g2000yqn.googlegroups.com> <393375.16569.qm@web65508.mail.ac4.yahoo.com> <2beddffc-c2cf-4238-8676-61399b9aeb79@k2g2000yql.googlegroups.com> <4d08db370904041259g6f87a0e0qb426f6d5ea1947ff@mail.gmail.com> <4d08db370904041352g11f411a5x7e9a900af3d4630a@mail.gmail.com> Message-ID: <49D85D76.1090808@erlang-consulting.com> Hynek Vychodil wrote: > mnesia uses optimistic locking. When NodeB's write is called than > transaction fails and is restarted. This is why mneasia transaction > should not contain side-effects. See mnesia manual for details. Actually, no. Mnesia waits for the locks needed before proceeding, and keeps the locks until it either aborts or commits. However, in any locking environment, one must guard against deadlocks. If the lock manager is centralized, it's possible to maintain a wait-for graph, which is scanned each time a new lock is requested. This approach doesn't scale in a distributed setting, so an alternative approach, called "deadlock prevention", is to allow only unidirectional dependencies (for some definition of unidirectional - e.g. from smaller to larger pids.) If a lock is requested that would create a dependency in the other direction, one of the transactions involved is restarted. This is why mnesia transactions can restart sometimes. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From tobbe@REDACTED Sun Apr 5 10:22:59 2009 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Sun, 05 Apr 2009 10:22:59 +0200 Subject: [erlang-questions] RPC from linkedin driver In-Reply-To: <49D609D5.2090107@ericsson.com> References: <722837.22586.qm@web31810.mail.mud.yahoo.com> <87ab6yhr2m.fsf@sej.hq.kred> <49D609D5.2090107@ericsson.com> Message-ID: Bertil Karlsson wrote: > Works fine for me. Maybe I didn't got your failed case exactly. I > changed namespaces. My examples (with your content) below. You're right! Sorry, it was a slight typo in my code that my aging eyes didn't catch (xmlms vs xmlns). Just for reference, here is my complete and working example: --- n.xsd --- --- n.xml --- Thanx, Tobbe > > mytest2.xsd > targetNamespace="blaha" > xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > > > > > > > > > mytest3.xsd > targetNamespace="blaha" > xmlns:b = "blaha" > xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > > > > > > > > > and > 1> {E,_}=xmerl_scan:string("",[]). > 2> {ok,S2} = xmerl_xsd:process_schema("mytest2.xsd"). > 3> xmerl_xsd:validate(E,S2). > 4> {ok,S3} = xmerl_xsd:process_schema("mytest3.xsd"). > 5> xmerl_xsd:validate(E,S3). > > all working as expected. > > /Bertil > > Torbjorn Tornkvist wrote: >> Kenneth Lundin writes: >> >> >>> We are working on significant performance improvements and new API's for >>> XMERL. >>> >> Hm...talking about xmerl. It seems like xmerl's xsd functionality >> doesn't like when you break out, e.g a complexType declaration from >> where it is referred to. >> >> So validating this: >> >> With: >> >> >> >> >> >> >> >> is fine, but with this: >> >> >> >> >> >> >> >> I get: >> >> {error,[{[],xmerl_xsd, >> {reference_undeclared,simpleType, >> {simpleType,{tLabel,[],[]}}}}]} >> >> >> ? Tobbe >> >> >> >>> The new XMERL will be at least 4 times faster than the current >>> version. The base for this is a completely new >>> SAX parser that you also can use directly with new API's. >>> >>> The memory consumption will also be significantly reduced. >>> >>> /Kenneth Erlang/OTP Ericsson >>> >>> On Tue, Mar 31, 2009 at 8:13 PM, Yogish Baliga wrote: >>> >>>> I am currently working on developing a linkedin driver (c language) for XML parser (xmerl is too slow). This is a SAX parser is given the following input: >>>> >>>> 1. XML to be parsed >>>> 2. Call back functions (MFA) for start of node, end of node and for text elements >>>> >>>> I found C APIs to do RPC calls from c-node (ei_rpc). This require ei_cnode and fd parameters. That means I need to run the port as a c-node. >>>> >>>> Is it possible to do RPC from linkedin driver without converting linkedin driver as a c-node? >>>> >>>> Thanx, >>>> -- baliga >>>> >>>> >>>> "The quality of programmers is a decreasing function of the density of GOTO statements in the programs they produce." - Edsger W. Dijkstra >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >> > From exta7@REDACTED Sun Apr 5 10:41:48 2009 From: exta7@REDACTED (Zvi) Date: Sun, 5 Apr 2009 01:41:48 -0700 (PDT) Subject: [erlang-questions] Erlang and Larrabee CPU In-Reply-To: <2a67d3ff0904041554n41864463jef8d13ffbe7b4213@mail.gmail.com> References: <2a67d3ff0904040932u3fc1a2a6r8555d8f8bc856dc8@mail.gmail.com> <2a67d3ff0904041554n41864463jef8d13ffbe7b4213@mail.gmail.com> Message-ID: <22891627.post@talk.nabble.com> buzzwords, buzzwords... I think with all the multicore buzz (partially attributed to Yariv's blog and Joe's book), people mixing different kind of parallelism: 1. Task-level parallelism Irregular concurrency - applications that need to derive parallelism from disparate concurrent tasks. 2. Data-parallel Concurrency more apporpriate for synchronized parallel execution (like in GPU/CUDA). Erlang's actor-based model is more apporpiate for #1. While bad scalar floating point performance and absence of built-in homogenous non-sequential data structures (vectors, matrices) doesn't help for #2. Erlang still can be used for controlling various accelerator devices, like Larabee and GPUs. Your are right, trhat LRB cores are essentialy general purpouse Pentium cores with extended x86-64 IA with 512-bit wide SIMD and hyperthreading. But initially it will be used as a GPU. With DirectX/OpenGL/CUDA/whatever drivers emulating GPU. I don't know in how many years we'll be able to run regular C/C++ code natively on it, yet Erlang ;-) Zvi G.S.-2 wrote: > > Those are good points Tim, I've also came over the following while reading > up on Larrabee: > > "A different version of Larrabee might sit in motherboard CPU sockets > using > QuickPath > , > but Intel has not yet announced plans for this" > > The following article > http://arstechnica.com/hardware/news/2007/06/clearing-up-the-confusion-over-intels-larrabee-part-ii.ars > also aludes to the possible future works of something like larrabee > running > directly in a CPU socket. By the way, at the end the mentioned "Gesher" > cpu > is currently known as "Sandy Bridges" (6-8 core, should be released this > or > next year). > > In any case, I just think that Erlang has a lot of potential for some > hardcore computing (I primarily use it for computationally intensive > projects on quad cores, and it's been working very well), and that we have > not yet utilized Tesla and similar potential "processing force > multipliers" > is sad since Erlang can really scale on those easier than other languages. > > On Sat, Apr 4, 2009 at 3:23 PM, Timothy Baldridge > wrote: > >> Right, although at launch, the Larrabee will be unable to run Erlang. >> IIRC, at launch Larrabee will require a program running in the CPU to >> hand it the instructions to run. This basically means that the Erlang >> VM would have to be rewritten to support Larrabee. As Larrabee does >> not support interrupts, and other hardware communication instructions, >> Erlang would have to make sure that all OS processes are kept in the >> conventional CPU cores, while the Larrabee is only handed the >> processes that only manipulate memory. On top of that, Larabee >> implementions will most likely not have direct access to the main CPU >> memory, so any process data would need to be transported to the GPU >> memory. >> >> Not impossible, but it still won't work out of the box. >> >> Timothy >> >> >> On Sat, Apr 4, 2009 at 4:04 PM, G.S. wrote: >> > The fact that Larrabee has 64 general purpose (relatively speaking) >> Cores, >> > and one can utilize them for processing is a benefit in itself. It's >> much >> > more general than the Nvidia's Tesla, and unlike cell architecture, all >> > Cores are the same. >> > After all, this is what Erlang is all about, concurrent high throughput >> > computing. >> > >> > >> > On Sat, Apr 4, 2009 at 1:53 PM, Kenneth Lundin >> > > >> > wrote: >> >> >> >> The Erlang VM needs an operating system to run on. >> >> Is there any OS that runs on the Larrabee? >> >> >> >> I have never heard of anyone running Erlang on the Larrabee and we >> >> have for sure never tried it and I don't really >> >> understand why that would be very interesting. >> >> >> >> Erlang can utilize a CPU with many general purpose cores or maybe act >> >> as a controller running still running on geneal purpose cores but >> >> administering jobs to be run on other special purpose cores. >> >> The extra instructions available on Larrabee is nothing the current >> >> Erlang VM can make benefit of. >> >> >> >> /Kenneth Erlang/OTP, Ericsson >> >> >> >> On Sat, Apr 4, 2009 at 6:32 PM, G.S. >> wrote: >> >> > Hello everyone, >> >> > >> >> > Does the Erlang community know by any chance whether Erlang will run >> on >> >> > the >> >> > Larrabbee cpu, and will be able to utilize all the cores properly, >> >> > compile...? >> >> > Larrabee is MIMD as you guys know, and so would be perfect for >> Erlang. >> >> > >> >> > Regards, >> >> > -Gene >> >> > >> >> > _______________________________________________ >> >> > erlang-questions mailing list >> >> > erlang-questions@REDACTED >> >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > >> > >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> >> >> >> -- >> ?One of the main causes of the fall of the Roman Empire was >> that?lacking zero?they had no way to indicate successful termination >> of their C programs.? >> (Robert Firth) >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://www.nabble.com/Erlang-and-Larrabee-CPU-tp22885451p22891627.html Sent from the Erlang Questions mailing list archive at Nabble.com. From steven.charles.davis@REDACTED Sun Apr 5 13:07:16 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sun, 05 Apr 2009 06:07:16 -0500 Subject: [erlang-questions] Storing funs in term files In-Reply-To: <49D855BA.4050601@erlang-consulting.com> References: <49D855BA.4050601@erlang-consulting.com> Message-ID: <49D890E4.2020603@gmail.com> Hi Ulf, Matthew's answer (file:script) did actually cope with the current situation. I would definitely be interested in seeing the code you wrote as it may inspire other approaches to the problem, which is, specifically, a protocol converter that uses declarative forms/formats. I needed to read in simple funs that apply simple transformations on particular elements to "tuple-ize" the input e.g. fun([X, Y]) -> { list_to_atom(X), Y } end. Of course, there is a strong argument to be made that I should be using leex/yecc for this, but... well, maybe when I put the converter up onto github it will be clear why I haven't! At the very least your module sounds very interesting from a learning/inspiration perspective! Best regards, Steve Ulf Wiger wrote: > > I once wrote a small module that would find a given > fun and fetch its abstract representation (provided > the module was compiled with debug info). > > Given the following brilliant program: > > -module(m). > > -export([f/2]). > > > f(N, X) -> > if > N==1; N==2 -> > element(N, > {fun() -> > X + 1 > end, > fun() -> > X - 1 > end}); > N == 3 -> > fun(Y) -> > X + Y > end > end. > > Eshell V5.6.5 (abort with ^G) > 1> m:f(1,17). > #Fun > 2> extract:f(v(2)). > {'fun',10, > {clauses,[{clause,10,[],[], > [{op,11,'+',{var,11,'X'},{integer,11,1}}]}]}} > > > If this approach suits you, I can send you the code. > > BR, > Ulf W > > Steve Davis wrote: >> Given that: >> 1> A = {echo, fun(X) -> X end}. >> {echo,#Fun} >> >> I have a scenario where it would be useful to store funs in term >> files, for example: >> >> % contents of the term file >> {echo, fun(X) -> X end}. >> >> 2>{ok, B} = file:consult("fun.term"). >> ** exception error: no match of right hand side value >> {error,{2,erl_parse,"bad term"}} >> >> Note that although the term file contents *passes the syntax checker*, >> the parser declares this to be a bad term. >> >> Is there a way to achieve this? If not, it seems odd to me that funs >> should be "second class citizens" in term files. >> >> Thanks! >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > From gamoto@REDACTED Sun Apr 5 19:32:24 2009 From: gamoto@REDACTED (Gamoto) Date: Sun, 5 Apr 2009 19:32:24 +0200 Subject: [erlang-questions] No timeout on connect References: <200904041438162228321@bluewin.ch>, <49D8304D.5060305@m5net.com> Message-ID: <200904051932239558328@bluewin.ch> I run on Windows server 2003 There is no parameter for making a "blocking" connect ? John >Gamoto wrote: >> What is wrong in this code ? When I run it, without a listening server, after a few second, I have a timeout error !! >> infinity parameter is not correctly defined ? >Which OS and Erlang release are you using? When I try that on R12B-5 >for both Linux and Windows it returns quickly as well, but the Reason is >'econnrefused' which is what I'd expect to see when there's no server there. > >The timeout parameter is how long the connection attempt will wait for a >response of any kind, be it success, refusal or some other kind of >failure. Setting it to 'infinity' (the default, by the way, so you >don't need to explicitly set it) doesn't mean that it will keep retrying >a failed connection indefinitely. > >Cheers, > >Bernard > From ryeguy1@REDACTED Sun Apr 5 19:53:25 2009 From: ryeguy1@REDACTED (Ryan Lepidi) Date: Sun, 5 Apr 2009 13:53:25 -0400 Subject: [erlang-questions] Couple of questions about mnesia locking In-Reply-To: <49D85D76.1090808@erlang-consulting.com> References: <18e85b62-ca61-475e-8260-4ec5080aa568@r37g2000yqn.googlegroups.com> <393375.16569.qm@web65508.mail.ac4.yahoo.com> <2beddffc-c2cf-4238-8676-61399b9aeb79@k2g2000yql.googlegroups.com> <4d08db370904041259g6f87a0e0qb426f6d5ea1947ff@mail.gmail.com> <4d08db370904041352g11f411a5x7e9a900af3d4630a@mail.gmail.com> <49D85D76.1090808@erlang-consulting.com> Message-ID: I apreciate your guys' help. I have a question though, what would happen in this situation? NodeA reads balance of 5; gets read lock on record NodeB reads balance of 5; gets read lock on record %on another node, so read lock is possible NodeB writes balance of 15; gets write lock on record %does the write then releases the lock NodeA writes balance of 10; gets write lock on record NodeA would have a stale value and NodeB would not have to wait for any locks, so neither of them would restart afaik. I know one way to prevent this is to acquire a write lock at the beginning, but how can you do that with an index_read? It seems the only way to do that would be to read the object then wread() it again with the object's primary key. Blech. Hopefully there is some other solution? Actually, after reading Ulf's reply, I just realized what I typed is probably answered by what he said. Do you mean ALL locks are acquired before any records are read or written? So in other words, the situation above is impossible? On Sun, Apr 5, 2009 at 3:27 AM, Ulf Wiger wrote: > Hynek Vychodil wrote: > >> mnesia uses optimistic locking. When NodeB's write is called than >> transaction fails and is restarted. This is why mneasia transaction should >> not contain side-effects. See mnesia manual for details. >> > > Actually, no. Mnesia waits for the locks needed before > proceeding, and keeps the locks until it either aborts > or commits. However, in any locking environment, one > must guard against deadlocks. If the lock manager is > centralized, it's possible to maintain a wait-for graph, > which is scanned each time a new lock is requested. > > This approach doesn't scale in a distributed setting, > so an alternative approach, called "deadlock prevention", > is to allow only unidirectional dependencies (for some > definition of unidirectional - e.g. from smaller to > larger pids.) If a lock is requested that would create > a dependency in the other direction, one of the > transactions involved is restarted. This is why mnesia > transactions can restart sometimes. > > BR, > Ulf W > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nm@REDACTED Sun Apr 5 20:47:04 2009 From: nm@REDACTED (Gaspar Chilingarov) Date: Sun, 05 Apr 2009 23:47:04 +0500 Subject: [erlang-questions] Storing funs in term files In-Reply-To: References: Message-ID: <49D8FCA8.3040801@web.am> Steve Davis wrote: > Given that: > 1> A = {echo, fun(X) -> X end}. > {echo,#Fun} > > I have a scenario where it would be useful to store funs in term > files, for example: > > % contents of the term file > {echo, fun(X) -> X end}. > > 2>{ok, B} = file:consult("fun.term"). > ** exception error: no match of right hand side value > {error,{2,erl_parse,"bad term"}} > use file:script and not file:consult :) I'd stuck in the same place several years ago :) @aldan ~/tmp> cat > a.term {echo, fun(X) -> X end}. @aldan ~/tmp> erl Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.6.3 (abort with ^G) 1> file:consult("a.term"). {error,{1,erl_parse,"bad term"}} 2> file:script("a.term"). {ok,{echo,#Fun}} 3> NOTICE: file:script is VERY uneffective/time consuming, so if you are going to read many files or read them several times - write some simple caching process around file:script . If you repeatedly call it on the same file - it will be main bottleneck, caching may improve performance 10000-100000 times ;). /Gaspar -- Gaspar Chilingarov tel +37493 419763 (mobile - leave voice mail message) icq 63174784 skype://gasparch e mailto:nm@REDACTED mailto:gasparch@REDACTED w http://gasparchilingarov.com/ From ulf.wiger@REDACTED Sun Apr 5 23:21:46 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sun, 5 Apr 2009 23:21:46 +0200 Subject: [erlang-questions] Couple of questions about mnesia locking Message-ID: A read lock can be upgraded to a write lock /only/ if there are no other read locks on the object. Otherwise the transaction must wait until the other read locks are released. In your example, this won't happen, and one of the two transactions must restart. You can go for a write lock directly if you want. For index_read(), there isn't a version that lets you specify the lock type, but according to the docs, it takes a read lock on the whole table. Then start by taking a write lock on the table instead. BR, Ulf W -- originalmedd. -- ?mne: Re: [erlang-questions] Couple of questions about mnesia locking Fr?n: Ryan Lepidi Datum: 2009.04.05 19.51 I apreciate your guys' help. I have a question though, what would happen in this situation? NodeA reads balance of 5; gets read lock on record NodeB reads balance of 5; gets read lock on record %on another node, so read lock is possible NodeB writes balance of 15; gets write lock on record %does the write then releases the lock NodeA writes balance of 10; gets write lock on record NodeA would have a stale value and NodeB would not have to wait for any locks, so neither of them would restart afaik. I know one way to prevent this is to acquire a write lock at the beginning, but how can you do that with an index_read? It seems the only way to do that would be to read the object then wread() it again with the object's primary key. Blech. Hopefully there is some other solution? Actually, after reading Ulf's reply, I just realized what I typed is probably answered by what he said. Do you mean ALL locks are acquired before any records are read or written? So in other words, the situation above is impossible? On Sun, Apr 5, 2009 at 3:27 AM, Ulf Wiger wrote: > Hynek Vychodil wrote: > >> mnesia uses optimistic locking. When NodeB's write is called than >> transaction fails and is restarted. This is why mneasia transaction should >> not contain side-effects. See mnesia manual for details. >> > > Actually, no. Mnesia waits for the locks needed before > proceeding, and keeps the locks until it either aborts > or commits. However, in any locking environment, one > must guard against deadlocks. If the lock manager is > centralized, it's possible to maintain a wait-for graph, > which is scanned each time a new lock is requested. > > This approach doesn't scale in a distributed setting, > so an alternative approach, called "deadlock prevention", > is to allow only unidirectional dependencies (for some > definition of unidirectional - e.g. from smaller to > larger pids.) If a lock is requested that would create > a dependency in the other direction, one of the > transactions involved is restarted. This is why mnesia > transactions can restart sometimes. > > BR, > Ulf W > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com > From steven.charles.davis@REDACTED Mon Apr 6 00:01:47 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sun, 05 Apr 2009 17:01:47 -0500 Subject: [erlang-questions] Storing funs in term files In-Reply-To: <49D8FCA8.3040801@web.am> References: <49D8FCA8.3040801@web.am> Message-ID: <49D92A4B.4070005@gmail.com> Hi Gaspar, Noted! I'm usually pretty careful about file I/O. In this case the initial file:script read will parameterize a module which will be used by the application for the actual "work". So it's an on-create function only :) Thanks and regards, Steve Gaspar Chilingarov wrote: > Steve Davis wrote: >> Given that: >> 1> A = {echo, fun(X) -> X end}. >> {echo,#Fun} >> >> I have a scenario where it would be useful to store funs in term >> files, for example: >> >> % contents of the term file >> {echo, fun(X) -> X end}. >> >> 2>{ok, B} = file:consult("fun.term"). >> ** exception error: no match of right hand side value >> {error,{2,erl_parse,"bad term"}} >> > > use file:script and not file:consult :) > > I'd stuck in the same place several years ago :) > > @aldan ~/tmp> cat > a.term > {echo, fun(X) -> X end}. > @aldan ~/tmp> erl > Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.6.3 (abort with ^G) > 1> file:consult("a.term"). > {error,{1,erl_parse,"bad term"}} > 2> file:script("a.term"). > {ok,{echo,#Fun}} > 3> > > NOTICE: file:script is VERY uneffective/time consuming, so if you are > going to read many files or read them several times - write some simple > caching process around file:script . > If you repeatedly call it on the same file - it will be main bottleneck, > caching may improve performance 10000-100000 times ;). > > /Gaspar > > > > > From gamoto@REDACTED Mon Apr 6 01:29:12 2009 From: gamoto@REDACTED (Gamoto) Date: Mon, 6 Apr 2009 00:29:12 +0100 Subject: [erlang-questions] checksum calculation Message-ID: <200904060029112519995@bluewin.ch> I have a string of bytes and would like to compute the checksum which is the xor of all bytes. Let S the string, N the current byte checksum( <>,Csum) -> checksum(Rest,Csum bxor N); The problems are: I don't know how to start (checksum(<>) ???) and how to finish ! First of all, is it the correct approach ? (I suppose I rather should make Csum Exclusive-OR N modulo 8 ???) From bernie@REDACTED Mon Apr 6 00:22:13 2009 From: bernie@REDACTED (Bernard Duggan) Date: Mon, 06 Apr 2009 08:22:13 +1000 Subject: [erlang-questions] No timeout on connect In-Reply-To: <200904051932239558328@bluewin.ch> References: <200904041438162228321@bluewin.ch>, <49D8304D.5060305@m5net.com> <200904051932239558328@bluewin.ch> Message-ID: <49D92F15.6000102@m5net.com> connect() is always blocking, that's why you can provide a timeout. If, however, you actually mean a connect that will continue to retry failed connections indefinitely, then no, you'd have to implement that behaviour yourself. Cheers, B Gamoto wrote: > I run on Windows server 2003 > There is no parameter for making a "blocking" connect ? > John >> Gamoto wrote: >>> What is wrong in this code ? When I run it, without a listening server, after a few second, I have a timeout error !! >>> infinity parameter is not correctly defined ? >> Which OS and Erlang release are you using? When I try that on R12B-5 >> for both Linux and Windows it returns quickly as well, but the Reason is >> 'econnrefused' which is what I'd expect to see when there's no server there. >> >> The timeout parameter is how long the connection attempt will wait for a >> response of any kind, be it success, refusal or some other kind of >> failure. Setting it to 'infinity' (the default, by the way, so you >> don't need to explicitly set it) doesn't mean that it will keep retrying >> a failed connection indefinitely. >> >> Cheers, >> >> Bernard >> > From jeffm@REDACTED Mon Apr 6 01:05:44 2009 From: jeffm@REDACTED (jm) Date: Mon, 06 Apr 2009 09:05:44 +1000 Subject: [erlang-questions] checksum calculation In-Reply-To: <200904060029112519995@bluewin.ch> References: <200904060029112519995@bluewin.ch> Message-ID: <49D93948.8090209@ghostgun.com> Is this what you had in mind? (NB: typed directly into email and is unchecked). checksum(B) when is_binary(B) -> checksum(B, 0). checksum(<<>>, Csum) -> %% this is the terminating case Csum; checksum(<>, Csum) -> %% this is the general cas eyou already had checksum(Rest, Csum bxor N). Hope that helps. Jeff. Gamoto wrote: > I have a string of bytes and would like to compute the checksum which is the xor of all bytes. > > Let S the string, N the current byte > > checksum( <>,Csum) -> > checksum(Rest,Csum bxor N); > > The problems are: I don't know how to start (checksum(<>) ???) and how to finish ! > First of all, is it the correct approach ? > (I suppose I rather should make Csum Exclusive-OR N modulo 8 ???) > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vances@REDACTED Mon Apr 6 01:09:40 2009 From: vances@REDACTED (Vance Shipley) Date: Sun, 5 Apr 2009 19:09:40 -0400 Subject: [erlang-questions] checksum calculation In-Reply-To: <200904060029112519995@bluewin.ch> References: <200904060029112519995@bluewin.ch> Message-ID: <20090405230939.GB236@h216-235-12-170.host.egate.net> Gamoto, You could call your checksum/2 function with zero for the accumulator but the conventional way is to export a checksum/1 function and just use checksum/2 internally. Put a clause head first which matches the empty input binary. -Vance -export([checksum/1]). checksum(Binary) -> checksum(Binary, 0). checksum( <<>>, Csum) -> Csum; checksum( <>, Csum) -> checksum(Rest, Csum bxor N). On Mon, Apr 06, 2009 at 12:29:12AM +0100, Gamoto wrote: } I have a string of bytes and would like to compute the } checksum which is the xor of all bytes. } } Let S the string, N the current byte } } checksum( <>,Csum) -> } checksum(Rest,Csum bxor N); } } The problems are: I don't know how to start (checksum(<>) ???) and how to finish ! From gamoto@REDACTED Mon Apr 6 11:30:56 2009 From: gamoto@REDACTED (Gamoto) Date: Mon, 6 Apr 2009 11:30:56 +0200 Subject: [erlang-questions] No timeout on connect References: <200904041438162228321@bluewin.ch>, <49D8304D.5060305@m5net.com>, <200904051932239558328@bluewin.ch>, <49D92F15.6000102@m5net.com> Message-ID: <200904061130558232964@bluewin.ch> I corrected my code as you said. connect is not blocking for me ! After 5-6 seconds, I have the message "Error on connect ! Timeout What is wrong ? -module(client). -export([start/0,wait/1]). start()-> case gen_tcp:connect("localhost",1688,[binary, {packet, 0}]) of {ok,Socket}-> io:format("Socket established~n"), loop(Socket); {error,Reason} -> io:format("Error on connect ! ~s~n",[Reason]) end. loop(Socket)-> gen_tcp:send(Socket,"1234"), wait(10000), loop(Socket). wait(Timeout)-> receive after Timeout-> 0 end. >connect() is always blocking, that's why you can provide a timeout. > >If, however, you actually mean a connect that will continue to retry >failed connections indefinitely, then no, you'd have to implement that >behaviour yourself. > >Cheers, > >B > >Gamoto wrote: >> I run on Windows server 2003 >> There is no parameter for making a "blocking" connect ? >> John >>> Gamoto wrote: >>>> What is wrong in this code ? When I run it, without a listening server, after a few second, I have a timeout error !! >>>> infinity parameter is not correctly defined ? >>> Which OS and Erlang release are you using? When I try that on R12B-5 >>> for both Linux and Windows it returns quickly as well, but the Reason is >>> 'econnrefused' which is what I'd expect to see when there's no server there. >>> >>> The timeout parameter is how long the connection attempt will wait for a >>> response of any kind, be it success, refusal or some other kind of >>> failure. Setting it to 'infinity' (the default, by the way, so you >>> don't need to explicitly set it) doesn't mean that it will keep retrying >>> a failed connection indefinitely. >>> >>> Cheers, >>> >>> Bernard >>> >> > From gamoto@REDACTED Mon Apr 6 11:34:51 2009 From: gamoto@REDACTED (Gamoto) Date: Mon, 6 Apr 2009 11:34:51 +0200 Subject: [erlang-questions] checksum calculation References: <200904060029112519995@bluewin.ch>, Message-ID: <200904061134514637116@bluewin.ch> If it is not a very good solution, would you like to suggest a better one, for me and the other readers ? > >On 6 Apr 2009, at 11:29 am, Gamoto wrote: > >> I have a string of bytes and would like to compute the checksum >> which is the xor of all bytes. >> >> Let S the string, N the current byte >> >> checksum( <>,Csum) -> >> checksum(Rest,Csum bxor N); >> >> The problems are: I don't know how to start (checksum(<>) ???) >> and how to finish ! > >checksum(Binary) -> > checksum(Binary, 0). > >checksum(<<>>, Sum) -> > Sum; >checksum(<>, Sum) -> > checksum(Rest, Sum bxor Byte). > >> >> First of all, is it the correct approach ? >> (I suppose I rather should make Csum Exclusive-OR N modulo 8 ???) > >Why? >The exclusive-OR of any number of bytes is still just one byte. > >Of course this isn't a very _good_ checksum, >but that's another issue. > From baryluk@REDACTED Mon Apr 6 12:02:26 2009 From: baryluk@REDACTED (Witold Baryluk) Date: Mon, 6 Apr 2009 12:02:26 +0200 Subject: [erlang-questions] Erlang and Larrabee CPU In-Reply-To: <22891627.post@talk.nabble.com> References: <2a67d3ff0904040932u3fc1a2a6r8555d8f8bc856dc8@mail.gmail.com> <2a67d3ff0904041554n41864463jef8d13ffbe7b4213@mail.gmail.com> <22891627.post@talk.nabble.com> Message-ID: <20090406100226.GB31258@smp.if.uj.edu.pl> On 04-05 01:41, Zvi wrote: > > I don't know in how many years we'll be able to run regular C/C++ code > natively on it, yet Erlang ;-) Actually Larabbe is x86 + extensions. It is regular multicore processor. Intel enginers was running lots of common existing C/C++ libraries on Larabbe. There will be probably version of larabbe which can be used as normal CPU, and run there OS (with Linux or BSD it will be very simple) As a computational platform Larabbe will be greate, just compile to x86 as usual (mayby with different -march, to use other optimalisations, and autovectorizations), put data and binary somewhere in RAM, run, and get results. With Erlang there is small problem with Larabbe as main CPU. What about IO? Can Larabbe generete or handle interupts from network cards, or disks? I know there will be some sort of DMA, but I'm just curious. Without interupt what can we do? Poll on each core, some area of memmory for notifications from host CPU. Ugly. -- Witold Baryluk JID: witold.baryluk // jabster.pl -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: Digital signature URL: From tony@REDACTED Mon Apr 6 12:57:21 2009 From: tony@REDACTED (Tony Rogvall) Date: Mon, 6 Apr 2009 12:57:21 +0200 Subject: [erlang-questions] checksum calculation In-Reply-To: <20090405230939.GB236@h216-235-12-170.host.egate.net> References: <200904060029112519995@bluewin.ch> <20090405230939.GB236@h216-235-12-170.host.egate.net> Message-ID: A small fix. On 6 apr 2009, at 01.09, Vance Shipley wrote: > Gamoto, > > You could call your checksum/2 function with zero for the > accumulator but the conventional way is to export a checksum/1 > function and just use checksum/2 internally. Put a clause head > first which matches the empty input binary. > > -Vance > > > -export([checksum/1]). > > checksum(Binary) -> > checksum(Binary, 0). > > checksum( <<>>, Csum) -> > Csum; > checksum( <>, Csum) -> > checksum(Rest, Csum bxor N). The last clause should be: checsum(<>, CSum) -> ... Otherwise the matching will match a binary with two byte values. <> = <<1,2,3,4,5>>. ** exception error: no match of right hand side value <<1,2,3,4,5>> <> = <<1,2,3,4,5>>. <<1,2,3,4,5>> 3> A. 1 4> B. <<2,3,4,5>> /Tony > > > > On Mon, Apr 06, 2009 at 12:29:12AM +0100, Gamoto wrote: > } I have a string of bytes and would like to compute the > } checksum which is the xor of all bytes. > } > } Let S the string, N the current byte > } > } checksum( <>,Csum) -> > } checksum(Rest,Csum bxor N); > } > } The problems are: I don't know how to start (checksum(<>) ???) > and how to finish ! > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From bengt.kleberg@REDACTED Mon Apr 6 17:13:08 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 06 Apr 2009 17:13:08 +0200 Subject: [erlang-questions] No timeout on connect In-Reply-To: <200904061130558232964@bluewin.ch> References: <200904041438162228321@bluewin.ch>, <49D8304D.5060305@m5net.com> , <200904051932239558328@bluewin.ch>, <49D92F15.6000102@m5net.com> <200904061130558232964@bluewin.ch> Message-ID: <1239030788.4558.29.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, What kind of server are you running? If it has done listen, but not accept, the timeout will be used. If there is no server, ie no listen, then you will get an error. bengt On Mon, 2009-04-06 at 11:30 +0200, Gamoto wrote: > I corrected my code as you said. connect is not blocking for me ! > After 5-6 seconds, I have the message "Error on connect ! Timeout > What is wrong ? > > -module(client). > -export([start/0,wait/1]). > > start()-> > case gen_tcp:connect("localhost",1688,[binary, {packet, 0}]) of > {ok,Socket}-> > io:format("Socket established~n"), > loop(Socket); > {error,Reason} -> io:format("Error on connect ! ~s~n",[Reason]) > end. > > loop(Socket)-> > gen_tcp:send(Socket,"1234"), > wait(10000), > loop(Socket). > > wait(Timeout)-> > receive > after Timeout-> > 0 > end. > > > > >connect() is always blocking, that's why you can provide a timeout. > > > >If, however, you actually mean a connect that will continue to retry > >failed connections indefinitely, then no, you'd have to implement that > >behaviour yourself. > > > >Cheers, > > > >B > > > >Gamoto wrote: > >> I run on Windows server 2003 > >> There is no parameter for making a "blocking" connect ? > >> John > >>> Gamoto wrote: > >>>> What is wrong in this code ? When I run it, without a listening server, after a few second, I have a timeout error !! > >>>> infinity parameter is not correctly defined ? > >>> Which OS and Erlang release are you using? When I try that on R12B-5 > >>> for both Linux and Windows it returns quickly as well, but the Reason is > >>> 'econnrefused' which is what I'd expect to see when there's no server there. > >>> > >>> The timeout parameter is how long the connection attempt will wait for a > >>> response of any kind, be it success, refusal or some other kind of > >>> failure. Setting it to 'infinity' (the default, by the way, so you > >>> don't need to explicitly set it) doesn't mean that it will keep retrying > >>> a failed connection indefinitely. > >>> > >>> Cheers, > >>> > >>> Bernard > >>> > >> > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From thomasl_erlang@REDACTED Mon Apr 6 19:55:59 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 6 Apr 2009 10:55:59 -0700 (PDT) Subject: [erlang-questions] Couple of questions about mnesia locking In-Reply-To: References: <18e85b62-ca61-475e-8260-4ec5080aa568@r37g2000yqn.googlegroups.com> <393375.16569.qm@web65508.mail.ac4.yahoo.com> <2beddffc-c2cf-4238-8676-61399b9aeb79@k2g2000yql.googlegroups.com> <4d08db370904041259g6f87a0e0qb426f6d5ea1947ff@mail.gmail.com> <4d08db370904041352g11f411a5x7e9a900af3d4630a@mail.gmail.com> <49D85D76.1090808@erlang-consulting.com> Message-ID: <834139.5114.qm@web111405.mail.gq1.yahoo.com> Your question has more to do with transactional systems in general than mnesia. Your example is not "serializable" and so wouldn't be permitted in a transactional database. As far as I can see, NodeA and NodeB would instead deadlock, and one of them would be aborted and perhaps retried. Regarding how this is implemented (though perhaps mnesia does things differently), before acquiring a write lock on the balance record, NodeB would first have to wait for NodeA to release its read lock on the same, and conversely, NodeA would wait for all read-lockers of the record to release their locks before acquiring its write lock. A simple way of getting things right is for a transaction to only releases its locks when it commits or aborts. (It's up to the database to detect and repair deadlocks.) Best, Thomas ________________________________ From: Ryan Lepidi To: Ulf Wiger Cc: erlang-questions@REDACTED Sent: Sunday, April 5, 2009 7:53:25 PM Subject: Re: [erlang-questions] Couple of questions about mnesia locking I apreciate your guys' help. I have a question though, what would happen in this situation? NodeA reads balance of 5; gets read lock on record NodeB reads balance of 5; gets read lock on record %on another node, so read lock is possible NodeB writes balance of 15; gets write lock on record %does the write then releases the lock NodeA writes balance of 10; gets write lock on record NodeA would have a stale value and NodeB would not have to wait for any locks, so neither of them would restart afaik. I know one way to prevent this is to acquire a write lock at the beginning, but how can you do that with an index_read? It seems the only way to do that would be to read the object then wread() it again with the object's primary key. Blech. Hopefully there is some other solution? Actually, after reading Ulf's reply, I just realized what I typed is probably answered by what he said. Do you mean ALL locks are acquired before any records are read or written? So in other words, the situation above is impossible? On Sun, Apr 5, 2009 at 3:27 AM, Ulf Wiger wrote: Hynek Vychodil wrote: mnesia uses optimistic locking. When NodeB's write is called than transaction fails and is restarted. This is why mneasia transaction should not contain side-effects. See mnesia manual for details. Actually, no. Mnesia waits for the locks needed before proceeding, and keeps the locks until it either aborts or commits. However, in any locking environment, one must guard against deadlocks. If the lock manager is centralized, it's possible to maintain a wait-for graph, which is scanned each time a new lock is requested. This approach doesn't scale in a distributed setting, so an alternative approach, called "deadlock prevention", is to allow only unidirectional dependencies (for some definition of unidirectional - e.g. from smaller to larger pids.) If a lock is requested that would create a dependency in the other direction, one of the transactions involved is restarted. This is why mnesia transactions can restart sometimes. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias@REDACTED Mon Apr 6 21:36:30 2009 From: matthias@REDACTED (Matthias Lang) Date: Mon, 6 Apr 2009 21:36:30 +0200 Subject: [erlang-questions] checksum calculation In-Reply-To: <200904061134514637116@bluewin.ch> References: <200904061134514637116@bluewin.ch> Message-ID: <20090406193630.GA2879@contorpis.lisalinda.com> On Monday, April 06, Gamoto wrote: > If it is not a very good solution, would you like to suggest a > better one, for me and the other readers ? The checksum you described has a number of undesirable properties. One is that it's 'blind' to the addition or removal of any octets with all bits set to zero. I.e. gamoto:checksum(<<1,2,3>>) == gamoto:checksum(<<1,0,2,3>>) Another is that it's blind to reordering in general: gamoto:checksum(<<1,2,3>>) == gamoto:checksum(<<3,2,1>>) Depending on the application, that might matter. As for alternatives, two common ones are CRCs and cryptographic checksums. They have various tradeoffs. erlang:md5sum() and crypto:sha() are examples of the latter. The properties and limitations of CRCs are well understood, while the limitations of cryptographic checksums are the subject of very active research. Wikipedia has decent articles about both sorts. Matthias From raould@REDACTED Tue Apr 7 00:52:34 2009 From: raould@REDACTED (Raoul Duke) Date: Mon, 6 Apr 2009 15:52:34 -0700 Subject: [erlang-questions] local vs. distributed differences? In-Reply-To: <91a2ba3e0904030900q11754d0eq186eb3f0a7a5a7c@mail.gmail.com> References: <91a2ba3e0904030900q11754d0eq186eb3f0a7a5a7c@mail.gmail.com> Message-ID: <91a2ba3e0904061552k74724400la874c736fa07d479@mail.gmail.com> hi, > reading the McErlang stuff, i learned that message delivery order is > only guaranteed when things aren't distributed. (looking around on the > net, it i've heard that it is further only when you have multiple > messages going from the same sender to the same receiver.) i misunderstood/read. (the McErlang paper notes that non-distributed message passing is "instantaneous" whereas distributed is not.) thanks to all for the education! From rhenig@REDACTED Tue Apr 7 01:41:39 2009 From: rhenig@REDACTED (Robert Henig) Date: Mon, 6 Apr 2009 19:41:39 -0400 Subject: [erlang-questions] Job position in Fremont, CA Message-ID: My apologies if this is inappropriate for this list and please let me know a better place. Redwood Systems an early stage startup in Fremont California. We are transforming energy efficient commercial lighting. Bringing together semiconductor, networking and systems specialists, Redwood is designing a revolutionary new platform that will exploit emerging solid-state, light emitting diode (LED) lighting technology. Redwood's goal is to optimize LEDs for commercial venues - controlled and automated, more energy efficient, easier to install and manage, more reliable and maintenance free. We are looking for an experienced Erlang Engineer. The successful candidate will design, test, maintain, and support Erlang applications written for embedded devices. Required Qualifications - 3 years professional experience with Erlang in large distributed systems - 5 years professional experience with an object-oriented languages (C++, Java) - BS or MS in Computer Science, Computer Engineering, Electrical Engineering or equivalent. Additional Qualifications - Experience with Mnesia. - Experience with Erlang port drivers. - Experience with rules engines (expert system shells). - Work history with early stage startups. Please send your resume to: careers@REDACTED -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Tue Apr 7 03:29:18 2009 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 7 Apr 2009 13:29:18 +1200 Subject: [erlang-questions] checksum calculation In-Reply-To: <200904061134514637116@bluewin.ch> References: <200904060029112519995@bluewin.ch>, <200904061134514637116@bluewin.ch> Message-ID: On 6 Apr 2009, at 9:34 pm, Gamoto wrote: > If it is not a very good solution, would you like to suggest a > better one, for me and the other readers ?\ Suppose you have a block of bytes and there is an error that results in one byte being replaced by a different byte. Then an XOR checksum will detect that difference. Suppose there is an error that results in two bytes being swapped. Then an XOR checksum will detect no change at all. Or suppose that two equal bytes are both replaced by the same new byte. Again, nothing noticed by XOR. Just look "checksum" up in the Wikipedia; that's as good a place as any to start. The 'zlib' module in Erlang already has support for crc32 and adler32. I thought I saw crc32 somewhere else as well. Theory and practice don't agree as much in practice as they do in theory, so it's worth having a look at "Performance of Checksums and CRCs over Real Data" by Jonathan Stone, Michael Greenwald, Craig Partridge, and Jim Hughes and at "Revisiting Fletcher and Adler Checksums" by Theresa Maxino, whose conclusions I found surprising. It all depends on what your data are like and what kinds of errors you plausibly need to protect against, really. From ryeguy1@REDACTED Tue Apr 7 04:11:51 2009 From: ryeguy1@REDACTED (ryeguy) Date: Mon, 6 Apr 2009 19:11:51 -0700 (PDT) Subject: [erlang-questions] In a mnesia cluster, which node is queried? Message-ID: If you have a mnesia table replicated on nodes A and B, how does node C (which does not contain a copy of the table) choose which table to execute a query on? Is it random? From tuscland@REDACTED Tue Apr 7 01:07:40 2009 From: tuscland@REDACTED (Camille Troillard) Date: Tue, 7 Apr 2009 01:07:40 +0200 Subject: [erlang-questions] Concurrent Processes and the Programming Erlang book Message-ID: Hello, The Programming Erlang book has a nice exercise at section 8.11. ?I'm sure?this problem must have been solved a billion times before, so I won't go too much into the details. "Write a ring benchmark. Create N processes in a ring. Send a message round the ring M times so that a total of N * M messages get sent. Time how long this takes for different values of N and M." Although it is written in the "Concurrent Programming" chapter, I wondered if this problem was really concurrent after all: ?the messages are sent to a ring of N processes, but it is not stated that shall be sent in parallel. ?So I decided to write a parallel version of this. Attached is an erlang module that will spawn a?ring of?N processes and send a total of M messages through it (that is N times N/M messages). To use it: rb:start(10, 10000). Will send 1000 messages 10 times in a 10 process ring. ?The result is a tuple containing timing informations. The results I have found are interesting in that it shows that Erlang starts to span the processing on multiple cores starting at 30 processes. ?At this point, efficiency drops in favor of multiprocessing gaining efficiency back up to 1000 parallel processes. Also attached is a graph showing the time spent to send one message for a MacBook Pro (2 cores), a MacPro (4 cores) and a small Lenovo Ideapad S10 (2 cores) under Windows, which to my great surprise compares pretty well to the two former competitors. ?The comparison between each computer is indeed flawed for many reasons, but the shape of the graphs is interesting. I would be happy to know your feedback about the code, and please let me know if there is something wrong in my interpretation. Best Regards, Camille -------------- next part -------------- A non-text attachment was scrubbed... Name: rb.erl Type: application/octet-stream Size: 4057 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Ring Bench Graph.png Type: image/png Size: 100422 bytes Desc: not available URL: From gamoto@REDACTED Tue Apr 7 10:54:46 2009 From: gamoto@REDACTED (Gamoto) Date: Tue, 7 Apr 2009 10:54:46 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 23, Issue 25 References: Message-ID: <200904071054449041054@bluewin.ch> Suppose you have an industrial machine which send messages following by the checksum calculated by the xor of all bytes, what can I do with your advices ;-) >Send erlang-questions mailing list submissions to > erlang-questions@REDACTED > >To subscribe or unsubscribe via the World Wide Web, visit > http://www.erlang.org/mailman/listinfo/erlang-questions >or, via email, send a message with subject or body 'help' to > erlang-questions-request@REDACTED > >You can reach the person managing the list at > erlang-questions-owner@REDACTED > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of erlang-questions digest..." > > >Today's Topics: > > 1. Re: checksum calculation (Richard O'Keefe) > 2. In a mnesia cluster, which node is queried? (ryeguy) > 3. Concurrent Processes and the Programming Erlang book > (Camille Troillard) > > >---------------------------------------------------------------------- > >Message: 1 >Date: Tue, 7 Apr 2009 13:29:18 +1200 >From: "Richard O'Keefe" >Subject: Re: [erlang-questions] checksum calculation >To: Gamoto >Cc: erlang-questions >Message-ID: >Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes > > >On 6 Apr 2009, at 9:34 pm, Gamoto wrote: > >> If it is not a very good solution, would you like to suggest a >> better one, for me and the other readers ?\ > >Suppose you have a block of bytes and there is an >error that results in one byte being replaced by >a different byte. Then an XOR checksum will detect >that difference. > >Suppose there is an error that results in two bytes >being swapped. Then an XOR checksum will detect no >change at all. Or suppose that two equal bytes are >both replaced by the same new byte. Again, nothing >noticed by XOR. > >Just look "checksum" up in the Wikipedia; that's as >good a place as any to start. > >The 'zlib' module in Erlang already has support for >crc32 and adler32. I thought I saw crc32 somewhere >else as well. > >Theory and practice don't agree as much in practice >as they do in theory, so it's worth having a look at >"Performance of Checksums and CRCs over Real Data" >by Jonathan Stone, Michael Greenwald, Craig Partridge, >and Jim Hughes >and at "Revisiting Fletcher and Adler Checksums" >by Theresa Maxino, whose conclusions I found surprising. > >It all depends on what your data are like and what >kinds of errors you plausibly need to protect against, >really. > > > > >------------------------------ > >Message: 2 >Date: Mon, 6 Apr 2009 19:11:51 -0700 (PDT) >From: ryeguy >Subject: [erlang-questions] In a mnesia cluster, which node is > queried? >To: erlang-questions@REDACTED >Message-ID: > >Content-Type: text/plain; charset=ISO-8859-1 > >If you have a mnesia table replicated on nodes A and B, how does node >C (which does not contain a copy of the table) choose which table to >execute a query on? Is it random? > > >------------------------------ > >Message: 3 >Date: Tue, 7 Apr 2009 01:07:40 +0200 >From: Camille Troillard >Subject: [erlang-questions] Concurrent Processes and the Programming > Erlang book >To: erlang-questions@REDACTED >Message-ID: > >Content-Type: text/plain; charset="iso-8859-1" > >Hello, > >The Programming Erlang book has a nice exercise at section 8.11. ?I'm >sure?this problem must have been solved a billion times before, so I >won't go too much into the details. > >"Write a ring benchmark. Create N processes in a ring. Send a message >round the ring M times so that a total of N * M messages get sent. >Time how long this takes for different values of N and M." > >Although it is written in the "Concurrent Programming" chapter, I >wondered if this problem was really concurrent after all: ?the >messages are sent to a ring of N processes, but it is not stated that >shall be sent in parallel. ?So I decided to write a parallel version >of this. >Attached is an erlang module that will spawn a?ring of?N processes and >send a total of M messages through it (that is N times N/M messages). >To use it: > >rb:start(10, 10000). > >Will send 1000 messages 10 times in a 10 process ring. ?The result is >a tuple containing timing informations. > >The results I have found are interesting in that it shows that Erlang >starts to span the processing on multiple cores starting at 30 >processes. ?At this point, efficiency drops in favor of >multiprocessing gaining efficiency back up to 1000 parallel processes. > >Also attached is a graph showing the time spent to send one message >for a MacBook Pro (2 cores), a MacPro (4 cores) and a small Lenovo >Ideapad S10 (2 cores) under Windows, which to my great surprise >compares pretty well to the two former competitors. ?The comparison >between each computer is indeed flawed for many reasons, but the shape >of the graphs is interesting. > >I would be happy to know your feedback about the code, and please let >me know if there is something wrong in my interpretation. > > >Best Regards, >Camille >-------------- next part -------------- >A non-text attachment was scrubbed... >Name: rb.erl >Type: application/octet-stream >Size: 4056 bytes >Desc: not available >Url : http://www.erlang.org/pipermail/erlang-questions/attachments/20090407/1ce97506/attachment.obj >-------------- next part -------------- >A non-text attachment was scrubbed... >Name: Ring Bench Graph.png >Type: image/png >Size: 100422 bytes >Desc: not available >Url : http://www.erlang.org/pipermail/erlang-questions/attachments/20090407/1ce97506/attachment.png > >------------------------------ > >_______________________________________________ >erlang-questions mailing list >erlang-questions@REDACTED >http://www.erlang.org/mailman/listinfo/erlang-questions > >End of erlang-questions Digest, Vol 23, Issue 25 >************************************************ From gamoto@REDACTED Tue Apr 7 10:55:53 2009 From: gamoto@REDACTED (Gamoto) Date: Tue, 7 Apr 2009 10:55:53 +0200 Subject: [erlang-questions] checksum calculation References: <200904060029112519995@bluewin.ch>, , <200904061134514637116@bluewin.ch>, Message-ID: <200904071055534829526@bluewin.ch> Richard, Suppose you have an industrial machine which send messages following by the checksum calculated by the xor of all bytes, what can I do with your advices ;-) John > >On 6 Apr 2009, at 9:34 pm, Gamoto wrote: > >> If it is not a very good solution, would you like to suggest a >> better one, for me and the other readers ?\ > >Suppose you have a block of bytes and there is an >error that results in one byte being replaced by >a different byte. Then an XOR checksum will detect >that difference. > >Suppose there is an error that results in two bytes >being swapped. Then an XOR checksum will detect no >change at all. Or suppose that two equal bytes are >both replaced by the same new byte. Again, nothing >noticed by XOR. > >Just look "checksum" up in the Wikipedia; that's as >good a place as any to start. > >The 'zlib' module in Erlang already has support for >crc32 and adler32. I thought I saw crc32 somewhere >else as well. > >Theory and practice don't agree as much in practice >as they do in theory, so it's worth having a look at >"Performance of Checksums and CRCs over Real Data" >by Jonathan Stone, Michael Greenwald, Craig Partridge, >and Jim Hughes >and at "Revisiting Fletcher and Adler Checksums" >by Theresa Maxino, whose conclusions I found surprising. > >It all depends on what your data are like and what >kinds of errors you plausibly need to protect against, >really. > > From gamoto@REDACTED Tue Apr 7 11:13:46 2009 From: gamoto@REDACTED (Gamoto) Date: Tue, 7 Apr 2009 11:13:46 +0200 Subject: [erlang-questions] strange behaviour of gen_tcp:connect Message-ID: <200904071113461917143@bluewin.ch> I an windows server 2003. I don't understand why gen_tcp:connect returns ALWAYS an error. "connect" should be blocking, the port is free, I didn't precise a timeout. I also tried with "localhost". Another strange effect: error returned is "econnrefused" or, when another emacs is opened with erlang code inside, the returned error is "timeout" !!! Is it "normal" with Erlang ? John start()-> case gen_tcp:connect("127.0.0.1",1688,[binary, {packet, 0}]) of {ok,Socket}-> io:format("Socket established~n"), loop(Socket); {error,Reason}-> io:format("Error on connect: ~s~n",[Reason]) end. From gamoto@REDACTED Tue Apr 7 11:20:07 2009 From: gamoto@REDACTED (Gamoto) Date: Tue, 7 Apr 2009 11:20:07 +0200 Subject: [erlang-questions] process - crash Message-ID: <200904071120068729167@bluewin.ch> When a process spawns (without link) another process, what happens if the spawned process crashes, mainly in a communication environment ? Does the memory release ? what is the impact on the first process ? on the sockets ? (Documentation reference welcome !) From bengt.kleberg@REDACTED Tue Apr 7 12:24:41 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 07 Apr 2009 12:24:41 +0200 Subject: [erlang-questions] strange behaviour of gen_tcp:connect In-Reply-To: <200904071113461917143@bluewin.ch> References: <200904071113461917143@bluewin.ch> Message-ID: <1239099881.4558.83.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, It is likely that deep down inside the Erlang VM the gen_tcp:connect is performed by the C library call connect. This C call is blocking and can return a timeout error. What do you get if you directly (in a C program) call connect with the arguments you have given to gen_tcp:connect? bengt On Tue, 2009-04-07 at 11:13 +0200, Gamoto wrote: > I an windows server 2003. I don't understand why gen_tcp:connect returns ALWAYS an error. > "connect" should be blocking, the port is free, I didn't precise a timeout. I also tried with "localhost". > Another strange effect: error returned is "econnrefused" or, when another emacs is opened with erlang code inside, the returned error is "timeout" !!! > Is it "normal" with Erlang ? > > John > > start()-> > case gen_tcp:connect("127.0.0.1",1688,[binary, {packet, 0}]) of > {ok,Socket}-> > io:format("Socket established~n"), > loop(Socket); > {error,Reason}-> > io:format("Error on connect: ~s~n",[Reason]) > end. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From raimo+erlang-questions@REDACTED Tue Apr 7 13:55:42 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Tue, 7 Apr 2009 13:55:42 +0200 Subject: [erlang-questions] strange behaviour of gen_tcp:connect In-Reply-To: <200904071113461917143@bluewin.ch> References: <200904071113461917143@bluewin.ch> Message-ID: <20090407115542.GA2642@erix.ericsson.se> On Tue, Apr 07, 2009 at 11:13:46AM +0200, Gamoto wrote: > I an windows server 2003. I don't understand why gen_tcp:connect returns ALWAYS an error. > "connect" should be blocking, the port is free, I didn't precise a timeout. I also tried with "localhost". > Another strange effect: error returned is "econnrefused" or, when another emacs is opened with erlang code inside, the returned error is "timeout" !!! > Is it "normal" with Erlang ? What do you mean by "the port is free". Something must be listening on port 1688 for the loopback interface. If nothing is listening on the port, the TCP stack of the OS will immediately inform gen_tcp about that, hence the econnrefused. This is basic TCP/IP, no Erlang quirks. I also have a Win2003Server: 1> gen_tcp:connect("127.0.0.1",3389,[binary, {packet, 0}]). {ok,#Port<0.444>} since I have a Windows remote desktop server listening on port 3389. If you really want the IP address, use the Erlang gen_tcp IP address tuple as documented in: http://www.erlang.org/doc/man/inet.html {127,0,0,1} instead of "127.0.0.1". The first is taken as an IP address direct, the second is processed through the name resolver. > > John > > start()-> > case gen_tcp:connect("127.0.0.1",1688,[binary, {packet, 0}]) of > {ok,Socket}-> > io:format("Socket established~n"), > loop(Socket); > {error,Reason}-> > io:format("Error on connect: ~s~n",[Reason]) > end. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From gamoto@REDACTED Tue Apr 7 14:47:01 2009 From: gamoto@REDACTED (Gamoto) Date: Tue, 7 Apr 2009 14:47:01 +0200 Subject: [erlang-questions] strange behaviour of gen_tcp:connect References: <200904071113461917143@bluewin.ch>, <20090407115542.GA2642@erix.ericsson.se> Message-ID: <200904071447015107575@bluewin.ch> The same code written in PHP is suspended in connect !!! I am not sure that is it a basic TCP behaviour, but maybe I am wrong ! >On Tue, Apr 07, 2009 at 11:13:46AM +0200, Gamoto wrote: >> I an windows server 2003. I don't understand why gen_tcp:connect returns ALWAYS an error. >> "connect" should be blocking, the port is free, I didn't precise a timeout. I also tried with "localhost". >> Another strange effect: error returned is "econnrefused" or, when another emacs is opened with erlang code inside, the returned error is "timeout" !!! >> Is it "normal" with Erlang ? > >What do you mean by "the port is free". Something must >be listening on port 1688 for the loopback interface. >If nothing is listening on the port, the TCP stack >of the OS will immediately inform gen_tcp about >that, hence the econnrefused. > >This is basic TCP/IP, no Erlang quirks. > >I also have a Win2003Server: > >1> gen_tcp:connect("127.0.0.1",3389,[binary, {packet, 0}]). >{ok,#Port<0.444>} > >since I have a Windows remote desktop server >listening on port 3389. > >If you really want the IP address, use the Erlang >gen_tcp IP address tuple as documented in: > http://www.erlang.org/doc/man/inet.html >{127,0,0,1} instead of "127.0.0.1". The first >is taken as an IP address direct, the second >is processed through the name resolver. > >> >> John >> >> start()-> >> case gen_tcp:connect("127.0.0.1",1688,[binary, {packet, 0}]) of >> {ok,Socket}-> >> io:format("Socket established~n"), >> loop(Socket); >> {error,Reason}-> >> io:format("Error on connect: ~s~n",[Reason]) >> end. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > >-- > >/ Raimo Niskanen, Erlang/OTP, Ericsson AB From ryeguy1@REDACTED Tue Apr 7 16:22:00 2009 From: ryeguy1@REDACTED (ryeguy) Date: Tue, 7 Apr 2009 07:22:00 -0700 (PDT) Subject: [erlang-questions] In a mnesia cluster, which node is queried? In-Reply-To: References: Message-ID: <7a8d005a-036c-4ada-896d-6719dbe7178b@p11g2000yqe.googlegroups.com> I reposted this question elsewhere, and I worded it differently. Here is my reworded question if it makes it more clear: Let's say you have a mnesia table replicated on nodes A and B. If on node C, which does not contain a copy of the table, I do mnesia:change_config(extra_db_nodes, [NodeA, NodeB]), and then on node C I do mnesia:dirty_read(user, bob) how does node C choose which node's copy of the table to execute a query on? On Apr 6, 10:11?pm, ryeguy wrote: > If you have a mnesia table replicated on nodes A and B, how does node > C (which does not contain a copy of the table) choose which table to > execute a query on? Is it random? > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From icfp.publicity@REDACTED Tue Apr 7 16:50:41 2009 From: icfp.publicity@REDACTED (Matthew Fluet (ICFP Publicity Chair)) Date: Tue, 7 Apr 2009 09:50:41 -0500 Subject: [erlang-questions] CFP: JFP Special Issue on Generic Programming Message-ID: <53ff55480904070750w5fce718i9385e926be9e8963@mail.gmail.com> OPEN CALL FOR PAPERS JFP Special Issue on Generic Programming Deadline: 1 October 2009 http://www.comlab.ox.ac.uk/ralf.hinze/JFP/cfp.html Scope ----- Generic programming is about making programs more adaptable by making them more general. Generic programs often embody non-traditional kinds of polymorphism; ordinary programs are obtained from them by suitably instantiating their parameters. In contrast to normal programs, the parameters of a generic program are often quite rich in structure; for example they may be other programs, types or type constructors, classes, concepts, or even programming paradigms. This special issue aims at documenting state-of-the-art research, new developments and directions for future investigation in the broad field of Generic Programming. It is an outgrowth of the series of Workshops on Generic Programming, which started in 1998 and which continues this year with an ICFP affiliated workshop in Edinburgh. Participants of the workshops are invited to submit a suitably revised and expanded version of their paper to the special issue. The call for papers is, however, open. Other contributions are equally welcome and are, indeed, encouraged. All submitted papers will be subjected to the same quality criteria, meeting the standards of the Journal of Functional Programming. The special issue seeks original contributions on all aspects of generic programming including but not limited to o adaptive object-oriented programming, o aspect-oriented programming, o case studies, o concepts (as in the STL/C++ sense), o component-based programming, o datatype-generic programming, o generic programming with dependent types, o meta-programming, o polytypic programming, and o programming with modules. Submission details ------------------ Manuscripts should be unpublished works and not submitted elsewhere. Revised versions of papers published in conference or workshop proceedings that have not appeared in archival journals are eligible for submission. Deadline for submission: 1 October 2009 Notification of acceptance or rejection: 15 January 2010 Revised version due: 15 March 2010 For submission details, please consult http://www.comlab.ox.ac.uk/ralf.hinze/JFP/cfp.html or see the Journal's web page http://journals.cambridge.org/jfp Guest Editor ------------ Ralf Hinze University of Oxford Computing Laboratory Wolfson Building, Parks Road, Oxford OX1 3QD, UK. Telephone: +44 (1865) 610700 Fax: +44 (1865) 283531 Email: ralf.hinze@REDACTED WWW: http://www.comlab.ox.ac.uk/ralf.hinze/ ------------------------------------------------------------------------------- From dgud@REDACTED Tue Apr 7 16:51:29 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Tue, 07 Apr 2009 16:51:29 +0200 Subject: [erlang-questions] In a mnesia cluster, which node is queried? In-Reply-To: <7a8d005a-036c-4ada-896d-6719dbe7178b@p11g2000yqe.googlegroups.com> References: <7a8d005a-036c-4ada-896d-6719dbe7178b@p11g2000yqe.googlegroups.com> Message-ID: <49DB6871.2070808@erix.ericsson.se> Like this from mnesia_lib: set_remote_where_to_read(Tab, Ignore) -> Active = val({Tab, active_replicas}), Valid = case mnesia_recover:get_master_nodes(Tab) of [] -> Active; Masters -> mnesia_lib:intersect(Masters, Active) end, Available = mnesia_lib:intersect(val({current, db_nodes}), Valid -- Ignore), DiscOnlyC = val({Tab, disc_only_copies}), Prefered = Available -- DiscOnlyC, if Prefered /= [] -> set({Tab, where_to_read}, hd(Prefered)); Available /= [] -> set({Tab, where_to_read}, hd(Available)); true -> set({Tab, where_to_read}, nowhere) end. ryeguy wrote: > I reposted this question elsewhere, and I worded it differently. Here > is my reworded question if it makes it more clear: > > Let's say you have a mnesia table replicated on nodes A and B. If on > node C, which does not contain a copy of the table, I do > mnesia:change_config(extra_db_nodes, [NodeA, NodeB]), and then on node > C I do mnesia:dirty_read(user, bob) how does node C choose which > node's copy of the table to execute a query on? > > On Apr 6, 10:11 pm, ryeguy wrote: >> If you have a mnesia table replicated on nodes A and B, how does node >> C (which does not contain a copy of the table) choose which table to >> execute a query on? Is it random? >> _______________________________________________ >> erlang-questions mailing list >> erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From nesrait@REDACTED Tue Apr 7 17:17:57 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Tue, 7 Apr 2009 16:17:57 +0100 Subject: [erlang-questions] process - crash In-Reply-To: <200904071120068729167@bluewin.ch> References: <200904071120068729167@bluewin.ch> Message-ID: <523869a70904070817y3a850f4bhb4d1fc01621fa744@mail.gmail.com> Hi! When a process spawns (without link) another process, what happens if the > spawned process crashes, mainly in a communication environment ? > Does the memory release ? what is the impact on the first process ? on the > sockets ? > Each erlang process is independent and if you don't setup a link/monitor it will crash without any other process getting notified about it. But that's no fun! :) You can checkout out these docs to see how a bunch of processes linked together behave/can be setup to behave: - http://erlang.org/doc/getting_started/robustness.html#4.2 (in http://erlang.org/doc/getting_started/part_frame.html) - http://www.erlang.org/course/error_handling.html - http://erlang.org/doc/reference_manual/processes.html#10.7 (in http://erlang.org/doc/reference_manual/part_frame.html) - http://www.erlang.org/doc/man/erlang.html Regarding the "in a communication environment" part... if you are sending a message to a process and it crashes you won't get any "sending failed" notification. If you really want to make sure that the message was received *and processed* then you have to notify the caller after finishing processing the message. I believe/read somewhere that the garbage collection is done on a per-process basis. When a process crashes the VM will "tidy things up". :) > (Documentation reference welcome !) > Joe's book will get you a long way. :) /Davide :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From gamoto@REDACTED Tue Apr 7 18:52:38 2009 From: gamoto@REDACTED (Gamoto) Date: Tue, 7 Apr 2009 18:52:38 +0200 Subject: [erlang-questions] strange behaviour of gen_tcp:connect References: <200904071113461917143@bluewin.ch>, <20090407115542.GA2642@erix.ericsson.se> Message-ID: <200904071852382384790@bluewin.ch> I mean there is neither server listening on this port nor other applications using it. I repeat what I observed: "connect"-erlang is suspended on windows server 2003, "connect"- php is not suspended on windows server 2003. >On Tue, Apr 07, 2009 at 11:13:46AM +0200, Gamoto wrote: >> I an windows server 2003. I don't understand why gen_tcp:connect returns ALWAYS an error. >> "connect" should be blocking, the port is free, I didn't precise a timeout. I also tried with "localhost". >> Another strange effect: error returned is "econnrefused" or, when another emacs is opened with erlang code inside, the returned error is "timeout" !!! >> Is it "normal" with Erlang ? > >What do you mean by "the port is free". Something must >be listening on port 1688 for the loopback interface. >If nothing is listening on the port, the TCP stack >of the OS will immediately inform gen_tcp about >that, hence the econnrefused. > >This is basic TCP/IP, no Erlang quirks. > >I also have a Win2003Server: > >1> gen_tcp:connect("127.0.0.1",3389,[binary, {packet, 0}]). >{ok,#Port<0.444>} > >since I have a Windows remote desktop server >listening on port 3389. > >If you really want the IP address, use the Erlang >gen_tcp IP address tuple as documented in: > http://www.erlang.org/doc/man/inet.html >{127,0,0,1} instead of "127.0.0.1". The first >is taken as an IP address direct, the second >is processed through the name resolver. > >> >> John >> >> start()-> >> case gen_tcp:connect("127.0.0.1",1688,[binary, {packet, 0}]) of >> {ok,Socket}-> >> io:format("Socket established~n"), >> loop(Socket); >> {error,Reason}-> >> io:format("Error on connect: ~s~n",[Reason]) >> end. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > >-- > >/ Raimo Niskanen, Erlang/OTP, Ericsson AB From dmercer@REDACTED Tue Apr 7 20:22:38 2009 From: dmercer@REDACTED (David Mercer) Date: Tue, 7 Apr 2009 13:22:38 -0500 Subject: [erlang-questions] checksum calculation In-Reply-To: <200904071055534829526@bluewin.ch> References: <200904060029112519995@bluewin.ch> <200904061134514637116@bluewin.ch> <200904071055534829526@bluewin.ch> Message-ID: On Tue, Apr 7, 2009 at 3:55 AM, Gamoto wrote: > Richard, > Suppose you have an industrial machine which send messages following by the > checksum calculated by the xor of all bytes, what can I do with your advices > ;-) I think you know the answer to that, but it doesn't change the fact that XOR is not a good checksum, which was Richard's original point: >Of course this isn't a very _good_ checksum, >but that's another issue. -------------- next part -------------- An HTML attachment was scrubbed... URL: From spyplane@REDACTED Tue Apr 7 20:54:10 2009 From: spyplane@REDACTED (Jared) Date: Tue, 7 Apr 2009 12:54:10 -0600 Subject: [erlang-questions] strange behaviour of gen_tcp:connect Message-ID: If nothing is listening on the port, then erlang is doing the correct behavior. PHP isn't exactly known for doing the "correct" behavior in all cases, (ie: 0 = "0" = "" = NULL). If you really want to be sure, write a small C program using connect so you can see that Erlang is in fact working correctly. -Jared >>I mean there is neither server listening on this port nor other applications using it. I repeat what I observed: "connect"-erlang is suspended on windows server 2003, "connect"- php is not suspended on windows server 2003. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffm@REDACTED Wed Apr 8 01:19:11 2009 From: jeffm@REDACTED (jm) Date: Wed, 08 Apr 2009 09:19:11 +1000 Subject: [erlang-questions] checksum calculation In-Reply-To: <200904071055534829526@bluewin.ch> References: <200904060029112519995@bluewin.ch>, , <200904061134514637116@bluewin.ch>, <200904071055534829526@bluewin.ch> Message-ID: <49DBDF6F.30601@ghostgun.com> Gamoto wrote: > Richard, > Suppose you have an industrial machine which send messages following by the checksum calculated by the xor of all bytes, what can I do with your advices ;-) > John > I take it by this that this is a given and out of your control. In which case your stuck, but should politely tell the manufacture they're a bunch of idiots highlighting the drawbacks mentioned by Richard and try to get the next revision fixed. If your lucky enough to be able change the checksum take a look at adler32/1 in the kernel/erlang section of the manual, or crc32/1 in the same section. example use of both, > erlang:adler32([1,2,3,[4,5]]). 2621456 > erlang:crc32([1,2,3,[4,5]]). 1191942644 I hope this solves your problem. Jeff. From ok@REDACTED Wed Apr 8 07:01:05 2009 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 8 Apr 2009 17:01:05 +1200 Subject: [erlang-questions] checksum calculation In-Reply-To: <200904071055534829526@bluewin.ch> References: <200904060029112519995@bluewin.ch>, , <200904061134514637116@bluewin.ch>, <200904071055534829526@bluewin.ch> Message-ID: On 7 Apr 2009, at 8:55 pm, Gamoto wrote: > Richard, > Suppose you have an industrial machine which send messages following > by the checksum calculated by the xor of all bytes, what can I do > with your advices ;-) Surely it is obvious that if you are exchanging messages with an existing system that uses a particular 'checksum' scheme, THAT is the checksum scheme that you use? It only makes sense to talk about what would be "a better [solution]" when it is _possible_ for you to deploy it at _both_ ends of the communication channel. If you have such a machine, I suggest that (a) you find out whether it is possible to select or program a different algorithm in it, and (b) you try to get some idea of what kinds of errors are possible between that machine and your computer(s), so that you know whether you should (c) worry a lot about uncaught errors, or not. >> It all depends on what your data are like and what >> kinds of errors you plausibly need to protect against, >> really. >> >> > > From sameer.p.pradhan@REDACTED Wed Apr 8 08:36:58 2009 From: sameer.p.pradhan@REDACTED (sameer pradhan) Date: Wed, 8 Apr 2009 12:06:58 +0530 Subject: [erlang-questions] Regarding gen_tcp:connect() Message-ID: <9ef06be80904072336i7a7bcb53o88ea28c53e2b119b@mail.gmail.com> This is Sameer here. I have used those lines in my code in client side of my program using "localhost" instead of IP address and its working fine. For that 1st u have to run the server part with gen_tcp:listen() and then gen_tcp:accept(). Then u can try to connect that socket from client side. If u need then i can send the appropriate code also. Here is the Example----> for Socket----> -module(socket11_server). -export([start_server/0]). start_server() -> {ok, Listen} = gen_tcp:listen(2345, [binary, {packet, 0},{reuseaddr, true},{active,true}]), io:format("listen :~p~n",[Listen]), {ok, Socket} = gen_tcp:accept(Listen), io:format("socket :~p~n",[Socket]), gen_tcp:close(Listen), loop(Socket). loop(Socket) -> receive {tcp, Socket, Bin} -> io:format("Server received binary = ~p~n",[Bin]), Str = binary_to_term(Bin), io:format("Server (unpacked) ~p~n",[Str]), {address_book,'addr@REDACTED'}!Str, loop(Socket); {tcp_closed, Socket} -> io:format("Server socket closed~n") end. And For client ----> -module(socket11_client). -export([client_eval/0,loop/1]). client_eval() -> case gen_tcp:connect("localhost" , 2345,[binary,{packet, 0}]) of {ok,Socket}-> io:format("Socket established~n"), io:format("socket :~p~n",[Socket]), register(client,spawn(?MODULE,loop,[Socket])); {error,Reason}-> io:format("Error on connect: ~s~n",[Reason]) end. loop(Socket)-> receive {client,stop}-> io:format("client socket closed"), gen_tcp:close(Socket); {client,Data}-> io:format("data is :::~p~n",[Data]), ok = gen_tcp:send(Socket, term_to_binary(Data)), io:format("~p~n",[Data]), loop(Socket); {tcp,Socket,Bin} -> io:format("Client received binary= ~p ~n ",[Bin]), Val = binary_to_term(Bin), io:format("Client result=~p~n",[Val]) , loop(Socket) end. -- Thanks & Regards Sameer Prakash Pradhan -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Wed Apr 8 09:08:51 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 8 Apr 2009 09:08:51 +0200 Subject: [erlang-questions] : Re: strange behaviour of gen_tcp:connect In-Reply-To: <200904071852382384790@bluewin.ch> References: <20090407115542.GA2642@erix.ericsson.se> <200904071852382384790@bluewin.ch> Message-ID: <20090408070851.GA30870@erix.ericsson.se> On Tue, Apr 07, 2009 at 06:52:38PM +0200, Gamoto wrote: > I mean there is neither server listening on this port nor other applications using it. If there is no listener on the destination port the correct response from any connect() is econnrefused. Go and read some TCP/IP FAQ or book. > I repeat what I observed: "connect"-erlang is suspended on windows server 2003, "connect"- php is not suspended on windows server 2003. If PHP connect does not return econnrefused when asked to connect to a destination port without listener ask why at some PHP mailing list, not here, because that sounds very confusing. If gen_tcp:connect({127,0,0,1}, 1688, [binary, {packet, 0}]) hangs for quite a while and then returns with a timeout you most probably have a firewall blocking the connect. If you get different behaviour from an Erlang shell started within Emacs than from one started from the command line (cmd.exe) or from the shorcuts "werl.exe" or "erl.exe", it is probably because the Erlang node is started with different parameters. In particular -sname vs -name is known to create differing name resolver setups, which may since you use destination "127.0.0.1" instead of {127,0,0,1} as I recommended, cause differing name lookup causing differing behaviour. Use an IP tuple such as {127,0,0,1} when you debug connect problems to eliminate name resolver problems. -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From steven.charles.davis@REDACTED Wed Apr 8 13:04:26 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 8 Apr 2009 04:04:26 -0700 (PDT) Subject: [erlang-questions] checksum calculation In-Reply-To: <200904071055534829526@bluewin.ch> References: <200904060029112519995@bluewin.ch>, , <200904061134514637116@bluewin.ch>, <200904071055534829526@bluewin.ch> Message-ID: <2306706d-0d84-49a0-97e9-fc6658fbf35f@g19g2000yql.googlegroups.com> Gamoto, What I would do is: 1) make a cup of tea, 2) open my browser to http://www.erlang.org/doc/ 3)...and start doing some reading. Steve On Apr 7, 3:55?am, "Gamoto" wrote: > Richard, > Suppose you have an industrial machine which send messages following by the checksum calculated by the xor of all bytes, what can I do with your advices ;-) > John > > > > > > > > >On 6 Apr 2009, at 9:34 pm, Gamoto wrote: > > >> If it is not a very good solution, would you like to suggest a ? > >> better one, for me and the other readers ?\ > > >Suppose you have a block of bytes and there is an > >error that results in one byte being replaced by > >a different byte. ?Then an XOR checksum will detect > >that difference. > > >Suppose there is an error that results in two bytes > >being swapped. ?Then an XOR checksum will detect no > >change at all. ?Or suppose that two equal bytes are > >both replaced by the same new byte. ?Again, nothing > >noticed by XOR. > > >Just look "checksum" up in the Wikipedia; that's as > >good a place as any to start. > > >The 'zlib' module in Erlang already has support for > >crc32 and adler32. ?I thought I saw crc32 somewhere > >else as well. > > >Theory and practice don't agree as much in practice > >as they do in theory, so it's worth having a look at > >"Performance of Checksums and CRCs over Real Data" > >by Jonathan Stone, Michael Greenwald, Craig Partridge, > >and Jim Hughes > >and at "Revisiting Fletcher and Adler Checksums" > >by Theresa Maxino, whose conclusions I found surprising. > > >It all depends on what your data are like and what > >kinds of errors you plausibly need to protect against, > >really. > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From oscar@REDACTED Wed Apr 8 13:27:24 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Wed, 08 Apr 2009 12:27:24 +0100 Subject: [erlang-questions] strange behaviour of gen_tcp:connect In-Reply-To: <200904071113461917143@bluewin.ch> References: <200904071113461917143@bluewin.ch> Message-ID: <49DC8A1C.80407@erlang-consulting.com> Hi, If the port really is free, then you will get a econnrefused, unless you have a firewall blocking connection attempts. Not that I have a windows server 2003 machine, but I'm still seeing at least one interesting thing here: First I start a listening socket on port 6666: ~% netcat -l -p 6666 Then I configure my iptables to trop all packets on the local interface to that port: # iptables -A INPUT -i lo -p tcp --dport 6666 -j DROP Then, I start an erlang shell and try to connect to port 6666: ~% erl Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [smp:2] [async-threads:0] [hipe] [ker Eshell V5.6.5 (abort with ^G) 1> gen_tcp:connect({127,0,0,1}, 6666, [binary, {packet, 0}]). {error,etimedout} Ok, wait here now a second, etimedout? This is from the gen_tcp manual: connect(Address, Port, Options) -> {ok, Socket} | {error, Reason} connect(Address, Port, Options, Timeout) -> {ok, Socket} | {error, Reason} ... Timeout = int() | infinity ... The optional Timeout parameter specifies a timeout in milliseconds. The default value is infinity. So, shouldn't we wait for infinity? 3> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}]]). {189001895,{error,etimedout}} 5> 189001895 / 1000000 / 60. 3.150031583333333 It seems the definition of infinity here is 3.15 minutes? Even when I specify the timeout explicitly I get the same result. 6> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}], infinity]). {188997939,{error,etimedout}} 7> 188997939 / 1000000 / 60. 3.14996565 Connecting to a different port, which I haven't firewalled I get the following: 8> gen_tcp:connect({127,0,0,1}, 6667, [binary, {packet, 0}]). {error,econnrefused} Removing the firewall I get: # iptables -D INPUT -i lo -p tcp --dport 6666 -j DROP 9> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}], infinity]). {527,{ok,#Port<0.434>}} Why is infinity so short? Gamoto wrote: > I an windows server 2003. I don't understand why gen_tcp:connect returns ALWAYS an error. > "connect" should be blocking, the port is free, I didn't precise a timeout. I also tried with "localhost". > Another strange effect: error returned is "econnrefused" or, when another emacs is opened with erlang code inside, the returned error is "timeout" !!! > Is it "normal" with Erlang ? > > John > > start()-> > case gen_tcp:connect("127.0.0.1",1688,[binary, {packet, 0}]) of > {ok,Socket}-> > io:format("Socket established~n"), > loop(Socket); > {error,Reason}-> > io:format("Error on connect: ~s~n",[Reason]) > end. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > Best regards -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From als@REDACTED Wed Apr 8 13:03:39 2009 From: als@REDACTED (Anthony Shipman) Date: Wed, 8 Apr 2009 22:03:39 +1100 Subject: [erlang-questions] tcp_send_error Message-ID: <200904082103.40041.als@iinet.net.au> I am looking at the source for inet_drv.c in 12B4. In the tcp_send_error() function it says * Note: The following message might get lost, in case the error * occurred when we tried to write taken from the queue (no caller). Can the message really get lost and under what circumstances? In the kernel application prim_inet:send() the code waits indefinitely for a response from the driver. If it can get lost then it looks like a send() can block forever. I've got a case where high traffic over a very slow link appears to result in prim_inet:send() getting stuck. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From sameer.p.pradhan@REDACTED Wed Apr 8 14:37:26 2009 From: sameer.p.pradhan@REDACTED (sameer pradhan) Date: Wed, 8 Apr 2009 18:07:26 +0530 Subject: [erlang-questions] Erlang on Emacs Message-ID: <9ef06be80904080537t2bf00b54m1cfd2d265b907aff@mail.gmail.com> Can Anybody tell me the full steps, how to run any erlang program on emacs . -- Thanks & Regards Sameer Prakash Pradhan -------------- next part -------------- An HTML attachment was scrubbed... URL: From gamoto@REDACTED Wed Apr 8 15:19:48 2009 From: gamoto@REDACTED (Gamoto) Date: Wed, 8 Apr 2009 15:19:48 +0200 Subject: [erlang-questions] strange behaviour of gen_tcp:connect References: <200904071113461917143@bluewin.ch>, <49DC8A1C.80407@erlang-consulting.com> Message-ID: <200904081519476203619@bluewin.ch> Hi, I constated the same with "infinity". We must wait for experts in order to have clarifications ... >Hi, > >If the port really is free, then you will get a econnrefused, unless you >have a firewall blocking connection attempts. > >Not that I have a windows server 2003 machine, but I'm still seeing at >least one interesting thing here: > >First I start a listening socket on port 6666: >~% netcat -l -p 6666 > >Then I configure my iptables to trop all packets on the local interface >to that port: ># iptables -A INPUT -i lo -p tcp --dport 6666 -j DROP > >Then, I start an erlang shell and try to connect to port 6666: >~% erl >Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [smp:2] >[async-threads:0] [hipe] [ker > >Eshell V5.6.5 (abort with ^G) >1> gen_tcp:connect({127,0,0,1}, 6666, [binary, {packet, 0}]). >{error,etimedout} > >Ok, wait here now a second, etimedout? This is from the gen_tcp manual: >connect(Address, Port, Options) -> {ok, Socket} | {error, Reason} >connect(Address, Port, Options, Timeout) -> {ok, Socket} | {error, Reason} >... >Timeout = int() | infinity >... >The optional Timeout parameter specifies a timeout in milliseconds. The >default value is infinity. > >So, shouldn't we wait for infinity? >3> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}]]). >{189001895,{error,etimedout}} >5> 189001895 / 1000000 / 60. >3.150031583333333 > >It seems the definition of infinity here is 3.15 minutes? > >Even when I specify the timeout explicitly I get the same result. >6> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}], >infinity]). >{188997939,{error,etimedout}} >7> 188997939 / 1000000 / 60. >3.14996565 > >Connecting to a different port, which I haven't firewalled I get the >following: >8> gen_tcp:connect({127,0,0,1}, 6667, [binary, {packet, >0}]). >{error,econnrefused} > >Removing the firewall I get: ># iptables -D INPUT -i lo -p tcp --dport 6666 -j DROP >9> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}], >infinity]). >{527,{ok,#Port<0.434>}} > >Why is infinity so short? > >Gamoto wrote: >> I an windows server 2003. I don't understand why gen_tcp:connect returns ALWAYS an error. >> "connect" should be blocking, the port is free, I didn't precise a timeout. I also tried with "localhost". >> Another strange effect: error returned is "econnrefused" or, when another emacs is opened with erlang code inside, the returned error is "timeout" !!! >> Is it "normal" with Erlang ? >> >> John >> >> start()-> >> case gen_tcp:connect("127.0.0.1",1688,[binary, {packet, 0}]) of >> {ok,Socket}-> >> io:format("Socket established~n"), >> loop(Socket); >> {error,Reason}-> >> io:format("Error on connect: ~s~n",[Reason]) >> end. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > >Best regards > >-- >Oscar Hellstr?m, oscar@REDACTED >Office: +44 20 7655 0337 >Mobile: +44 798 45 44 773 >Erlang Training and Consulting Ltd >http://www.erlang-consulting.com/ > From raimo+erlang-questions@REDACTED Wed Apr 8 16:23:07 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 8 Apr 2009 16:23:07 +0200 Subject: [erlang-questions] : strange behaviour of gen_tcp:connect In-Reply-To: <49DC8A1C.80407@erlang-consulting.com> References: <200904071113461917143@bluewin.ch> <49DC8A1C.80407@erlang-consulting.com> Message-ID: <20090408142307.GA9872@erix.ericsson.se> On Wed, Apr 08, 2009 at 12:27:24PM +0100, Oscar Hellstr?m wrote: > Hi, > > If the port really is free, then you will get a econnrefused, unless you > have a firewall blocking connection attempts. > > Not that I have a windows server 2003 machine, but I'm still seeing at > least one interesting thing here: > > First I start a listening socket on port 6666: > ~% netcat -l -p 6666 > > Then I configure my iptables to trop all packets on the local interface > to that port: > # iptables -A INPUT -i lo -p tcp --dport 6666 -j DROP > > Then, I start an erlang shell and try to connect to port 6666: > ~% erl > Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [smp:2] > [async-threads:0] [hipe] [ker > > Eshell V5.6.5 (abort with ^G) > 1> gen_tcp:connect({127,0,0,1}, 6666, [binary, {packet, 0}]). > {error,etimedout} > > Ok, wait here now a second, etimedout? This is from the gen_tcp manual: > connect(Address, Port, Options) -> {ok, Socket} | {error, Reason} > connect(Address, Port, Options, Timeout) -> {ok, Socket} | {error, Reason} > ... > Timeout = int() | infinity > ... > The optional Timeout parameter specifies a timeout in milliseconds. The > default value is infinity. > > So, shouldn't we wait for infinity? > 3> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}]]). > {189001895,{error,etimedout}} > 5> 189001895 / 1000000 / 60. > 3.150031583333333 > > It seems the definition of infinity here is 3.15 minutes? It is most probably the definition of fatal timeout in the TCP stack. So the man page forget to mention that if the OS connect() call returns with a timeout, gen_tcp:connect will also return with a timeout, even if none was specified. > > Even when I specify the timeout explicitly I get the same result. > 6> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}], > infinity]). > {188997939,{error,etimedout}} > 7> 188997939 / 1000000 / 60. > 3.14996565 > > Connecting to a different port, which I haven't firewalled I get the > following: > 8> gen_tcp:connect({127,0,0,1}, 6667, [binary, {packet, > 0}]). > {error,econnrefused} > > Removing the firewall I get: > # iptables -D INPUT -i lo -p tcp --dport 6666 -j DROP > 9> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}], > infinity]). > {527,{ok,#Port<0.434>}} > > Why is infinity so short? : -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From sverker@REDACTED Wed Apr 8 16:28:12 2009 From: sverker@REDACTED (Sverker Eriksson) Date: Wed, 08 Apr 2009 16:28:12 +0200 Subject: [erlang-questions] tcp_send_error In-Reply-To: <200904082103.40041.als@iinet.net.au> References: <200904082103.40041.als@iinet.net.au> Message-ID: <49DCB47C.5070902@erix.ericsson.se> Anthony Shipman wrote: > I am looking at the source for inet_drv.c in 12B4. In the tcp_send_error() > function it says > > * Note: The following message might get lost, in case the error > * occurred when we tried to write taken from the queue (no caller). > > Can the message really get lost and under what circumstances? > > When the process is not blocking in prim_inet:send() waiting for a reply. That is, the send operation was done asynchronous triggered by an internal polled write-event from the socket. > In the kernel application prim_inet:send() the code waits indefinitely for a > response from the driver. If it can get lost then it looks like a send() can > block forever. I've got a case where high traffic over a very slow link > appears to result in prim_inet:send() getting stuck. > > Changes have been made to that code in R12B-5, R13A, R13B. Here are two fixes in the release notes regarding hanging send's: R13A: Calling gen_tcp:send() from several processes on socket with option send_timeout could lead to much longer timeout than specified. The solution is a new socket option {send_timeout_close,true} that will do automatic close on timeout. Subsequent calls to send will then immediately fail due to the closed connection. Coming R13B: Fixed a bug on Windows that could make gen_tcp:send hang trying to send an iolist of more than 16 binaries. /Sverker, Erlang/OTP Ericsson From fmilicchio@REDACTED Wed Apr 8 19:21:29 2009 From: fmilicchio@REDACTED (Franco Milicchio) Date: Wed, 08 Apr 2009 19:21:29 +0200 Subject: [erlang-questions] State of the Union: FFI In-Reply-To: <22831017.post@talk.nabble.com> References: <2812B7B9-6B8C-4CDE-A966-96624AF61625@me.com> <22831017.post@talk.nabble.com> Message-ID: <01D2B728-D19B-4923-A5A8-DE08CC70A908@me.com> I have started porting the patch to R13A, although I can't say if it really works: it doesn't compile! Makefile error, not a C one :) You may find the source code at: http://plm.dia.uniroma3.it/milicchio/public/otp_src_R13A-ffi.zip (62 MB) I have no time left today, but if we all start figuring out what's wrong with it, we may end up having the FFI working on this new release. I have marked the C code with comments (/* FFI START */ and / * FFI END */) where I had doubts about applying Alceste's patch, so it should be easy to spot them. By the way, no news about the reason FFI hasn't been taken into account yet? Cheers! -- Franco Milicchio DIA - Dept. of Computer Science and Engineering University Roma Tre http://plm.dia.uniroma3.it/milicchio/ -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available URL: From rvirding@REDACTED Thu Apr 9 03:14:46 2009 From: rvirding@REDACTED (Robert Virding) Date: Thu, 9 Apr 2009 03:14:46 +0200 Subject: [erlang-questions] Backtracking in Erlang, part 2 - passing data Message-ID: <3dbc6d1c0904081814n49f61189j8cbe67dfa74776e2@mail.gmail.com> Here (finally) is the second part of a solution on how to write backtracking code in Erlang. This part shows how you can handle data. In the first part I showed how we could program backtracking in a generic way in Erlang. While Erlang does not directly support it, it is relatively easy to do. In this part we will look at some ways of handling data within this context. The basic problem is how to get data out of a function as, in this context, functions never return. For a specific application this may not be a problem as either each function always explcitly knows what the contunation is, or a it is possible to have a local convention of how to pass arguments. For an example of this see the Erlog parser in the file erlog_parse.erl where each continuation function has two arguments, the remaining tokens and the term parsed so far. This works well for this specific case. This is not possible in the general case or when writing generic functions. Seeing we cannot return values we will adopt the method used in logic languages like prolog (or C) of "returning" values through the function arguments. For example the following "function" fubar/2 (written in a logic style) which takes input in the argument X and "returns" data through the argument Y: fubar(X, Y) :- foo(X, M, N), bar(M, O), baz(N, O, Y). Each of the functions foo/3, bar/2 and baz/3 behave in a similar way but they have varying numbers of input and output arguments. I will show one way how this can done. We will define a variables structure which contains the bindings of variables. It has the following interface: new_vars() -> Vars. new_var(Vars) -> {Var,Vars}. bind_var(Var, Value, Vars) -> Vars. get_var(Var, Vars) -> Value. A requirement on the Vars structure is that all variable bindings are undone on backtracking. Note that we are not really defining logical variables here or implementing unification, we are just creating variables and binding them. There is no default value for a variable, trying to get the value of an unbound variable will generate an error. We will adopt the convention that all continuation functions have one argument and they will be called with the current Vars structure. We will also adopt the convention that each normal function will have its arguments in the following order: first come normal Erlang arguments, then the Vars structure, then the arguments which use the Vars structure with the input arguments first followed by the output arguments, and finally the continuation. Using Vars and this convention we could translate fubar/2 into the following Erlang function: fubar(Vars0, X, Y, Next) -> %% Create the new variables in fubar. {M,Vars1} = new_var(Vars0), {N,Vars2} = new_var(Vars1), {O,Vars3} = new_var(Vars2), Next2 = fun (Vars) -> baz(Vars, N, O, Y, Next) end, Next1 = fun (Vars) -> bar(Vars, M, O, Next2) end, foo(Vars, X, M, N, Next1). Here we have assumed that fubar is part of a larger application which has created the Vars structure. The continuation function is called with the current Vars. So for example the (trivial) function bar/2 which has M as input and binds O for output could be written: bar(Vars0, M, O, Next) -> Mval = get_var(M, Vars), Oval = , Vars1 = bind_var(O, Oval, Vars), Next(Vars1). Choice points are now introduced by: cp([fun (Vs) -> do_stuff_a(Vs, Next) end, fun (Vs) -> do_stuff_b(Vs, Next) end, fun (Vs) -> do_stuff_c(Vs, Next) end, ...], Vars). The code for cp/2, is still simple: cp(Vars, [G|Gs]) -> case G(Vars) of {succeed,Value} -> {succeed,Value}; fail -> cp(Vars, Gs) end; cp(_, []) -> fail. We see here that if the Vars structure does not use side effects then we will automatically undo all bindings on backtrack?ng. I will give a simple definition of the Vars structure and its interface. It uses dicts to store the variable bindings. -record(vars, {vc,dict}). new_vars() -> #vars{vc=0,dict=dict:new()}. new_var(#vars{vc=Vc,dict=Dict}=Vars) -> {{var,Vc},Vars#vars{vc=Vc+1}}. bind_var({var,Var}, Value, #vars{dict=Dict}=Vars) -> Vars#vars{dict=dict:store(Var, Value, Dict)}. get_var({var,Var}, #vars{dict=Dict}) -> dict:fetch(Var, Dict). That's it, we're done. Again a lot of explanation for quite a simple concept and very little code. In the next installment I will give an example of how this can be used and some problems with the current implementation. As before I have also posted this to my blogg for those who prefer to read there, Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter.mccarthy.0807@REDACTED Thu Apr 9 10:22:53 2009 From: peter.mccarthy.0807@REDACTED (Peter McCarthy) Date: Thu, 9 Apr 2009 09:22:53 +0100 Subject: [erlang-questions] Erlang on Emacs Message-ID: <57d241cf0904090122p6238cd9ap48f0444e4e2bf7c@mail.gmail.com> Hi Sameer I recommend that you install Distel, then everything should become clear: http://fresh.homeunix.net/~luke/distel/ http://bc.tech.coop/blog/070719.html Regards Peter From gamoto@REDACTED Thu Apr 9 11:00:33 2009 From: gamoto@REDACTED (Gamoto) Date: Thu, 9 Apr 2009 11:00:33 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 23, Issue 29 References: Message-ID: <200904091100327295961@bluewin.ch> Hi Steve, Yes: RTFM as say Linux people. But it is not my mentality. If I don't down then I ask. If I know then I share. Have a good day ! John >Send erlang-questions mailing list submissions to > erlang-questions@REDACTED > >To subscribe or unsubscribe via the World Wide Web, visit > http://www.erlang.org/mailman/listinfo/erlang-questions >or, via email, send a message with subject or body 'help' to > erlang-questions-request@REDACTED > >You can reach the person managing the list at > erlang-questions-owner@REDACTED > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of erlang-questions digest..." > > >Today's Topics: > > 1. Re: checksum calculation (Steve Davis) > 2. Re: strange behaviour of gen_tcp:connect (Oscar Hellstr?m) > 3. tcp_send_error (Anthony Shipman) > 4. Erlang on Emacs (sameer pradhan) > 5. Re: strange behaviour of gen_tcp:connect (Gamoto) > 6. Re: : strange behaviour of gen_tcp:connect (Raimo Niskanen) > 7. Re: tcp_send_error (Sverker Eriksson) > 8. Re: State of the Union: FFI (Franco Milicchio) > > >---------------------------------------------------------------------- > >Message: 1 >Date: Wed, 8 Apr 2009 04:04:26 -0700 (PDT) >From: Steve Davis >Subject: Re: [erlang-questions] checksum calculation >To: erlang-questions@REDACTED >Message-ID: > <2306706d-0d84-49a0-97e9-fc6658fbf35f@REDACTED> >Content-Type: text/plain; charset=ISO-8859-1 > >Gamoto, > >What I would do is: >1) make a cup of tea, >2) open my browser to http://www.erlang.org/doc/ >3)...and start doing some reading. > >Steve > >On Apr 7, 3:55?am, "Gamoto" wrote: >> Richard, >> Suppose you have an industrial machine which send messages following by the checksum calculated by the xor of all bytes, what can I do with your advices ;-) >> John >> >> >> >> >> >> >> >> >On 6 Apr 2009, at 9:34 pm, Gamoto wrote: >> >> >> If it is not a very good solution, would you like to suggest a ? >> >> better one, for me and the other readers ?\ >> >> >Suppose you have a block of bytes and there is an >> >error that results in one byte being replaced by >> >a different byte. ?Then an XOR checksum will detect >> >that difference. >> >> >Suppose there is an error that results in two bytes >> >being swapped. ?Then an XOR checksum will detect no >> >change at all. ?Or suppose that two equal bytes are >> >both replaced by the same new byte. ?Again, nothing >> >noticed by XOR. >> >> >Just look "checksum" up in the Wikipedia; that's as >> >good a place as any to start. >> >> >The 'zlib' module in Erlang already has support for >> >crc32 and adler32. ?I thought I saw crc32 somewhere >> >else as well. >> >> >Theory and practice don't agree as much in practice >> >as they do in theory, so it's worth having a look at >> >"Performance of Checksums and CRCs over Real Data" >> >by Jonathan Stone, Michael Greenwald, Craig Partridge, >> >and Jim Hughes >> >and at "Revisiting Fletcher and Adler Checksums" >> >by Theresa Maxino, whose conclusions I found surprising. >> >> >It all depends on what your data are like and what >> >kinds of errors you plausibly need to protect against, >> >really. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > > >------------------------------ > >Message: 2 >Date: Wed, 08 Apr 2009 12:27:24 +0100 >From: Oscar Hellstr?m >Subject: Re: [erlang-questions] strange behaviour of gen_tcp:connect >To: Gamoto >Cc: erlang-questions >Message-ID: <49DC8A1C.80407@REDACTED> >Content-Type: text/plain; charset=ISO-8859-1 > >Hi, > >If the port really is free, then you will get a econnrefused, unless you >have a firewall blocking connection attempts. > >Not that I have a windows server 2003 machine, but I'm still seeing at >least one interesting thing here: > >First I start a listening socket on port 6666: >~% netcat -l -p 6666 > >Then I configure my iptables to trop all packets on the local interface >to that port: ># iptables -A INPUT -i lo -p tcp --dport 6666 -j DROP > >Then, I start an erlang shell and try to connect to port 6666: >~% erl >Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [smp:2] >[async-threads:0] [hipe] [ker > >Eshell V5.6.5 (abort with ^G) >1> gen_tcp:connect({127,0,0,1}, 6666, [binary, {packet, 0}]). >{error,etimedout} > >Ok, wait here now a second, etimedout? This is from the gen_tcp manual: >connect(Address, Port, Options) -> {ok, Socket} | {error, Reason} >connect(Address, Port, Options, Timeout) -> {ok, Socket} | {error, Reason} >... >Timeout = int() | infinity >... >The optional Timeout parameter specifies a timeout in milliseconds. The >default value is infinity. > >So, shouldn't we wait for infinity? >3> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}]]). >{189001895,{error,etimedout}} >5> 189001895 / 1000000 / 60. >3.150031583333333 > >It seems the definition of infinity here is 3.15 minutes? > >Even when I specify the timeout explicitly I get the same result. >6> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}], >infinity]). >{188997939,{error,etimedout}} >7> 188997939 / 1000000 / 60. >3.14996565 > >Connecting to a different port, which I haven't firewalled I get the >following: >8> gen_tcp:connect({127,0,0,1}, 6667, [binary, {packet, >0}]). >{error,econnrefused} > >Removing the firewall I get: ># iptables -D INPUT -i lo -p tcp --dport 6666 -j DROP >9> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}], >infinity]). >{527,{ok,#Port<0.434>}} > >Why is infinity so short? > >Gamoto wrote: >> I an windows server 2003. I don't understand why gen_tcp:connect returns ALWAYS an error. >> "connect" should be blocking, the port is free, I didn't precise a timeout. I also tried with "localhost". >> Another strange effect: error returned is "econnrefused" or, when another emacs is opened with erlang code inside, the returned error is "timeout" !!! >> Is it "normal" with Erlang ? >> >> John >> >> start()-> >> case gen_tcp:connect("127.0.0.1",1688,[binary, {packet, 0}]) of >> {ok,Socket}-> >> io:format("Socket established~n"), >> loop(Socket); >> {error,Reason}-> >> io:format("Error on connect: ~s~n",[Reason]) >> end. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > >Best regards > >-- >Oscar Hellstr?m, oscar@REDACTED >Office: +44 20 7655 0337 >Mobile: +44 798 45 44 773 >Erlang Training and Consulting Ltd >http://www.erlang-consulting.com/ > > > >------------------------------ > >Message: 3 >Date: Wed, 8 Apr 2009 22:03:39 +1100 >From: Anthony Shipman >Subject: [erlang-questions] tcp_send_error >To: erlang-questions >Message-ID: <200904082103.40041.als@REDACTED> >Content-Type: text/plain; charset="us-ascii" > >I am looking at the source for inet_drv.c in 12B4. In the tcp_send_error() >function it says > > * Note: The following message might get lost, in case the error > * occurred when we tried to write taken from the queue (no caller). > >Can the message really get lost and under what circumstances? > >In the kernel application prim_inet:send() the code waits indefinitely for a >response from the driver. If it can get lost then it looks like a send() can >block forever. I've got a case where high traffic over a very slow link >appears to result in prim_inet:send() getting stuck. > >-- >Anthony Shipman Mamas don't let your babies >als@REDACTED grow up to be outsourced. > > >------------------------------ > >Message: 4 >Date: Wed, 8 Apr 2009 18:07:26 +0530 >From: sameer pradhan >Subject: [erlang-questions] Erlang on Emacs >To: erlang-questions@REDACTED >Message-ID: > <9ef06be80904080537t2bf00b54m1cfd2d265b907aff@REDACTED> >Content-Type: text/plain; charset="iso-8859-1" > >Can Anybody tell me the full steps, how to run any erlang program on emacs . > >-- >Thanks & Regards >Sameer Prakash Pradhan >-------------- next part -------------- >An HTML attachment was scrubbed... >URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20090408/acc9afc7/attachment-0001.html > >------------------------------ > >Message: 5 >Date: Wed, 8 Apr 2009 15:19:48 +0200 >From: "Gamoto" >Subject: Re: [erlang-questions] strange behaviour of gen_tcp:connect >To: " Oscar_Hellstr?m " >Cc: erlang-questions >Message-ID: <200904081519476203619@REDACTED> >Content-Type: text/plain; charset="iso-8859-1" > >Hi, >I constated the same with "infinity". We must wait for experts in order to have clarifications ... >>Hi, >> >>If the port really is free, then you will get a econnrefused, unless you >>have a firewall blocking connection attempts. >> >>Not that I have a windows server 2003 machine, but I'm still seeing at >>least one interesting thing here: >> >>First I start a listening socket on port 6666: >>~% netcat -l -p 6666 >> >>Then I configure my iptables to trop all packets on the local interface >>to that port: >># iptables -A INPUT -i lo -p tcp --dport 6666 -j DROP >> >>Then, I start an erlang shell and try to connect to port 6666: >>~% erl >>Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [smp:2] >>[async-threads:0] [hipe] [ker >> >>Eshell V5.6.5 (abort with ^G) >>1> gen_tcp:connect({127,0,0,1}, 6666, [binary, {packet, 0}]). >>{error,etimedout} >> >>Ok, wait here now a second, etimedout? This is from the gen_tcp manual: >>connect(Address, Port, Options) -> {ok, Socket} | {error, Reason} >>connect(Address, Port, Options, Timeout) -> {ok, Socket} | {error, Reason} >>... >>Timeout = int() | infinity >>... >>The optional Timeout parameter specifies a timeout in milliseconds. The >>default value is infinity. >> >>So, shouldn't we wait for infinity? >>3> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}]]). >>{189001895,{error,etimedout}} >>5> 189001895 / 1000000 / 60. >>3.150031583333333 >> >>It seems the definition of infinity here is 3.15 minutes? >> >>Even when I specify the timeout explicitly I get the same result. >>6> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}], >>infinity]). >>{188997939,{error,etimedout}} >>7> 188997939 / 1000000 / 60. >>3.14996565 >> >>Connecting to a different port, which I haven't firewalled I get the >>following: >>8> gen_tcp:connect({127,0,0,1}, 6667, [binary, {packet, >>0}]). >>{error,econnrefused} >> >>Removing the firewall I get: >># iptables -D INPUT -i lo -p tcp --dport 6666 -j DROP >>9> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}], >>infinity]). >>{527,{ok,#Port<0.434>}} >> >>Why is infinity so short? >> >>Gamoto wrote: >>> I an windows server 2003. I don't understand why gen_tcp:connect returns ALWAYS an error. >>> "connect" should be blocking, the port is free, I didn't precise a timeout. I also tried with "localhost". >>> Another strange effect: error returned is "econnrefused" or, when another emacs is opened with erlang code inside, the returned error is "timeout" !!! >>> Is it "normal" with Erlang ? >>> >>> John >>> >>> start()-> >>> case gen_tcp:connect("127.0.0.1",1688,[binary, {packet, 0}]) of >>> {ok,Socket}-> >>> io:format("Socket established~n"), >>> loop(Socket); >>> {error,Reason}-> >>> io:format("Error on connect: ~s~n",[Reason]) >>> end. >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >>Best regards >> >>-- >>Oscar Hellstr?m, oscar@REDACTED >>Office: +44 20 7655 0337 >>Mobile: +44 798 45 44 773 >>Erlang Training and Consulting Ltd >>http://www.erlang-consulting.com/ >> > >------------------------------ > >Message: 6 >Date: Wed, 8 Apr 2009 16:23:07 +0200 >From: Raimo Niskanen >Subject: Re: [erlang-questions] : strange behaviour of > gen_tcp:connect >To: Oscar Hellstr?m , > erlang-questions@REDACTED >Message-ID: <20090408142307.GA9872@REDACTED> >Content-Type: text/plain; charset=iso-8859-1 > >On Wed, Apr 08, 2009 at 12:27:24PM +0100, Oscar Hellstr?m wrote: >> Hi, >> >> If the port really is free, then you will get a econnrefused, unless you >> have a firewall blocking connection attempts. >> >> Not that I have a windows server 2003 machine, but I'm still seeing at >> least one interesting thing here: >> >> First I start a listening socket on port 6666: >> ~% netcat -l -p 6666 >> >> Then I configure my iptables to trop all packets on the local interface >> to that port: >> # iptables -A INPUT -i lo -p tcp --dport 6666 -j DROP >> >> Then, I start an erlang shell and try to connect to port 6666: >> ~% erl >> Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [smp:2] >> [async-threads:0] [hipe] [ker >> >> Eshell V5.6.5 (abort with ^G) >> 1> gen_tcp:connect({127,0,0,1}, 6666, [binary, {packet, 0}]). >> {error,etimedout} >> >> Ok, wait here now a second, etimedout? This is from the gen_tcp manual: >> connect(Address, Port, Options) -> {ok, Socket} | {error, Reason} >> connect(Address, Port, Options, Timeout) -> {ok, Socket} | {error, Reason} >> ... >> Timeout = int() | infinity >> ... >> The optional Timeout parameter specifies a timeout in milliseconds. The >> default value is infinity. >> >> So, shouldn't we wait for infinity? >> 3> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}]]). >> {189001895,{error,etimedout}} >> 5> 189001895 / 1000000 / 60. >> 3.150031583333333 >> >> It seems the definition of infinity here is 3.15 minutes? > >It is most probably the definition of fatal timeout in the >TCP stack. So the man page forget to mention that if >the OS connect() call returns with a timeout, gen_tcp:connect >will also return with a timeout, even if none was specified. > >> >> Even when I specify the timeout explicitly I get the same result. >> 6> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}], >> infinity]). >> {188997939,{error,etimedout}} >> 7> 188997939 / 1000000 / 60. >> 3.14996565 >> >> Connecting to a different port, which I haven't firewalled I get the >> following: >> 8> gen_tcp:connect({127,0,0,1}, 6667, [binary, {packet, >> 0}]). >> {error,econnrefused} >> >> Removing the firewall I get: >> # iptables -D INPUT -i lo -p tcp --dport 6666 -j DROP >> 9> timer:tc(gen_tcp, connect, [{127,0,0,1}, 6666, [binary, {packet, 0}], >> infinity]). >> {527,{ok,#Port<0.434>}} >> >> Why is infinity so short? >: > >-- > >/ Raimo Niskanen, Erlang/OTP, Ericsson AB > > >------------------------------ > >Message: 7 >Date: Wed, 08 Apr 2009 16:28:12 +0200 >From: Sverker Eriksson >Subject: Re: [erlang-questions] tcp_send_error >Cc: erlang-questions >Message-ID: <49DCB47C.5070902@REDACTED> >Content-Type: text/plain; charset=ISO-8859-1; format=flowed > >Anthony Shipman wrote: >> I am looking at the source for inet_drv.c in 12B4. In the tcp_send_error() >> function it says >> >> * Note: The following message might get lost, in case the error >> * occurred when we tried to write taken from the queue (no caller). >> >> Can the message really get lost and under what circumstances? >> >> >When the process is not blocking in prim_inet:send() waiting for a >reply. That is, the send operation was done asynchronous triggered by an >internal polled write-event from the socket. > >> In the kernel application prim_inet:send() the code waits indefinitely for a >> response from the driver. If it can get lost then it looks like a send() can >> block forever. I've got a case where high traffic over a very slow link >> appears to result in prim_inet:send() getting stuck. >> >> >Changes have been made to that code in R12B-5, R13A, R13B. Here are two >fixes in the release notes regarding hanging send's: > >R13A: >Calling gen_tcp:send() from several processes on socket with option >send_timeout >could lead to much longer timeout than specified. The solution is a new >socket option >{send_timeout_close,true} that will do automatic close on timeout. >Subsequent calls >to send will then immediately fail due to the closed connection. > >Coming R13B: >Fixed a bug on Windows that could make gen_tcp:send hang trying to send >an iolist >of more than 16 binaries. > > >/Sverker, Erlang/OTP Ericsson > > > > >------------------------------ > >Message: 8 >Date: Wed, 08 Apr 2009 19:21:29 +0200 >From: Franco Milicchio >Subject: Re: [erlang-questions] State of the Union: FFI >To: Zvi >Cc: erlang-questions@REDACTED >Message-ID: <01D2B728-D19B-4923-A5A8-DE08CC70A908@REDACTED> >Content-Type: text/plain; charset="us-ascii" > >I have started porting the patch to R13A, although I can't say if it >really works: it doesn't compile! Makefile error, not a C one :) > >You may find the source code at: http://plm.dia.uniroma3.it/milicchio/public/otp_src_R13A-ffi.zip > (62 MB) > > >I have no time left today, but if we all start figuring out what's >wrong with it, we may end up having the FFI working on this new >release. I have marked the C code with comments (/* FFI START */ and / >* FFI END */) where I had doubts about applying Alceste's patch, so it >should be easy to spot them. > >By the way, no news about the reason FFI hasn't been taken into >account yet? > >Cheers! > >-- >Franco Milicchio > >DIA - Dept. of Computer Science and Engineering >University Roma Tre >http://plm.dia.uniroma3.it/milicchio/ > >-------------- next part -------------- >A non-text attachment was scrubbed... >Name: smime.p7s >Type: application/pkcs7-signature >Size: 2417 bytes >Desc: not available >Url : http://www.erlang.org/pipermail/erlang-questions/attachments/20090408/f0963b9e/attachment.bin > >------------------------------ > >_______________________________________________ >erlang-questions mailing list >erlang-questions@REDACTED >http://www.erlang.org/mailman/listinfo/erlang-questions > >End of erlang-questions Digest, Vol 23, Issue 29 >************************************************ From gleber.p@REDACTED Thu Apr 9 11:52:56 2009 From: gleber.p@REDACTED (Gleb Peregud) Date: Thu, 9 Apr 2009 11:52:56 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 23, Issue 29 In-Reply-To: <200904091100327295961@bluewin.ch> References: <200904091100327295961@bluewin.ch> Message-ID: <14f0e3620904090252t540cdfb1q13c2ef0ebc2790dd@mail.gmail.com> On Thu, Apr 9, 2009 at 11:00, Gamoto wrote: > Hi Steve, > Yes: RTFM ?as say Linux people. > But it is not my mentality. If I don't down then I ask. If I know then I share. > Have a good day ! > John Hello, John. I'm very sorry, but Steve is absolutely right. Please don't shift your work to the others. Many of your problems/questions are solved/answered on the web. Please use Google more often. >>When replying, please edit your Subject line so it is more specific >>than "Re: Contents of erlang-questions digest..." He is absolutely right here too. I guess you should read thoroughly "How To Ask Questions The Smart Way" [1] by Eric Raymond. Please respect other members of the mailing list and their time by keeping their inboxes tidy and clean. 1: http://www.catb.org/~esr/faqs/smart-questions.html Best, Gleb Peregud From freza@REDACTED Thu Apr 9 12:37:06 2009 From: freza@REDACTED (Jachym Holecek) Date: Thu, 9 Apr 2009 12:37:06 +0200 Subject: [erlang-questions] Erlang on Emacs In-Reply-To: <57d241cf0904090122p6238cd9ap48f0444e4e2bf7c@mail.gmail.com> References: <57d241cf0904090122p6238cd9ap48f0444e4e2bf7c@mail.gmail.com> Message-ID: <20090409103706.GA3601@hanele> Hello, # Peter McCarthy 2009-04-09: > I recommend that you install Distel, then everything should become clear: > > http://fresh.homeunix.net/~luke/distel/ FWIW distel doesn't work with CVS version of Emacs -- it fails to connect to Erlang node. I didn't have the time (nor motivation, really) to look into it in more detail. -- Jachym From alpar@REDACTED Thu Apr 9 12:59:47 2009 From: alpar@REDACTED (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=) Date: Thu, 09 Apr 2009 10:59:47 +0000 Subject: [erlang-questions] Erlang on Emacs In-Reply-To: <20090409103706.GA3601@hanele> References: <57d241cf0904090122p6238cd9ap48f0444e4e2bf7c@mail.gmail.com> <20090409103706.GA3601@hanele> Message-ID: <1239274787.6323.47.camel@piko> > FWIW distel doesn't work with CVS version of Emacs -- it fails to > connect to Erlang node. I didn't have the time (nor motivation, > really) to look into it in more detail. Strangely, it works for me. (Well, more-or-less. When I press "C-c C-d l" for the first time, it asks for the name of a node, but does not show the process list. However, it seems that it silently connects successfully to the node, thus if I press "C-c C-d l" again, it works alright.) Regards, Alpar > > -- Jachym > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From peter.mccarthy.0807@REDACTED Thu Apr 9 13:04:08 2009 From: peter.mccarthy.0807@REDACTED (Peter McCarthy) Date: Thu, 9 Apr 2009 12:04:08 +0100 Subject: [erlang-questions] Erlang on Emacs Message-ID: <57d241cf0904090404v75dbb8fay113a3dbf1951ec4e@mail.gmail.com> Hi Jachym > FWIW distel doesn't work with CVS version of Emacs -- it fails to > connect to Erlang node. I didn't have the time (nor motivation, > really) to look into it in more detail. That's unfortunate. All I can say is that I installed Emacs (v22.1.1) via the Package Manager (I'm running Ubuntu Hardy). I then installed Distel following Bill Clementson's instructions (http://bc.tech.coop/blog/070719.html). And, within an hour, I was productive. Regards Peter From zheng.cuizh@REDACTED Fri Apr 10 09:15:36 2009 From: zheng.cuizh@REDACTED (Charles Cui) Date: Fri, 10 Apr 2009 15:15:36 +0800 Subject: [erlang-questions] math:pow(10, 1000). ===> exception error: bad argument in an arithmetic expression Message-ID: <60d704580904100015u795800d7ub49d687a852f6d5c@mail.gmail.com> math:pow(10,1000). ** exception error: bad argument in an arithmetic expression in function math:pow/2 called as math:pow(10,1000) I want to do bigint compute,such as math:pow(a,b). Can Erlang do this? Any one help? -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Fri Apr 10 09:46:49 2009 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 10 Apr 2009 10:46:49 +0300 Subject: [erlang-questions] math:pow(10, 1000). ===> exception error: bad argument in an arithmetic expression In-Reply-To: <60d704580904100015u795800d7ub49d687a852f6d5c@mail.gmail.com> References: <60d704580904100015u795800d7ub49d687a852f6d5c@mail.gmail.com> Message-ID: <49DEF969.8070902@cs.ntua.gr> Charles Cui wrote: > math:pow(10,1000). > ** exception error: bad argument in an arithmetic expression > in function math:pow/2 > called as math:pow(10,1000) > > I want to do bigint compute,such as math:pow(a,b). > Can Erlang do this? Sure it can. It's a Turing complete language after all... You just have to define it yourself. One possible definition appears below: ------------------------------------------------------- -module(m). -export([pow/2]). -spec pow(integer(), non_neg_integer()) -> integer() ; (float(), non_neg_integer()) -> float(). pow(X, N) when is_integer(N), N >= 0 -> pow(X, N, 1). pow(_, 0, P) -> P; pow(X, N, A) -> pow(X, N-1, A*X). --------------------------------------------------------- Eshell V5.7 (abort with ^G) 1> c(m). {ok,m} 2> m:pow(10, 100). 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Kostis From vychodil.hynek@REDACTED Fri Apr 10 10:36:30 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 10 Apr 2009 10:36:30 +0200 Subject: [erlang-questions] math:pow(10, 1000). ===> exception error: bad argument in an arithmetic expression In-Reply-To: <49DEF969.8070902@cs.ntua.gr> References: <60d704580904100015u795800d7ub49d687a852f6d5c@mail.gmail.com> <49DEF969.8070902@cs.ntua.gr> Message-ID: <4d08db370904100136g40208ac7kabf766f25496e76@mail.gmail.com> And here is faster O(logN) version -module(m). -export([pow/2, test/0]). pow(X, N) when is_integer(N), N >= 0 -> pow(X, N, 1); pow(X, N) when is_integer(N) -> 1 / pow(X, -N, 1); pow(X, N) when is_float(N) -> math:pow(X, N). pow(_, 0, P) -> P; pow(X, N, A) when N rem 2 =:= 0 -> pow(X * X, N div 2, A); pow(X, N, A) -> pow(X, N - 1, A * X). test() -> [begin X = 1 bsl N, X = pow(2, N) end || N <- lists:seq(0, 10)], [begin X = 1 / (1 bsl N), X = pow(2, -N) end || N <- lists:seq(1, 10)]. On Fri, Apr 10, 2009 at 9:46 AM, Kostis Sagonas wrote: > Charles Cui wrote: > > math:pow(10,1000). > > ** exception error: bad argument in an arithmetic expression > > in function math:pow/2 > > called as math:pow(10,1000) > > > > I want to do bigint compute,such as math:pow(a,b). > > Can Erlang do this? > > Sure it can. It's a Turing complete language after all... > You just have to define it yourself. > One possible definition appears below: > > ------------------------------------------------------- > -module(m). > -export([pow/2]). > > -spec pow(integer(), non_neg_integer()) -> integer() > ; (float(), non_neg_integer()) -> float(). > > pow(X, N) when is_integer(N), N >= 0 -> pow(X, N, 1). > > pow(_, 0, P) -> P; > pow(X, N, A) -> pow(X, N-1, A*X). > > --------------------------------------------------------- > Eshell V5.7 (abort with ^G) > 1> c(m). > {ok,m} > 2> m:pow(10, 100). > > 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From freza@REDACTED Fri Apr 10 11:21:00 2009 From: freza@REDACTED (Jachym Holecek) Date: Fri, 10 Apr 2009 11:21:00 +0200 Subject: [erlang-questions] Erlang on Emacs In-Reply-To: <20090409103706.GA3601@hanele> References: <57d241cf0904090122p6238cd9ap48f0444e4e2bf7c@mail.gmail.com> <20090409103706.GA3601@hanele> Message-ID: <20090410092100.GA2407@hanele> # Jachym Holecek 2009-04-09: > # Peter McCarthy 2009-04-09: > > I recommend that you install Distel, then everything should become clear: > > > > http://fresh.homeunix.net/~luke/distel/ > > FWIW distel doesn't work with CVS version of Emacs -- it fails to > connect to Erlang node. I didn't have the time (nor motivation, > really) to look into it in more detail. I received a private reply saying this works for other people, so I got curious and tried again with a fresh checkout of http://code.google.com/p/distel/ pointing Emacs to R12B-3 version of erlang.el, and indeed it works! I've been using Jungerl distel + older erlang.el with some local hacks previously and there must have been some odd interaction somewhere... Sorry for the confusion, -- Jachym From ulf.wiger@REDACTED Fri Apr 10 14:00:34 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Fri, 10 Apr 2009 14:00:34 +0200 Subject: [erlang-questions] Advance notice, Sthlm Erlang User Grp 23 May Message-ID: This is an advance notice that we'll arrange a Stockholm Erlang Users Group meeting on 23 May. Location TBA. The main attraction will be Richard Carlsson. Richard will give a talk on "EUnit - Tips and Tricks", that he is preparing for the Bay Area Erlang Factory conference. So make a note in your calendars. Hope to see many of you there. BR, Ulf W From chsu79@REDACTED Fri Apr 10 14:22:32 2009 From: chsu79@REDACTED (Christian) Date: Fri, 10 Apr 2009 14:22:32 +0200 Subject: [erlang-questions] Advance notice, Sthlm Erlang User Grp 23 May In-Reply-To: References: Message-ID: On Fri, Apr 10, 2009 at 14:00, Ulf Wiger wrote: > This is an advance notice that we'll arrange a Stockholm Erlang Users Group meeting on 23 May. Location TBA. TBA? From ulf.wiger@REDACTED Fri Apr 10 14:28:25 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Fri, 10 Apr 2009 14:28:25 +0200 Subject: [erlang-questions] Advance notice, Sthlm Erlang User Grp 23 April In-Reply-To: References: Message-ID: <49DF3B69.8000708@erlang-consulting.com> Christian wrote: > On Fri, Apr 10, 2009 at 14:00, Ulf Wiger > wrote: >> This is an advance notice that we'll arrange a Stockholm Erlang >> Users Group meeting on 23 May. Location TBA. > > TBA? TBA = To Be Announced. We'll decide on appropriate premises next week. Apologies. I was typing on my mobile phone. Also, NOTE WELL, it's 23 April - not May. Thursday, 23 April, the week before Erlang Factory in Palo Alto. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From macfisherman@REDACTED Mon Apr 13 05:13:18 2009 From: macfisherman@REDACTED (Jeff Macdonald) Date: Sun, 12 Apr 2009 23:13:18 -0400 Subject: [erlang-questions] remote spawns and sending messages to the remote PID Message-ID: <45ae90370904122013u5caa7862l61047ebbd7d60351@mail.gmail.com> Hi, I'm just getting my feet wet in erlang. I have Joe's book, but I wanted to try some low level stuff myself. I created a small counter module. It simply increments a value every time it see's an inc message and sends a reply back to the caller supplied PID. This works fine within a single node. However, I can't see to get it to work correctly when I start two nodes on the same computer using sname (foo and bar). First I spawn a local receive loop: (foo@REDACTED)2> R=spawn(fun counter:loop/0). <0.43.0> Testing it on that node works: (foo@REDACTED)3> R ! {ok,5}. Value is 5 {ok,5} Now I spawn the counter on the bar node: (foo@REDACTED)3> S=spawn('bar@REDACTED',counter,run,[5]). <5734.41.0> and send it a message: (foo@REDACTED)4> S ! {inc, R}. {inc,<0.38.0>} Normally when this is done on the local node, I get this: (foo@REDACTED)5> T=counter:run(5). <0.48.0> (foo@REDACTED)6> T ! {inc, R}. Value is 1 {inc,<0.38.0>} Note the Value line in the output. I'm aware of the rpc library, but I thought I could do simple things like above without it. Below is the code. I'm not currently using the registered process name. It was my understanding that all that one needed was a PID. If one used a registered process name instead, than one needed the node too. Is that incorrect? TIA -module(counter). -export([run/1, counter/2, loop/0]). run(Limit) -> S = spawn(counter, counter, [Limit, 0]), register(counter, S), S. counter(Limit, Sum) -> receive {value, Requester} -> Requester ! {ok, Sum}, counter(Limit, Sum); {inc, Requester} when Sum < Limit -> Requester ! {ok, Sum + 1}, counter(Limit, Sum + 1); {inc, Requester} -> Requester ! {error, limit}, counter(Limit, Sum) end. loop() -> receive {ok, V} -> io:format("Value is ~p~n",[V]), loop(); {error, Reason} -> io:format("Error ~p~n",[Reason]), loop() end. -- Jeff Macdonald Ayer, MA From Lennart.Ohman@REDACTED Mon Apr 13 06:16:04 2009 From: Lennart.Ohman@REDACTED (=?iso-8859-1?Q?Lennart_=D6hman?=) Date: Mon, 13 Apr 2009 06:16:04 +0200 Subject: [erlang-questions] remote spawns and sending messages to the remote PID In-Reply-To: <45ae90370904122013u5caa7862l61047ebbd7d60351@mail.gmail.com> References: <45ae90370904122013u5caa7862l61047ebbd7d60351@mail.gmail.com> Message-ID: Hi, the reason why this does not work is that you are not doing it the same way locally versus when doing it remote. The return value bound to the shell variable S in your example is not the process identifier of your counter process, merely some kind of intermediate process you choose to use in the remote example. Best Regards Lennart ------------------------------------------------------------- Lennart ?hman direct : +46 8 587 623 27 Sj?land & Thyselius Telecom AB cellular: +46 70 552 6735 H?lsingegatan 43, 10 th floor fax : +46 8 667 82 30 SE-113 31 STOCKHOLM, SWEDEN email : lennart.ohman@REDACTED -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Jeff Macdonald Sent: den 13 april 2009 05:13 To: erlang-questions@REDACTED Subject: [erlang-questions] remote spawns and sending messages to the remote PID Hi, I'm just getting my feet wet in erlang. I have Joe's book, but I wanted to try some low level stuff myself. I created a small counter module. It simply increments a value every time it see's an inc message and sends a reply back to the caller supplied PID. This works fine within a single node. However, I can't see to get it to work correctly when I start two nodes on the same computer using sname (foo and bar). First I spawn a local receive loop: (foo@REDACTED)2> R=spawn(fun counter:loop/0). <0.43.0> Testing it on that node works: (foo@REDACTED)3> R ! {ok,5}. Value is 5 {ok,5} Now I spawn the counter on the bar node: (foo@REDACTED)3> S=spawn('bar@REDACTED',counter,run,[5]). <5734.41.0> and send it a message: (foo@REDACTED)4> S ! {inc, R}. {inc,<0.38.0>} Normally when this is done on the local node, I get this: (foo@REDACTED)5> T=counter:run(5). <0.48.0> (foo@REDACTED)6> T ! {inc, R}. Value is 1 {inc,<0.38.0>} Note the Value line in the output. I'm aware of the rpc library, but I thought I could do simple things like above without it. Below is the code. I'm not currently using the registered process name. It was my understanding that all that one needed was a PID. If one used a registered process name instead, than one needed the node too. Is that incorrect? TIA -module(counter). -export([run/1, counter/2, loop/0]). run(Limit) -> S = spawn(counter, counter, [Limit, 0]), register(counter, S), S. counter(Limit, Sum) -> receive {value, Requester} -> Requester ! {ok, Sum}, counter(Limit, Sum); {inc, Requester} when Sum < Limit -> Requester ! {ok, Sum + 1}, counter(Limit, Sum + 1); {inc, Requester} -> Requester ! {error, limit}, counter(Limit, Sum) end. loop() -> receive {ok, V} -> io:format("Value is ~p~n",[V]), loop(); {error, Reason} -> io:format("Error ~p~n",[Reason]), loop() end. -- Jeff Macdonald Ayer, MA _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From yangzd2006@REDACTED Mon Apr 13 10:38:08 2009 From: yangzd2006@REDACTED (=?GB2312?B?yMu85MrA?=) Date: Mon, 13 Apr 2009 16:38:08 +0800 Subject: [erlang-questions] module syntax help Message-ID: <55f414200904130138g3b1d9cc5t8c80e5124dcc909d@mail.gmail.com> code get from openpoker??-module(exch, [Cbk, Context, Modules]).? What?s it mean?Is it correct module syntax?thank? -------------- next part -------------- An HTML attachment was scrubbed... URL: From xushiweizh@REDACTED Mon Apr 13 10:52:55 2009 From: xushiweizh@REDACTED (shiwei xu) Date: Mon, 13 Apr 2009 16:52:55 +0800 Subject: [erlang-questions] module syntax help In-Reply-To: <55f414200904130138g3b1d9cc5t8c80e5124dcc909d@mail.gmail.com> References: <55f414200904130138g3b1d9cc5t8c80e5124dcc909d@mail.gmail.com> Message-ID: See http://erlang-china.org/study/parameterized-module.html 2009/4/13 ??? > code get from openpoker??-module(exch, [Cbk, Context, Modules]).? > What?s it mean?Is it correct module syntax?thank? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kdr2@REDACTED Mon Apr 13 11:08:03 2009 From: kdr2@REDACTED (KDr2) Date: Mon, 13 Apr 2009 17:08:03 +0800 Subject: [erlang-questions] module syntax help In-Reply-To: <55f414200904130138g3b1d9cc5t8c80e5124dcc909d@mail.gmail.com> References: <55f414200904130138g3b1d9cc5t8c80e5124dcc909d@mail.gmail.com> Message-ID: It's parameterized module,To declare a parameterized module, simply specify some variable names in the module declaration: *-module(foo,[Bar, Baz]).* That's it! You're done. You've created a parameterized module. You got a func called 'new' , And you can now use Bar and Baz in the scope of any functions defined in your module. code: -module(xx,[A,B]). -compile(export_all). test()-> io:format("A=~w,B=~w~n",[A,B]). result: Eshell V5.6.5 (abort with ^G) 1> B=xx:new(abc,"hehe"). {xx,abc,"hehe"} 2> B:test(). A=abc,B=[104,101,104,101] ok 3> btw: ???????? 2009/4/13 ??? > code get from openpoker??-module(exch, [Cbk, Context, Modules]).? > What?s it mean?Is it correct module syntax?thank? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, -- KDr2, at x-macro.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vlm@REDACTED Mon Apr 13 11:09:57 2009 From: vlm@REDACTED (Lev Walkin) Date: Mon, 13 Apr 2009 02:09:57 -0700 Subject: [erlang-questions] module syntax help In-Reply-To: <55f414200904130138g3b1d9cc5t8c80e5124dcc909d@mail.gmail.com> References: <55f414200904130138g3b1d9cc5t8c80e5124dcc909d@mail.gmail.com> Message-ID: <49E30165.5080603@lionet.info> Easy one: http://www.google.com/search?q=parameterized+modules+erlang ??? wrote: > code get from openpoker??-module(exch, [Cbk, Context, Modules]).? > What?s it mean?Is it correct module syntax?thank? > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From masse@REDACTED Mon Apr 13 13:53:41 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 13 Apr 2009 13:53:41 +0200 Subject: [erlang-questions] Erlang on Emacs In-Reply-To: <20090410092100.GA2407@hanele> (Jachym Holecek's message of "Fri\, 10 Apr 2009 11\:21\:00 +0200") References: <57d241cf0904090122p6238cd9ap48f0444e4e2bf7c@mail.gmail.com> <20090409103706.GA3601@hanele> <20090410092100.GA2407@hanele> Message-ID: <877i1oepmi.fsf@dixie.cronqvi.st> Jachym Holecek writes: > # Jachym Holecek 2009-04-09: >> # Peter McCarthy 2009-04-09: >> > I recommend that you install Distel, then everything should become clear: >> > >> > http://fresh.homeunix.net/~luke/distel/ >> >> FWIW distel doesn't work with CVS version of Emacs -- it fails to >> connect to Erlang node. I didn't have the time (nor motivation, >> really) to look into it in more detail. > > I received a private reply saying this works for other people, > so I got curious and tried again with a fresh checkout of > > http://code.google.com/p/distel/ > > pointing Emacs to R12B-3 version of erlang.el, and indeed it works! AFAIK, google code distel works with any combination of Erlang R9-R13 and Gnu Emacs 19-23 + some versions of XEmacs. Most of the user base is pretty bleeding edge, so it's pretty much guaranteed to work with the current and upcoming releases (right now Erlang R12-R13 and Emacs 22-23.) > I've been using Jungerl distel + older erlang.el with some local hacks > previously and there must have been some odd interaction somewhere... Jungerl distel hasn't been updated in quite a few years, and only exists because it's too much work to delete it. The OTP erlang.el is not really maintained. I can recommend the erlang.el from erlware; http://git.erlware.org/erlware-mode.git mats From masse@REDACTED Mon Apr 13 13:57:13 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 13 Apr 2009 13:57:13 +0200 Subject: [erlang-questions] Erlang on Emacs In-Reply-To: <1239274787.6323.47.camel@piko> (=?iso-8859-1?Q?=22Alp=E1r_J?= =?iso-8859-1?Q?=FCttner=22's?= message of "Thu\, 09 Apr 2009 10\:59\:47 +0000") References: <57d241cf0904090122p6238cd9ap48f0444e4e2bf7c@mail.gmail.com> <20090409103706.GA3601@hanele> <1239274787.6323.47.camel@piko> Message-ID: <873accepgm.fsf@dixie.cronqvi.st> Alp?r J?ttner writes: >> FWIW distel doesn't work with CVS version of Emacs -- it fails to >> connect to Erlang node. I didn't have the time (nor motivation, >> really) to look into it in more detail. > > Strangely, it works for me. > > (Well, more-or-less. When I press "C-c C-d l" for the first time, it > asks for the name of a node, but does not show the process list. > However, it seems that it silently connects successfully to the node, > thus if I press "C-c C-d l" again, it works alright.) that's a "feature" in the sense that it's not easy to fix without breaking things. The recommended way to connect is to do; "C-c C-d n" "C-c C-d g" mats From exta7@REDACTED Mon Apr 13 14:32:10 2009 From: exta7@REDACTED (Zvi) Date: Mon, 13 Apr 2009 05:32:10 -0700 (PDT) Subject: [erlang-questions] State of the Union: FFI In-Reply-To: <01D2B728-D19B-4923-A5A8-DE08CC70A908@me.com> References: <2812B7B9-6B8C-4CDE-A966-96624AF61625@me.com> <22831017.post@talk.nabble.com> <01D2B728-D19B-4923-A5A8-DE08CC70A908@me.com> Message-ID: <23021754.post@talk.nabble.com> Hi Franco, did u run ./otp_build autoconf before ./configure ? You need to install autoconf to use it: apt-get install autoconf I did: ./otp_build autoconf ./configure make and got compilation errors in beam/erl_bif_ddll.c : beam/erl_bif_ddll.c: In function 'erl_ddll_info_2': beam/erl_bif_ddll.c:833: error: 'de' undeclared (first use in this function) beam/erl_bif_ddll.c:833: error: (Each undeclared identifier is reported only once beam/erl_bif_ddll.c:833: error: for each function it appears in.) beam/erl_bif_ddll.c: In function 'do_unload_driver_entry': beam/erl_bif_ddll.c:1790: error: 'erts_driver_t' has no member named 'drv' beam/erl_bif_ddll.c:1791: error: 'erts_driver_t' has no member named 'drv' make[3]: *** [obj/i686-pc-linux-gnu/opt/smp/erl_bif_ddll.o] Error 1 make[3]: Leaving directory `/root/erlang/otp_src_R13A-ffi/erts/emulator' make[2]: *** [opt] Error 2 make[2]: Leaving directory `/root/erlang/otp_src_R13A-ffi/erts/emulator' make[1]: *** [smp] Error 2 make[1]: Leaving directory `/root/erlang/otp_src_R13A-ffi/erts' make: *** [emulator] Error 2 [root@REDACTED otp_src_R13A-ffi]# Thanks, Zvi Franco Milicchio-4 wrote: > > I have started porting the patch to R13A, although I can't say if it > really works: it doesn't compile! Makefile error, not a C one :) > > You may find the source code at: > http://plm.dia.uniroma3.it/milicchio/public/otp_src_R13A-ffi.zip > (62 MB) > > > I have no time left today, but if we all start figuring out what's > wrong with it, we may end up having the FFI working on this new > release. I have marked the C code with comments (/* FFI START */ and / > * FFI END */) where I had doubts about applying Alceste's patch, so it > should be easy to spot them. > > By the way, no news about the reason FFI hasn't been taken into > account yet? > > Cheers! > > -- > Franco Milicchio > > DIA - Dept. of Computer Science and Engineering > University Roma Tre > http://plm.dia.uniroma3.it/milicchio/ > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://www.nabble.com/State-of-the-Union%3A-FFI-tp22824174p23021754.html Sent from the Erlang Questions mailing list archive at Nabble.com. From steven.charles.davis@REDACTED Mon Apr 13 22:16:55 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 13 Apr 2009 13:16:55 -0700 (PDT) Subject: [erlang-questions] What is the correct representation of text in erlang programs? Message-ID: <358746d2-bfc7-469a-80ef-49d73d3937c2@q2g2000vbr.googlegroups.com> Working with HTTP means a lot of work with text, I have been frequently facing issues in trying to figure out whether a list of integers represents a text string or just a list of integers (or something else), and found myself wishing for a string type in Erlang (please, please read further before wasting time responding to this particular thought!). I read quite a few past threads on this issue, and found a lot of ideas and discussion about the "rightness" or otherwise of a string type I found certain arguments pretty convincing, and I have ditched the whole idea of a "string type" as a maguffin. So what to do? Although the issue is old, I don't see any readily available guidance. Here is my thinking on it: I use JSON as it's familiar and simple, but the same issue applies to most imported data. Take a simple incoming JSON object such as: { "hello": "world", } You would of course actually receive something like: "{\"hello\": \"world\"}", or <<"{\"hello\": \"world\"}">> The question then is: what is the correct term equivalent of this JSON object? Given that a JSON object is a list of pairs, "K" : V, then the most obvious solution would be: [ { hello, "world"} ] ... where the pair list that represents the object would be a list of two-tuples with an atom key and the "string" represented as a list of integers. But suppose we add in an array (which of course is also a list): { "hello": [ "world", "again" ], } Including an array "of strings" for the value makes life considerably more indeterminate. When processing the data type. You need to decide whether something Is a list of things or a representation of a text thing, and that's not always (in fact, rarely) easy. Looking at it this way, I've come to the conclusion that the "one true way" to represent text values inside erlang terms is actually as binaries... so for our example the correct solution would be: [ {hello: <<"world">>} ] and [ {hello: [ <<"world">>, <<"again">>] } ] Apart from "is this correct?", I have two questions: 1) If you use the rule of "text as binaries only", will this lead to the correct solution in all cases of imported data types? 2) Are there boundary conditions I should be aware of? BR Steve From steven.charles.davis@REDACTED Mon Apr 13 22:23:29 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 13 Apr 2009 15:23:29 -0500 Subject: [erlang-questions] What is the correct representation of text in erlang programs? In-Reply-To: <358746d2-bfc7-469a-80ef-49d73d3937c2@q2g2000vbr.googlegroups.com> References: <358746d2-bfc7-469a-80ef-49d73d3937c2@q2g2000vbr.googlegroups.com> Message-ID: <49E39F41.5@gmail.com> Please ignore the extraneous additional comma separators! i.e. { "hello": [ "world", "again" ], } ...should obviously read... { "hello": [ "world", "again" ] } etc. Steve Davis wrote: > Working with HTTP means a lot of work with text, I have been From elias@REDACTED Mon Apr 13 23:09:51 2009 From: elias@REDACTED (Elias Torres) Date: Mon, 13 Apr 2009 17:09:51 -0400 Subject: [erlang-questions] What is the correct representation of text in erlang programs? In-Reply-To: <49E39F41.5@gmail.com> References: <358746d2-bfc7-469a-80ef-49d73d3937c2@q2g2000vbr.googlegroups.com> <49E39F41.5@gmail.com> Message-ID: Have you read this: http://www.erlang.org/eeps/eep-0018.html or http://mail-archives.apache.org/mod_mbox/couchdb-dev/200807.mbox/%3cD1FB7B22-2C53-4D58-895B-912CB92A296A@REDACTED%3e -Elias On Mon, Apr 13, 2009 at 4:23 PM, Steve Davis wrote: > Please ignore the extraneous additional comma separators! i.e. > { > "hello": [ "world", "again" ], > } > ...should obviously read... > { > "hello": [ "world", "again" ] > } > etc. > > Steve Davis wrote: > > Working with HTTP means a lot of work with text, I have been > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Mon Apr 13 23:39:06 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 13 Apr 2009 14:39:06 -0700 (PDT) Subject: [erlang-questions] What is the correct representation of text in erlang programs? In-Reply-To: References: <358746d2-bfc7-469a-80ef-49d73d3937c2@q2g2000vbr.googlegroups.com> <49E39F41.5@gmail.com> Message-ID: <1d133884-bc12-481d-b055-50b62b196827@v15g2000yqn.googlegroups.com> On Apr 13, 4:09?pm, Elias Torres wrote: > Have you read this: > ?http://www.erlang.org/eeps/eep-0018.html > > or > > http://mail-archives.apache.org/mod_mbox/couchdb-dev/200807.mbox/%3cD1FB7B2 2-2C53-4D58-895B-912CB92A2...@REDACTED%3e > > -Elias > > On Mon, Apr 13, 2009 at 4:23 PM, Steve Davis > I have now! Thank you for these links. Apart from my obvious typos it seems that the JSON EEP authors have come to the same conclusions for the JSON data type. So would it be fair to say that, as a general design principle for representing strings in erlang terms then a binary representation is far more preferable than a "list of integers"? I know it's basic question, but it's fundamental to a great deal of code, and no clear guidance is offered/obvious. /s From steven.charles.davis@REDACTED Mon Apr 13 23:53:34 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 13 Apr 2009 14:53:34 -0700 (PDT) Subject: [erlang-questions] What is the correct representation of text in erlang programs? In-Reply-To: <1d133884-bc12-481d-b055-50b62b196827@v15g2000yqn.googlegroups.com> References: <358746d2-bfc7-469a-80ef-49d73d3937c2@q2g2000vbr.googlegroups.com> <49E39F41.5@gmail.com> <1d133884-bc12-481d-b055-50b62b196827@v15g2000yqn.googlegroups.com> Message-ID: On Apr 13, 4:39?pm, Steve Davis wrote: > So would it be fair to say that, as a general design principle for > representing strings in erlang terms then a binary representation is > far more preferable than a "list of integers"? > Additionally 1) do people tend to agree with Joe's guidance in that exchange re:couchdb, and if so why isn't it plastered all over the tutorials? 3) Shouldn't the word "string" be banned from the debate about text in erlang apart from as a reference to a specific foreign data type? 3) Are my questions too trite? From steven.charles.davis@REDACTED Tue Apr 14 00:11:36 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 13 Apr 2009 15:11:36 -0700 (PDT) Subject: [erlang-questions] module syntax help In-Reply-To: <49E30165.5080603@lionet.info> References: <55f414200904130138g3b1d9cc5t8c80e5124dcc909d@mail.gmail.com> <49E30165.5080603@lionet.info> Message-ID: <485e15e5-ec54-4353-a95c-dd0bc506c64e@g37g2000yqn.googlegroups.com> Followup question: If you call new twice, e.g. 1> P = mymodule:new(Params). 2> P = mymodule:new(Params). I'd be right in thinking that P is exactly the same instance of the parameterized module, correct? i.e. if I call mymodule:new(Params) with the same parameters 100000 times there's no memory (or otherwise) impact on the VM? /s On Apr 13, 4:09 am, Lev Walkin wrote: > Easy one: > > http://www.google.com/search?q=parameterized+modules+erlang > > ??? wrote: > > code get from openpoker?"-module(exch, [Cbk, Context, Modules])." > > What's it mean?Is it correct module syntax?thank? > > > ------------------------------------------------------------------------ > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From saleyn@REDACTED Tue Apr 14 01:51:27 2009 From: saleyn@REDACTED (Serge Aleynikov) Date: Mon, 13 Apr 2009 19:51:27 -0400 Subject: [erlang-questions] bug: R12B-4 global_group registration has a process leak causing occasional node restarts Message-ID: <49E3CFFF.6040303@gmail.com> It appears that R12B-4 has a faulty implementation of global_group management that results in a process leak eventually causing a node restart when the default process_limit is reached. I don't have R13-A installed, but since I haven't seen anything in kernel release notes indicating changes in the global_groups, I assume the same issue exists in the latest version. Attached is a patch fixing the issue. Here are the steps reproducing the problem: $ cat test.config [ {kernel, [{global_groups, [{marc, ['a@REDACTED', 'b@REDACTED']}]}]} ]. $ erl -sname a -config test.config (a@REDACTED)1> global:register_name(test, self()). yes $ erl -sname b -config test.config (b@REDACTED)1> length(processes()). 30 (b@REDACTED)2> global_group:whereis_name({group, marc}, test). <2334.40.0> (b@REDACTED)3> length(processes()). 34 (b@REDACTED)4> global_group:whereis_name({group, marc}, test). <2334.40.0> (b@REDACTED)5> length(processes()). 35 (b@REDACTED)6> global_group:whereis_name({group, marc}, test). <2334.40.0> (b@REDACTED)7> length(processes()). 36 After applying the patch the same test holds: $ erl -sname b -config test.config (b@REDACTED)1> length(processes()). 30 (b@REDACTED)2> global_group:whereis_name({group, marc}, test). <2334.40.0> (b@REDACTED)3> length(processes()). 33 (b@REDACTED)4> global_group:whereis_name({group, marc}, test). <2334.40.0> (b@REDACTED)5> length(processes()). 33 (b@REDACTED)6> global_group:whereis_name({group, marc}, test). <2334.40.0> (b@REDACTED)7> length(processes()). 33 Regards, Serge -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: global_group.erl.R12B-4.patch URL: From macfisherman@REDACTED Tue Apr 14 03:34:57 2009 From: macfisherman@REDACTED (Jeff Macdonald) Date: Mon, 13 Apr 2009 21:34:57 -0400 Subject: [erlang-questions] remote spawns and sending messages to the remote PID In-Reply-To: References: <45ae90370904122013u5caa7862l61047ebbd7d60351@mail.gmail.com> Message-ID: <45ae90370904131834w2ed7e768qb89023f87eac753b@mail.gmail.com> On Mon, Apr 13, 2009 at 12:16 AM, Lennart ?hman wrote: > Hi, the reason why this does not work is that you are not doing it the same way locally versus when doing it remote. The return value bound to the shell variable S in your example is not the process identifier of your counter process, merely some kind of intermediate process you choose to use in the remote example. ah. So there isn't a way that a PID actually represents a remote process? But that isn't true because if I do this: (foo@REDACTED)10> { counter, 'bar@REDACTED' } ! {inc, R}. {inc,<0.38.0>} Value is 1 which caused this code fragment to run on the remote node: {inc, Requester} when Sum < Limit -> Requester ! {ok, Sum + 1}, counter(Limit, Sum + 1); isn't the Requester variable a remote PID? What value is there to having spawn/4 return a PID? I'm obviously confused. :) -- Jeff Macdonald Ayer, MA From bernie@REDACTED Tue Apr 14 04:05:15 2009 From: bernie@REDACTED (Bernard Duggan) Date: Tue, 14 Apr 2009 12:05:15 +1000 Subject: [erlang-questions] remote spawns and sending messages to the remote PID In-Reply-To: <45ae90370904122013u5caa7862l61047ebbd7d60351@mail.gmail.com> References: <45ae90370904122013u5caa7862l61047ebbd7d60351@mail.gmail.com> Message-ID: <49E3EF5B.8030402@m5net.com> Hi Jeff, The problem's pretty straightforward. This: > Now I spawn the counter on the bar node: > (foo@REDACTED)3> S=spawn('bar@REDACTED',counter,run,[5]). > <5734.41.0> > Returns the process ID of the process executing the counter:run function. Whereas this: > (foo@REDACTED)5> T=counter:run(5). > <0.48.0> > Returns the return value of the counter:run function, which is a process spawned from within that function. Basically, you're getting confused between the return value of spawn(), which is a function that creates a process, and the return value of counter:run which is also a function that creates a process. When you call spawn('somenode', counter, run, [5]) it launches a process which executes counter:run, which in turn launches another process (by virtue of having a further call to spawn() in it). It's the process returned by the spawn() /inside/ counter:run() that you want to send the message to. Try this instead: S = spawn('bar@REDACTED', counter, counter, [5, 0]). That will bypass the extra call to spawn() and give you the PID you actually want to send messages to. Cheers, B From vik@REDACTED Tue Apr 14 04:46:15 2009 From: vik@REDACTED (Vik Olliver) Date: Tue, 14 Apr 2009 14:46:15 +1200 Subject: [erlang-questions] Easy way to spot undefined & empty lists? Message-ID: <49E3F8F7.9000000@catalyst.net.nz> What's the nice way to do: parse_result(undefined) -> {error,"String not defined"}; parse_result("") -> {error,"String not defined"}. Vik :v) From arnoldja@REDACTED Tue Apr 14 05:35:04 2009 From: arnoldja@REDACTED (John A Arnold) Date: Mon, 13 Apr 2009 23:35:04 -0400 Subject: [erlang-questions] AUTO: John A Arnold is out of the office. (returning 04/20/2009) Message-ID: I am out of the office until 04/20/2009. I am on vacation and will return to the office on April 20th. I will respond to your message when I return. If you need assistance on messaging matters in the interim, please contact either:: Karen Phillips: 212 745 4085 or Deepak Elias : 203 486 2074 Karen Phillips krphill@REDACTED, Emily Peyton eapeyto@REDACTED or Deepak Elias delias@REDACTED Note: This is an automated response to your message "erlang-questions Digest, Vol 23, Issue 35" sent on 4/13/09 19:51:44. This is the only notification you will receive while this person is away. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Tue Apr 14 06:19:41 2009 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 14 Apr 2009 16:19:41 +1200 Subject: [erlang-questions] Easy way to spot undefined & empty lists? In-Reply-To: <49E3F8F7.9000000@catalyst.net.nz> References: <49E3F8F7.9000000@catalyst.net.nz> Message-ID: <3263A6A2-6AEA-49A5-AB1C-3B93BDD75E51@cs.otago.ac.nz> On 14 Apr 2009, at 2:46 pm, Vik Olliver wrote: > What's the nice way to do: > > parse_result(undefined) -> > {error,"String not defined"}; > parse_result("") -> > {error,"String not defined"}. That is. If you don't like the duplication, there's a general technique ("add another function"): parse_result(undefined) -> string_not_defined(); parse_result("") -> string_not_defined(). string_not_defined() -> {error, "String not defined"}. When you are checking for patterns with no variables, you can use == in a guard: parse_result(Foo) when Foo == undefined ; Foo == "" -> {error, "String not defined"}. This removes the duplication, but makes the patterns harder to see. From vik@REDACTED Tue Apr 14 06:54:46 2009 From: vik@REDACTED (Vik Olliver) Date: Tue, 14 Apr 2009 16:54:46 +1200 Subject: [erlang-questions] Easy way to spot undefined & empty lists? In-Reply-To: <3263A6A2-6AEA-49A5-AB1C-3B93BDD75E51@cs.otago.ac.nz> References: <49E3F8F7.9000000@catalyst.net.nz> <3263A6A2-6AEA-49A5-AB1C-3B93BDD75E51@cs.otago.ac.nz> Message-ID: <49E41716.6030301@catalyst.net.nz> On 14/04/09 Richard O'Keefe wrote: > > parse_result(Foo) when Foo == undefined ; Foo == "" -> > {error, "String not defined"}. > > This removes the duplication, but makes the patterns > harder to see. That's the one I was looking for. It was hard to write, it's meant to be hard to understand! :) Vik :v) From francesco@REDACTED Tue Apr 14 07:16:29 2009 From: francesco@REDACTED (Francesco Cesarini (Erlang Training and Consulting)) Date: Tue, 14 Apr 2009 06:16:29 +0100 Subject: [erlang-questions] gen_udp in passive mode Message-ID: <49E41C2D.8020001@erlang-consulting.com> Running a UDP socket in passive mode, you retrieve the packets using gen_udp:recv(Socket, Length). I could not find any reference to what Length is used for in the documentation (Other than being used in gen_tcp module when packet types are raw). Is there a reason to have it here other than symmetry in the call among the modules? I recall a thread on the mailing list some time ago, but might be wrong as I could not find any reference to it. Thanks, Francesco -- http://www.erlang-consulting.com From v@REDACTED Tue Apr 14 07:54:04 2009 From: v@REDACTED (Valentin Micic) Date: Tue, 14 Apr 2009 07:54:04 +0200 Subject: [erlang-questions] gen_udp in passive mode In-Reply-To: <49E41C2D.8020001@erlang-consulting.com> Message-ID: <200904140544.n3E5i2Rc007804@mail.pharos-avantgard.com> I don't think that length make any sense in gen_udp:recv/2 in fact, I do not think that gen_udp:recv makes any sense at all. If anything, one should have called such a function gen_udp:recvfrom, which is, if memory serves me correctly, the name of the system call to retrieve a message from UDP socket. Considering that UDP respects message boundaries, it would be more in a spirit of Erlang to implement such a function with one argument only, e.g. gen_udp:recvfrom( UDP_socket ). V. -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Francesco Cesarini (Erlang Training and Consulting) Sent: 14 April 2009 07:16 AM To: erlang-questions@REDACTED Subject: [erlang-questions] gen_udp in passive mode Running a UDP socket in passive mode, you retrieve the packets using gen_udp:recv(Socket, Length). I could not find any reference to what Length is used for in the documentation (Other than being used in gen_tcp module when packet types are raw). Is there a reason to have it here other than symmetry in the call among the modules? I recall a thread on the mailing list some time ago, but might be wrong as I could not find any reference to it. Thanks, Francesco -- http://www.erlang-consulting.com _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From richardc@REDACTED Tue Apr 14 09:20:57 2009 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 14 Apr 2009 09:20:57 +0200 Subject: [erlang-questions] module syntax help In-Reply-To: <485e15e5-ec54-4353-a95c-dd0bc506c64e@g37g2000yqn.googlegroups.com> References: <55f414200904130138g3b1d9cc5t8c80e5124dcc909d@mail.gmail.com> <49E30165.5080603@lionet.info> <485e15e5-ec54-4353-a95c-dd0bc506c64e@g37g2000yqn.googlegroups.com> Message-ID: <49E43959.6090106@it.uu.se> Steve Davis wrote: > If you call new twice, e.g. > > 1> P = mymodule:new(Params). > 2> P = mymodule:new(Params). > > I'd be right in thinking that P is exactly the same instance of the > parameterized module, correct? > > i.e. if I call mymodule:new(Params) with the same parameters 100000 > times there's no memory (or otherwise) impact on the VM? The impact would be similar to running the following function the same number of times: new(P1,...,Pn) -> {some_tag, P1, ..., Pn}.. I.e., a small object is created on the heap, on the order of n+k words for some small k. As usual, these will be garbage collected when they are no longer referenced. (The current representation uses tuples, but this is meant to change, so never rely on that.) /Richard From cbenac@REDACTED Tue Apr 14 12:10:48 2009 From: cbenac@REDACTED (Clara Benac Earle) Date: Tue, 14 Apr 2009 12:10:48 +0200 Subject: [erlang-questions] McErlang first public release In-Reply-To: <523869a70904022122k479e4979id5b85b1be6c6e088@mail.gmail.com> References: <49D21C84.6080701@fi.upm.es> <91a2ba3e0904011049g7768f18ata96eed090a843f29@mail.gmail.com> <523869a70904022122k479e4979id5b85b1be6c6e088@mail.gmail.com> Message-ID: <49E46128.5050409@fi.upm.es> Hi Davide and Raoul, Glad to hear that you are interested in McErlang, we want more users :-) We will continuing to improve the tool so keep watching, and please send us suggestions for new features and bug reports. By the way, we will be giving a tutorial at the SF Bay Area Erlang Factory for those of you in the vicinity (see http://www.erlang-factory.com). Best regards, Clara Davide Marqu?s wrote: > On Wed, Apr 1, 2009 at 6:49 PM, Raoul Duke > wrote: > > > Please take a look at https://babel.ls.fi.upm.es/trac/McErlang/ > try the > > tool and send us your questions, comments, bug reports, etc. > > www.cs.chalmers.se/~hanssv/doc/icfp07-McErlang.pdf > > > very cool! i think concurrency/distribution clearly needs model > checking to develop 'correct' systems (as opposed to ones that 'just' > handle failure dynamically). hope to get some free time (ha ha!) to > try this all out. > > > I just read the tutorials and presentations on the site and I *have* > to say I really admire the work you've done with McErlang! > Congrats! :) > > From what I can tell, the best way to get an overview of McErlang > (without wasting too much of that ethereal free time :)) is this > presentation: > https://babel.ls.fi.upm.es/trac/McErlang/attachment/wiki/talks/costDec2008.pdf. > I think this sums it up quite nicely: > [McErlang]"An alternative implementation of Erlang for testing!" > > (writting this got me hungry...) > > /Davide :) > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From macfisherman@REDACTED Tue Apr 14 13:32:24 2009 From: macfisherman@REDACTED (Jeff Macdonald) Date: Tue, 14 Apr 2009 07:32:24 -0400 Subject: [erlang-questions] remote spawns and sending messages to the remote PID In-Reply-To: <49E3EF5B.8030402@m5net.com> References: <45ae90370904122013u5caa7862l61047ebbd7d60351@mail.gmail.com> <49E3EF5B.8030402@m5net.com> Message-ID: <45ae90370904140432y750831efkcd2d477b65fc8aef@mail.gmail.com> On Mon, Apr 13, 2009 at 10:05 PM, Bernard Duggan wrote: > Hi Jeff, > ? ?The problem's pretty straightforward. > This: >> Now I spawn the counter on the bar node: >> (foo@REDACTED)3> S=spawn('bar@REDACTED',counter,run,[5]). >> <5734.41.0> >> > Returns the process ID of the process executing the counter:run function. > > Whereas this: >> (foo@REDACTED)5> T=counter:run(5). >> <0.48.0> >> > Returns the return value of the counter:run function, which is a process > spawned from within that function. > > Basically, you're getting confused between the return value of spawn(), > which is a function that creates a process, and the return value of > counter:run which is also a function that creates a process. ?When you > call spawn('somenode', counter, run, [5]) it launches a process which > executes counter:run, which in turn launches another process (by virtue > of having a further call to spawn() in it). ?It's the process returned > by the spawn() /inside/ counter:run() that you want to send the message > to. ?Try this instead: > > S = spawn('bar@REDACTED', counter, counter, [5, 0]). > > That will bypass the extra call to spawn() and give you the PID you > actually want to send messages to. Thanks! Light bulb went off with that explanation. Thanks again. -- Jeff Macdonald Ayer, MA From rvirding@REDACTED Tue Apr 14 18:11:12 2009 From: rvirding@REDACTED (Robert Virding) Date: Tue, 14 Apr 2009 18:11:12 +0200 Subject: [erlang-questions] What is the correct representation of text in erlang programs? In-Reply-To: References: <358746d2-bfc7-469a-80ef-49d73d3937c2@q2g2000vbr.googlegroups.com> <49E39F41.5@gmail.com> <1d133884-bc12-481d-b055-50b62b196827@v15g2000yqn.googlegroups.com> Message-ID: <3dbc6d1c0904140911s3b34b70fpf2b961081406bd4b@mail.gmail.com> I think you are really looking at two different problems here: 1. How to represent external, for example JSON, data in a suitable way, more specifically how to be able to see the difference between sequences and strings both represented by lists. 2. What is a good representation of "strings" in Erlang. They are different problems. I personally feel that within an app you generally know what types of data you are working on, if a list is a string or a, well, list. If not you should probably think over how your app is designed. The problem of representing external data in a suitable way should, of course, be handled by the boundary layer, and once past that there should be no ambiguity. This is not saying that strings as lists of integers is the best way of representing them, but rather that not properly disambiguating strings and lists in the boundary layer is not a reason not to represent strings as lists. Maybe there should be a character type, but think of the problems involved in introducing it. Not for the implementors my you, but for most existing apps. At least when using lists you don't have to worry about the internal representation as you would always have to do when using binaries, or another C-string like equivalent. IMAO, Robert 2009/4/13 Steve Davis > > > On Apr 13, 4:39 pm, Steve Davis > wrote: > > So would it be fair to say that, as a general design principle for > > representing strings in erlang terms then a binary representation is > > far more preferable than a "list of integers"? > > > > Additionally > > 1) do people tend to agree with Joe's guidance in that exchange > re:couchdb, and if so why isn't it plastered all over the tutorials? > 3) Shouldn't the word "string" be banned from the debate about text in > erlang apart from as a reference to a specific foreign data type? > 3) Are my questions too trite? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From uaforum1@REDACTED Wed Apr 15 05:20:49 2009 From: uaforum1@REDACTED (ulf_A) Date: Tue, 14 Apr 2009 20:20:49 -0700 (PDT) Subject: [erlang-questions] gen_server and the ! operator Message-ID: <23023749.post@talk.nabble.com> Hello, i have a understanding problem with otp gen_server and the ! (send) operator. In my small test programm, i use the "normal" way to use the gen_server behavior. example: myServer:findById(Id). This example use the module mySever with the behavior gen_server and calls the exported function findById with the parameter Id. That means, that the caller has to know the target module. In my next example, i only know the name of the server, not more. I want to do is this: whereis(myServer) ! {Id}. I lookup the registered name myServer and then i want to send a message to the pid. But every time i try it i get no result. Is there anybody who can tell me how to send a message to the pid of a gen_server? Thx, Ulf -- View this message in context: http://www.nabble.com/gen_server-and-the-%21-operator-tp23023749p23023749.html Sent from the Erlang Questions mailing list archive at Nabble.com. From bernie@REDACTED Wed Apr 15 05:35:06 2009 From: bernie@REDACTED (Bernard Duggan) Date: Wed, 15 Apr 2009 13:35:06 +1000 Subject: [erlang-questions] gen_server and the ! operator In-Reply-To: <23023749.post@talk.nabble.com> References: <23023749.post@talk.nabble.com> Message-ID: <49E555EA.7050508@m5net.com> ulf_A wrote: > example: myServer:findById(Id). > > I want to do is this: > > whereis(myServer) ! {Id}. > For a start, whereis() finds a registered process name, not a module name (which myServer seems to be based on the first example). You need to register your server process with a line like: register(myserver_process) then you can send to it with: whereis(myserver_process) ! {Id} or indeed the shorthand form: myserver_process ! {Id} However, generally the "right" way to send a message to a gen_server (where you don't require a response) is to use gen_server:cast(). Cheers, Bernard From magnus@REDACTED Wed Apr 15 11:39:45 2009 From: magnus@REDACTED (Magnus Henoch) Date: Wed, 15 Apr 2009 10:39:45 +0100 Subject: [erlang-questions] gen_server and the ! operator References: <23023749.post@talk.nabble.com> Message-ID: <84skka45ni.fsf@linux-b2a3.site> ulf_A writes: > Hello, > > i have a understanding problem with otp gen_server and the ! (send) > operator. > > In my small test programm, i use the "normal" way to use the gen_server > behavior. How does your start_link function look? Maybe like this: start_link(Name) -> gen_server:start_link({local, Name}, ?MODULE, [], []). If so, you can run myServer:start_link(foo) to have the server register itself as 'foo'. (More likely, you would put ?MODULE instead of Name, to always use the same name as the module.) > I want to do is this: > > whereis(myServer) ! {Id}. If you have done the above, you just write: foo ! {Id}. The server's handle_info function will then be called: handle_info({Id}, State) -> io:format("got id message: ~p~n", [Id]), {noreply, State}. Hope that helps, -- Magnus Henoch, magnus@REDACTED Erlang Training and Consulting http://www.erlang-consulting.com/ From projevie@REDACTED Wed Apr 15 12:03:50 2009 From: projevie@REDACTED (projevie@REDACTED) Date: Wed, 15 Apr 2009 03:03:50 -0700 Subject: [erlang-questions] =?iso-8859-1?q?Resposta_Autom=E1tica_de_Aus=EA?= =?iso-8859-1?q?ncia?= In-Reply-To: Message-ID: An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Wed Apr 15 13:55:13 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 15 Apr 2009 13:55:13 +0200 Subject: [erlang-questions] ANN: Erlang/OTP R13B will be released on April 22 Message-ID: I am happy to announce that Erlang/OTP R13B will be released on April 22. This is one week earlier than previously announced. R13B is intended for use in products and contains a number of corrections and minor additional features compared with R13A. /Regards Kenneth Erlang/OTP, Ericsson From john.hughes@REDACTED Wed Apr 15 15:16:06 2009 From: john.hughes@REDACTED (John Hughes) Date: Wed, 15 Apr 2009 15:16:06 +0200 Subject: [erlang-questions] QuickCheck at the Bay Area Erlang University April 27-19th Message-ID: <000001c9bdcc$55d59ad0$0180d070$@hughes@quviq.com> Just a reminder that a QuickCheck training course will be held as part of the Erlang University in the Bay Area. This is the same training course that we normally give for customers (at a higher price per participant), and includes a free one-month licence to try out on your own code afterwards. So there's no better time to try out QuickCheck for yourself! http://www.erlang-factory.com/conference/SFBayAreaErlangFactory2009/universi ty/QuickCheck It's about time to register if you would like to attend, so we can plan for the right numbers. John Hughes -------------- next part -------------- An HTML attachment was scrubbed... URL: From connorsml@REDACTED Wed Apr 15 17:36:36 2009 From: connorsml@REDACTED (Michael Connors) Date: Wed, 15 Apr 2009 17:36:36 +0200 Subject: [erlang-questions] reading excel files in Erlang Message-ID: Hi, Does anyone know if there is an Erlang module for extracting data from data from excel files? I didn't find one on CEAN, but I am new to Erlang so could be looking in the wrong place. Regards -- Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From sgolovan@REDACTED Wed Apr 15 18:33:56 2009 From: sgolovan@REDACTED (Sergei Golovan) Date: Wed, 15 Apr 2009 20:33:56 +0400 Subject: [erlang-questions] wxErlang gl and glu modules conflict with esdl Message-ID: Hi! While trying Erlang R13A (and R13B snapshot) I've found that esdl modules gl and glu don't work anymore. Their names clash with glu and gl modules from wxErlang. May be it would be better to ship gl and glu under some different names? It's always a bad idea to break existing libraries which are in use by other projects (modeller Wings 3D uses esdl and breaks if wxErlang is installed). Since gl and glu aren't used in Erlang/OTP applications yet, it's relatively cheap to change the modules names. Cheers! -- Sergei Golovan From exta7@REDACTED Wed Apr 15 19:25:39 2009 From: exta7@REDACTED (Zvi) Date: Wed, 15 Apr 2009 10:25:39 -0700 (PDT) Subject: [erlang-questions] State of the Union: FFI In-Reply-To: <23021754.post@talk.nabble.com> References: <2812B7B9-6B8C-4CDE-A966-96624AF61625@me.com> <22831017.post@talk.nabble.com> <01D2B728-D19B-4923-A5A8-DE08CC70A908@me.com> <23021754.post@talk.nabble.com> Message-ID: <23063427.post@talk.nabble.com> Hi Franco, I got to the point where it's compiling. For some reason the erl_ddll.erl didn't built by make clean (probably prebuilt), so I did: but FFI still doesn't work: Erlang R13A (erts-5.7) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7 (abort with ^G) 1> ffi:sizeof(uint). 4 2> erl_ddll:load_library("/tmp", libc, [{preload, [{isupper, {sint,sint}}]}]). {error,{open_error,-12}} 3> I tried to generate a diff against your zip, but it generates to many changes b/c you included all the i386-apple-darwin9.6.0 stuff). There is no ArithAlloc macro in R13A, so I changed it to HAlloc. There is digit_t type in R13A so I defined it as ErtsHalfDigit (typedef Uint16 digit_t;) Fortunattely there not too much changes: beam/erl_bif_ddll.c:833: res = build_preloads_info(p, de->hndl); CHANGED_TO: res = build_preloads_info(p, drv->handle); /* ZVI */ beam/erl_bif_ddll.c:1790 erts_free(ERTS_ALC_T_DRV, q->drv->driver_name); CHANGED_TO: erts_free(ERTS_ALC_T_DRV, q->entry->driver_name); /* ZVI */ beam/erl_bif_ddll.c:1791 erts_free(ERTS_ALC_T_DRV, q->drv); CHANGED_TO: erts_free(ERTS_ALC_T_DRV, q->entry); /* ZVI */ beam/erl_bif_ffi_endianness.h:185 hp = ArithAlloc(p, 1 + 1); CHANGED_TO: hp = HAlloc(p, 1 + 1); /* ZVI */ beam/erl_bif_ffi_endianness.h:207 hp = ArithAlloc(p, 1 + words_count); CHANGED_TO: hp = HAlloc(p, 1 + words_count); /* ZVI */ beam/erl_bif_ffi_endianness.h:36 ADDED: #define digit_t ErtsHalfDigit Can you prepare a clean diff against R13A sources? Maybe Alceste will help us. BR, Zvi Zvi wrote: > > Hi Franco, > > did u run ./otp_build autoconf before ./configure ? > You need to install autoconf to use it: > > apt-get install autoconf > > I did: > > ./otp_build autoconf > ./configure > make > > and got compilation errors in beam/erl_bif_ddll.c : > > > beam/erl_bif_ddll.c: In function 'erl_ddll_info_2': > beam/erl_bif_ddll.c:833: error: 'de' undeclared (first use in this > function) > beam/erl_bif_ddll.c:833: error: (Each undeclared identifier is reported > only once > beam/erl_bif_ddll.c:833: error: for each function it appears in.) > beam/erl_bif_ddll.c: In function 'do_unload_driver_entry': > beam/erl_bif_ddll.c:1790: error: 'erts_driver_t' has no member named 'drv' > beam/erl_bif_ddll.c:1791: error: 'erts_driver_t' has no member named 'drv' > make[3]: *** [obj/i686-pc-linux-gnu/opt/smp/erl_bif_ddll.o] Error 1 > make[3]: Leaving directory `/root/erlang/otp_src_R13A-ffi/erts/emulator' > make[2]: *** [opt] Error 2 > make[2]: Leaving directory `/root/erlang/otp_src_R13A-ffi/erts/emulator' > make[1]: *** [smp] Error 2 > make[1]: Leaving directory `/root/erlang/otp_src_R13A-ffi/erts' > make: *** [emulator] Error 2 > [root@REDACTED otp_src_R13A-ffi]# > > > Thanks, > Zvi > > > > > Franco Milicchio-4 wrote: >> >> I have started porting the patch to R13A, although I can't say if it >> really works: it doesn't compile! Makefile error, not a C one :) >> >> You may find the source code at: >> http://plm.dia.uniroma3.it/milicchio/public/otp_src_R13A-ffi.zip >> (62 MB) >> >> >> I have no time left today, but if we all start figuring out what's >> wrong with it, we may end up having the FFI working on this new >> release. I have marked the C code with comments (/* FFI START */ and / >> * FFI END */) where I had doubts about applying Alceste's patch, so it >> should be easy to spot them. >> >> By the way, no news about the reason FFI hasn't been taken into >> account yet? >> >> Cheers! >> >> -- >> Franco Milicchio >> >> DIA - Dept. of Computer Science and Engineering >> University Roma Tre >> http://plm.dia.uniroma3.it/milicchio/ >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -- View this message in context: http://www.nabble.com/State-of-the-Union%3A-FFI-tp22824174p23063427.html Sent from the Erlang Questions mailing list archive at Nabble.com. From exta7@REDACTED Wed Apr 15 19:32:41 2009 From: exta7@REDACTED (Zvi) Date: Wed, 15 Apr 2009 10:32:41 -0700 (PDT) Subject: [erlang-questions] State of the Union: FFI In-Reply-To: <23021754.post@talk.nabble.com> References: <2812B7B9-6B8C-4CDE-A966-96624AF61625@me.com> <22831017.post@talk.nabble.com> <01D2B728-D19B-4923-A5A8-DE08CC70A908@me.com> <23021754.post@talk.nabble.com> Message-ID: <23063501.post@talk.nabble.com> Hi Franco, I got to the point where it's compiling. For some reason the erl_ddll.erl didn't built by make clean (probably prebuilt), so I did: cd /usr/local/lib/erlang/lib/kernel-2.13 erlc -I ./include -o ./ebin ./src/erl_ddll.erl but FFI still doesn't work: Erlang R13A (erts-5.7) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7 (abort with ^G) 1> ffi:sizeof(uint). 4 2> erl_ddll:load_library("/tmp", libc, [{preload, [{isupper, {sint,sint}}]}]). {error,{open_error,-12}} 3> I tried to generate a diff against your zip, but it generates to many changes b/c you included all the i386-apple-darwin9.6.0 stuff). There is no ArithAlloc macro in R13A, so I changed it to HAlloc. There is digit_t type in R13A so I defined it as ErtsHalfDigit (typedef Uint16 digit_t;) Fortunattely there not too much changes: beam/erl_bif_ddll.c:833: res = build_preloads_info(p, de->hndl); CHANGED_TO: res = build_preloads_info(p, drv->handle); /* ZVI */ beam/erl_bif_ddll.c:1790 erts_free(ERTS_ALC_T_DRV, q->drv->driver_name); CHANGED_TO: erts_free(ERTS_ALC_T_DRV, q->entry->driver_name); /* ZVI */ beam/erl_bif_ddll.c:1791 erts_free(ERTS_ALC_T_DRV, q->drv); CHANGED_TO: erts_free(ERTS_ALC_T_DRV, q->entry); /* ZVI */ beam/erl_bif_ffi_endianness.h:185 hp = ArithAlloc(p, 1 + 1); CHANGED_TO: hp = HAlloc(p, 1 + 1); /* ZVI */ beam/erl_bif_ffi_endianness.h:207 hp = ArithAlloc(p, 1 + words_count); CHANGED_TO: hp = HAlloc(p, 1 + words_count); /* ZVI */ beam/erl_bif_ffi_endianness.h:36 ADDED: #define digit_t ErtsHalfDigit Can you prepare a clean diff against R13A sources? Maybe Alceste will help us. BR, Zvi Franco Milicchio-4 wrote: > > I have started porting the patch to R13A, although I can't say if it > really works: it doesn't compile! Makefile error, not a C one :) > > You may find the source code at: > http://plm.dia.uniroma3.it/milicchio/public/otp_src_R13A-ffi.zip > (62 MB) > > > I have no time left today, but if we all start figuring out what's > wrong with it, we may end up having the FFI working on this new > release. I have marked the C code with comments (/* FFI START */ and / > * FFI END */) where I had doubts about applying Alceste's patch, so it > should be easy to spot them. > > By the way, no news about the reason FFI hasn't been taken into > account yet? > > Cheers! > > -- > Franco Milicchio > > DIA - Dept. of Computer Science and Engineering > University Roma Tre > http://plm.dia.uniroma3.it/milicchio/ > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://www.nabble.com/State-of-the-Union%3A-FFI-tp22824174p23063501.html Sent from the Erlang Questions mailing list archive at Nabble.com. From matt.handler@REDACTED Wed Apr 15 20:13:00 2009 From: matt.handler@REDACTED (Matt Handler) Date: Wed, 15 Apr 2009 14:13:00 -0400 Subject: [erlang-questions] distribution trouble on Centos 5.2 Message-ID: <49427c610904151113l75516c72h47bf8fdfc32c3c6a@mail.gmail.com> Trying to get communication between nodes to work in erlang, but having trouble (both nodes are running R12B5 with the patch). I'm following the steps from When Distribution Won't Work : 1. start clever@REDACTED , littleguy@REDACTED (both with long names, both with same cookie, using -rsh ssh) 2. kill epmd and restart it with -d -d for debugging mode 3. from littleguy I call *net:ping('clever@REDACTED').* and it returns *pang* 4. no messages go by on epmd on clever@REDACTED 5. running *tcpdump port 4369* on clever@REDACTED and pinging again from littleguy@REDACTED, i see that the messages are in fact coming in: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes 09:45:22.158227 IP server2.net.40141 > server1.net.epmd: S 2310861565:2310861565(0) win 5840 so it looks like the messages are making it between the servers, but not making it to erlang. any ideas? -------------- next part -------------- An HTML attachment was scrubbed... URL: From sgolovan@REDACTED Wed Apr 15 20:22:49 2009 From: sgolovan@REDACTED (Sergei Golovan) Date: Wed, 15 Apr 2009 22:22:49 +0400 Subject: [erlang-questions] distribution trouble on Centos 5.2 In-Reply-To: <49427c610904151113l75516c72h47bf8fdfc32c3c6a@mail.gmail.com> References: <49427c610904151113l75516c72h47bf8fdfc32c3c6a@mail.gmail.com> Message-ID: On Wed, Apr 15, 2009 at 10:13 PM, Matt Handler wrote: > 1. start clever@REDACTED , littleguy@REDACTED (both with long names, both > with same cookie, using -rsh ssh) > 2. kill epmd and restart it with -d -d for debugging mode Try to do these two steps in the reverse order. Killing epmd makes already started erlang nodes lost. -- Sergei Golovan From erlangy@REDACTED Wed Apr 15 20:26:14 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 15 Apr 2009 11:26:14 -0700 Subject: [erlang-questions] reading excel files in Erlang In-Reply-To: References: Message-ID: <20090415182614.GV29268@delora.autosys.us> I do not know of any Erlang direct-from-excel spreadsheet tool. If you export from xls to a comma delimited file, you could do something like Column_data = lists:nth( Col, re:split(Line, ",") ) ~M On Wed, Apr 15, 2009 at 05:36:36PM +0200, Michael Connors wrote: > Hi, > Does anyone know if there is an Erlang module for extracting data from > data from excel files? > I didn't find one on CEAN, but I am new to Erlang so could be looking > in the wrong place. > Regards > -- > Michael > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From matt.handler@REDACTED Wed Apr 15 20:28:07 2009 From: matt.handler@REDACTED (Matt Handler) Date: Wed, 15 Apr 2009 14:28:07 -0400 Subject: [erlang-questions] distribution trouble on Centos 5.2 In-Reply-To: References: <49427c610904151113l75516c72h47bf8fdfc32c3c6a@mail.gmail.com> Message-ID: <49427c610904151128u3a67d0a2if53dd2b1be32983d@mail.gmail.com> restarted the servers, still having the exact same problem, tcpdump still shows the messages but epmd gets nothing and the response is "pang" verified that they are both starting with -name and both have the same cookie On Wed, Apr 15, 2009 at 2:22 PM, Sergei Golovan wrote: > On Wed, Apr 15, 2009 at 10:13 PM, Matt Handler > wrote: > > 1. start clever@REDACTED , littleguy@REDACTED (both with long > names, both > > with same cookie, using -rsh ssh) > > > 2. kill epmd and restart it with -d -d for debugging mode > > Try to do these two steps in the reverse order. Killing epmd makes > already started erlang nodes lost. > > -- > Sergei Golovan > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pfisher@REDACTED Wed Apr 15 20:18:19 2009 From: pfisher@REDACTED (Paul Fisher) Date: Wed, 15 Apr 2009 13:18:19 -0500 Subject: [erlang-questions] distribution trouble on Centos 5.2 In-Reply-To: <49427c610904151113l75516c72h47bf8fdfc32c3c6a@mail.gmail.com> References: <49427c610904151113l75516c72h47bf8fdfc32c3c6a@mail.gmail.com> Message-ID: <49E624EB.9000006@alertlogic.net> Matt Handler wrote: > Trying to get communication between nodes to work in erlang, but having > trouble (both nodes are running R12B5 with the patch). I'm following > the steps from When Distribution Won't Work > : > > 1. start clever@REDACTED , > littleguy@REDACTED (both with > long names, both with same cookie, using -rsh ssh) > 2. kill epmd and restart it with -d -d for debugging mode > 3. from littleguy I call *net:ping('clever@REDACTED > ').* and it returns *pang* > 4. no messages go by on epmd on clever@REDACTED > > 5. running *tcpdump port 4369* on clever@REDACTED > and pinging again from > littleguy@REDACTED , i see that > the messages are in fact coming in: > > listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes > 09:45:22.158227 IP server2.net.40141 > server1.net.epmd: S > 2310861565:2310861565(0) win 5840 0,nop,wscale 7> > > so it looks like the messages are making it between the servers, but not > making it to erlang. any ideas? > Try the following: 1) verify the cookie is the same on both nodes (erlang:get_cookie/0) 2) verify both vms are being started with either -name or -sname -- paul From connorsml@REDACTED Wed Apr 15 21:12:31 2009 From: connorsml@REDACTED (Michael Connors) Date: Wed, 15 Apr 2009 21:12:31 +0200 Subject: [erlang-questions] reading excel files in Erlang In-Reply-To: <20090415182614.GV29268@delora.autosys.us> References: <20090415182614.GV29268@delora.autosys.us> Message-ID: > > > If you export from xls to a comma delimited file, you could > do something like > > Column_data = lists:nth( Col, re:split(Line, ",") ) > I guess that will do the job alright. Thanks for your help. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From taavi@REDACTED Wed Apr 15 21:23:07 2009 From: taavi@REDACTED (Taavi Talvik) Date: Wed, 15 Apr 2009 22:23:07 +0300 Subject: [erlang-questions] reading excel files in Erlang In-Reply-To: References: Message-ID: <98B29F63-6A41-46E3-A211-72388DBE378C@uninet.ee> On Apr 15, 2009, at 6:36 PM, Michael Connors wrote: > Hi, > Does anyone know if there is an Erlang module for extracting data > from data from excel files? > I didn't find one on CEAN, but I am new to Erlang so could be > looking in the wrong place. You can try xls2html. Using os:cmd(..) convert to xml and then handle xml. xls2xml is a free filter from Microsoft Excel to XML, and a free C library. Using the program xls2xml, you can extract the content of a file generated by Microsoft Excel and express its content using XML. A library written in C which is able to do the same is provided too. http://www.freebsd.org/cgi/cvsweb.cgi/ports/textproc/xls2xml/ best regards, taavi From vladdu55@REDACTED Wed Apr 15 22:52:37 2009 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 15 Apr 2009 22:52:37 +0200 Subject: [erlang-questions] replacing 'user' process Message-ID: <95be1d3b0904151352h3cecfc93ubb9271ecde810fb5@mail.gmail.com> Hi! I need to install my own 'user' server to handle the io. Opening a remote shell is not good enough, because some applications write directly to user and that output is lost. The user module is hardcoded in the kernel application startup, so I guess it's not as simple as killing the original and registering my own. Can it be done at all? Maybe -noshell and -detached could help? best regards, Vlad From fritchie@REDACTED Wed Apr 15 23:09:09 2009 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Wed, 15 Apr 2009 16:09:09 -0500 Subject: [erlang-questions] The timer server: bug or feature? Message-ID: <60419.1239829749@snookles.snookles.com> Hi, all. I've got an app that uses the timer module liberally, specifically timer:send_interval/2. I also have some regression tests that starts hundreds of gen_server and gen_fsm processes that use timer:send_interval/2 (usually with a period of 1 second) and are stopped a few seconds later ... both nicely shutdown and not-very-nicely stopped by exit(Pid, kill). After the regression tests finish and all test processes are dead, I find that the timer_server process is consuming about 45% of one of my CPU cores. The undocumented timer:get_status/1 function says: (foo_dev@REDACTED)6> application:stop(foo). ok (foo_dev@REDACTED)7> timer:get_status(). {{timer_tab,1096},{timer_interval_tab,184}} (This is Erlang/OTP R12B-5, on a Linux platform, if that matters.) So it seems like there are hundreds of items that are orphaned in the timer server's private state. Is this a bug or feature? The OTP docs say that the caller of send_interval/2 will be link()'ed, which I assume means that cleanup should be automatic.... -Scott From fredrik.svahn@REDACTED Wed Apr 15 23:31:58 2009 From: fredrik.svahn@REDACTED (Fredrik Svahn) Date: Wed, 15 Apr 2009 23:31:58 +0200 Subject: [erlang-questions] replacing 'user' process In-Reply-To: <95be1d3b0904151352h3cecfc93ubb9271ecde810fb5@mail.gmail.com> References: <95be1d3b0904151352h3cecfc93ubb9271ecde810fb5@mail.gmail.com> Message-ID: erlc myuser.erl erl -user myuser undocumented and probably unsupported? BR /Fredrik On Wed, Apr 15, 2009 at 10:52 PM, Vlad Dumitrescu wrote: > Hi! > > I need to install my own 'user' server to handle the io. Opening a > remote shell is not good enough, because some applications write > directly to user and that output is lost. The user module is hardcoded > in the kernel application startup, so I guess it's not as simple as > killing the original and registering my own. Can it be done at all? > Maybe -noshell and -detached could help? > > best regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mtalyans@REDACTED Wed Apr 15 22:38:20 2009 From: mtalyans@REDACTED (mtalyans) Date: Wed, 15 Apr 2009 13:38:20 -0700 Subject: [erlang-questions] Question about http client Message-ID: Hi All, I am a rank beginner, so please bear with me: I am fetching Web content from a set of URLs using http:request. For most of URLs everything works fine; however for some of them I see error reports on the console that look like so: <0.49.0> spawned pid <0.50.0> (here my main process spawns another one to do the fetch) =ERROR REPORT==== 15-Apr-2009::13:29:50 === ** Generic server <0.51.0> terminating ** Last message in was {tcp_closed,#Port<0.1570>} ** When Server state == {state, {request,#Ref<0.0.0.67>,<0.50.0>,0,http, {"message.real.com",80}, "/Msg/7.0/win32",[],get, {http_request_h,undefined,"keep-alive", undefined,undefined,undefined,undefined, undefined,undefined,undefined,undefined, undefined,undefined,undefined,undefined, undefined,undefined,"message.real.com", undefined,undefined,undefined,undefined, undefined,undefined,undefined,undefined, undefined,[],undefined,undefined, undefined,undefined,"0",undefined, undefined,undefined,undefined,undefined, undefined,[]}, {[],[]}, {http_options,"HTTP/1.1",5000,true,[], undefined,true}, "http://message.real.com/Msg/7.0/win32",[], none,[]}, {tcp_session, {{"message.real.com",80},<0.51.0>}, false,http,#Port<0.1570>,1,keep_alive}, undefined,undefined,undefined, {httpc_response,parse,[nolimit,true]}, {[],[]}, {[],[]}, new,[],nolimit,nolimit, {options, {undefined,[]}, 0,2,5,120000,2,disabled,enabled,false}, {timers, [{#Ref<0.0.0.67>,#Ref<0.0.0.77>}], undefined}, httpc_manager,undefined} ** Reason for termination == ** session_remotly_closed <0.50.0>: normal clause "ERLANG: Request error session_remotly_closed on http://message.real.com/Msg/7.0/win32" (here my fetched process gets results) As far as I can tell, session has been remotely closed. I don?t mind a failure like this, but I would like to get rid of the error reports, as I am fetching many, many URLs. I set verbose option to false, and I also catch everything around the call to http:request (in fact, the last line in the snippet is my own printout of the normal clause in the try/catch), all to no avail. It seems that what is terminating is not the process I have spawned to do the fetch. In other cases, I get content properly fetched, and then get an error report with a timeout: <0.49.0> spawned pid <0.50.0> <0.50.0>: normal clause "Normal completion" =ERROR REPORT==== 15-Apr-2009::13:35:05 === ** Generic server <0.51.0> terminating ** Last message in was {timeout,#Ref<0.0.0.67>} ** When Server state == {state,undefined, {tcp_session, {{"links.preplogic.com",80},<0.51.0>}, false,http,#Port<0.1570>,1,keep_alive}, undefined,undefined,undefined,undefined, {[],[]}, {[],[]}, keep_alive,[],nolimit,nolimit, {options, {undefined,[]}, 0,2,5,120000,2,disabled,enabled,false}, {timers,[],#Ref<0.0.0.78>}, httpc_manager,undefined} ** Reason for termination == ** {{badrecord,request}, [{httpc_handler,handle_info,2}, {gen_server,handle_msg,5}, {proc_lib,init_p_do_apply,3}]} Could someone in the know help me to solve this issue? Thanks in advance! -------------- next part -------------- An HTML attachment was scrubbed... URL: From saleyn@REDACTED Thu Apr 16 03:23:40 2009 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 15 Apr 2009 21:23:40 -0400 Subject: [erlang-questions] The timer server: bug or feature? In-Reply-To: <60419.1239829749@snookles.snookles.com> References: <60419.1239829749@snookles.snookles.com> Message-ID: <49E6889C.6070803@gmail.com> This seems rather odd indeed. I suggest you take a look at ets:tab2list(timer_tab) -> [{{NextUSecSinceEpoch, Ref}, Timer, MFA}] Timer = timeout | {repeat, Interval, Pid} and ets:tab2list(interval_tab) -> [{Ref, {repeat, Interval, Pid}, MFA}] and see if the Pids referenced in timer_tab are your gen_servers'. Also you might want to set up a trace on timer:pid_delete/1 just to see if the pids are cleared indeed. Serge Scott Lystig Fritchie wrote: > Hi, all. I've got an app that uses the timer module liberally, > specifically timer:send_interval/2. I also have some regression tests > that starts hundreds of gen_server and gen_fsm processes that use > timer:send_interval/2 (usually with a period of 1 second) and are > stopped a few seconds later ... both nicely shutdown and > not-very-nicely stopped by exit(Pid, kill). > > After the regression tests finish and all test processes are dead, I > find that the timer_server process is consuming about 45% of one of my > CPU cores. The undocumented timer:get_status/1 function says: > > (foo_dev@REDACTED)6> application:stop(foo). > ok > (foo_dev@REDACTED)7> timer:get_status(). > {{timer_tab,1096},{timer_interval_tab,184}} > > (This is Erlang/OTP R12B-5, on a Linux platform, if that matters.) > > So it seems like there are hundreds of items that are orphaned in the > timer server's private state. Is this a bug or feature? The OTP docs > say that the caller of send_interval/2 will be link()'ed, which I assume > means that cleanup should be automatic.... > > -Scott > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jebenitez@REDACTED Thu Apr 16 07:14:09 2009 From: jebenitez@REDACTED (Jose Enrique Benitez Jimenez) Date: Thu, 16 Apr 2009 01:14:09 -0400 Subject: [erlang-questions] How to change epmd port Message-ID: hello friends, I have a server written in Erlang, but some clients can not connect because the port used by the daemon by default (4369) is blocked, is there any way to specify a different port when you start the application? thanks From kdr2@REDACTED Thu Apr 16 08:06:49 2009 From: kdr2@REDACTED (KDr2) Date: Thu, 16 Apr 2009 14:06:49 +0800 Subject: [erlang-questions] How to change epmd port In-Reply-To: References: Message-ID: run epmd -daemon -port your_port_num first before start your server. On Thu, Apr 16, 2009 at 1:14 PM, Jose Enrique Benitez Jimenez < jebenitez@REDACTED> wrote: > hello friends, > I have a server written in Erlang, but some clients can not connect because > the port used by the daemon by default (4369) is blocked, is there any way > to specify a different port when you start the application? > thanks > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, -- KDr2, at x-macro.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dgud@REDACTED Thu Apr 16 08:23:58 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Thu, 16 Apr 2009 08:23:58 +0200 Subject: [erlang-questions] wxErlang gl and glu modules conflict with esdl In-Reply-To: References: Message-ID: <49E6CEFE.3010708@erix.ericsson.se> I did think about it, I've written both the libraries, but decided to ignore it, esdl it mostly (only?) used by wings and don't work in smp emulator, so I thought the future would belong to wxErlang which will be included with Erlang/OTP instead. Also the code is better in the wxErlang and covers later revisions, what would be best would an identical api that would discover which backend to run. You can easily run erl -pa /PATH/TO/ESDL/ -s wings start for wings. I also had name problems, gl2 wx_gl :-) /Dan Sergei Golovan wrote: > Hi! > > While trying Erlang R13A (and R13B snapshot) I've found that esdl > modules gl and glu don't work anymore. Their names clash with glu and > gl modules from wxErlang. May be it would be better to ship gl and glu > under some different names? It's always a bad idea to break existing > libraries which are in use by other projects (modeller Wings 3D uses > esdl and breaks if wxErlang is installed). Since gl and glu aren't > used in Erlang/OTP applications yet, it's relatively cheap to change > the modules names. > > Cheers! From Roman@REDACTED Thu Apr 16 08:24:01 2009 From: Roman@REDACTED (Roman@REDACTED) Date: Thu, 16 Apr 2009 11:24:01 +0500 Subject: [erlang-questions] memory leak. Message-ID: Hi dear Team, A problem appeared with the memory leak. Function "erlang:memory()" shows that "total" parameter grows constantly and fast, during the day it increases from 60 Mb till 510 Mb. "System" parameter also grows constantly, not as much fast, reaching 400 Mb. "process" parameter although does not reach 100 Mb. Top FreeBSD utility?s "size" parameter also increases from 70 Mb till 600 Mb. System crashes on "mem_error" of the module "zlib.erl" or on the error "system_limit" while creating new process {erlang,open_port,[{spawn,zlib_drv},[binary]]}. "yaws", "error_logger" and some gen_server-s work on the computer. No database except "ets" is used during the functioning, but the used memory doesn?t exceed 1 Mb. Server receives messages each second. The memory releases after restarting erlang. Restarting individual gen_server-s gives nothing. What is the reason of appearing memory leak problem? -- Best regards, Roman Shuplov. From bengt.kleberg@REDACTED Thu Apr 16 08:43:25 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 16 Apr 2009 08:43:25 +0200 Subject: [erlang-questions] Question about http client In-Reply-To: References: Message-ID: <1239864205.4521.3.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, It seems as if you are getting error reports from the SASL application (http://www.erlang.org/doc/man/sasl_app.html). If this is the case you could either turn it off: "The following configuration parameters are defined for the SASL application. See app(4) for more information about configuration parameters: sasl_error_logger = Value Value is one of: tty Installs sasl_report_tty_h in the error logger. This is the default option. {file,FileName} Installs sasl_report_file_h in the error logger. This makes all reports go to the file FileName. FileName is a string. false No SASL error logger handler is installed." or you could replace it with one that is less verbose: "The default simple handler is called alarm_handler and it may be exchanged by calling gen_event:swap_handler/3 as gen_event:swap_handler(alarm_handler, {alarm_handler, swap}, {NewHandler, Args}). NewHandler:init({Args, {alarm_handler, Alarms}}) is called. Refer to gen_event(3) for further details." bengt On Wed, 2009-04-15 at 13:38 -0700, mtalyans wrote: > Hi All, > > I am a rank beginner, so please bear with me: > > I am fetching Web content from a set of URLs using http:request. For > most of URLs everything works fine; however for some of them I see > error reports on the console that look like so: > > <0.49.0> spawned pid <0.50.0> (here my main process spawns another one > to do the fetch) > > =ERROR REPORT==== 15-Apr-2009::13:29:50 === > ** Generic server <0.51.0> terminating > ** Last message in was {tcp_closed,#Port<0.1570>} > ** When Server state == {state, > {request,#Ref<0.0.0.67>,<0.50.0>,0,http, > {"message.real.com",80}, > "/Msg/7.0/win32",[],get, > {http_request_h,undefined,"keep-alive", > undefined,undefined,undefined,undefined, > undefined,undefined,undefined,undefined, > undefined,undefined,undefined,undefined, > undefined,undefined,"message.real.com", > undefined,undefined,undefined,undefined, > undefined,undefined,undefined,undefined, > undefined,[],undefined,undefined, > undefined,undefined,"0",undefined, > undefined,undefined,undefined,undefined, > undefined,[]}, > {[],[]}, > {http_options,"HTTP/1.1",5000,true,[], > undefined,true}, > "http://message.real.com/Msg/7.0/win32",[], > none,[]}, > {tcp_session, > {{"message.real.com",80},<0.51.0>}, > false,http,#Port<0.1570>,1,keep_alive}, > undefined,undefined,undefined, > {httpc_response,parse,[nolimit,true]}, > {[],[]}, > {[],[]}, > new,[],nolimit,nolimit, > {options, > {undefined,[]}, > 0,2,5,120000,2,disabled,enabled,false}, > {timers, > [{#Ref<0.0.0.67>,#Ref<0.0.0.77>}], > undefined}, > httpc_manager,undefined} > ** Reason for termination == > ** session_remotly_closed > <0.50.0>: normal clause "ERLANG: Request error session_remotly_closed > on http://message.real.com/Msg/7.0/win32" (here my fetched process > gets results) > > As far as I can tell, session has been remotely closed. I don?t mind a > failure like this, but I would like to get rid of the error reports, > as I am fetching many, many URLs. I set verbose option to false, and I > also catch everything around the call to http:request (in fact, the > last line in the snippet is my own printout of the normal clause in > the try/catch), all to no avail. It seems that what is terminating is > not the process I have spawned to do the fetch. > > In other cases, I get content properly fetched, and then get an error > report with a timeout: > > <0.49.0> spawned pid <0.50.0> > <0.50.0>: normal clause "Normal completion" > > =ERROR REPORT==== 15-Apr-2009::13:35:05 === > ** Generic server <0.51.0> terminating > ** Last message in was {timeout,#Ref<0.0.0.67>} > ** When Server state == {state,undefined, > {tcp_session, > {{"links.preplogic.com",80},<0.51.0>}, > false,http,#Port<0.1570>,1,keep_alive}, > undefined,undefined,undefined,undefined, > {[],[]}, > {[],[]}, > keep_alive,[],nolimit,nolimit, > {options, > {undefined,[]}, > 0,2,5,120000,2,disabled,enabled,false}, > {timers,[],#Ref<0.0.0.78>}, > httpc_manager,undefined} > ** Reason for termination == > ** {{badrecord,request}, > [{httpc_handler,handle_info,2}, > {gen_server,handle_msg,5}, > {proc_lib,init_p_do_apply,3}]} > > Could someone in the know help me to solve this issue? > > Thanks in advance! > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From sgolovan@REDACTED Thu Apr 16 09:07:41 2009 From: sgolovan@REDACTED (Sergei Golovan) Date: Thu, 16 Apr 2009 11:07:41 +0400 Subject: [erlang-questions] wxErlang gl and glu modules conflict with esdl In-Reply-To: <49E6CEFE.3010708@erix.ericsson.se> References: <49E6CEFE.3010708@erix.ericsson.se> Message-ID: On Thu, Apr 16, 2009 at 10:23 AM, wrote: > I did think about it, I've written both the libraries, but decided to ignore it, esdl it > mostly (only?) used by wings and don't work in smp emulator, so I thought the future would The future belongs to wxErlang, but for now esdl has some features wxErlang hasn't (e.g. sound support) > belong to wxErlang which will be included with Erlang/OTP instead. > Also the code is better in the wxErlang and covers later revisions, what would be best > would an identical api that would discover which backend to run. > > You can easily run erl -pa /PATH/TO/ESDL/ -s wings start for wings. It would be natural to add -pa option if esdl hadn't installed to Erlang root directory by default. > > I also had name problems, gl2 wx_gl :-) wxgl looks just fine to me. It clearly shows that the module belongs to wx application. Another idea would be to rename gl and glu modules in esdl (to esdl_gl, esdl_glu) and release a new version compatible with R13B (currently esdl heavily uses removed erlang:fault/1 and obsolete tests binary/1, list/1 etc.). Though changing API in existing library is always a pain for users. Cheers! -- Sergei Golovan From vladdu55@REDACTED Thu Apr 16 09:13:34 2009 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 16 Apr 2009 09:13:34 +0200 Subject: [erlang-questions] replacing 'user' process In-Reply-To: References: <95be1d3b0904151352h3cecfc93ubb9271ecde810fb5@mail.gmail.com> Message-ID: <95be1d3b0904160013j73bbb9q8e700280e438a68b@mail.gmail.com> On Wed, Apr 15, 2009 at 23:31, Fredrik Svahn wrote: > erlc myuser.erl > erl -user myuser I'll try that, thanks a lot! > undocumented and probably unsupported? I can live with that :-) regards, Vlad > BR /Fredrik > > On Wed, Apr 15, 2009 at 10:52 PM, Vlad Dumitrescu > wrote: >> I need to install my own 'user' server to handle the io. From ngocdaothanh@REDACTED Thu Apr 16 09:50:52 2009 From: ngocdaothanh@REDACTED (Ngoc Dao) Date: Thu, 16 Apr 2009 16:50:52 +0900 Subject: [erlang-questions] ANN: Erlang/OTP R13B will be released on April 22 In-Reply-To: References: Message-ID: <5c493e530904160050u41d8299fjbac3f9c00af181a1@mail.gmail.com> Thank you, we are all looking forward to the release. I run a "hello world" Yaws appmod on R13A and the number of req/s is 1.5 times compared to running on R12B-5. Regards, Ngoc. On Wed, Apr 15, 2009 at 8:55 PM, Kenneth Lundin wrote: > I am happy to announce that Erlang/OTP R13B will be released on April 22. > This is one week earlier than previously announced. > > R13B is intended for use in products and contains a number of > corrections and minor additional features compared with R13A. > > /Regards Kenneth Erlang/OTP, Ericsson -------------- next part -------------- An HTML attachment was scrubbed... URL: From kdr2@REDACTED Thu Apr 16 10:16:47 2009 From: kdr2@REDACTED (KDr2) Date: Thu, 16 Apr 2009 16:16:47 +0800 Subject: [erlang-questions] ANN: Erlang/OTP R13B will be released on April 22 In-Reply-To: References: Message-ID: Glad to hear this! And , by the way, is there any plan of Erlang on AIX? On Wed, Apr 15, 2009 at 7:55 PM, Kenneth Lundin wrote: > I am happy to announce that Erlang/OTP R13B will be released on April 22. > This is one week earlier than previously announced. > > R13B is intended for use in products and contains a number of > corrections and minor additional features compared with R13A. > > /Regards Kenneth Erlang/OTP, Ericsson > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, -- KDr2, at x-macro.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Thu Apr 16 11:39:40 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 16 Apr 2009 11:39:40 +0200 Subject: [erlang-questions] reading excel files in Erlang In-Reply-To: (Michael Connors's message of "Wed\, 15 Apr 2009 17\:36\:36 +0200") References: Message-ID: <87skk9x7hf.fsf@sterlett.hq.kred> Michael Connors writes: > Hi, > Does anyone know if there is an Erlang module for extracting data from data > from excel files? > I didn't find one on CEAN, but I am new to Erlang so could be looking in the > wrong place. in older releases (~R9 or so) there was an application called "comet" that used COM to manipulate MS documents. See e.g. http://www.erlang.se/euc/00/Comet.ppt I've never used it, and have no idea if still (or ever) works. mats From alceste@REDACTED Thu Apr 16 12:04:19 2009 From: alceste@REDACTED (Alceste Scalas) Date: Thu, 16 Apr 2009 12:04:19 +0200 Subject: [erlang-questions] State of the Union: FFI In-Reply-To: <23063501.post@talk.nabble.com> References: <2812B7B9-6B8C-4CDE-A966-96624AF61625@me.com> <22831017.post@talk.nabble.com> <01D2B728-D19B-4923-A5A8-DE08CC70A908@me.com> <23021754.post@talk.nabble.com> <23063501.post@talk.nabble.com> Message-ID: <1239876259.10508.29.camel@gnatziu> Il giorno mer, 15/04/2009 alle 10.32 -0700, Zvi ha scritto: > There is no ArithAlloc macro in R13A, so I changed it to HAlloc. > There is digit_t type in R13A so I defined it as ErtsHalfDigit (typedef > Uint16 digit_t;) > Fortunattely there not too much changes: [...] > > Can you prepare a clean diff against R13A sources? > Maybe Alceste will help us. Thank you for your work! I'm a bit busy right now, but I'll try your changes here and generate some clean diffs (I'm managing the FFI stuff in a Mercurial repository, I'll need to rebase everything on R13A in order to keep the history). Regards, and thanks again, -- Alceste Scalas CRS4 - http://www.crs4.it/ From cbenac@REDACTED Thu Apr 16 11:56:14 2009 From: cbenac@REDACTED (Clara Benac Earle) Date: Thu, 16 Apr 2009 11:56:14 +0200 Subject: [erlang-questions] CFP Erlang Workshop 2009 Message-ID: <49E700BE.8040705@fi.upm.es> Dear all, The submission date, 8th of May, for the ACM SIGPLAN Erlang Workshop is quickly approaching. We are looking forwards to receiving many good submissions this year! Please see attached pdf and distributed it as you see it fits. More info at: http://www.erlang.org/workshop/2009/ Best regards, Clara -------------- next part -------------- A non-text attachment was scrubbed... Name: EW09.pdf Type: application/pdf Size: 225740 bytes Desc: not available URL: From vladdu55@REDACTED Thu Apr 16 12:47:38 2009 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 16 Apr 2009 12:47:38 +0200 Subject: [erlang-questions] using edoc programatically Message-ID: <95be1d3b0904160347v4deeb401p5ebdf3317428234f@mail.gmail.com> Hi! edoc can't be used programatically, it does its magic and just crashes if something is wrong. It would be much more useful (at least for us, tool builders :-) if it would have an API much more like the compiler: in case of errors/warnings, return them in a list. Also, it should not stop on the first error, but continue at least with the other files in the processing queue, so that one can catch as many problems as possible with each run. I was planning to make a private copy of edoc and try to hack it together according to these wishes, but thought that maybe Richard C. has a slow day and might lend a hand :-) From browsing the code, it seems there's quite a bit to rewrite... best regards, Vlad From richardc@REDACTED Thu Apr 16 13:09:32 2009 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 16 Apr 2009 13:09:32 +0200 Subject: [erlang-questions] using edoc programatically In-Reply-To: <95be1d3b0904160347v4deeb401p5ebdf3317428234f@mail.gmail.com> References: <95be1d3b0904160347v4deeb401p5ebdf3317428234f@mail.gmail.com> Message-ID: <49E711EC.20106@it.uu.se> Vlad Dumitrescu wrote: > edoc can't be used programatically, it does its magic and just crashes > if something is wrong. It would be much more useful (at least for us, > tool builders :-) if it would have an API much more like the compiler: > in case of errors/warnings, return them in a list. > Also, it should not stop on the first error, but continue at least > with the other files in the processing queue, so that one can catch as > many problems as possible with each run. > > I was planning to make a private copy of edoc and try to hack it > together according to these wishes, but thought that maybe Richard C. > has a slow day and might lend a hand :-) From browsing the code, it > seems there's quite a bit to rewrite... Hi Vlad. Yes, I know about these problems with the current behaviour. Sadly, I've had little time to do any serious work on edoc. But this thing might not be all that huge, if you feel like trying to hack it. /Richard From jlprasantha@REDACTED Thu Apr 16 13:14:19 2009 From: jlprasantha@REDACTED (prasantha kumara) Date: Thu, 16 Apr 2009 16:44:19 +0530 Subject: [erlang-questions] Cannot install fallback" Message-ID: hi all! i am progamming in erlang with mnesia database.i create a datatable using following expression mnesia:create_table(users, [{disc_copies,[node(),e2@REDACTED]},{attributes, record_info(fields,users)}]), i think it is created properly . but when i try to read the table it gives the following error. error,{"Cannot install fallback",enoent}} can any body let me know why this error occured and how can it be overcome? regars prasantha -------------- next part -------------- An HTML attachment was scrubbed... URL: From mihai@REDACTED Thu Apr 16 13:36:55 2009 From: mihai@REDACTED (Mihai Balea) Date: Thu, 16 Apr 2009 07:36:55 -0400 Subject: [erlang-questions] memory leak. In-Reply-To: References: Message-ID: <4C87BF70-32B3-426E-9570-86712ED7A379@hates.ms> On Apr 16, 2009, at 2:24 AM, Roman@REDACTED wrote: > Hi dear Team, > > A problem appeared with the memory leak. Function "erlang:memory()" > shows > that "total" parameter grows constantly and fast, during the day it > increases from 60 Mb till 510 Mb. "System" parameter also grows > constantly, not as much fast, reaching 400 Mb. > "process" parameter although does not reach 100 Mb. Top FreeBSD > utility?s > "size" parameter also increases from 70 Mb till 600 Mb. > System crashes on "mem_error" of the module "zlib.erl" or on the error > "system_limit" while creating new process > {erlang,open_port,[{spawn,zlib_drv},[binary]]}. "yaws", > "error_logger" and > some gen_server-s work on the computer. No database except "ets" is > used > during the functioning, but the used memory doesn?t exceed 1 Mb. > Server > receives messages each second. > The memory releases after restarting erlang. Restarting individual > gen_server-s gives nothing. > > What is the reason of appearing memory leak problem? Chances are, a programming error on your part. The fact that you're getting "system_limit" errors when creating new processes leads me to believe that you might not have a memory leak per se, but a process leak. Meaning you are dynamically creating processes, but don't shut them down. You can find the number of processes on your node using length(processes()). Try to see if this number increases constantly during operation. Mihai From exta7@REDACTED Thu Apr 16 14:17:49 2009 From: exta7@REDACTED (Zvi) Date: Thu, 16 Apr 2009 05:17:49 -0700 (PDT) Subject: [erlang-questions] State of the Union: FFI In-Reply-To: <1239876259.10508.29.camel@gnatziu> References: <2812B7B9-6B8C-4CDE-A966-96624AF61625@me.com> <22831017.post@talk.nabble.com> <01D2B728-D19B-4923-A5A8-DE08CC70A908@me.com> <23021754.post@talk.nabble.com> <23063501.post@talk.nabble.com> <1239876259.10508.29.camel@gnatziu> Message-ID: <23076763.post@talk.nabble.com> I would suggest waiting for R13B for rebase; will be released on 22/04. Alceste Scalas wrote: > > Il giorno mer, 15/04/2009 alle 10.32 -0700, Zvi ha scritto: >> There is no ArithAlloc macro in R13A, so I changed it to HAlloc. >> There is digit_t type in R13A so I defined it as ErtsHalfDigit (typedef >> Uint16 digit_t;) >> Fortunattely there not too much changes: [...] >> >> Can you prepare a clean diff against R13A sources? >> Maybe Alceste will help us. > > > Thank you for your work! > > I'm a bit busy right now, but I'll try your changes here and generate > some clean diffs (I'm managing the FFI stuff in a Mercurial repository, > I'll need to rebase everything on R13A in order to keep the history). > > Regards, and thanks again, > -- > Alceste Scalas > CRS4 - http://www.crs4.it/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/State-of-the-Union%3A-FFI-tp22824174p23076763.html Sent from the Erlang Questions mailing list archive at Nabble.com. From ulf.wiger@REDACTED Thu Apr 16 15:26:45 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 16 Apr 2009 15:26:45 +0200 Subject: [erlang-questions] Stockholm Erlang User Group Meeting 23 April Message-ID: <49E73215.8020003@erlang-consulting.com> Here are the details for the next Stockholm Erlang User Group Meeting: Date : Thursday 23 April 2009 Time : 18:00 Place: Ericsson in ?lvsj? *** Advance registration required *** Register via email to me: ulf.wiger (at) erlang-consulting.com e.g. by replying to this mail. Schedule: - Kenneth Lundin presents Erlang/OTP R13B - EUnit - Tips and Tricks, by Richard Carlsson, Kreditor - Q&A - Erlounge, at some suitable location (yet to be determined) Instructions on how to get there can be found here: http://www.erlang.se/contact/alvsjo.shtml Here is a map view: http://tinyurl.com/cp9lc6 Welcome! Ulf Wiger -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From thomasmallen@REDACTED Thu Apr 16 16:54:41 2009 From: thomasmallen@REDACTED (Thomas Allen) Date: Thu, 16 Apr 2009 10:54:41 -0400 Subject: [erlang-questions] BeautifulSoup in Erlang Message-ID: <87b18a720904160754q5d206d8ereac5e1d8667a83a7@mail.gmail.com> Are there any libraries that work like Python's BeautifulSoup (allowing selector queries on XML docs) written in Erlang? We're indexing some pages at my job, and I'm interested in this being my first practical use of Erlang, so I'd appreciate any recommendations. Thomas Allen From rvirding@REDACTED Thu Apr 16 17:11:32 2009 From: rvirding@REDACTED (Robert Virding) Date: Thu, 16 Apr 2009 17:11:32 +0200 Subject: [erlang-questions] Games programming in Erlang Message-ID: <3dbc6d1c0904160811n3dab0022j8daa9a93d7eac8a4@mail.gmail.com> A while back (a few years?) I remember there was something about programing computer games on/with Erlang. Unfortunately the articles are quite old so I wonder if anyone has some more recent references. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryeguy1@REDACTED Thu Apr 16 17:22:26 2009 From: ryeguy1@REDACTED (ryeguy) Date: Thu, 16 Apr 2009 08:22:26 -0700 (PDT) Subject: [erlang-questions] Games programming in Erlang In-Reply-To: <3dbc6d1c0904160811n3dab0022j8daa9a93d7eac8a4@mail.gmail.com> References: <3dbc6d1c0904160811n3dab0022j8daa9a93d7eac8a4@mail.gmail.com> Message-ID: <4764d82b-7208-4c69-a8e5-947c215346c1@w40g2000yqd.googlegroups.com> This MAY be the article that you were talking about that you consider "old", but if not, here is one about writing an Open Poker server in erlang: http://www.devmaster.net/articles/mmo-scalable-server/ Other than that, the only game server I have heard of being written in erlang is vendetta online. But they have no information about the specs as far as I know. On Apr 16, 11:11?am, Robert Virding wrote: > A while back (a few years?) I remember there was something about programing > computer games on/with Erlang. Unfortunately the articles are quite old so I > wonder if anyone has some more recent references. > > Robert > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From zambal@REDACTED Thu Apr 16 17:51:19 2009 From: zambal@REDACTED (zambal) Date: Thu, 16 Apr 2009 08:51:19 -0700 (PDT) Subject: [erlang-questions] Games programming in Erlang In-Reply-To: <3dbc6d1c0904160811n3dab0022j8daa9a93d7eac8a4@mail.gmail.com> References: <3dbc6d1c0904160811n3dab0022j8daa9a93d7eac8a4@mail.gmail.com> Message-ID: A year ago James Hague started with his serie of articles, Purely Functional Retrogames: http://prog21.dadgum.com/23.html --- vincent From gleber.p@REDACTED Thu Apr 16 18:15:25 2009 From: gleber.p@REDACTED (Gleb Peregud) Date: Thu, 16 Apr 2009 18:15:25 +0200 Subject: [erlang-questions] Games programming in Erlang In-Reply-To: References: <3dbc6d1c0904160811n3dab0022j8daa9a93d7eac8a4@mail.gmail.com> Message-ID: <14f0e3620904160915td7dbe4br40279d49f0e2fc8a@mail.gmail.com> There is an ongoing project MMO game SMASH. It's blog is located here: http://sunweaver.blogspot.com/ On Thu, Apr 16, 2009 at 17:51, zambal wrote: > A year ago James Hague started with his serie of articles, Purely > Functional Retrogames: > > http://prog21.dadgum.com/23.html > > --- > vincent > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From attila.r.nohl@REDACTED Thu Apr 16 18:15:42 2009 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Thu, 16 Apr 2009 18:15:42 +0200 Subject: [erlang-questions] Erlang-java interaction problem? Message-ID: <401d3ba30904160915l1cb8f66fse72eb5b706e01c0c@mail.gmail.com> Hello! I was playing around with an application on OTP R13A and got a couple of interesting error messages. The first is this: Got invalid data on distribution channel, offending packet is: <<112,131,104,3,97,2,100,0,0,103,100,0,32,99,111,111,114,100,105,110,97,116,111,114,95,101,116,104,97,110,108,95,48,48,48,49,55,64,109,119,108,120,52,48,53,0,0,0,144,0,0,0,0,3,131,104,107,3,14,46,102,105,114,115,116,97,99,116,105,118,105,116,121,0,0,9,98,255,255,255,255,36,103,101,110,95,99,97,108,108,104,2,103,100,0,26,101,116,104,97,110,108,95,115,116,114,101,97,109,49,52,54,54,57,64,109,119,108,120,52,48,53,0,0,0,2,0,0,0,0,0,101,100,0,26>> I think it comes from the dist.c file. The other error messages come from the jinterface: com.ericsson.otp.erlang.OtpErlangDecodeException: Not valid integer tag: 95 com.ericsson.otp.erlang.OtpErlangDecodeException: Not valid list tag: 0 I'm not sure if this is related to the above message. It might have something to do with code using the I/O-protocol and not being updated. Also the used java library might be out of date due to build system problems. Any ideas? From pablo.polvorin@REDACTED Thu Apr 16 18:26:35 2009 From: pablo.polvorin@REDACTED (Pablo Polvorin) Date: Thu, 16 Apr 2009 13:26:35 -0300 Subject: [erlang-questions] BeautifulSoup in Erlang In-Reply-To: <87b18a720904160754q5d206d8ereac5e1d8667a83a7@mail.gmail.com> References: <87b18a720904160754q5d206d8ereac5e1d8667a83a7@mail.gmail.com> Message-ID: <1ffe809c0904160926w1bd68278xd7b0b6c11c871366@mail.gmail.com> Hi, mochiweb has an html parser that outputs a simple tree-like struct, you can work directly with it, or for simple use cases you could also like to do xpath over it. http://github.com/JacobVorreuter/mochixpath/tree/master see example: http://ppolv.wordpress.com/2008/05/09/fun-with-mochiwebs-html-parser-and-xpath/ cheers 2009/4/16 Thomas Allen : > Are there any libraries that work like Python's BeautifulSoup > (allowing selector queries on XML docs) written in Erlang? We're > indexing some pages at my job, and I'm interested in this being my > first practical use of Erlang, so I'd appreciate any recommendations. > > Thomas Allen > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From connorsml@REDACTED Thu Apr 16 21:19:42 2009 From: connorsml@REDACTED (Michael Connors) Date: Thu, 16 Apr 2009 21:19:42 +0200 Subject: [erlang-questions] reading excel files in Erlang In-Reply-To: <49E778AE.1050600@mweb.co.za> References: <49E778AE.1050600@mweb.co.za> Message-ID: Thanks everyone, I think I will try the csv option for now, because I am running Windows so I guess that is COM out (and ODBC also?). Regards, -- Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From hpjcon@REDACTED Thu Apr 16 20:27:58 2009 From: hpjcon@REDACTED (Jan Jacobs) Date: Thu, 16 Apr 2009 20:27:58 +0200 Subject: [erlang-questions] reading excel files in Erlang In-Reply-To: References: Message-ID: <49E778AE.1050600@mweb.co.za> Hi Michael, Use ODBC, it is the easiest way of getting data from excel files. See example below: ConnStr = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=c:\\projects\\DeepBlue\\lib\\prototype\\ebin\\data\\Saco.xls;DefaultDir=c:\\projects\\DeepBlue\\lib\\prototype\\ebin\\data;", {ok,Ref} = odbc:connect( ConnStr, [{timeout, 45000}] ), {selected, _ColData, DataList} = odbc:sql_query( Ref, "SELECT * FROM [Query$];" ), process_cards( Tab, DataList ), odbc:disconnect( Ref ) Important info from http://www.connectionstrings.com/ Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=C:\MyExcel.xls;DefaultDir=c:\mypath; SQL syntax "SELECT * FROM [sheet1$]". I.e. excel worksheet name followed by a "$" and wrapped in "[" "]" brackets. Cheers Jan Michael Connors wrote: > Hi, > Does anyone know if there is an Erlang module for extracting data from > data from excel files? > I didn't find one on CEAN, but I am new to Erlang so could be looking > in the wrong place. > > Regards > -- > Michael > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > ------------------------------------------------------------------------ > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 8.0.238 / Virus Database: 270.11.57/2060 - Release Date: 04/15/09 06:34:00 > > From masse@REDACTED Thu Apr 16 23:11:52 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 16 Apr 2009 23:11:52 +0200 Subject: [erlang-questions] Question about http client In-Reply-To: (mtalyans@cisco.com's message of "Wed\, 15 Apr 2009 13\:38\:20 -0700") References: Message-ID: <87skk8cnhj.fsf@dixie.cronqvi.st> mtalyans writes: > Hi All, > > I am a rank beginner, so please bear with me: > > I am fetching Web content from a set of URLs using http:request. For > most of URLs everything works fine; however for some of them I see > error reports on the console that look like so: ... tons of crap... > ** Reason for termination == > ** session_remotly_closed > > As far as I can tell, session has been remotely closed. that is indeed what's happening. > I don?t mind a failure like this, but I would like to get rid of > the error reports, as I am fetching many, many URLs. it is a bizarre design decision to print an error report for a perfectly normal event. there has been some complaining about this on erlang-bugs (by me among others) to no avail. The only sane solution (turning off sasl is insane) I've been able to come up with is to patch; IIRC you have to replace the atom 'session_remotly_closed' with 'shutdown' in a few lines like this; httpc_handler.erl: {stop, session_remotly_closed, State}; > In other cases, I get content properly fetched, and then get an error report > with a timeout: > > <0.49.0> spawned pid <0.50.0> > <0.50.0>: normal clause "Normal completion" > > =ERROR REPORT==== 15-Apr-2009::13:35:05 === > ** Generic server <0.51.0> terminating > ** Last message in was {timeout,#Ref<0.0.0.67>} > ** When Server state == {state,undefined, > {tcp_session, > {{"links.preplogic.com",80},<0.51.0>}, > false,http,#Port<0.1570>,1,keep_alive}, > undefined,undefined,undefined,undefined, > {[],[]}, > {[],[]}, > keep_alive,[],nolimit,nolimit, > {options, > {undefined,[]}, > 0,2,5,120000,2,disabled,enabled,false}, > {timers,[],#Ref<0.0.0.78>}, > httpc_manager,undefined} > ** Reason for termination == > ** {{badrecord,request}, > [{httpc_handler,handle_info,2}, > {gen_server,handle_msg,5}, > {proc_lib,init_p_do_apply,3}]} > > Could someone in the know help me to solve this issue? this looks like a "real" bug. handle_info/2 expects a to be handed a record, but it gets an atom, namely 'request'. This will happens if you type 'request' instead of 'Request' at the right place... I'll CC this to erlang-bugs, in case the OTP guys miss it. mats From kevin@REDACTED Fri Apr 17 02:48:28 2009 From: kevin@REDACTED (Kevin A. Smith) Date: Thu, 16 Apr 2009 20:48:28 -0400 Subject: [erlang-questions] reading excel files in Erlang In-Reply-To: <49E778AE.1050600@mweb.co.za> References: <49E778AE.1050600@mweb.co.za> Message-ID: Another possibility would be to use Apache POI (http:// poi.apache.org/) and JInterface. --Kevin On Apr 16, 2009, at 2:27 PM, Jan Jacobs wrote: > Hi Michael, > > Use ODBC, it is the easiest way of getting data from excel files. > See example below: > > ConnStr = > "Driver={Microsoft Excel Driver > (*.xls)};DriverId=790;Dbq=c:\\projects\\DeepBlue\\lib\\prototype\ > \ebin\\data\\Saco.xls;DefaultDir=c:\\projects\\DeepBlue\\lib\ > \prototype\\ebin\\data;", > > {ok,Ref} = odbc:connect( ConnStr, [{timeout, 45000}] ), > {selected, _ColData, DataList} = odbc:sql_query( Ref, "SELECT * FROM > [Query$];" ), > process_cards( Tab, DataList ), > odbc:disconnect( Ref ) > > Important info from http://www.connectionstrings.com/ > Driver={Microsoft Excel Driver > (*.xls)};DriverId=790;Dbq=C:\MyExcel.xls;DefaultDir=c:\mypath; > SQL syntax "SELECT * FROM [sheet1$]". I.e. excel worksheet name > followed by a "$" and wrapped in "[" "]" brackets. > > Cheers > Jan > > Michael Connors wrote: >> Hi, >> Does anyone know if there is an Erlang module for extracting data >> from >> data from excel files? >> I didn't find one on CEAN, but I am new to Erlang so could be looking >> in the wrong place. >> >> Regards >> -- >> Michael >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> ------------------------------------------------------------------------ >> >> >> No virus found in this incoming message. >> Checked by AVG - www.avg.com >> Version: 8.0.238 / Virus Database: 270.11.57/2060 - Release Date: >> 04/15/09 06:34:00 >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From samb@REDACTED Fri Apr 17 04:00:35 2009 From: samb@REDACTED (Sam Bobroff) Date: Fri, 17 Apr 2009 12:00:35 +1000 Subject: [erlang-questions] QLC doesn't use lookup joins on bare values Message-ID: <20090417120035.2952da30@samb-cm> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Erlangers, I've discovered that when performing a QLC query, QLC is unable to use a fast join unless the values being returned by both generators are wrapped as tuples. Does anyone know if this is caused just because that pattern isn't recognised by QLC? Would it be worth adding this as a pattern? Here's an example (notice that "one" is done by traversal and is slow, while "two" is done by a merge join and is fast): - -module(question). - -export([start/0]). - -include_lib("stdlib/include/qlc.hrl"). - -define(N, 1000). start() -> TA = ets:new(ta, []), TB = ets:new(tb, []), [ ets:insert(TA, {X}) || X <- lists:seq(1, ?N) ], [ ets:insert(TB, {X, $a - 1 + (X rem 26)}) || X <- lists:seq(1, ?N) ], one(TA, TB), two(TA, TB), init:stop(). one(TA, TB) -> TMP = qlc:q([A || {A} <- ets:table(TA)]), QLC = qlc:q([element(2, B) || A <- TMP, B <- ets:table(TB), A =:= element(2, B)]), do("one", QLC). two(TA, TB) -> TMP = qlc:q([A || A <- ets:table(TA)]), QLC = qlc:q([element(2, B) || {A} <- TMP, B <- ets:table(TB), A =:= element(2, B)]), do("two", QLC). do(Name, QLC) -> io:fwrite("Query Info for query ~p: ~s\n", [Name, qlc:info(QLC)]), ST = now(), Result = qlc:e(QLC), ET = now(), io:fwrite("Query time: ~ps\nResults: ~p\n", [timer:now_diff(ET, ST) / 1000000, length(Result)]). Running this on my machine (running Erlang R12B): $ erlc question.erl && erl -noshell -run question Query Info for query "one": qlc:q([element(2, B) || A <- ets:table(8204, [{traverse,{select,[{{'$1'},[true],['$1']}]}}]), B <- ets:table(12301), A =:= element(2, B)]) Query time: 0.908338s Results: 1000 Query Info for query "two": begin V1 = qlc:q([P0 || P0 = {A} <- qlc:keysort(1, ets:table(8204), [])]), V2 = qlc:q([[G1|B] || G1 <- V1, B <- qlc:keysort(2, ets:table(12301), []), element(1, G1) == element(2, B)], [{join,merge}]), qlc:q([element(2, B) || [{A}|B] <- V2, A =:= element(2, B)]) end Query time: 0.010174s Results: 1000 Cheers, Sam. - -- Sam Bobroff | sam@REDACTED | M5 Networks -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAknn4sMACgkQm97/UHSa/AQJ1wCfa5OxpvF+RngKfFniuXQxWZ8i BxMAnifufDoqp0ZrRYdd4oHILmPyBCez =250i -----END PGP SIGNATURE----- From vances@REDACTED Fri Apr 17 04:07:04 2009 From: vances@REDACTED (Vance Shipley) Date: Thu, 16 Apr 2009 22:07:04 -0400 Subject: [erlang-questions] OTP compliant gen_tcp client Message-ID: <20090417020703.GJ379@h216-235-12-174.host.egate.net> In order to have well behaved OTP compliant applications we must be sure to process all of the system messages received. Using behaviours such as gen_server and gen_fsm will ensure that the proper handlers are in place for those system messages. Where you will run into trouble however is when your process is blocking as it does in a selective receive. Many library functions will put your process into a selective receive, and obvious example being gen_server:call/3. A lot has been written about gen_tcp server side implementation strategies and I see that there are a lot of subtle issues to be considered to get it just right. I haven't been able to find anything written on the client side. I have attached an example of a client side finite state machine and vite you to punch holes in it. The call to gen_tcp:connect/3 may take several minutes to return in the case of a time out so calling it in the init/1 function is a very bad idea. If you create a connecting state and call gen_tcp:connect/3 from that state handler it solves the problem of hanging the supervisor however the process will still not respond to system messages until after it returns. This breaks lots of OTP goodness. So the solution would seem to be to spawn a process to wait on the connection. Once connected it sets the controlling process to be the gen_fsm pid and sends the socket back. -- -Vance -------------- next part -------------- -module(client_fsm). -behaviour(gen_fsm). -export([init/1, handle_event/3, handle_sync_event/4, handle_info/3, terminate/3, code_change/4]). -export([connecting/2, connected/3]). -export([connect/3]). -record(statedata, {connecter, socket, address, port}). -define(RETRY_TIMER, 5000). init([Address, Port]) -> process_flag(trap_exit, true), StateData = #statedata{address = Address, port = Port}, {ok, connecting, StateData, 0}. connecting(timeout, #statedata{address = Address, port = Port} = StateData) -> Pid = proc_lib:spawn_link(?MODULE, connect, [self(), Address, Port]), {next_state, connecting, StateData#statedata{connecter = Pid}}; connecting({Connecter, Socket}, #statedata{connecter = Connecter} = StateData) when is_port(Socket) -> {next_state, connected, StateData#statedata{socket = Socket}}; connecting({Connecter, {error, econnrefused}}, #statedata{connecter = Connecter} = StateData) -> io:fwrite("Connection refused by remote host~n"), {next_state, connecting, StateData}; connecting({Connecter, {error, etimedout}}, #statedata{connecter = Connecter} = StateData) -> io:fwrite("No response from remote host~n"), {next_state, connecting, StateData}; connecting({Connecter, {error, enetunreach}}, #statedata{connecter = Connecter} = StateData) -> io:fwrite("Remote network unreachable~n"), {next_state, connecting, StateData}; connecting({Connecter, {error, ehostunreach}}, #statedata{connecter = Connecter} = StateData) -> io:fwrite("Remote host unreachable~n"), {next_state, connecting, StateData}; connecting({Connecter, {error, Reason}}, #statedata{connecter = Connecter} = StateData) -> io:fwrite("Connection failed~n"), {stop, Reason, StateData}. connected({tcp_send, Data}, _From, #statedata{socket = Socket} = StateData) -> case gen_tcp:send(Socket, Data) of ok -> {reply, ok, connected, StateData}; {error, Reason} = Reply -> {stop, Reason, Reply, StateData} end; connected(_Event, _From, StateData) -> {reply, {error, badarg}, connected, StateData}. handle_event(_Event, StateName, StateData) -> {next_state, StateName, StateData}. handle_sync_event(_Event, _From, StateName, StateData) -> {reply, ok, StateName, StateData}. handle_info({tcp, Socket, Data}, StateName, #statedata{socket = Socket} = StateData) -> io:fwrite("Recieved: ~w~n", [Data]), {next_state, StateName, StateData}; handle_info({tcp_closed, Socket}, _StateName, #statedata{socket = Socket} = StateData) -> io:fwrite("Remote end closed connection~n"), {stop, normal, StateData}; handle_info({'EXIT', _Connecter, normal}, connecting, StateData) -> {next_state, connecting, StateData, ?RETRY_TIMER}; handle_info({'EXIT', _Connecter, normal}, StateName, StateData) -> {next_state, StateName, StateData}. terminate(_Reason, _StateName, _StateData) -> io:fwrite("Graceful exit~n"). code_change(_OldVsn, StateName, StateData, _Extra) -> {ok, next_state, StateName, StateData}. connect(Fsm, Address, Port) -> case gen_tcp:connect(Address, Port, []) of {ok, Socket} -> ok = gen_tcp:controlling_process(Socket, Fsm), gen_fsm:send_event(Fsm, {self(), Socket}); Error -> gen_fsm:send_event(Fsm, {self(), Error}) end. From btolputt@REDACTED Fri Apr 17 02:29:36 2009 From: btolputt@REDACTED (Benjamin Tolputt) Date: Fri, 17 Apr 2009 10:29:36 +1000 Subject: [erlang-questions] Games programming in Erlang In-Reply-To: <3dbc6d1c0904160811n3dab0022j8daa9a93d7eac8a4@mail.gmail.com> References: <3dbc6d1c0904160811n3dab0022j8daa9a93d7eac8a4@mail.gmail.com> Message-ID: <49E7CD70.30102@bigpond.net.au> Robert Virding wrote: > A while back (a few years?) I remember there was something about > programing computer games on/with Erlang. Unfortunately the articles > are quite old so I wonder if anyone has some more recent references. Aside from the SMASH, MMO Server Engine in blogged development (http://sunweaver.blogspot.com/), I'm afraid there isn't any development I could find. That, and while interesting, I think an MMO server is just another way of framing the term "super scalable application server", something Erlang is already known for :) Vendetta Online (an online space-combat simulator) also use Erlang in their project, I'm sure they'd appreciate the interest were you to contact them on it. Given it is an interest of mine, I try to keep track on the subject. If you're looking for the latest "client side" project, I think the last one was in 2003, linking Erlang into an open-source 3D Engine (NebulaDevice). The paper for it is located here (www.erlang.se/euc/03/proceedings/0950Mikael.pdf). -- Regards, Benjamin Tolputt Analyst Programmer From steve.kirsch@REDACTED Fri Apr 17 05:28:51 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Thu, 16 Apr 2009 20:28:51 -0700 Subject: [erlang-questions] can you directly generate a binary from format/2 ? In-Reply-To: <20090417020703.GJ379@h216-235-12-174.host.egate.net> Message-ID: <76BB7F270C366D47AA79851BB0B39D8102945298@exchg02.propel.com> io_lib:format("test", []). returns the string "test". What I'd like is a way to return <<"test">> instead from the output of format. Is there a format/2 somewhere that returns a binary? From steve.kirsch@REDACTED Fri Apr 17 07:16:31 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Thu, 16 Apr 2009 22:16:31 -0700 Subject: [erlang-questions] index for lists and tuples? Message-ID: <76BB7F270C366D47AA79851BB0B39D810294529D@exchg02.propel.com> I am looking for an index function for lists and tuples that returns the index of the first element that matches a query term. For example: index({a, b, c}, b) would return 2 index([a, b, c], c) would return 3 But I couldn't seem to find a function like this either for lists or tuples. Sure, I could write one, but am I just looking in the wrong place? This seems like a pretty basic function. In my case, I wanted to make a tuple of logging levels like {all, info, warn, errors, none} and then I can compare the atom supplied by the log request and compare its numeric index into this tuple to index value of the requested logging level to determine whether to log or not. I was surprised not to find a simple index function. In Python, you can write: [6,7,8,9].index(8) which would return 2 (since they start numbering at 0). From btolputt@REDACTED Fri Apr 17 02:29:25 2009 From: btolputt@REDACTED (Benjamin Tolputt) Date: Fri, 17 Apr 2009 10:29:25 +1000 Subject: [erlang-questions] Games programming in Erlang In-Reply-To: <3dbc6d1c0904160811n3dab0022j8daa9a93d7eac8a4@mail.gmail.com> References: <3dbc6d1c0904160811n3dab0022j8daa9a93d7eac8a4@mail.gmail.com> Message-ID: <49E7CD65.3030804@bigpond.net.au> Robert Virding wrote: > A while back (a few years?) I remember there was something about > programing computer games on/with Erlang. Unfortunately the articles > are quite old so I wonder if anyone has some more recent references. Aside from the SMASH, MMO Server Engine in blogged development (http://sunweaver.blogspot.com/), I'm afraid there isn't any development I could find. That, and while interesting, I think an MMO server is just another way of framing the term "super scalable application server", something Erlang is already known for :) Vendetta Online (an online space-combat simulator) also use Erlang in their project, I'm sure they'd appreciate the interest were you to contact them on it. Given it is an interest of mine, I try to keep track on the subject. If you're looking for the latest "client side" project, I think the last one was in 2003, linking Erlang into an open-source 3D Engine (NebulaDevice). The paper for it is located here (www.erlang.se/euc/03/proceedings/0950Mikael.pdf). -- Regards, Benjamin Tolputt Analyst Programmer Mob: 0417 456 505 Email: btolputt@REDACTED This email and any files transmitted with it are confidential to the intended recipient and may be privileged. If you have received this email inadvertently or you are not the intended recipient, you may not disseminate, distribute, copy or in any way rely on it. Further, you should notify the sender immediately and delete the email from your computer. Whilst we have taken precautions to alert us to the presence of computer viruses, we cannot guarantee that this email and any files transmitted with it are free from such viruses. From btolputt@REDACTED Fri Apr 17 05:07:12 2009 From: btolputt@REDACTED (Benjamin Tolputt) Date: Fri, 17 Apr 2009 13:07:12 +1000 Subject: [erlang-questions] Games programming in Erlang In-Reply-To: <49E7CD70.30102@bigpond.net.au> References: <3dbc6d1c0904160811n3dab0022j8daa9a93d7eac8a4@mail.gmail.com> <49E7CD70.30102@bigpond.net.au> Message-ID: <49E7F260.80201@bigpond.net.au> Robert Virding wrote: > A while back (a few years?) I remember there was something about > programing computer games on/with Erlang. Unfortunately the articles > are quite old so I wonder if anyone has some more recent references. > Might I be so bold as to ask why you're inquiring? -- Regards, Benjamin Tolputt Analyst Programmer From bengt.kleberg@REDACTED Fri Apr 17 08:11:21 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 17 Apr 2009 08:11:21 +0200 Subject: [erlang-questions] can you directly generate a binary from format/2 ? In-Reply-To: <76BB7F270C366D47AA79851BB0B39D8102945298@exchg02.propel.com> References: <76BB7F270C366D47AA79851BB0B39D8102945298@exchg02.propel.com> Message-ID: <1239948681.4501.3.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, There is no such format that I know of. It would probably be a good idea to just change the list to a binary: erlang:list_to_binary(io_lib:format("test", [])). bengt On Thu, 2009-04-16 at 20:28 -0700, Steve Kirsch wrote: > io_lib:format("test", []). > > returns the string "test". > > What I'd like is a way to return <<"test">> instead from the output of > format. > > Is there a format/2 somewhere that returns a binary? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From icarmenates@REDACTED Fri Apr 17 08:14:12 2009 From: icarmenates@REDACTED (Ivan Carmenates Garcia) Date: Fri, 17 Apr 2009 02:14:12 -0400 Subject: [erlang-questions] change epmd listen port still without resolve for us Message-ID: Hi, friends, I am new here, I'm partner of Jose Enrique Benitez. Well, none of these solutions about changing epmd port works fine in ours case If I use to run epmd -daemon -port 5900 on cmd windows console, yes it puts epmd to listen throw port 5900 but then when I start a server node: erl -sname test -setcookie cookie -kernel inet_dist_listen_min 5800 inet_dist_listen_max 5801 -s main_app start then it start other instance of epmd daemon runing on default port 4369. so that's instance I was created befor running on port 5900 still of that way listen nothing happent with that. I try too to run server node without epmd using -no_epmd to see if the epmd running on port 5900 it used but I just get {error_logger,{{2009,4,16},{16,36,21}},"Protocol: ~p: register error: ~p~n",["inet_tcp",{noproc,{gen_server,call,[erl_epmd,{register,test,5800},infinity]}}]} ............................. I try too the enviroment variable ERL_EPMD_PORT but on windows seems not works Well, How I can resolve this little problem? From samb@REDACTED Fri Apr 17 08:27:18 2009 From: samb@REDACTED (Sam Bobroff) Date: Fri, 17 Apr 2009 16:27:18 +1000 Subject: [erlang-questions] index for lists and tuples? In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810294529D@exchg02.propel.com> References: <76BB7F270C366D47AA79851BB0B39D810294529D@exchg02.propel.com> Message-ID: <20090417162718.34438a44@samb-cm> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thu, 16 Apr 2009 22:16:31 -0700 Steve Kirsch wrote: > I am looking for an index function for lists and tuples that returns > the index of the first element that matches a query term. > > For example: > > index({a, b, c}, b) would return 2 > > index([a, b, c], c) would return 3 [snip] This isn't a general solution, but if you're searching in a list of characters (e.g. integers), you can use string:chr to do what you want. 1> string:chr([4, 5, 6], 5). 2 I suspect if you're going to do lookups like that, a better solution would be to use a key/value list (see the lists module) or an orddict (see the orddict module). Cheers, Sam. - -- Sam Bobroff | sam@REDACTED | M5 Networks -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAknoIUYACgkQm97/UHSa/ARl8gCfTjDi3swqN4S9S/uJJjphxqJk cEQAnjPLufYEVPRj4extyL4S9OiTjFYl =bn8d -----END PGP SIGNATURE----- From matthias@REDACTED Fri Apr 17 08:10:17 2009 From: matthias@REDACTED (Matthias Lang) Date: Fri, 17 Apr 2009 08:10:17 +0200 Subject: [erlang-questions] can you directly generate a binary from format/2 ? In-Reply-To: <76BB7F270C366D47AA79851BB0B39D8102945298@exchg02.propel.com> References: <20090417020703.GJ379@h216-235-12-174.host.egate.net> <76BB7F270C366D47AA79851BB0B39D8102945298@exchg02.propel.com> Message-ID: <20090417061017.GA3697@contorpis.lisalinda.com> On Thursday, April 16, Steve Kirsch wrote: > io_lib:format("test", []). > > returns the string "test". > > What I'd like is a way to return <<"test">> instead from the output of > format. > > Is there a format/2 somewhere that returns a binary? No, not directly. I assume you're aware of erlang:list_to_binary/1. Matthias From rtrlists@REDACTED Fri Apr 17 10:20:47 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Fri, 17 Apr 2009 09:20:47 +0100 Subject: [erlang-questions] reading excel files in Erlang In-Reply-To: References: <49E778AE.1050600@mweb.co.za> Message-ID: <6a3ae47e0904170120t5e15b1fbl96807ae787f96923@mail.gmail.com> On Thu, Apr 16, 2009 at 8:19 PM, Michael Connors wrote: > Thanks everyone, I think I will try the csv option for now, because I am > running Windows so I guess that is COM out (and ODBC also?). Microsoft invented ODBC. So it's pretty much ubiquitous in Windows land. I'd try the ODBC approach first, before dropping down a level to CSV files. Robby From connorsml@REDACTED Fri Apr 17 10:52:42 2009 From: connorsml@REDACTED (Michael Connors) Date: Fri, 17 Apr 2009 10:52:42 +0200 Subject: [erlang-questions] reading excel files in Erlang In-Reply-To: <6a3ae47e0904170120t5e15b1fbl96807ae787f96923@mail.gmail.com> References: <49E778AE.1050600@mweb.co.za> <6a3ae47e0904170120t5e15b1fbl96807ae787f96923@mail.gmail.com> Message-ID: Sorry, what I intended to say was that 'I am not running Windows' 2009/4/17 Robert Raschke > On Thu, Apr 16, 2009 at 8:19 PM, Michael Connors > wrote: > > Thanks everyone, I think I will try the csv option for now, because I am > > running Windows so I guess that is COM out (and ODBC also?). > > Microsoft invented ODBC. So it's pretty much ubiquitous in Windows land. > I'd try the ODBC approach first, before dropping down a level to CSV files. > > Robby > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Michael Connors -------------- next part -------------- An HTML attachment was scrubbed... URL: From sverker@REDACTED Fri Apr 17 11:04:21 2009 From: sverker@REDACTED (Sverker Eriksson) Date: Fri, 17 Apr 2009 11:04:21 +0200 Subject: [erlang-questions] change epmd listen port still without resolve for us In-Reply-To: References: Message-ID: <49E84615.7070504@erix.ericsson.se> Use the environment variable ERL_EPMD_PORT that was introduced in R13A. It should work on windows as well. In earlier versions the port number is hard coded in erts/epmd/epmd.mk for the emulator. /Sverker, Erlang/OTP Ericsson Ivan Carmenates Garcia wrote: > Hi, friends, I am new here, I'm partner of Jose Enrique Benitez. > > Well, none of these solutions about changing epmd port works fine in ours case > If I use to run epmd -daemon -port 5900 on cmd windows console, yes it puts epmd to listen throw port 5900 > but then when I start a server node: > > erl -sname test -setcookie cookie -kernel inet_dist_listen_min 5800 inet_dist_listen_max 5801 -s main_app start > > then it start other instance of epmd daemon runing on default port 4369. > > so that's instance I was created befor running on port 5900 still of that way listen nothing happent with that. > > I try too to run server node without epmd using -no_epmd to see if the epmd running on port 5900 it used but I just get > > {error_logger,{{2009,4,16},{16,36,21}},"Protocol: ~p: register error: ~p~n",["inet_tcp",{noproc,{gen_server,call,[erl_epmd,{register,test,5800},infinity]}}]} ............................. > > I try too the enviroment variable ERL_EPMD_PORT but on windows seems not works > > Well, How I can resolve this little problem? > From Roman@REDACTED Fri Apr 17 14:10:00 2009 From: Roman@REDACTED (Roman@REDACTED) Date: Fri, 17 Apr 2009 17:10:00 +0500 Subject: [erlang-questions] memory leak. In-Reply-To: <4C87BF70-32B3-426E-9570-86712ED7A379@hates.ms> References: <4C87BF70-32B3-426E-9570-86712ED7A379@hates.ms> Message-ID: On Thu, 16 Apr 2009 16:36:55 +0500, Mihai Balea wrote: I don't think, that a problem in process leak. First restart count process: 8400, next: 13082, next 11110 > > On Apr 16, 2009, at 2:24 AM, Roman@REDACTED wrote: > >> Hi dear Team, >> >> A problem appeared with the memory leak. Function "erlang:memory()" >> shows >> that "total" parameter grows constantly and fast, during the day it >> increases from 60 Mb till 510 Mb. "System" parameter also grows >> constantly, not as much fast, reaching 400 Mb. >> "process" parameter although does not reach 100 Mb. Top FreeBSD >> utility?s >> "size" parameter also increases from 70 Mb till 600 Mb. >> System crashes on "mem_error" of the module "zlib.erl" or on the error >> "system_limit" while creating new process >> {erlang,open_port,[{spawn,zlib_drv},[binary]]}. "yaws", >> "error_logger" and >> some gen_server-s work on the computer. No database except "ets" is >> used >> during the functioning, but the used memory doesn?t exceed 1 Mb. >> Server >> receives messages each second. >> The memory releases after restarting erlang. Restarting individual >> gen_server-s gives nothing. >> >> What is the reason of appearing memory leak problem? > > Chances are, a programming error on your part. > > The fact that you're getting "system_limit" errors when creating new > processes leads me to believe that you might not have a memory leak > per se, but a process leak. Meaning you are dynamically creating > processes, but don't shut them down. > > You can find the number of processes on your node using > > length(processes()). > > Try to see if this number increases constantly during operation. > > Mihai > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Best regards, Roman Shuplov. From vychodil.hynek@REDACTED Fri Apr 17 14:26:04 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 17 Apr 2009 14:26:04 +0200 Subject: [erlang-questions] QLC doesn't use lookup joins on bare values In-Reply-To: <20090417120035.2952da30@samb-cm> References: <20090417120035.2952da30@samb-cm> Message-ID: <4d08db370904170526v6dc3bfacy98e03df8d967ceda@mail.gmail.com> I don't understand why you do it. You should write simple: three(TA, TB) -> QLC = qlc:q([B || {A} <- ets:table(TA), {_,B} <- ets:table(TB), A =:= B]), do("two", QLC). With N = 10000: $ erl -noshell -run question Query Info for query "one": qlc:q([element(2, B) || A <- ets:table(8204, [{traverse,{select,[{{'$1'},[true],['$1']}]}}]), B <- ets:table(12301), A =:= element(2, B)]) Query time: 28.2231s Results: 10000 Query Info for query "two": begin V1 = qlc:q([P0 || P0 = {A} <- qlc:keysort(1, ets:table(8204), [])]), V2 = qlc:q([[G1|B] || G1 <- V1, B <- qlc:keysort(2, ets:table(12301), []), element(1, G1) == element(2, B)], [{join,merge}]), qlc:q([element(2, B) || [{A}|B] <- V2, A =:= element(2, B)]) end Query time: 0.036186s Results: 10000 Query Info for query "three": begin V1 = qlc:q([P0 || P0 = {_,B} <- ets:table(12301)]), V2 = qlc:q([[G1|G2] || G2 <- V1, G1 <- ets:table(8204), element(2, G1) =:= element(1, G2)], [{join,lookup}]), qlc:q([B || [{A}|{_,B}] <- V2, A =:= B]) end Query time: 0.016635s Results: 10000 On Fri, Apr 17, 2009 at 4:00 AM, Sam Bobroff wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi Erlangers, > > I've discovered that when performing a QLC query, QLC is unable to use > a fast join unless the values being returned by both generators are > wrapped as tuples. > > Does anyone know if this is caused just because that pattern isn't > recognised by QLC? Would it be worth adding this as a pattern? > > Here's an example (notice that "one" is done by traversal and is slow, > while "two" is done by a merge join and is fast): > > - -module(question). > - -export([start/0]). > > - -include_lib("stdlib/include/qlc.hrl"). > > - -define(N, 1000). > > start() -> > TA = ets:new(ta, []), > TB = ets:new(tb, []), > [ ets:insert(TA, {X}) || X <- lists:seq(1, ?N) ], > [ ets:insert(TB, {X, $a - 1 + (X rem 26)}) || X <- lists:seq(1, ?N) > ], > one(TA, TB), > two(TA, TB), > init:stop(). > > one(TA, TB) -> > TMP = qlc:q([A || {A} <- ets:table(TA)]), > QLC = qlc:q([element(2, B) || A <- TMP, B <- ets:table(TB), A =:= > element(2, B)]), > do("one", QLC). > > two(TA, TB) -> > TMP = qlc:q([A || A <- ets:table(TA)]), > QLC = qlc:q([element(2, B) || {A} <- TMP, B <- ets:table(TB), A =:= > element(2, B)]), > do("two", QLC). > > do(Name, QLC) -> > io:fwrite("Query Info for query ~p: ~s\n", [Name, qlc:info(QLC)]), > ST = now(), > Result = qlc:e(QLC), > ET = now(), > io:fwrite("Query time: ~ps\nResults: ~p\n", [timer:now_diff(ET, ST) > / 1000000, length(Result)]). > > Running this on my machine (running Erlang R12B): > > $ erlc question.erl && erl -noshell -run question > Query Info for query "one": qlc:q([element(2, B) || > A <- > ets:table(8204, > [{traverse,{select,[{{'$1'},[true],['$1']}]}}]), > B <- ets:table(12301), > A =:= element(2, B)]) > Query time: 0.908338s > Results: 1000 > Query Info for query "two": begin > V1 = > qlc:q([P0 || > P0 = {A} <- qlc:keysort(1, ets:table(8204), [])]), > V2 = > qlc:q([[G1|B] || > G1 <- V1, > B <- qlc:keysort(2, ets:table(12301), []), > element(1, G1) == element(2, B)], > [{join,merge}]), > qlc:q([element(2, B) || > [{A}|B] <- V2, > A =:= element(2, B)]) > end > Query time: 0.010174s > Results: 1000 > > Cheers, > Sam. > - -- > Sam Bobroff | sam@REDACTED | M5 Networks > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAknn4sMACgkQm97/UHSa/AQJ1wCfa5OxpvF+RngKfFniuXQxWZ8i > BxMAnifufDoqp0ZrRYdd4oHILmPyBCez > =250i > -----END PGP SIGNATURE----- > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Fri Apr 17 14:40:39 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 17 Apr 2009 14:40:39 +0200 Subject: [erlang-questions] memory leak. In-Reply-To: References: <4C87BF70-32B3-426E-9570-86712ED7A379@hates.ms> Message-ID: <4d08db370904170540g3b1194c1s9f500707e360e47a@mail.gmail.com> You can't deduce anything usable from those numbers. Those processes can hold various amount of memory. Thousands of processes is not usual unless you run application which is usual to have this amount of processes. On Fri, Apr 17, 2009 at 2:10 PM, Roman@REDACTED wrote: > On Thu, 16 Apr 2009 16:36:55 +0500, Mihai Balea wrote: > > > > I don't think, that a problem in process leak. > First restart count process: 8400, next: 13082, next 11110 > > > > > > > On Apr 16, 2009, at 2:24 AM, Roman@REDACTED wrote: > > > >> Hi dear Team, > >> > >> A problem appeared with the memory leak. Function "erlang:memory()" > >> shows > >> that "total" parameter grows constantly and fast, during the day it > >> increases from 60 Mb till 510 Mb. "System" parameter also grows > >> constantly, not as much fast, reaching 400 Mb. > >> "process" parameter although does not reach 100 Mb. Top FreeBSD > >> utility?s > >> "size" parameter also increases from 70 Mb till 600 Mb. > >> System crashes on "mem_error" of the module "zlib.erl" or on the error > >> "system_limit" while creating new process > >> {erlang,open_port,[{spawn,zlib_drv},[binary]]}. "yaws", > >> "error_logger" and > >> some gen_server-s work on the computer. No database except "ets" is > >> used > >> during the functioning, but the used memory doesn?t exceed 1 Mb. > >> Server > >> receives messages each second. > >> The memory releases after restarting erlang. Restarting individual > >> gen_server-s gives nothing. > >> > >> What is the reason of appearing memory leak problem? > > > > Chances are, a programming error on your part. > > > > The fact that you're getting "system_limit" errors when creating new > > processes leads me to believe that you might not have a memory leak > > per se, but a process leak. Meaning you are dynamically creating > > processes, but don't shut them down. > > > > You can find the number of processes on your node using > > > > length(processes()). > > > > Try to see if this number increases constantly during operation. > > > > Mihai > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -- > Best regards, > Roman Shuplov. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mm@REDACTED Fri Apr 17 15:00:20 2009 From: mm@REDACTED (marmll) Date: Fri, 17 Apr 2009 06:00:20 -0700 (PDT) Subject: [erlang-questions] Too many processes Message-ID: <23097100.post@talk.nabble.com> Hi, i have the following problem: My error_logger tells me that I?am having ?Too many processes? and the erlang engine crashed. When I?am starting the gen_server I?am checking the erlang:system_info(process_count) and they tells me 80 processes. Codesnip from init: F = fun(Sock) -> parse_packet(Sock, Client) end, tcp_server:stop(Port), {ok, _} = tcp_server:start_raw_server(Port, F, 10240,2048), And here my parse_packet: parse_packet(Socket, Client) -> receive {tcp, Socket, Bin} -> io:format("--> ~w~n", [Bin]); {tcp_closed, Socket} -> error_logger:error_report([{module, ?MODULE},{line, ?LINE},{message, "tcpclosed"},{call, "tcp_closed aus receive"},{now,now()}]); {packet, Packet} -> io:format("<-- ~w~n", [Packet]), parse_packet(Socket, Client) end. With every connect to the server my process_count is increasing 1 ! How can I handle the process_count ? I think the the tail recursion at parse_packet is not good. Please help me Thanks -- View this message in context: http://www.nabble.com/Too-many-processes-tp23097100p23097100.html Sent from the Erlang Questions mailing list archive at Nabble.com. From ext@REDACTED Fri Apr 17 15:12:38 2009 From: ext@REDACTED (David Sveningsson) Date: Fri, 17 Apr 2009 15:12:38 +0200 Subject: [erlang-questions] Unbuffered/blocking gen_tcp send Message-ID: <49E88046.5070603@sidvind.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, is it possible to have gen_tcp:send block until the receiver has received the package using gen_tcp:recv? For instance if the sender transmits packages which takes long time to process for the receiver. I've been experimenting with the buffer sizes but even setting to sndbuf and recbuf to 1 won't make gen_tcp:send to block, unless the packages are large (1Kb+). I guess it would be possible to manually implement flow-control by acknowledging each package but I would rather just have gen_tcp:send block. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAknogEYACgkQ6pa1H/H5pqX6WQCg1kZz6alB/cTWQuyHA4hKugRC 13gAoJqSNkkUz/il3znllx6bD2LTTRZK =KI0V -----END PGP SIGNATURE----- From rvirding@REDACTED Fri Apr 17 15:16:30 2009 From: rvirding@REDACTED (Robert Virding) Date: Fri, 17 Apr 2009 15:16:30 +0200 Subject: [erlang-questions] Games programming in Erlang In-Reply-To: <49E7F260.80201@bigpond.net.au> References: <3dbc6d1c0904160811n3dab0022j8daa9a93d7eac8a4@mail.gmail.com> <49E7CD70.30102@bigpond.net.au> <49E7F260.80201@bigpond.net.au> Message-ID: <3dbc6d1c0904170616u1d6deddbn52f15285f84165fd@mail.gmail.com> Partly just curious and partly thinking aloud. Robert 2009/4/17 Benjamin Tolputt > Robert Virding wrote: > > A while back (a few years?) I remember there was something about > > programing computer games on/with Erlang. Unfortunately the articles > > are quite old so I wonder if anyone has some more recent references. > > > > Might I be so bold as to ask why you're inquiring? > > -- > Regards, > > Benjamin Tolputt > Analyst Programmer > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From colm.dougan@REDACTED Fri Apr 17 15:39:41 2009 From: colm.dougan@REDACTED (Colm Dougan) Date: Fri, 17 Apr 2009 14:39:41 +0100 Subject: [erlang-questions] index for lists and tuples? In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810294529D@exchg02.propel.com> References: <76BB7F270C366D47AA79851BB0B39D810294529D@exchg02.propel.com> Message-ID: <24d4f39c0904170639g7d2878c1maca149183503ee23@mail.gmail.com> On Fri, Apr 17, 2009 at 6:16 AM, Steve Kirsch wrote: > I am looking for an index function for lists and tuples that returns the > index of the first element that matches a query term. > > For example: > > index({a, b, c}, b) would return 2 > > index([a, b, c], c) would return 3 Steve, there is no such function in the general case but the subject was discussed in a recent thread : http://www.erlang.org/pipermail/erlang-questions/2008-November/040189.html Colm From bernie@REDACTED Fri Apr 17 15:44:43 2009 From: bernie@REDACTED (Bernard Duggan) Date: Fri, 17 Apr 2009 23:44:43 +1000 Subject: [erlang-questions] QLC doesn't use lookup joins on bare values In-Reply-To: <4d08db370904170526v6dc3bfacy98e03df8d967ceda@mail.gmail.com> References: <20090417120035.2952da30@samb-cm> <4d08db370904170526v6dc3bfacy98e03df8d967ceda@mail.gmail.com> Message-ID: <49E887CB.6070902@m5net.com> What Sam gave is just a minimal example to demonstrate the behaviour in question. Obviously we're not actually using a whole qlc query just to produce the results of a simple table generator. Cheers, B Hynek Vychodil wrote: > I don't understand why you do it. You should write simple: > > three(TA, TB) -> > QLC = qlc:q([B || {A} <- ets:table(TA), {_,B} <- ets:table(TB), A =:= > B]), > do("two", QLC). > > With N = 10000: > $ erl -noshell -run question > Query Info for query "one": qlc:q([element(2, B) || > A <- > ets:table(8204, > [{traverse,{select,[{{'$1'},[true],['$1']}]}}]), > B <- ets:table(12301), > A =:= element(2, B)]) > Query time: 28.2231s > Results: 10000 > Query Info for query "two": begin > V1 = > qlc:q([P0 || > P0 = {A} <- qlc:keysort(1, ets:table(8204), [])]), > V2 = > qlc:q([[G1|B] || > G1 <- V1, > B <- qlc:keysort(2, ets:table(12301), []), > element(1, G1) == element(2, B)], > [{join,merge}]), > qlc:q([element(2, B) || > [{A}|B] <- V2, > A =:= element(2, B)]) > end > Query time: 0.036186s > Results: 10000 > Query Info for query "three": begin > V1 = > qlc:q([P0 || > P0 = {_,B} <- ets:table(12301)]), > V2 = > qlc:q([[G1|G2] || > G2 <- V1, > G1 <- ets:table(8204), > element(2, G1) =:= element(1, G2)], > [{join,lookup}]), > qlc:q([B || > [{A}|{_,B}] <- V2, > A =:= B]) > end > Query time: 0.016635s > Results: 10000 > > On Fri, Apr 17, 2009 at 4:00 AM, Sam Bobroff wrote: > > Hi Erlangers, > > I've discovered that when performing a QLC query, QLC is unable to use > a fast join unless the values being returned by both generators are > wrapped as tuples. > > Does anyone know if this is caused just because that pattern isn't > recognised by QLC? Would it be worth adding this as a pattern? > > Here's an example (notice that "one" is done by traversal and is slow, > while "two" is done by a merge join and is fast): > > -module(question). > -export([start/0]). > > -include_lib("stdlib/include/qlc.hrl"). > > -define(N, 1000). > > start() -> > TA = ets:new(ta, []), > TB = ets:new(tb, []), > [ ets:insert(TA, {X}) || X <- lists:seq(1, ?N) ], > [ ets:insert(TB, {X, $a - 1 + (X rem 26)}) || X <- lists:seq(1, ?N) > ], > one(TA, TB), > two(TA, TB), > init:stop(). > > one(TA, TB) -> > TMP = qlc:q([A || {A} <- ets:table(TA)]), > QLC = qlc:q([element(2, B) || A <- TMP, B <- ets:table(TB), A =:= > element(2, B)]), > do("one", QLC). > > two(TA, TB) -> > TMP = qlc:q([A || A <- ets:table(TA)]), > QLC = qlc:q([element(2, B) || {A} <- TMP, B <- ets:table(TB), A =:= > element(2, B)]), > do("two", QLC). > > do(Name, QLC) -> > io:fwrite("Query Info for query ~p: ~s\n", [Name, qlc:info(QLC)]), > ST = now(), > Result = qlc:e(QLC), > ET = now(), > io:fwrite("Query time: ~ps\nResults: ~p\n", [timer:now_diff(ET, ST) > / 1000000, length(Result)]). > > Running this on my machine (running Erlang R12B): > > $ erlc question.erl && erl -noshell -run question > Query Info for query "one": qlc:q([element(2, B) || > A <- > ets:table(8204, > [{traverse,{select,[{{'$1'},[true],['$1']}]}}]), > B <- ets:table(12301), > A =:= element(2, B)]) > Query time: 0.908338s > Results: 1000 > Query Info for query "two": begin > V1 = > qlc:q([P0 || > P0 = {A} <- qlc:keysort(1, ets:table(8204), [])]), > V2 = > qlc:q([[G1|B] || > G1 <- V1, > B <- qlc:keysort(2, ets:table(12301), []), > element(1, G1) == element(2, B)], > [{join,merge}]), > qlc:q([element(2, B) || > [{A}|B] <- V2, > A =:= element(2, B)]) > end > Query time: 0.010174s > Results: 1000 > > Cheers, > Sam. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions >> > ------------------------------------------------------------------------ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From matthias@REDACTED Fri Apr 17 16:16:05 2009 From: matthias@REDACTED (Matthias Lang) Date: Fri, 17 Apr 2009 16:16:05 +0200 Subject: [erlang-questions] Unbuffered/blocking gen_tcp send In-Reply-To: <49E88046.5070603@sidvind.com> References: <49E88046.5070603@sidvind.com> Message-ID: <20090417141605.GA6058@contorpis.lisalinda.com> Hi, > Hi, is it possible to have gen_tcp:send block until the receiver has > received the package using gen_tcp:recv? For instance if the sender > transmits packages which takes long time to process for the receiver. gen_tcp:send can't do this for you. More generally, TCP doesn't provide that service. (And: TCP's interface upwards is streams, not packets. The packets you get from the {packet, N} modes in gen_tcp are added by Erlang on top of TCP) > I've been experimenting with the buffer sizes but even setting to sndbuf > and recbuf to 1 won't make gen_tcp:send to block, unless the packages > are large (1Kb+). > I guess it would be possible to manually implement flow-control by > acknowledging each package but I would rather just have gen_tcp:send block. You've got the right idea. TCP has flow control, but it can't be controlled at the fine level you would like it to, i.e. down to whether a given "packet" has been received by an application at the other end or not. If you want that, you have to implement it yourself on top of TCP. Matthias From ext@REDACTED Fri Apr 17 16:58:49 2009 From: ext@REDACTED (David Sveningsson) Date: Fri, 17 Apr 2009 16:58:49 +0200 Subject: [erlang-questions] Unbuffered/blocking gen_tcp send In-Reply-To: <20090417141605.GA6058@contorpis.lisalinda.com> References: <49E88046.5070603@sidvind.com> <20090417141605.GA6058@contorpis.lisalinda.com> Message-ID: <49E89929.2060505@sidvind.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Matthias Lang wrote: > Hi, > >> Hi, is it possible to have gen_tcp:send block until the receiver has >> received the package using gen_tcp:recv? For instance if the sender >> transmits packages which takes long time to process for the receiver. > > gen_tcp:send can't do this for you. More generally, TCP doesn't provide > that service. (And: TCP's interface upwards is streams, not packets. The > packets you get from the {packet, N} modes in gen_tcp are added by Erlang > on top of TCP) > >> I've been experimenting with the buffer sizes but even setting to sndbuf >> and recbuf to 1 won't make gen_tcp:send to block, unless the packages >> are large (1Kb+). > >> I guess it would be possible to manually implement flow-control by >> acknowledging each package but I would rather just have gen_tcp:send block. > > You've got the right idea. TCP has flow control, but it can't be > controlled at the fine level you would like it to, i.e. down to > whether a given "packet" has been received by an application at the > other end or not. If you want that, you have to implement it yourself > on top of TCP. > > Matthias Ok, thanks. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAknomSkACgkQ6pa1H/H5pqWeDwCeN09xjkGiw77WCtluWi34r06t 1s8An344zRDJfmGMIPP4sHZpwTHL7o8M =rcwp -----END PGP SIGNATURE----- From tsuraan@REDACTED Fri Apr 17 17:46:43 2009 From: tsuraan@REDACTED (tsuraan) Date: Fri, 17 Apr 2009 10:46:43 -0500 Subject: [erlang-questions] reading excel files in Erlang In-Reply-To: References: <49E778AE.1050600@mweb.co.za> Message-ID: <84fb38e30904170846g381c706n4b9dabe52bd6f3b4@mail.gmail.com> On 16/04/2009, Kevin A. Smith wrote: > Another possibility would be to use Apache POI (http:// > poi.apache.org/) and JInterface. I would second this: Apache POI is really solid, and has support for old and new (MSXML) office formats, as of the 3.5 beta. JInterface is also rather pain-free, so it's not a bad route at all. From magnus@REDACTED Fri Apr 17 17:54:08 2009 From: magnus@REDACTED (Magnus Henoch) Date: Fri, 17 Apr 2009 16:54:08 +0100 Subject: [erlang-questions] Unbuffered/blocking gen_tcp send References: <49E88046.5070603@sidvind.com> <20090417141605.GA6058@contorpis.lisalinda.com> Message-ID: <84d4bb8ee7.fsf@linux-b2a3.site> Matthias Lang writes: > TCP has flow control, but it can't be controlled at the fine level you > would like it to, i.e. down to whether a given "packet" has been > received by an application at the other end or not. Actually, it can. The receiver acknowledges to the sender exactly which bytes have been received. However, I don't know of any TCP implementation that makes that information available to the programmer... -- Magnus Henoch, magnus@REDACTED Erlang Training and Consulting http://www.erlang-consulting.com/ From bqt@REDACTED Fri Apr 17 18:38:49 2009 From: bqt@REDACTED (Johnny Billquist) Date: Fri, 17 Apr 2009 18:38:49 +0200 Subject: [erlang-questions] Unbuffered/blocking gen_tcp send In-Reply-To: <84d4bb8ee7.fsf@linux-b2a3.site> References: <49E88046.5070603@sidvind.com> <20090417141605.GA6058@contorpis.lisalinda.com> <84d4bb8ee7.fsf@linux-b2a3.site> Message-ID: <49E8B099.8060809@softjar.se> Magnus Henoch wrote: > Matthias Lang writes: > >> TCP has flow control, but it can't be controlled at the fine level you >> would like it to, i.e. down to whether a given "packet" has been >> received by an application at the other end or not. > > Actually, it can. The receiver acknowledges to the sender exactly which > bytes have been received. However, I don't know of any TCP > implementation that makes that information available to the > programmer... Actually, no. The received ack information in TCP do not tell which bytes have been received by the program at the other end, only that they have arrived to the TCP stack at the other end. It means that they are available for the program at the other end, but wether or not that program actually have recevied them you can't tell. Johnny -- Johnny Billquist || "I'm on a bus || on a psychedelic trip email: bqt@REDACTED || Reading murder books pdp is alive! || tryin' to stay hip" - B. Idol From per@REDACTED Fri Apr 17 20:59:49 2009 From: per@REDACTED (Per Hedeland) Date: Fri, 17 Apr 2009 20:59:49 +0200 (CEST) Subject: [erlang-questions] Unbuffered/blocking gen_tcp send In-Reply-To: <49E8B099.8060809@softjar.se> Message-ID: <200904171859.n3HIxnei060575@pluto.hedeland.org> Johnny Billquist wrote: > >Magnus Henoch wrote: >> Matthias Lang writes: >> >>> TCP has flow control, but it can't be controlled at the fine level you >>> would like it to, i.e. down to whether a given "packet" has been >>> received by an application at the other end or not. >> >> Actually, it can. The receiver acknowledges to the sender exactly which >> bytes have been received. However, I don't know of any TCP >> implementation that makes that information available to the >> programmer... > >Actually, no. The received ack information in TCP do not tell which >bytes have been received by the program at the other end, only that they >have arrived to the TCP stack at the other end. It means that they are >available for the program at the other end, but wether or not that >program actually have recevied them you can't tell. Not to mention that while the ack gives the last byte successfully received, you obviously don't ack every byte individually. And "delayed ack" is standard/required functionality in TCP since forever. In combination with Nagle, this means that if you send 100 bytes, you may have to wait for an effective eternity before you see the ack. But of course the standard Erlang slogan "add another process" applies here too. Implementing a "block-until-received-send" abstraction on top of gen_tcp by means of user-level acks should amount to one process and on the order of 10 lines of code at each end. On a more general note, it seems the discussions about gen_tcp/gen_udp usage on this list generally involve people that either have absolutely no idea how the underlying protocols work, or that delve into the most obscure implementation details (I'll confess to being guilty of the latter). Occasionally I wonder if Erlang/OTP makes IP networking too easy - if you had to populate some weird record with carefully byte-ordered data and call half a dozen obscure functions before any data would travel over the net, maybe people would make some effort to understand what they were doing.:-) (Or just copy someone else's incantations as "pure gospel, no questions asked".:-) --Per From valentin@REDACTED Fri Apr 17 23:50:59 2009 From: valentin@REDACTED (Valentin Micic) Date: Fri, 17 Apr 2009 23:50:59 +0200 Subject: [erlang-questions] gen_sctp on Windows Message-ID: <1E7388E772CA4B8F98150DF12D0D81BC@moneymaker2> Hi all, Has anyone magaged to make gen_sctp work on (win|lose)dows? V. From saleyn@REDACTED Sat Apr 18 01:50:30 2009 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 17 Apr 2009 19:50:30 -0400 Subject: [erlang-questions] gen_sctp on Windows In-Reply-To: <1E7388E772CA4B8F98150DF12D0D81BC@moneymaker2> References: <1E7388E772CA4B8F98150DF12D0D81BC@moneymaker2> Message-ID: <49E915C6.4000503@gmail.com> Currently this is not possible because Windows doesn't have native support for SCTP (at least it didn't at the time we wrote the SCTP driver) and the inet_drv.c driver is based on the socket SCTP API implemented by linux/solaris. Serge Valentin Micic wrote: > Hi all, > > Has anyone magaged to make gen_sctp work on (win|lose)dows? > > V. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From thatsnotright@REDACTED Sat Apr 18 01:58:54 2009 From: thatsnotright@REDACTED (Rob Elsner) Date: Fri, 17 Apr 2009 17:58:54 -0600 Subject: [erlang-questions] Using sigwait in linked driver causes erl_ddll:load to return {error, {open_error, -10}} Message-ID: Greetings, I've been tinkering with the Linux timer API (following the examples given by the rt-tests programs) and a simple linked driver with Erlang. This is my first foray into each of these, so forgive me if I'm over looking something simple. I'm using Gentoo Linux localhost 2.6.27-gentoo-r8 #4 SMP PREEMPT Fri Apr 17 08:19:37 MDT 2009 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 5000+ AuthenticAMD GNU/Linux as well as erl Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [smp:2] [async-threads:0] [hipe] (I've tested with and without hipe) What I've found is that if I comment out my use of sigwait (which is in the process handler), erl_ddll:load will return ok. If I leave this in, erl_ddll:load returns -10 status. Has anyone seen something like this? Does anyone have more useful ideas how I can figure out why it's failing? I was assuming a library mismatch but I can't figure out what, and I even leave in other sig* functions (such as sigemptyset and sigprocmask). I build with -fPIC -lrt -m64 -shared Thanks in advance, Rob Elsner Here's a quick strace of the output: 11683 getcwd("/home/me/workspace/timer/timer_test/ebin"..., 8191) = 38 11683 open("./timer_drv.so", O_RDONLY) = 7 11683 read(7, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\n\0\0\0\0\0\0@"..., 832) = 832 11683 fstat(7, {st_mode=S_IFREG|0755, st_size=12728, ...}) = 0 11683 getcwd("/home/me/workspace/timer/timer_test/ebin"..., 128) = 38 11683 mmap(NULL, 2105776, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 7, 0) = 0x7fa7b62b8000 11683 mprotect(0x7fa7b62ba000, 2093056, PROT_NONE) = 0 11683 mmap(0x7fa7b64b9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 7, 0x1000) = 0x7fa7b64b9000 11683 close(7) = 0 11683 munmap(0x7fa7b62b8000, 2105776) = 0 11683 clock_gettime(CLOCK_MONOTONIC, {8538, 165029854}) = 0 11683 write(4, "!"..., 1) = 1 11684 <... poll resumed> ) = 1 ([{fd=3, revents=POLLIN|POLLRDNORM}]) 11684 read(3, 11683 ioctl(0, TIOCGWINSZ 11684 <... read resumed> "!"..., 32) = 1 11683 <... ioctl resumed> , {ws_row=48, ws_col=247, ws_xpixel=1486, ws_ypixel=628}) = 0 11684 read(3, 0x4350e6f0, 32) = -1 EAGAIN (Resource temporarily unavailable) 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 168957734}) = 0 11683 getcwd( 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 170047654}) = 0 11683 <... getcwd resumed> "/home/me/workspace/timer/timer_test/ebin"..., 8191) = 38 11684 poll([{fd=3, events=POLLIN|POLLRDNORM}, {fd=0, events=POLLIN|POLLRDNORM}], 2, 3593783 11683 stat("/home/me/workspace/timer/timer_test/ebin/./io_lib_pretty.beam", 0x42d0dd20) = -1 ENOENT (No such file or directory) 11683 open("/home/me/workspace/timer/timer_test/ebin/./io_lib_pretty.beam", O_RDONLY) = -1 ENOENT (No such file or directory) 11683 stat("/usr/lib64/erlang/lib/kernel-2.12.5/ebin/io_lib_pretty.beam", 0x42d0dd20) = -1 ENOENT (No such file or directory) 11683 open("/usr/lib64/erlang/lib/kernel-2.12.5/ebin/io_lib_pretty.beam", O_RDONLY) = -1 ENOENT (No such file or directory) 11683 stat("/usr/lib64/erlang/lib/stdlib-1.15.5/ebin/io_lib_pretty.beam", {st_mode=S_IFREG|0644, st_size=27804, ...}) = 0 11683 open("/usr/lib64/erlang/lib/stdlib-1.15.5/ebin/io_lib_pretty.beam", O_RDONLY) = 7 11683 read(7, "FOR1\0\0l\224BEAMAtom\0\0\3|\0\0\0^\rio_lib_p"..., 27804) = 27804 11683 close(7) = 0 11683 getcwd("/home/me/workspace/timer/timer_test/ebin"..., 8191) = 38 11683 write(4, "!"..., 1 11684 <... poll resumed> ) = 1 ([{fd=3, revents=POLLIN|POLLRDNORM}]) 11684 read(3, "!"..., 32) = 1 11684 read(3, 0x4350e6f0, 32) = -1 EAGAIN (Resource temporarily unavailable) 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 194262414}) = 0 11684 futex(0x89bc40, FUTEX_WAIT, 2, NULL 11683 <... write resumed> ) = 1 11683 futex(0x89bc40, FUTEX_WAKE, 1 11684 <... futex resumed> ) = 0 11684 futex(0x89bc40, FUTEX_WAKE, 1) = 0 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 197150974}) = 0 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 197823334}) = 0 11684 poll([{fd=3, events=POLLIN|POLLRDNORM}, {fd=0, events=POLLIN|POLLRDNORM}], 2, 3593755 11683 <... futex resumed> ) = 1 11683 write(0, "{error,{open_error,-10}}"..., 24) = 24 From thatsnotright@REDACTED Sat Apr 18 02:00:47 2009 From: thatsnotright@REDACTED (Rob Elsner) Date: Fri, 17 Apr 2009 18:00:47 -0600 Subject: [erlang-questions] Using sigwait in linked driver causes erl_ddll:load to return {error, {open_error, -10}} Message-ID: Greetings, I've been tinkering with the Linux timer API (following the examples given by the rt-tests programs) and a simple linked driver with Erlang. This is my first foray into each of these, so forgive me if I'm over looking something simple. I'm using Gentoo Linux localhost 2.6.27-gentoo-r8 #4 SMP PREEMPT Fri Apr 17 08:19:37 MDT 2009 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 5000+ AuthenticAMD GNU/Linux as well as erl Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [smp:2] [async-threads:0] [hipe] (I've tested with and without hipe) What I've found is that if I comment out my use of sigwait (which is in the process handler), erl_ddll:load will return ok. If I leave this in, erl_ddll:load returns -10 status. Has anyone seen something like this? Does anyone have more useful ideas how I can figure out why it's failing? I was assuming a library mismatch but I can't figure out what, and I even leave in other sig* functions (such as sigemptyset and sigprocmask). I build with -fPIC -lrt -m64 -shared Thanks in advance, Rob Elsner Here's a quick strace of the output: 11683 getcwd("/home/me/workspace/timer/timer_test/ebin"..., 8191) = 38 11683 open("./timer_drv.so", O_RDONLY) = 7 11683 read(7, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\n\0\0\0\0\0\0@"..., 832) = 832 11683 fstat(7, {st_mode=S_IFREG|0755, st_size=12728, ...}) = 0 11683 getcwd("/home/me/workspace/timer/timer_test/ebin"..., 128) = 38 11683 mmap(NULL, 2105776, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 7, 0) = 0x7fa7b62b8000 11683 mprotect(0x7fa7b62ba000, 2093056, PROT_NONE) = 0 11683 mmap(0x7fa7b64b9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 7, 0x1000) = 0x7fa7b64b9000 11683 close(7) = 0 11683 munmap(0x7fa7b62b8000, 2105776) = 0 11683 clock_gettime(CLOCK_MONOTONIC, {8538, 165029854}) = 0 11683 write(4, "!"..., 1) = 1 11684 <... poll resumed> ) = 1 ([{fd=3, revents=POLLIN|POLLRDNORM}]) 11684 read(3, 11683 ioctl(0, TIOCGWINSZ 11684 <... read resumed> "!"..., 32) = 1 11683 <... ioctl resumed> , {ws_row=48, ws_col=247, ws_xpixel=1486, ws_ypixel=628}) = 0 11684 read(3, 0x4350e6f0, 32) = -1 EAGAIN (Resource temporarily unavailable) 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 168957734}) = 0 11683 getcwd( 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 170047654}) = 0 11683 <... getcwd resumed> "/home/me/workspace/timer/timer_test/ebin"..., 8191) = 38 11684 poll([{fd=3, events=POLLIN|POLLRDNORM}, {fd=0, events=POLLIN|POLLRDNORM}], 2, 3593783 11683 stat("/home/me/workspace/timer/timer_test/ebin/./io_lib_pretty.beam", 0x42d0dd20) = -1 ENOENT (No such file or directory) 11683 open("/home/me/workspace/timer/timer_test/ebin/./io_lib_pretty.beam", O_RDONLY) = -1 ENOENT (No such file or directory) 11683 stat("/usr/lib64/erlang/lib/kernel-2.12.5/ebin/io_lib_pretty.beam", 0x42d0dd20) = -1 ENOENT (No such file or directory) 11683 open("/usr/lib64/erlang/lib/kernel-2.12.5/ebin/io_lib_pretty.beam", O_RDONLY) = -1 ENOENT (No such file or directory) 11683 stat("/usr/lib64/erlang/lib/stdlib-1.15.5/ebin/io_lib_pretty.beam", {st_mode=S_IFREG|0644, st_size=27804, ...}) = 0 11683 open("/usr/lib64/erlang/lib/stdlib-1.15.5/ebin/io_lib_pretty.beam", O_RDONLY) = 7 11683 read(7, "FOR1\0\0l\224BEAMAtom\0\0\3|\0\0\0^\rio_lib_p"..., 27804) = 27804 11683 close(7) = 0 11683 getcwd("/home/me/workspace/timer/timer_test/ebin"..., 8191) = 38 11683 write(4, "!"..., 1 11684 <... poll resumed> ) = 1 ([{fd=3, revents=POLLIN|POLLRDNORM}]) 11684 read(3, "!"..., 32) = 1 11684 read(3, 0x4350e6f0, 32) = -1 EAGAIN (Resource temporarily unavailable) 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 194262414}) = 0 11684 futex(0x89bc40, FUTEX_WAIT, 2, NULL 11683 <... write resumed> ) = 1 11683 futex(0x89bc40, FUTEX_WAKE, 1 11684 <... futex resumed> ) = 0 11684 futex(0x89bc40, FUTEX_WAKE, 1) = 0 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 197150974}) = 0 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 197823334}) = 0 11684 poll([{fd=3, events=POLLIN|POLLRDNORM}, {fd=0, events=POLLIN|POLLRDNORM}], 2, 3593755 11683 <... futex resumed> ) = 1 11683 write(0, "{error,{open_error,-10}}"..., 24) = 24 From saleyn@REDACTED Sat Apr 18 02:39:58 2009 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 17 Apr 2009 20:39:58 -0400 Subject: [erlang-questions] gen_sctp on Windows In-Reply-To: References: <1E7388E772CA4B8F98150DF12D0D81BC@moneymaker2> <49E915C6.4000503@gmail.com> Message-ID: <49E9215E.3000408@gmail.com> I am nearly 100% that if you buy some 3rd party SCTP library for windows (though I am not aware of any open-source ones), it would have support for standard SCTP socket API (*). In that case it might be sufficient just to patch the inet_drv's configure/Makefile to add SCTP support for windows. Serge (*) http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13 Valentin Micic wrote: > I understand, thank you. > In theory at least, it should be possible to achieve this via some form > of SCTP dll. Or am I way off the mark? > Mind you, it doesn't need to be perfect -- our production is on Solaris > and Linux. We only develop & unit test on Windoze... > > V. > ----- Original Message ----- From: "Serge Aleynikov" > To: "Valentin Micic" > Cc: > Sent: Saturday, April 18, 2009 1:50 AM > Subject: Re: [erlang-questions] gen_sctp on Windows > > >> Currently this is not possible because Windows doesn't have native >> support for SCTP (at least it didn't at the time we wrote the SCTP >> driver) and the inet_drv.c driver is based on the socket SCTP API >> implemented by linux/solaris. >> >> Serge >> >> Valentin Micic wrote: >>> Hi all, >>> >>> Has anyone magaged to make gen_sctp work on (win|lose)dows? >>> >>> V. >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> > > From justin.giancola@REDACTED Sat Apr 18 04:04:27 2009 From: justin.giancola@REDACTED (Justin Giancola) Date: Fri, 17 Apr 2009 22:04:27 -0400 Subject: [erlang-questions] simple_logger error in Joe Armstrong's Thesis Message-ID: <688f5b410904171904m17906ce0t9a5adacb9032130@mail.gmail.com> Hello, I've been reading through Joe's thesis (http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf), and in the supervisor example (6.5.2) he comments that there was an unmentioned error in the simple_logger.erl listing. Now, not only did I not notice this error when reading simple_logger.erl the first time around, but even under close examination I can't for the life of me figure out what it is. Would someone with a sharper eye be kind enough to point it out? The listing is Figure 6.2 on page 142 of the thesis (and page 153 of the .pdf linked above). Thanks, Justin From valentin@REDACTED Sat Apr 18 02:14:47 2009 From: valentin@REDACTED (Valentin Micic) Date: Sat, 18 Apr 2009 02:14:47 +0200 Subject: [erlang-questions] gen_sctp on Windows References: <1E7388E772CA4B8F98150DF12D0D81BC@moneymaker2> <49E915C6.4000503@gmail.com> Message-ID: I understand, thank you. In theory at least, it should be possible to achieve this via some form of SCTP dll. Or am I way off the mark? Mind you, it doesn't need to be perfect -- our production is on Solaris and Linux. We only develop & unit test on Windoze... V. ----- Original Message ----- From: "Serge Aleynikov" To: "Valentin Micic" Cc: Sent: Saturday, April 18, 2009 1:50 AM Subject: Re: [erlang-questions] gen_sctp on Windows > Currently this is not possible because Windows doesn't have native support > for SCTP (at least it didn't at the time we wrote the SCTP driver) and the > inet_drv.c driver is based on the socket SCTP API implemented by > linux/solaris. > > Serge > > Valentin Micic wrote: >> Hi all, >> >> Has anyone magaged to make gen_sctp work on (win|lose)dows? >> >> V. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From vychodil.hynek@REDACTED Sat Apr 18 09:38:15 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Sat, 18 Apr 2009 09:38:15 +0200 Subject: [erlang-questions] Using sigwait in linked driver causes erl_ddll:load to return {error, {open_error, -10}} In-Reply-To: References: Message-ID: <4d08db370904180038n2dfcc170g16927c562c7973b4@mail.gmail.com> Signal handling is at per process handling in Linux (in *nix systems generally). IMHO it is wrong idea using it in linked-in drivers at all. You will end up with unmaintainable mess because each change in signal handling in erts or any other linked-in driver will break whole system. >From man page: sigwait suspends the calling thread until one of the signals in set is delivered to the calling thread. It then stores the number of the signal received in the location pointed to by sig and returns. The signals in set must be blocked and not ignored on entrance to sigwait. If the delivered signal has a signal handler function attached, that function is not called. As you can see, you can easily break things there. For example may be you wait for same signal which is vital for erl_ddll:load or any other part of erts. On Sat, Apr 18, 2009 at 2:00 AM, Rob Elsner wrote: > Greetings, > > I've been tinkering with the Linux timer API (following the examples > given by the rt-tests programs) and a simple linked driver with > Erlang. This is my first foray into each of these, so forgive me if > I'm over looking something simple. > > I'm using Gentoo Linux localhost 2.6.27-gentoo-r8 #4 SMP PREEMPT Fri > Apr 17 08:19:37 MDT 2009 x86_64 AMD Athlon(tm) 64 X2 Dual Core > Processor 5000+ AuthenticAMD GNU/Linux > > as well as erl Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] > [smp:2] [async-threads:0] [hipe] (I've tested with and without hipe) > > What I've found is that if I comment out my use of sigwait (which is > in the process handler), erl_ddll:load will return ok. If I leave > this in, erl_ddll:load returns -10 status. > > Has anyone seen something like this? Does anyone have more useful > ideas how I can figure out why it's failing? I was assuming a library > mismatch but I can't figure out what, and I even leave in other sig* > functions (such as sigemptyset and sigprocmask). > > I build with -fPIC -lrt -m64 -shared > > Thanks in advance, > Rob Elsner > > Here's a quick strace of the output: > > 11683 getcwd("/home/me/workspace/timer/timer_test/ebin"..., 8191) = 38 > 11683 open("./timer_drv.so", O_RDONLY) = 7 > 11683 read(7, > "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\n\0\0\0\0\0\0@"..., > 832) = 832 > 11683 fstat(7, {st_mode=S_IFREG|0755, st_size=12728, ...}) = 0 > 11683 getcwd("/home/me/workspace/timer/timer_test/ebin"..., 128) = 38 > 11683 mmap(NULL, 2105776, PROT_READ|PROT_EXEC, > MAP_PRIVATE|MAP_DENYWRITE, 7, 0) = 0x7fa7b62b8000 > 11683 mprotect(0x7fa7b62ba000, 2093056, PROT_NONE) = 0 > 11683 mmap(0x7fa7b64b9000, 8192, PROT_READ|PROT_WRITE, > MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 7, 0x1000) = 0x7fa7b64b9000 > 11683 close(7) = 0 > 11683 munmap(0x7fa7b62b8000, 2105776) = 0 > 11683 clock_gettime(CLOCK_MONOTONIC, {8538, 165029854}) = 0 > 11683 write(4, "!"..., 1) = 1 > 11684 <... poll resumed> ) = 1 ([{fd=3, > revents=POLLIN|POLLRDNORM}]) > 11684 read(3, > 11683 ioctl(0, TIOCGWINSZ > 11684 <... read resumed> "!"..., 32) = 1 > 11683 <... ioctl resumed> , {ws_row=48, ws_col=247, ws_xpixel=1486, > ws_ypixel=628}) = 0 > 11684 read(3, 0x4350e6f0, 32) = -1 EAGAIN (Resource > temporarily unavailable) > 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 168957734}) = 0 > 11683 getcwd( > 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 170047654}) = 0 > 11683 <... getcwd resumed> > "/home/me/workspace/timer/timer_test/ebin"..., 8191) = 38 > 11684 poll([{fd=3, events=POLLIN|POLLRDNORM}, {fd=0, > events=POLLIN|POLLRDNORM}], 2, 3593783 > 11683 stat("/home/me/workspace/timer/timer_test/ebin/./io_lib_pretty.beam", > 0x42d0dd20) = -1 ENOENT (No such file or directory) > 11683 open("/home/me/workspace/timer/timer_test/ebin/./io_lib_pretty.beam", > O_RDONLY) = -1 ENOENT (No such file or directory) > 11683 stat("/usr/lib64/erlang/lib/kernel-2.12.5/ebin/io_lib_pretty.beam", > 0x42d0dd20) = -1 ENOENT (No such file or directory) > 11683 open("/usr/lib64/erlang/lib/kernel-2.12.5/ebin/io_lib_pretty.beam", > O_RDONLY) = -1 ENOENT (No such file or directory) > 11683 stat("/usr/lib64/erlang/lib/stdlib-1.15.5/ebin/io_lib_pretty.beam", > {st_mode=S_IFREG|0644, st_size=27804, ...}) = 0 > 11683 open("/usr/lib64/erlang/lib/stdlib-1.15.5/ebin/io_lib_pretty.beam", > O_RDONLY) = 7 > 11683 read(7, "FOR1\0\0l\224BEAMAtom\0\0\3|\0\0\0^\rio_lib_p"..., 27804) = > 27804 > 11683 close(7) = 0 > 11683 getcwd("/home/me/workspace/timer/timer_test/ebin"..., 8191) = 38 > 11683 write(4, "!"..., 1 > 11684 <... poll resumed> ) = 1 ([{fd=3, > revents=POLLIN|POLLRDNORM}]) > 11684 read(3, "!"..., 32) = 1 > 11684 read(3, 0x4350e6f0, 32) = -1 EAGAIN (Resource > temporarily unavailable) > 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 194262414}) = 0 > 11684 futex(0x89bc40, FUTEX_WAIT, 2, NULL > 11683 <... write resumed> ) = 1 > 11683 futex(0x89bc40, FUTEX_WAKE, 1 > 11684 <... futex resumed> ) = 0 > 11684 futex(0x89bc40, FUTEX_WAKE, 1) = 0 > 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 197150974}) = 0 > 11684 clock_gettime(CLOCK_MONOTONIC, {8538, 197823334}) = 0 > 11684 poll([{fd=3, events=POLLIN|POLLRDNORM}, {fd=0, > events=POLLIN|POLLRDNORM}], 2, 3593755 > 11683 <... futex resumed> ) = 1 > 11683 write(0, "{error,{open_error,-10}}"..., 24) = 24 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon@REDACTED Sat Apr 18 11:49:19 2009 From: gordon@REDACTED (Gordon Guthrie) Date: Sat, 18 Apr 2009 10:49:19 +0100 Subject: [erlang-questions] RegExp Behaviour Message-ID: Folks This looks like a bug to me, but after many years regexp still gives me the creeps :( > regexp:gsub("abcde", "c", "x"). {ok, "abxde", 1} One substitution, new string, tickety-boo! > regexp:gsub("ab:de", ":", "&"). {ok, "ab:de", 1} One substitution, but the old string, erk? Gordon -------------- next part -------------- An HTML attachment was scrubbed... URL: From bernie@REDACTED Sat Apr 18 12:28:00 2009 From: bernie@REDACTED (Bernard Duggan) Date: Sat, 18 Apr 2009 20:28:00 +1000 Subject: [erlang-questions] RegExp Behaviour In-Reply-To: References: Message-ID: <49E9AB30.5090102@m5net.com> I'd say it's behaving just fine. Check the documentation for regexp:sub(). "A & in the string New is replaced by the matched substring of String." Cheers, B Gordon Guthrie wrote: > Folks > This looks like a bug to me, but after many years regexp still gives me the > creeps :( > >> regexp:gsub("abcde", "c", "x"). > {ok, "abxde", 1} > > One substitution, new string, tickety-boo! > >> regexp:gsub("ab:de", ":", "&"). > {ok, "ab:de", 1} > > One substitution, but the old string, erk? > > Gordon > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From harveyd@REDACTED Sat Apr 18 12:37:33 2009 From: harveyd@REDACTED (Dale Harvey) Date: Sat, 18 Apr 2009 11:37:33 +0100 Subject: [erlang-questions] RegExp Behaviour In-Reply-To: References: Message-ID: regexp:gsub("ab:de", ":", "\\&"). & replaces the match with the substring of the match, so it was just replacing c with c regexp is deprecated though, and will probably be taken out the release after the one next week. 2009/4/18 Gordon Guthrie > Folks > This looks like a bug to me, but after many years regexp still gives me the > creeps :( > > > regexp:gsub("abcde", "c", "x"). > {ok, "abxde", 1} > > One substitution, new string, tickety-boo! > > > regexp:gsub("ab:de", ":", "&"). > {ok, "ab:de", 1} > > One substitution, but the old string, erk? > > Gordon > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon@REDACTED Sat Apr 18 12:42:09 2009 From: gordon@REDACTED (Gordon Guthrie) Date: Sat, 18 Apr 2009 11:42:09 +0100 Subject: [erlang-questions] RegExp Behaviour In-Reply-To: <49E9AB30.5090102@m5net.com> References: <49E9AB30.5090102@m5net.com> Message-ID: B How embarrassing, I read the documentation for gsub, and read and re-read the regexp character stuff elsewhere in the documentation, but didn't read what was staring me in the face... However, on reading it, the phrase: "A & in the string New is replaced by the matched substring of String." leaves me completely bemused. 'on doing a substitution, don't'. I suppose it could have some 'flow of control use'? G On Sat, Apr 18, 2009 at 11:28 AM, Bernard Duggan wrote: > I'd say it's behaving just fine. Check the documentation for > regexp:sub(). "A & in the string New is replaced by the matched > substring of String." > > Cheers, > > B > > Gordon Guthrie wrote: > > Folks > > This looks like a bug to me, but after many years regexp still gives me > the > > creeps :( > > > >> regexp:gsub("abcde", "c", "x"). > > {ok, "abxde", 1} > > > > One substitution, new string, tickety-boo! > > > >> regexp:gsub("ab:de", ":", "&"). > > {ok, "ab:de", 1} > > > > One substitution, but the old string, erk? > > > > Gordon > > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bqt@REDACTED Sat Apr 18 14:06:02 2009 From: bqt@REDACTED (Johnny Billquist) Date: Sat, 18 Apr 2009 14:06:02 +0200 Subject: [erlang-questions] RegExp Behaviour In-Reply-To: References: <49E9AB30.5090102@m5net.com> Message-ID: <49E9C22A.3030408@softjar.se> Well, youre not thinking big enough. :-) How about regexp:gsub("foobarquux","o","&x"). Ie. append an "x" after each "o". Just as a small, stupid example of when "&" might be used/useful. Johnny Gordon Guthrie wrote: > B > > How embarrassing, I read the documentation for gsub, and read and > re-read the regexp character stuff elsewhere in the documentation, but > didn't read what was staring me in the face... > > However, on reading it, the phrase: > > "A & in the string New is replaced by the matched > substring of String." > > leaves me completely bemused. 'on doing a substitution, don't'. > > I suppose it could have some 'flow of control use'? > > G > > On Sat, Apr 18, 2009 at 11:28 AM, Bernard Duggan > wrote: > > I'd say it's behaving just fine. Check the documentation for > regexp:sub(). "A & in the string New is replaced by the matched > substring of String." > > Cheers, > > B > > Gordon Guthrie wrote: > > Folks > > This looks like a bug to me, but after many years regexp still > gives me the > > creeps :( > > > >> regexp:gsub("abcde", "c", "x"). > > {ok, "abxde", 1} > > > > One substitution, new string, tickety-boo! > > > >> regexp:gsub("ab:de", ":", "&"). > > {ok, "ab:de", 1} > > > > One substitution, but the old string, erk? > > > > Gordon > > > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Johnny Billquist || "I'm on a bus || on a psychedelic trip email: bqt@REDACTED || Reading murder books pdp is alive! || tryin' to stay hip" - B. Idol From gamoto@REDACTED Sat Apr 18 14:52:56 2009 From: gamoto@REDACTED (Gamoto) Date: Sat, 18 Apr 2009 14:52:56 +0200 Subject: [erlang-questions] two problems with erlide Message-ID: <200904181452558247516@bluewin.ch> Hi, I have just installed Eclipse 3.4.2 and Erlide 0.5.0 I followed the Erlide documentation (I believe ...) and now I try to run the "hello_world" example. 1) I have the message "could not compile file" , type "erlang problem" the hello_world.erl file has a small cross on a red background. 2) the syntax coloring seems to not be activated. How to enable it ? windows->preferences->erlang->syntax coloring: enable has no effect for me ! John From thatsnotright@REDACTED Sat Apr 18 15:49:18 2009 From: thatsnotright@REDACTED (Rob Elsner) Date: Sat, 18 Apr 2009 07:49:18 -0600 Subject: [erlang-questions] Using sigwait in linked driver causes erl_ddll:load to return {error, {open_error, -10}} In-Reply-To: <4d08db370904180038n2dfcc170g16927c562c7973b4@mail.gmail.com> References: <4d08db370904180038n2dfcc170g16927c562c7973b4@mail.gmail.com> Message-ID: Hynek, > Signal handling is at per process handling in Linux (in *nix systems > generally). IMHO it is wrong idea using it in linked-in drivers at all. You > will end up with unmaintainable mess because each change in signal handling > in erts or any other linked-in driver will break whole system. That's fine that you think it's the wrong idea, but it's one of the few ways to get high resolution timers. I chose a linked in driver because of the reduced communication overhead back to an erlang process. The sigwait is not called until a process actually uses the port for the driver, all of the other setup is done identically. If I leave sigwait uncommented, it won't load. If I comment out just that line, the driver loads correctly. Thanks, Rob From thatsnotright@REDACTED Sat Apr 18 15:53:59 2009 From: thatsnotright@REDACTED (Rob Elsner) Date: Sat, 18 Apr 2009 07:53:59 -0600 Subject: [erlang-questions] two problems with erlide In-Reply-To: <200904181452558247516@bluewin.ch> References: <200904181452558247516@bluewin.ch> Message-ID: On your project, right click and select "Toggle Erlang Nature" (if I recall the name correctly) Also, make sure it is really happy with the Erlang installation location you selected in the Preferences dialog. Rob From jeedward@REDACTED Sat Apr 18 16:03:17 2009 From: jeedward@REDACTED (John Edward) Date: Sat, 18 Apr 2009 07:03:17 -0700 (PDT) Subject: [erlang-questions] Extended draft paper submission: call for papers Message-ID: <877077.29412.qm@web45903.mail.sp1.yahoo.com> Extended draft paper submission: call for papers ? This Extended Call for Papers is for those who didn't get a chance to submit the papers for the earlier call for papers. The papers received and accepted in response to this extended call for papers will be included in the final version of the respective conference proceedings. These proceedings will be either ready by the time of the conference (i.e., they will be available during the conference) or soon after the conference (before the end of August 2009), based how fast the proceedings can be prepared. Note: If you have already submitted a paper (whether accepted or rejected or currently under review) for MULTICONF-09, please DO NOT submit that paper again to this extended call for papers. IMPORTANT DATES: Draft paper submission date: May 11, 2009 Acceptance/rejection decision: May 21, 2009 Camera ready paper and copyright and pre-registration due: May 28, 2009 Conference dates: July 13-16, 2009 ? The extended deadline for draft paper submission at the 2009 Multi Conference in Computer Science, Information Technology and Control systems and Computational Science and Computer Engineering (MULTICONF-09) (website: http://www.PromoteResearch.org) is just few weeks from now. We invite draft paper submissions. The event consists of the following conferences: ????????? International Conference on Artificial Intelligence and Pattern Recognition (AIPR-09) ????????? International Conference on Automation, Robotics and Control Systems (ARCS-09) ????????? International Conference on Bioinformatics, Computational Biology, Genomics and Chemoinformatics (BCBGC-09) ????????? International Conference on Enterprise Information Systems and Web Technologies (EISWT-09) ????????? International Conference on High Performance Computing, Networking and Communication Systems (HPCNCS-09) ????????? International Conference on Information Security and Privacy (ISP-09) ????????? International Conference on Recent Advances in Information Technology and Applications (RAITA-09) ????????? International Conference on Software Engineering Theory and Practice (SETP-09) ????????? International Conference on Theory and Applications of Computational Science (TACS-09) ????????? International Conference on Theoretical and Mathematical Foundations of Computer Science (TMFCS-09) ? The website http://www.PromoteResearch.org? contains more details. ? Sincerely John Edward Publicity committee ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve.kirsch@REDACTED Sat Apr 18 18:18:26 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Sat, 18 Apr 2009 09:18:26 -0700 Subject: [erlang-questions] index for lists and tuples? In-Reply-To: <24d4f39c0904170639g7d2878c1maca149183503ee23@mail.gmail.com> Message-ID: <76BB7F270C366D47AA79851BB0B39D81029452F1@exchg02.propel.com> Thanks for the reference. I agree with the poster who suggested lists:pos. There are times you really want this (such as in my case where other solutions would be more clunky) and the suggested lists:pos would be a natural way to do this. This seems like a surprising omission from an otherwise pretty complete set of functions. -----Original Message----- From: Colm Dougan [mailto:colm.dougan@REDACTED] On Fri, Apr 17, 2009 at 6:16 AM, Steve Kirsch wrote: > I am looking for an index function for lists and tuples that returns > the index of the first element that matches a query term. > > For example: > > index({a, b, c}, b) would return 2 > > index([a, b, c], c) would return 3 Steve, there is no such function in the general case but the subject was discussed in a recent thread : http://www.erlang.org/pipermail/erlang-questions/2008-November/040189.ht ml Colm From sandeepkampati@REDACTED Sat Apr 18 19:37:33 2009 From: sandeepkampati@REDACTED (sandeep_k) Date: Sat, 18 Apr 2009 10:37:33 -0700 (PDT) Subject: [erlang-questions] problem with pread,recursrsive func Message-ID: <23115395.post@talk.nabble.com> I has written a plug in tsung which read data from file and send though UDP Socket But when I crated 10 users per sec with 30 sec it is taking full memory when commented pread it is working properly How to avoid this problem , is this problem due to recursive function ? How to flush for Data buffer ? Read_send(Fd,Offset) -> Case File:pread(Fd,Offset,4096) of {ok,Data} -> I am send data using UDP socket NewOffset=Offset+4096, I will recursively call this function till 20Mb file is read Read(Fd,NewOffset); _ -> Error end -- View this message in context: http://www.nabble.com/problem-with-pread%2Crecursrsive-func-tp23115395p23115395.html Sent from the Erlang Questions mailing list archive at Nabble.com. From saleyn@REDACTED Sun Apr 19 00:53:32 2009 From: saleyn@REDACTED (Serge Aleynikov) Date: Sat, 18 Apr 2009 18:53:32 -0400 Subject: [erlang-questions] Using sigwait in linked driver causes erl_ddll:load to return {error, {open_error, -10}} In-Reply-To: References: <4d08db370904180038n2dfcc170g16927c562c7973b4@mail.gmail.com> Message-ID: <49EA59EC.7000902@gmail.com> Could you share with us how high resolution timers are related to sigwait? If your mere use of linked-in driver is to get access to high-res timers, the overhead of calling a function through a linked-in driver (that can take 5-10us) will defeat the purpose of high-res timers (that give nanosec resolution). Though up until FFI is embedded in the distribution this is the "fastest" existing interface. Serge Rob Elsner wrote: > Hynek, > >> Signal handling is at per process handling in Linux (in *nix systems >> generally). IMHO it is wrong idea using it in linked-in drivers at all. You >> will end up with unmaintainable mess because each change in signal handling >> in erts or any other linked-in driver will break whole system. > > That's fine that you think it's the wrong idea, but it's one of the > few ways to get high resolution timers. I chose a linked in driver > because of the reduced communication overhead back to an erlang > process. > > The sigwait is not called until a process actually uses the port for > the driver, all of the other setup is done identically. If I leave > sigwait uncommented, it won't load. If I comment out just that line, > the driver loads correctly. > > Thanks, > Rob > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From MARTIN.LOGAN@REDACTED Sun Apr 19 00:00:24 2009 From: MARTIN.LOGAN@REDACTED (Logan, Martin) Date: Sat, 18 Apr 2009 17:00:24 -0500 Subject: [erlang-questions] Distributing nodes and full awareness Message-ID: When net_kernel:connect_node/1 is called or net_adm:ping/1 or some such to establish a connection between nodes at some time subsequent to that connection all the nodes in the cloud of nodes will be known by the newly connected node. So, if node a connects to node b and b already knows about c and d then at some point shortly after the connection of node a node a will know about nodes b,c and d. How is this accomplished and what are the semantics. How can it be known when the transfer of all nodes in the system is completed. I notice that after a net adm ping nodes() returns a list of length n and 5 seconds later even though no new nodes have been added to the cloud it returns n + y. Can anyone save me the time of digging into the code to figure out the semantics here? Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From gamoto@REDACTED Sun Apr 19 02:27:04 2009 From: gamoto@REDACTED (Gamoto) Date: Sun, 19 Apr 2009 01:27:04 +0100 Subject: [erlang-questions] two problems with erlide References: <200904181452558247516@bluewin.ch>, Message-ID: <200904190127039232603@bluewin.ch> >On your project, right click and select "Toggle Erlang Nature" (if I >recall the name correctly) Nothing happens when I click Toggle Erlang Nature ... > >Also, make sure it is really happy with the Erlang installation >location you selected in the Preferences dialog. I entered the actual location of erlang: c:/program files/erl5.6.5 > >Rob From thatsnotright@REDACTED Sun Apr 19 01:29:28 2009 From: thatsnotright@REDACTED (Rob Elsner) Date: Sat, 18 Apr 2009 17:29:28 -0600 Subject: [erlang-questions] two problems with erlide In-Reply-To: <200904190127039232603@bluewin.ch> References: <200904181452558247516@bluewin.ch> <200904190127039232603@bluewin.ch> Message-ID: As a side note, did you use the full Eclipse download? The 300+MB modeling one? A coworker of mine has had trouble with Erlide and the minimal downloads (aka the C/C++, Java or PHP versions). > I entered the actual location of erlang: c:/program files/erl5.6.5 Does it generate .beam files automatically, at least? Rob From thatsnotright@REDACTED Sun Apr 19 01:26:33 2009 From: thatsnotright@REDACTED (Rob Elsner) Date: Sat, 18 Apr 2009 17:26:33 -0600 Subject: [erlang-questions] Using sigwait in linked driver causes erl_ddll:load to return {error, {open_error, -10}} In-Reply-To: <49EA59EC.7000902@gmail.com> References: <4d08db370904180038n2dfcc170g16927c562c7973b4@mail.gmail.com> <49EA59EC.7000902@gmail.com> Message-ID: Serge, > Could you share with us how high resolution timers are related to sigwait? > sigwait is then used to wait for that signal, at which point I would message the Erlang process. Is there a better way? I am not concerned about accurate timing of events, what I truly need is relatively accurate signaling to do work. In this case I am looking for reliable timers to generate UDP packets in the microsecond range. > If your mere use of linked-in driver is to get access to high-res timers, > the overhead of calling a function through a linked-in driver (that can take > 5-10us) will defeat the purpose of high-res timers (that give nanosec > resolution). Though up until FFI is embedded in the distribution this is > the "fastest" existing interface. When we did some testing with the Erlang built in timer server, the best we could mange reliably was 1 millisecond. If you look at the rt-tests http://www.kernel.org/pub/linux/kernel/people/tglx/rt-tests/ the cyclictest uses timer_create to generate a sigevent at a specified interval. On my hardware this provides a practical 10us timer interval. I are looking for ~100us interval timer resolution. Thanks, Rob From gamoto@REDACTED Sun Apr 19 02:04:35 2009 From: gamoto@REDACTED (Gamoto) Date: Sun, 19 Apr 2009 02:04:35 +0200 Subject: [erlang-questions] two problems with erlide References: <200904181452558247516@bluewin.ch>, , <200904190127039232603@bluewin.ch>, Message-ID: <200904190204356674475@bluewin.ch> I am using Eclipse-SDK-3.4.2-win32.zip (156Mb) no beams files After a restart, the cross on red background disappeared. But the module is never automatically compiled. >As a side note, did you use the full Eclipse download? The 300+MB >modeling one? A coworker of mine has had trouble with Erlide and the >minimal downloads (aka the C/C++, Java or PHP versions). > >> I entered the actual location of erlang: c:/program files/erl5.6.5 > >Does it generate .beam files automatically, at least? > >Rob From matthias@REDACTED Sun Apr 19 09:38:02 2009 From: matthias@REDACTED (Matthias Lang) Date: Sun, 19 Apr 2009 09:38:02 +0200 Subject: [erlang-questions] index for lists and tuples? In-Reply-To: <76BB7F270C366D47AA79851BB0B39D81029452F1@exchg02.propel.com> References: <24d4f39c0904170639g7d2878c1maca149183503ee23@mail.gmail.com> <76BB7F270C366D47AA79851BB0B39D81029452F1@exchg02.propel.com> Message-ID: <20090419073802.GA3426@contorpis.lisalinda.com> On Saturday, April 18, Steve Kirsch wrote: > Thanks for the reference. I agree with the poster who suggested > lists:pos. > There are times you really want this (such as in my case where other > solutions would be more clunky) and the suggested lists:pos would be a > natural way to do this. Your original problem was: | In my case, I wanted to make a tuple of logging levels like {all, info, | warn, errors, none} and then I can compare the atom supplied by the log | request and compare its numeric index into this tuple to index value of | the requested logging level to determine whether to log or not. That's pretty much what I'd do if I was writing a C program. In Erlang, my first approach would be: %% Currently_logging is the subset of currently active logging levels, %% e.g. it might be [warn, errors, none] log({Level, Message}, Currently_logging) -> case lists:member(Level, Currently_logging) of true -> write_to_log(Message); _ -> ignore end. Going back to your python/C approach: you can see it as defining an an ordering of atoms, i.e. that 'all' is greater than 'info', etc. In C, you get that completely free because the integer representation of atoms (enums) is visible. In python, you're doing it by simulating a dictionary (map) with an array. So you could just use a dictionary, e.g. an orddict: Levels = [{all, 1}, {info, 2}, {warn, 3}, {errors, 4}, {none, 5}] That isn't pretty, but it's close to the python approach. Venturing on to thin ice, you could also just choose your logging atoms so that they have the order you want. If the levels are ['1_all', '2_info', '3_warn', '4_errors', '5_none'], the code becomes: log({Level, Message}, Currently_logging) when Level >= Currently_logging -> write_to_log(Message); log(_,_) -> ignore. those numbered atoms make it fairly obvious what you're up to. If you fancy fame among future maintainers, you could just choose logging levels which happen to be in the right order, e.g. [all, info, possible_error, sertain_error, zero_logs]. Compensating for that last thing, a cerious note: if you haven't already looked at Erlang's tracing mechanisms, i.e. erlang:trace(), now would be a good time. Tracing lets you solve a lot of problems you'd otherwise solve with logging. Matt p.s. while I'm at it: does Python even have something corresponding to atoms? From bbmaj7@REDACTED Sun Apr 19 12:59:01 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Sun, 19 Apr 2009 03:59:01 -0700 (PDT) Subject: [erlang-questions] memory leak. In-Reply-To: References: <4C87BF70-32B3-426E-9570-86712ED7A379@hates.ms> Message-ID: <804933.72432.qm@web65515.mail.ac4.yahoo.com> If your have processes which create large (or many) binaries then it may be the generational garbage collector taking too long to do a full sweep. If this is the case some small number of processes should grow very large. A combination of processes() and process_info() (eg. sort by heap_size) might provide some insight. You can interactively and harmlessly call garbage_collect(Pid) on suspects to find out - they should release what is unneeded and the change will show up in the erlang node VM size. If you find some class of process releases a lot after garbage_collect(Pid), try spawning those with {fullsweep_after,0}. See the hints in the documentation for spawn_opt/4. appmon might also be useful if the processes generally have long lifetimes. appmon allows you to use a GUI to examine the processes as they run. ----- Original Message ---- > I don't think, that a problem in process leak. > First restart count process: 8400, next: 13082, next 11110 > > > Chances are, a programming error on your part. > > > > The fact that you're getting "system_limit" errors when creating new > > processes leads me to believe that you might not have a memory leak > > per se, but a process leak. Meaning you are dynamically creating > > processes, but don't shut them down. > > > > You can find the number of processes on your node using > > > > length(processes()). > > > > Try to see if this number increases constantly during operation. Enjoy a better web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. From johanmunk@REDACTED Sun Apr 19 13:37:43 2009 From: johanmunk@REDACTED (johan munk) Date: Sun, 19 Apr 2009 13:37:43 +0200 Subject: [erlang-questions] HiPE issue Message-ID: Apparently, this message didn't get through. I experience that HiPE generates unsound code: ------------- -module(hmmm). -export([nooo/1]). nooo({Fst, List}) -> nooo([Fst | List]); nooo([_ | _]) -> ok. ------------- erlc +native hmmm.erl ------------- Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.6.5 (abort with ^G) 1> hmmm:nooo({sure, []}). When HiPE-compiled hmmm:nooo/1 loops on input matching the first clause. Without +native it returns 'ok' as expected. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikpe@REDACTED Sun Apr 19 15:46:21 2009 From: mikpe@REDACTED (Mikael Pettersson) Date: Sun, 19 Apr 2009 15:46:21 +0200 Subject: [erlang-questions] HiPE issue In-Reply-To: References: Message-ID: <18923.11053.196214.136262@pilspetsen.it.uu.se> johan munk writes: > Apparently, this message didn't get through. > > I experience that HiPE generates unsound code: > ------------- > > -module(hmmm). > -export([nooo/1]). > > nooo({Fst, List}) -> nooo([Fst | List]); > nooo([_ | _]) -> ok. > > ------------- > > erlc +native hmmm.erl > > ------------- > > Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.6.5 (abort with ^G) > 1> hmmm:nooo({sure, []}). > > > When HiPE-compiled hmmm:nooo/1 loops on input matching the first clause. > Without +native it returns 'ok' as expected. Confirmed with R13B prerelease on i686-pc-linux-gnu. I'll look into it. From kostis@REDACTED Sun Apr 19 15:45:49 2009 From: kostis@REDACTED (Kostis Sagonas) Date: Sun, 19 Apr 2009 16:45:49 +0300 Subject: [erlang-questions] HiPE issue In-Reply-To: References: Message-ID: <49EB2B0D.2000909@cs.ntua.gr> johan munk wrote: > Apparently, this message didn't get through. > > I experience that HiPE generates unsound code: > .... > > When HiPE-compiled hmmm:nooo/1 loops on input matching the first clause. > Without +native it returns 'ok' as expected. Thanks for your bug report. We will try to fix this soon. However, it unlikely the fix will make it to the R13B release. In the meantime, you can bypass this by compiling to native code using: erlc +native +'{hipe,[no_icode_ssa_struct_reuse]}' hmmm.erl Kostis From dennisbyrne@REDACTED Sun Apr 19 16:46:19 2009 From: dennisbyrne@REDACTED (Dennis Byrne) Date: Sun, 19 Apr 2009 09:46:19 -0500 Subject: [erlang-questions] receiving pang from net_adm:ping/1 even though net_adm:names/0 shows the other node Message-ID: <446564320904190746x5ee8825bk6c9d069f420b6f34@mail.gmail.com> Never had problem with this before but this is the first time I've used a Mac. Here's the info: >From console A ... $ erl -sname foo -setcookie c (foo@REDACTED)1> >From console B ... $ erl -name bar -setcookie c (bar@REDACTED)1> >From console C ... $ /usr/local/lib/erlang/erts-5.6.4/bin/epmd -names epmd: up and running on port 4369 with data: name bar at port 51292 name foo at port 51290 >From Console B ... (bar@REDACTED)1> net_adm:ping(bar@REDACTED). pong (bar@REDACTED)2> net_adm:ping(foo@REDACTED). pang (bar@REDACTED)3> net_adm:names(). {ok,[{"foo",51290},{"bar",51292}]} Note that the pang is received after the cursor hangs for a few seconds. The cursor does not hang when I type net_adm:ping(foo@REDACTED). -- Dennis Byrne From thatsnotright@REDACTED Sun Apr 19 17:35:38 2009 From: thatsnotright@REDACTED (Rob Elsner) Date: Sun, 19 Apr 2009 09:35:38 -0600 Subject: [erlang-questions] Using sigwait in linked driver causes erl_ddll:load to return {error, {open_error, -10}} In-Reply-To: <49EB3D5C.8030701@gmail.com> References: <4d08db370904180038n2dfcc170g16927c562c7973b4@mail.gmail.com> <49EA59EC.7000902@gmail.com> <49EB3D5C.8030701@gmail.com> Message-ID: Serge, > It is true that Erlang emulator doesn't have a good way of dealing with > sub-millisecond timers. ?I think Ulf Wigger touched on this topic in the > list some time back. I will have to find that email chain, to read it. I haven't seen too much on Erlang and timers, just little bits here and there. > If you happen to be using a linux kernel 2.6.22 or later you can use a more > fancy timer mechanism via timerfd syscall. ?This can create a timer file > descriptor that you can register with the emulator via driver_select call. > ?This timer will have microsecond precision. That is a great idea. I didn't know about the timerfd. I will try this approach first, since I'm out of ideas why calling sigwait makes loading fail but commenting out only sigwait makes my driver load. Thank you for the excellent suggestion, I knew someone out there would have a different approach. I'll post-back on here when I get that working. Rob From saleyn@REDACTED Sun Apr 19 16:40:49 2009 From: saleyn@REDACTED (Serge Aleynikov) Date: Sun, 19 Apr 2009 10:40:49 -0400 Subject: [erlang-questions] Distributing nodes and full awareness In-Reply-To: References: Message-ID: <49EB37F1.60509@gmail.com> The global name server (with help of global_group server if global name space is partitioned into global groups) maintains the fully interconnected mesh of nodes. If you don't desire to have this functionality enabled, you can disable it by passing "-connect_all false" to the emulator at startup. However this will inhibit the global name registration functionality. If you have a large network (such as one of the networks we have with somewhat 400 nodes), and still would like to take advantage of global name registration, you can partition the global name space (via {kernel, [{global_group, [{GroupName, Nodes}]}]} option), so that only a handful of "master" nodes maintains a fully connected mesh, and other "auxiliary" nodes connect to one (or some) nodes in the "master" ring. net_adm:ping(Node) uses net_kernel and global. If you need to make sure that all mesh connectivity is fully synchronous, you can call global:sync() prior to issuing net_adm:ping/1. Serge Logan, Martin wrote: > When net_kernel:connect_node/1 is called or net_adm:ping/1 or some such to establish a connection between nodes at some time subsequent to that connection all the nodes in the cloud of nodes will be known by the newly connected node. So, if node a connects to node b and b already knows about c and d then at some point shortly after the connection of node a node a will know about nodes b,c and d. How is this accomplished and what are the semantics. How can it be known when the transfer of all nodes in the system is completed. I notice that after a net adm ping nodes() returns a list of length n and 5 seconds later even though no new nodes have been added to the cloud it returns n + y. Can anyone save me the time of digging into the code to figure out the semantics here? > > Cheers, > Martin > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From saleyn@REDACTED Sun Apr 19 17:03:56 2009 From: saleyn@REDACTED (Serge Aleynikov) Date: Sun, 19 Apr 2009 11:03:56 -0400 Subject: [erlang-questions] Using sigwait in linked driver causes erl_ddll:load to return {error, {open_error, -10}} In-Reply-To: References: <4d08db370904180038n2dfcc170g16927c562c7973b4@mail.gmail.com> <49EA59EC.7000902@gmail.com> Message-ID: <49EB3D5C.8030701@gmail.com> It is true that Erlang emulator doesn't have a good way of dealing with sub-millisecond timers. I think Ulf Wigger touched on this topic in the list some time back. If you happen to be using a linux kernel 2.6.22 or later you can use a more fancy timer mechanism via timerfd syscall. This can create a timer file descriptor that you can register with the emulator via driver_select call. This timer will have microsecond precision. Serge Rob Elsner wrote: > Serge, > >> Could you share with us how high resolution timers are related to sigwait? >> > > sigwait is then used to wait for that signal, at which point I would > message the Erlang process. > > Is there a better way? I am not concerned about accurate timing of > events, what I truly need is relatively accurate signaling to do work. > In this case I am looking for reliable timers to generate UDP packets > in the microsecond range. > >> If your mere use of linked-in driver is to get access to high-res timers, >> the overhead of calling a function through a linked-in driver (that can take >> 5-10us) will defeat the purpose of high-res timers (that give nanosec >> resolution). Though up until FFI is embedded in the distribution this is >> the "fastest" existing interface. > > When we did some testing with the Erlang built in timer server, the > best we could mange reliably was 1 millisecond. If you look at the > rt-tests > http://www.kernel.org/pub/linux/kernel/people/tglx/rt-tests/ > > the cyclictest uses timer_create to generate a sigevent at a specified > interval. On my hardware this provides a practical 10us timer > interval. I are looking for ~100us interval timer resolution. > > Thanks, > Rob > From per.melin@REDACTED Sun Apr 19 18:54:10 2009 From: per.melin@REDACTED (Per Melin) Date: Sun, 19 Apr 2009 18:54:10 +0200 Subject: [erlang-questions] receiving pang from net_adm:ping/1 even though net_adm:names/0 shows the other node In-Reply-To: <446564320904190746x5ee8825bk6c9d069f420b6f34@mail.gmail.com> References: <446564320904190746x5ee8825bk6c9d069f420b6f34@mail.gmail.com> Message-ID: On Sun, Apr 19, 2009 at 4:46 PM, Dennis Byrne wrote: > >From console A ... > > $ erl -sname foo -setcookie c > (foo@REDACTED)1> > > >From console B ... > > $ erl -name bar -setcookie c > (bar@REDACTED)1> What if you don't start one node with -sname and the other with -name? From dennis@REDACTED Sun Apr 19 18:49:00 2009 From: dennis@REDACTED (Dennis Byrne) Date: Sun, 19 Apr 2009 11:49:00 -0500 Subject: [erlang-questions] receiving pang from net_adm:ping/1 even though net_adm:names/0 shows the other node (reposted) Message-ID: <446564320904190949o1988fb28vb8c1aefa58a979ea@mail.gmail.com> (sorry if this goes to the list twice, I've just rejoined the list and accidentally sent the original email an hour ago from the incorrect email alias). OK, here's the problem. Never had problem with this before but this is the first time I've used a Mac. Here's the info: >From console A ... $ erl -sname foo -setcookie c (foo@REDACTED)1> >From console B ... $ erl -name bar -setcookie c (bar@REDACTED)1> >From console C ... $ /usr/local/lib/erlang/erts-5.6.4/bin/epmd -names epmd: up and running on port 4369 with data: name bar at port 51292 name foo at port 51290 >From Console B ... (bar@REDACTED)1> net_adm:ping(bar@REDACTED). pong (bar@REDACTED)2> net_adm:ping(foo@REDACTED). pang (bar@REDACTED)3> net_adm:names(). {ok,[{"foo",51290},{"bar",51292}]} Note that the pang is received after the cursor hangs for a few seconds. The cursor does not hang when I type net_adm:ping(foo@REDACTED). -- Dennis Byrne From dennisbyrne@REDACTED Sun Apr 19 19:03:57 2009 From: dennisbyrne@REDACTED (Dennis Byrne) Date: Sun, 19 Apr 2009 12:03:57 -0500 Subject: [erlang-questions] receiving pang from net_adm:ping/1 even though net_adm:names/0 shows the other node In-Reply-To: References: <446564320904190746x5ee8825bk6c9d069f420b6f34@mail.gmail.com> Message-ID: <446564320904191003t6c15f928t9ff16ab82f9ac6ce@mail.gmail.com> I tried that as well but went with the simpler example to the list. Here's what -name does ... >From Console A ... $ erl -name foo -setcookie c >From Console B ... $ erl -name bar -setcookie c (bar@REDACTED)1> net_adm:names(). {error,nxdomain} (bar@REDACTED)2> net_adm:ping(bar@REDACTED). pong (bar@REDACTED)3> net_adm:ping(foo@REDACTED). pang >From Console C ... $ /usr/local/lib/erlang/erts-5.6.4/bin/epmd -names epmd: up and running on port 4369 with data: name bar at port 51557 name foo at port 51555 Same problem, but notice that net_adm:names/0 no longer works correctly. Dennis Byrne On Sun, Apr 19, 2009 at 11:54 AM, Per Melin wrote: > On Sun, Apr 19, 2009 at 4:46 PM, Dennis Byrne wrote: >> >From console A ... >> >> $ erl -sname foo -setcookie c >> (foo@REDACTED)1> >> >> >From console B ... >> >> $ erl -name bar -setcookie c >> (bar@REDACTED)1> > > What if you don't start one node with -sname and the other with -name? > -- Dennis Byrne From per.melin@REDACTED Sun Apr 19 19:18:22 2009 From: per.melin@REDACTED (Per Melin) Date: Sun, 19 Apr 2009 19:18:22 +0200 Subject: [erlang-questions] receiving pang from net_adm:ping/1 even though net_adm:names/0 shows the other node In-Reply-To: <446564320904191003t6c15f928t9ff16ab82f9ac6ce@mail.gmail.com> References: <446564320904190746x5ee8825bk6c9d069f420b6f34@mail.gmail.com> <446564320904191003t6c15f928t9ff16ab82f9ac6ce@mail.gmail.com> Message-ID: On Sun, Apr 19, 2009 at 7:03 PM, Dennis Byrne wrote: > $ erl -name bar -setcookie c > (bar@REDACTED)1> net_adm:names(). > {error,nxdomain} nxdomain means non-existing domain, which I guess means that your machine's DNS name isn't actually 207.hyperband.com. Can that be correct? Try starting both nodes with -sname. That doesn't require a valid hostname. From dennisbyrne@REDACTED Sun Apr 19 19:30:24 2009 From: dennisbyrne@REDACTED (Dennis Byrne) Date: Sun, 19 Apr 2009 12:30:24 -0500 Subject: [erlang-questions] receiving pang from net_adm:ping/1 even though net_adm:names/0 shows the other node In-Reply-To: References: <446564320904190746x5ee8825bk6c9d069f420b6f34@mail.gmail.com> <446564320904191003t6c15f928t9ff16ab82f9ac6ce@mail.gmail.com> Message-ID: <446564320904191030o4b0cef3ck6a3de8b394b38e21@mail.gmail.com> On Sun, Apr 19, 2009 at 12:18 PM, Per Melin wrote: > On Sun, Apr 19, 2009 at 7:03 PM, Dennis Byrne wrote: >> $ erl -name bar -setcookie c >> (bar@REDACTED)1> net_adm:names(). >> {error,nxdomain} > > nxdomain means non-existing domain, which I guess means that your > machine's DNS name isn't actually 207.hyperband.com. Can that be > correct? I thought this as well but if you will notice though, the bar node has no problem pinging itself using this domain. You are correct though because I cannot even ping the machine using a standard ping outside of erlang. $ ping 207.hyperband.com ping: cannot resolve 207.hyperband.com: Unknown host One more thing to note. In syslog I can see that my ISP is setting my hostname to 207.230.10.129.ip.anet.com . I can ping my machine (outside of erlang) using this: $ ping 207.230.10.129.ip.anet.com PING 207.230.10.129.ip.anet.com (207.230.10.129): 56 data bytes 64 bytes from 207.230.10.129: icmp_seq=0 ttl=64 time=0.038 ms But ping fails using this hostname within Erlang. (bar@REDACTED)6> net_adm:ping('bar@REDACTED'). pang > Try starting both nodes with -sname. That doesn't require a valid hostname. This is what I did in the original post, starting the nodes with $ erl -sname foo -setcookie c and $ erl -sname bar -setcookie c . -- Dennis Byrne From per.melin@REDACTED Sun Apr 19 19:43:51 2009 From: per.melin@REDACTED (Per Melin) Date: Sun, 19 Apr 2009 19:43:51 +0200 Subject: [erlang-questions] receiving pang from net_adm:ping/1 even though net_adm:names/0 shows the other node In-Reply-To: <446564320904191030o4b0cef3ck6a3de8b394b38e21@mail.gmail.com> References: <446564320904190746x5ee8825bk6c9d069f420b6f34@mail.gmail.com> <446564320904191003t6c15f928t9ff16ab82f9ac6ce@mail.gmail.com> <446564320904191030o4b0cef3ck6a3de8b394b38e21@mail.gmail.com> Message-ID: On Sun, Apr 19, 2009 at 7:30 PM, Dennis Byrne wrote: >> Try starting both nodes with -sname. That doesn't require a valid hostname. > > This is what I did in the original post, starting the nodes with $ erl > -sname foo -setcookie c and $ erl -sname bar -setcookie c . Well, if you go back and look what you posted that wasn't actually it. Anyway, I tried to change my hostname to 207 and then the same thing happened to me as you describe in your original post. It seems it is a bad idea in general to have a numeric hostname, since there is no way to tell it apart from an IP-number. fanboy:~$ sudo hostname 207 fanboy:~$ ping 207 PING 207 (0.0.0.207): 56 data bytes From dennisbyrne@REDACTED Sun Apr 19 19:52:57 2009 From: dennisbyrne@REDACTED (Dennis Byrne) Date: Sun, 19 Apr 2009 12:52:57 -0500 Subject: [erlang-questions] receiving pang from net_adm:ping/1 even though net_adm:names/0 shows the other node In-Reply-To: References: <446564320904190746x5ee8825bk6c9d069f420b6f34@mail.gmail.com> <446564320904191003t6c15f928t9ff16ab82f9ac6ce@mail.gmail.com> <446564320904191030o4b0cef3ck6a3de8b394b38e21@mail.gmail.com> Message-ID: <446564320904191052h3d18bb66l1d346295a3ca8190@mail.gmail.com> On Sun, Apr 19, 2009 at 12:43 PM, Per Melin wrote: > On Sun, Apr 19, 2009 at 7:30 PM, Dennis Byrne wrote: >>> Try starting both nodes with -sname. That doesn't require a valid hostname. >> >> This is what I did in the original post, starting the nodes with $ erl >> -sname foo -setcookie c and $ erl -sname bar -setcookie c . > > Well, if you go back and look what you posted that wasn't actually it. You are correct. I looked back and it looks like the bar node was brought up with -name instead of -sname . I think this was a typo however because I have reverified same problem using -sname. Also, -name wouldn't have given the next console line of "bar@REDACTED" - that is how erlang behaves with -sname (as you probably already know). Thanks for noticing this though. Is there any way to force erlang to just use an IP address rather than do a DNS lookup? I always find myself wanting to do this when I debug issues like this. > Anyway, I tried to change my hostname to 207 and then the same thing > happened to me as you describe in your original post. It seems it is a > bad idea in general to have a numeric hostname, since there is no way > to tell it apart from an IP-number. > > fanboy:~$ sudo hostname 207 > fanboy:~$ ping 207 > PING 207 (0.0.0.207): 56 data bytes > -- Dennis Byrne From per.melin@REDACTED Sun Apr 19 20:03:16 2009 From: per.melin@REDACTED (Per Melin) Date: Sun, 19 Apr 2009 20:03:16 +0200 Subject: [erlang-questions] receiving pang from net_adm:ping/1 even though net_adm:names/0 shows the other node In-Reply-To: <446564320904191052h3d18bb66l1d346295a3ca8190@mail.gmail.com> References: <446564320904190746x5ee8825bk6c9d069f420b6f34@mail.gmail.com> <446564320904191003t6c15f928t9ff16ab82f9ac6ce@mail.gmail.com> <446564320904191030o4b0cef3ck6a3de8b394b38e21@mail.gmail.com> <446564320904191052h3d18bb66l1d346295a3ca8190@mail.gmail.com> Message-ID: On Sun, Apr 19, 2009 at 7:52 PM, Dennis Byrne wrote: > Is there any way to force erlang to just use an IP address rather than > do a DNS lookup? ?I always find myself wanting to do this when I debug > issues like this. It will use an IP if you do. $ erl -name foo@REDACTED and $ erl -name bar@REDACTED (bar@REDACTED)1> net_adm:ping('foo@REDACTED'). pong (bar@REDACTED)2> nodes(). ['foo@REDACTED'] Note that you need the single tick quotes around the nodename here to make it a parsable atom. From dennisbyrne@REDACTED Sun Apr 19 20:36:45 2009 From: dennisbyrne@REDACTED (Dennis Byrne) Date: Sun, 19 Apr 2009 13:36:45 -0500 Subject: [erlang-questions] receiving pang from net_adm:ping/1 even though net_adm:names/0 shows the other node In-Reply-To: References: <446564320904190746x5ee8825bk6c9d069f420b6f34@mail.gmail.com> <446564320904191003t6c15f928t9ff16ab82f9ac6ce@mail.gmail.com> <446564320904191030o4b0cef3ck6a3de8b394b38e21@mail.gmail.com> <446564320904191052h3d18bb66l1d346295a3ca8190@mail.gmail.com> Message-ID: <446564320904191136o35009c92oa3e6a37dd05cd95c@mail.gmail.com> Thanks Per, that gets me there. Dennis On Sun, Apr 19, 2009 at 1:03 PM, Per Melin wrote: > On Sun, Apr 19, 2009 at 7:52 PM, Dennis Byrne wrote: >> Is there any way to force erlang to just use an IP address rather than >> do a DNS lookup? ?I always find myself wanting to do this when I debug >> issues like this. > > It will use an IP if you do. > > $ erl -name foo@REDACTED > > and > > $ erl -name bar@REDACTED > > (bar@REDACTED)1> net_adm:ping('foo@REDACTED'). > pong > (bar@REDACTED)2> nodes(). > ['foo@REDACTED'] > > Note that you need the single tick quotes around the nodename here to > make it a parsable atom. > -- Dennis Byrne From vances@REDACTED Sun Apr 19 21:11:40 2009 From: vances@REDACTED (Vance Shipley) Date: Sun, 19 Apr 2009 15:11:40 -0400 Subject: [erlang-questions] OTP compliant gen_tcp client In-Reply-To: <20090417020703.GJ379@h216-235-12-174.host.egate.net> References: <20090417020703.GJ379@h216-235-12-174.host.egate.net> Message-ID: <20090419191137.GA1181@h216-235-12-170.host.egate.net> On Thu, Apr 16, 2009 at 10:07:04PM -0400, Vance Shipley wrote: } A lot has been written about gen_tcp server side implementation } strategies and I see that there are a lot of subtle issues } to be considered to get it just right. I call gen_tcp:connect/3 with {active, false} in a new process and when it returns successfully I call gen_tcp:controlling_process/2 to make the main process the new owner of the Socket. Then I send the returned Socket to the main process. On receipt the main gen_fsm process calls inet:setopts/2 to set the Socket to {active, once} and transitions to the connected state. I was worried that I would have to then look to see if I'd received anything from the Socket, for example {tcp_closed, Socket}, and forward it to the main process however I now understand that gen_tcp:controlling_process/2 does this for you. Nice. The only worry I have left is whether I should send the Socket to the main gen_fsm process before or after calling gen_tcp:controlling_process/2. If I send it first and then gen_tcp:controlling_process/2 then forwards a received {tcp_closed, Socket} it would be the proper order. On the other hand if the main process calls inet:setopts/2 before the child process finishes with gen_tcp:controlling_process/2 we have a problem. Hmmm .... -- -Vance From tomjmalone@REDACTED Sun Apr 19 22:41:46 2009 From: tomjmalone@REDACTED (Tom Malone) Date: Sun, 19 Apr 2009 21:41:46 +0100 Subject: [erlang-questions] Graphing options in erlang Message-ID: Is there a good graphing/charting library in erlang, I will want to do an x/y scatter graph, with a time based y axis and a log scale on the x axis, i have had a google and can't find one. I hoped i missed something. Thanks in advance Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From thatsnotright@REDACTED Sun Apr 19 23:03:03 2009 From: thatsnotright@REDACTED (Rob Elsner) Date: Sun, 19 Apr 2009 15:03:03 -0600 Subject: [erlang-questions] Graphing options in erlang In-Reply-To: References: Message-ID: Tom, There are tk bindings for erlang, and Tk:Graph as a package. Rob On Sun, Apr 19, 2009 at 2:41 PM, Tom Malone wrote: > Is there a good graphing/charting library in erlang, I will want to do an > x/y scatter graph, with a time based y axis and a log scale on the x axis, i > have had a google and can't find one. I hoped i missed something. > > Thanks in advance > > Tom From ok@REDACTED Mon Apr 20 04:54:20 2009 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 20 Apr 2009 14:54:20 +1200 Subject: [erlang-questions] Graphing options in erlang In-Reply-To: References: Message-ID: <68646767-DFF7-4BBA-9831-91FA6462B5E2@cs.otago.ac.nz> On 20 Apr 2009, at 8:41 am, Tom Malone wrote: > Is there a good graphing/charting library in erlang, I will want to > do an x/y scatter graph, with a time based y axis and a log scale on > the x axis, i have had a google and can't find one. I hoped i missed > something. My recommendation would be to use the R statistics environment and talk to it through a socket. Simple to set up, and you're not likely to get better-looking graphs. From bengt.kleberg@REDACTED Mon Apr 20 08:29:23 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 20 Apr 2009 08:29:23 +0200 Subject: [erlang-questions] problem with pread,recursrsive func In-Reply-To: <23115395.post@talk.nabble.com> References: <23115395.post@talk.nabble.com> Message-ID: <1240208963.30648.5.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, If it is ok with you I will interpret your statement about flushing buffer to mean force garbage collect. If that is what you want to do, please try to add: erlang:garbage_collect() after sending to UDP, before the call to read/2 If you want more help it would be nice if you could send more of the real code. Not all of it, of course. bengt On Sat, 2009-04-18 at 10:37 -0700, sandeep_k wrote: > I has written a plug in tsung which read data from file and send though UDP > Socket > But when I crated 10 users per sec with 30 sec it is taking full memory > when commented pread it is working properly > How to avoid this problem , is this problem due to recursive function ? > How to flush for Data buffer ? > > Read_send(Fd,Offset) -> > Case File:pread(Fd,Offset,4096) of > {ok,Data} -> > I am send data using UDP socket > NewOffset=Offset+4096, > I will recursively call this function till 20Mb file is read > Read(Fd,NewOffset); > _ -> > Error > end > From bengt.kleberg@REDACTED Mon Apr 20 08:47:11 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 20 Apr 2009 08:47:11 +0200 Subject: [erlang-questions] simple_logger error in Joe Armstrong's Thesis In-Reply-To: <688f5b410904171904m17906ce0t9a5adacb9032130@mail.gmail.com> References: <688f5b410904171904m17906ce0t9a5adacb9032130@mail.gmail.com> Message-ID: <1240210031.30648.13.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, I do not know what the error is but when looking at the listing I think that there are two things wrong with it. 1) Line 6-7: two callbacks for behaviour gen_event are missing. 2) Line 14: the return value of gen_event:add_handler/3 is ignored. bengt "On Fri, 2009-04-17 at 22:04 -0400, Justin Giancola wrote: > Hello, > > I've been reading through Joe's thesis > (http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf), and in the > supervisor example (6.5.2) he comments that there was an unmentioned > error in the simple_logger.erl listing. Now, not only did I not > notice this error when reading simple_logger.erl the first time > around, but even under close examination I can't for the life of me > figure out what it is. > > Would someone with a sharper eye be kind enough to point it out? > > The listing is Figure 6.2 on page 142 of the thesis (and page 153 of > the .pdf linked above). > > Thanks, > > > Justin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From bengt.kleberg@REDACTED Mon Apr 20 09:16:43 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 20 Apr 2009 09:16:43 +0200 Subject: [erlang-questions] Too many processes In-Reply-To: <23097100.post@talk.nabble.com> References: <23097100.post@talk.nabble.com> Message-ID: <1240211803.30648.23.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, The tail recursion for the message {packet, Packet} is good. The other two messages makes parse_packet/2 return, stopping the recursion. The argument Client is not used and could be removed. Presumably the too many processes are created somewhere else in your code. bengt On Fri, 2009-04-17 at 06:00 -0700, marmll wrote: > Hi, > > i have the following problem: > > My error_logger tells me that I?am having ?Too many processes? and the > erlang engine crashed. > When I?am starting the gen_server I?am checking the > erlang:system_info(process_count) and they tells me 80 processes. > > Codesnip from init: > F = fun(Sock) -> parse_packet(Sock, Client) end, > tcp_server:stop(Port), > {ok, _} = tcp_server:start_raw_server(Port, F, 10240,2048), > > And here my parse_packet: > > parse_packet(Socket, Client) -> > receive > {tcp, Socket, Bin} -> > io:format("--> ~w~n", [Bin]); > {tcp_closed, Socket} -> > error_logger:error_report([{module, ?MODULE},{line, > ?LINE},{message, "tcpclosed"},{call, "tcp_closed aus > receive"},{now,now()}]); > {packet, Packet} -> > io:format("<-- ~w~n", [Packet]), > parse_packet(Socket, Client) > end. > > With every connect to the server my process_count is increasing 1 ! > > How can I handle the process_count ? I think the the tail recursion at > parse_packet is not good. > > Please help me > Thanks > > -- > View this message in context: http://www.nabble.com/Too-many-processes-tp23097100p23097100.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From zerthurd@REDACTED Mon Apr 20 10:16:07 2009 From: zerthurd@REDACTED (Maxim Treskin) Date: Mon, 20 Apr 2009 15:16:07 +0700 Subject: [erlang-questions] sctp_peeloff() support in OTP Message-ID: Hello Is sctp_peeloff() will be supported in OTP nearest releases? Is it possible to send messages from one SCTP-association to one process? -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Mon Apr 20 10:29:46 2009 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 20 Apr 2009 10:29:46 +0200 Subject: [erlang-questions] two problems with erlide In-Reply-To: <200904190204356674475@bluewin.ch> References: <200904181452558247516@bluewin.ch> <200904190127039232603@bluewin.ch> <200904190204356674475@bluewin.ch> Message-ID: <95be1d3b0904200129u644a2cbfv6813de3be6149c08@mail.gmail.com> Hi! On Sun, Apr 19, 2009 at 02:04, Gamoto wrote: > I am using Eclipse-SDK-3.4.2-win32.zip (156Mb) This is an eclipse bundle that works fine. > After a restart, the cross on red background disappeared. > But the module is never automatically compiled. Could you please go to Window->preferences->erlang->send report, create one and send it to me? It might help finding out what's wrong. regards, Vlad From steve.kirsch@REDACTED Mon Apr 20 09:32:14 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Mon, 20 Apr 2009 00:32:14 -0700 Subject: [erlang-questions] A simple multiply in the shell will kill the shell and its supervisor In-Reply-To: <68646767-DFF7-4BBA-9831-91FA6462B5E2@cs.otago.ac.nz> Message-ID: <76BB7F270C366D47AA79851BB0B39D810294531E@exchg02.propel.com> This only seems to kill erlang's shell permanently using erl on Windows. werl on the same machine works fine. Startup erl on windows. type in one line: A=7480957234592457928345982345987234857923589723485728347598245927385724 852984. B=A*A*A*A*A. C=B*B*B*B*B*B*B*B*B*B*B. D=C*C*C*C*C*C*C*C*C*C*C. then your erl will stop responding. It isn't in a loop and it isn't using up cpu or crash dumping. It is just completely dead. I've tried this on two completely different PC's running windows XP Pro with the same result. You do it on werl on the same machine, everything is fine. Do it from erl, and it hangs. i am using R12B. inspection via a remote shell reveals that these processes have disappeared from i() listing: <0.26.0> supervisor_bridge:user_sup/1 233 81 0 gen_server:loop/6 9 <0.28.0> user:server/2 377 600 0 user user:get_chars/7 21 <0.29.0> erlang:apply/2 4181 4649 0 shell:get_command1/5 16 <0.35.0> erlang:apply/2 1597 2550 0 shell:eval_loop/3 6 why is this happening? From egil@REDACTED Mon Apr 20 11:53:48 2009 From: egil@REDACTED (=?ISO-8859-1?Q?Bj=F6rn-Egil_Dahlberg?=) Date: Mon, 20 Apr 2009 11:53:48 +0200 Subject: [erlang-questions] Graphing options in erlang In-Reply-To: <68646767-DFF7-4BBA-9831-91FA6462B5E2@cs.otago.ac.nz> References: <68646767-DFF7-4BBA-9831-91FA6462B5E2@cs.otago.ac.nz> Message-ID: <49EC462C.3020309@erix.ericsson.se> Another option is perhaps to use eplot which is written in pure erlang. Eplot is not complete, but it works well for alot of cases. It uses egd as backend and can output png, eps or raw bitmap. It uses wxErlang to view results if no output option is given. I use it to visualize data when benchmarking. It suits my needs but I haven't spent a lot of time to add new features or fine tuning it. From command line it uses escript but one can use the module egd_chart to incorporate it in any other module. Documentation is sparse at the moment. Interested parties should direct their attention to: http://github.com/psyeugenic/eplot/tree/master // Bj?rn-Egil Richard O'Keefe wrote: > On 20 Apr 2009, at 8:41 am, Tom Malone wrote: > >> Is there a good graphing/charting library in erlang, I will want to >> do an x/y scatter graph, with a time based y axis and a log scale on >> the x axis, i have had a google and can't find one. I hoped i missed >> something. > > My recommendation would be to use the R statistics environment > and talk to it through a socket. Simple to set up, and you're > not likely to get better-looking graphs. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From branchingfactor@REDACTED Mon Apr 20 11:43:18 2009 From: branchingfactor@REDACTED (BranchingFactor) Date: Mon, 20 Apr 2009 02:43:18 -0700 (PDT) Subject: [erlang-questions] fread() for numbers - beginner question In-Reply-To: Message-ID: <437871.42937.qm@web59203.mail.re1.yahoo.com> I'd like to io_lib:fread() a number from a string.? Unfortunately, if I use "~f" for floating point number, then fread rejects numbers that don't have fractional parts: > io_lib:fread("~f", "1"). {error,{fread,float}} > io_lib:fread("~f", "1."). {error,{fread,float}} (I find this very strange, since both 1 and 1. can be represented in a floating point number.) And if I use "~d" for decimal integers, then fread won't read past the decimal point: > io_lib:fread("~d", "1.0"). {ok,[1],".0"} What is the easiest way to scan a number from a string in erlang?? Ideally it would scan any number in any input format and return an Erlang object that satisfied the is_number() predicate. Thank you, BF -------------- next part -------------- An HTML attachment was scrubbed... URL: From rtrlists@REDACTED Mon Apr 20 12:57:22 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Mon, 20 Apr 2009 11:57:22 +0100 Subject: [erlang-questions] fread() for numbers - beginner question In-Reply-To: <437871.42937.qm@web59203.mail.re1.yahoo.com> References: <437871.42937.qm@web59203.mail.re1.yahoo.com> Message-ID: <6a3ae47e0904200357w7f45e543q6b835b35d4ac2b15@mail.gmail.com> On Mon, Apr 20, 2009 at 10:43 AM, BranchingFactor wrote: > I'd like to io_lib:fread() a number from a string.? Unfortunately, if I use > "~f" for floating point number, then fread rejects numbers that don't have > fractional parts: > >> io_lib:fread("~f", "1"). > {error,{fread,float}} >> io_lib:fread("~f", "1."). > {error,{fread,float}} > > (I find this very strange, since both 1 and 1. can be represented in a > floating point number.) > And if I use "~d" for decimal integers, then fread won't read past the > decimal point: > >> io_lib:fread("~d", "1.0"). > {ok,[1],".0"} > > What is the easiest way to scan a number from a string in erlang?? Ideally > it would scan any number in any input format and return an Erlang object > that satisfied the is_number() predicate. scan_number(S) -> case io_lib:fread("~f", S) of {error, _} -> io_lib:fread("~d", S); Result -> Result end. This doesn't handle 16#ffff and friends though. but you can extend it according to you needs. And "1." is not a valid Erlang number. Robby From alex.tkachman@REDACTED Mon Apr 20 13:03:45 2009 From: alex.tkachman@REDACTED (Alex Tkachman) Date: Mon, 20 Apr 2009 14:03:45 +0300 Subject: [erlang-questions] Erlang Guru Requied in Tel Aviv area Message-ID: <4cf0f24c0904200403ie480d28nde6152c88b2656e2@mail.gmail.com> Hi! Hope my question is not against rules of the list. I need Erlang Guru in Tel Aviv area either for contract or to full-time position. Please contact me if you are such Guru or know one. Best regards Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Mon Apr 20 13:48:44 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 20 Apr 2009 13:48:44 +0200 Subject: [erlang-questions] sctp_peeloff() support in OTP In-Reply-To: References: Message-ID: <20090420114844.GA8297@erix.ericsson.se> On Mon, Apr 20, 2009 at 03:16:07PM +0700, Maxim Treskin wrote: > Hello > > Is sctp_peeloff() will be supported in OTP nearest releases? Is it possible > to send messages from one SCTP-association to one process? I can promise sctp_peelof() will not be supported in R13B. For later releases it depends on the demand from chiefly paying customers, or on if I get a clean patch. It is unfortunately not a small change. I also guess active mode would be more important. > > -- > Maxim Treskin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From zerthurd@REDACTED Mon Apr 20 14:07:03 2009 From: zerthurd@REDACTED (Maxim Treskin) Date: Mon, 20 Apr 2009 19:07:03 +0700 Subject: [erlang-questions] sctp_peeloff() support in OTP In-Reply-To: <20090420114844.GA8297@erix.ericsson.se> References: <20090420114844.GA8297@erix.ericsson.se> Message-ID: What is active mode? If socket port sends messages to process without gen_sctp:recv is active mode, then it works now. May be it is something another? -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Mon Apr 20 14:38:44 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 20 Apr 2009 14:38:44 +0200 Subject: [erlang-questions] : sctp_peeloff() support in OTP In-Reply-To: References: <20090420114844.GA8297@erix.ericsson.se> Message-ID: <20090420123844.GB8817@erix.ericsson.se> On Mon, Apr 20, 2009 at 07:07:03PM +0700, Maxim Treskin wrote: > What is active mode? If socket port sends messages to process without > gen_sctp:recv is active mode, then it works now. May be it is something > another? Well, what do you know, I had already fixed it but forgot all about it. But our test suites really could test it much more... What about you open source users. Is active mode working fine for you? Under heavy load? In that case Peeloff is a possible next large feature to implement, if not the only missing large feature...? Anybody missing something other important? > > -- > Maxim Treskin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From vychodil.hynek@REDACTED Mon Apr 20 15:14:35 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Mon, 20 Apr 2009 15:14:35 +0200 Subject: [erlang-questions] A simple multiply in the shell will kill the shell and its supervisor In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810294531E@exchg02.propel.com> References: <68646767-DFF7-4BBA-9831-91FA6462B5E2@cs.otago.ac.nz> <76BB7F270C366D47AA79851BB0B39D810294531E@exchg02.propel.com> Message-ID: <4d08db370904200614k6f8041fawbd041e4331d6ec51@mail.gmail.com> Try do this: B=A*A*A*A*A,C=B*B*B*B*B*B*B*B*B*B*B,D=C*C*C*C*C*C*C*C*C*C*C,ok. There can be problem is with io speed. On Mon, Apr 20, 2009 at 9:32 AM, Steve Kirsch wrote: > This only seems to kill erlang's shell permanently using erl on Windows. > werl on the same machine works fine. > > Startup erl on windows. > > type in one line: > A=7480957234592457928345982345987234857923589723485728347598245927385724 > 852984. B=A*A*A*A*A. C=B*B*B*B*B*B*B*B*B*B*B. D=C*C*C*C*C*C*C*C*C*C*C. > > then your erl will stop responding. It isn't in a loop and it isn't > using up cpu or crash dumping. > > It is just completely dead. > > I've tried this on two completely different PC's running windows XP Pro > with the same result. You do it on werl on the same machine, everything > is fine. Do it from erl, and it hangs. > > i am using R12B. > > inspection via a remote shell reveals that these processes have > disappeared from i() listing: > <0.26.0> supervisor_bridge:user_sup/1 233 > 81 0 > gen_server:loop/6 9 > > <0.28.0> user:server/2 377 > 600 0 > user user:get_chars/7 21 > > <0.29.0> erlang:apply/2 4181 > 4649 0 > shell:get_command1/5 16 > > <0.35.0> erlang:apply/2 1597 > 2550 0 > shell:eval_loop/3 6 > > > why is this happening? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve.kirsch@REDACTED Mon Apr 20 17:51:54 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Mon, 20 Apr 2009 08:51:54 -0700 Subject: [erlang-questions] A simple multiply in the shell will kill the shell and its supervisor In-Reply-To: <4d08db370904200614k6f8041fawbd041e4331d6ec51@mail.gmail.com> Message-ID: <76BB7F270C366D47AA79851BB0B39D8102945331@exchg02.propel.com> sure, it works with "fewer" C's in the computation. I already knew that. What do you meean a problem with io speed? I'm not trying to make this computation, I was only doing it for fun and was amazed I could crash the shell and its supervisor and nobody restarted anything doing something as simple as a multiply. Why does this happen and why does it happen only with erl and not werl on the same windows machine? ________________________________ From: Hynek Vychodil [mailto:vychodil.hynek@REDACTED] Sent: Monday, April 20, 2009 6:15 AM To: Steve Kirsch Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] A simple multiply in the shell will kill the shell and its supervisor Try do this: B=A*A*A*A*A,C=B*B*B*B*B*B*B*B*B*B*B,D=C*C*C*C*C*C*C*C*C*C*C,ok. There can be problem is with io speed. On Mon, Apr 20, 2009 at 9:32 AM, Steve Kirsch wrote: This only seems to kill erlang's shell permanently using erl on Windows. werl on the same machine works fine. Startup erl on windows. type in one line: A=7480957234592457928345982345987234857923589723485728347598245927385724 852984. B=A*A*A*A*A. C=B*B*B*B*B*B*B*B*B*B*B. D=C*C*C*C*C*C*C*C*C*C*C. then your erl will stop responding. It isn't in a loop and it isn't using up cpu or crash dumping. It is just completely dead. I've tried this on two completely different PC's running windows XP Pro with the same result. You do it on werl on the same machine, everything is fine. Do it from erl, and it hangs. i am using R12B. inspection via a remote shell reveals that these processes have disappeared from i() listing: <0.26.0> supervisor_bridge:user_sup/1 233 81 0 gen_server:loop/6 9 <0.28.0> user:server/2 377 600 0 user user:get_chars/7 21 <0.29.0> erlang:apply/2 4181 4649 0 shell:get_command1/5 16 <0.35.0> erlang:apply/2 1597 2550 0 shell:eval_loop/3 6 why is this happening? _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From branchingfactor@REDACTED Mon Apr 20 18:02:05 2009 From: branchingfactor@REDACTED (BranchingFactor) Date: Mon, 20 Apr 2009 09:02:05 -0700 (PDT) Subject: [erlang-questions] fread() for numbers - beginner question In-Reply-To: <6a3ae47e0904200357w7f45e543q6b835b35d4ac2b15@mail.gmail.com> Message-ID: <649666.56623.qm@web59203.mail.re1.yahoo.com> Thanks for the quick reply,?? Robbi.??? I was hoping to avoid the try-and-try-again approach b/c it doesn't extend so nicely to scanning multiple items from a string.? Does Erlang provide any way to read what many other programming languages consider to be the printed representation of a number? --- On Mon, 4/20/09, Robert Raschke wrote: From: Robert Raschke Subject: Re: [erlang-questions] fread() for numbers - beginner question To: branchingfactor@REDACTED Cc: erlang-questions@REDACTED Date: Monday, April 20, 2009, 6:57 AM On Mon, Apr 20, 2009 at 10:43 AM, BranchingFactor wrote: > I'd like to io_lib:fread() a number from a string.? Unfortunately, if I use > "~f" for floating point number, then fread rejects numbers that don't have > fractional parts: > >> io_lib:fread("~f", "1"). > {error,{fread,float}} >> io_lib:fread("~f", "1."). > {error,{fread,float}} > > (I find this very strange, since both 1 and 1. can be represented in a > floating point number.) > And if I use "~d" for decimal integers, then fread won't read past the > decimal point: > >> io_lib:fread("~d", "1.0"). > {ok,[1],".0"} > > What is the easiest way to scan a number from a string in erlang?? Ideally > it would scan any number in any input format and return an Erlang object > that satisfied the is_number() predicate. scan_number(S) -> case io_lib:fread("~f", S) of {error, _} -> io_lib:fread("~d", S); Result -> Result end. This doesn't handle 16#ffff and friends though. but you can extend it according to you needs. And "1." is not a valid Erlang number. Robby -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Mon Apr 20 18:05:58 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Mon, 20 Apr 2009 18:05:58 +0200 Subject: [erlang-questions] A simple multiply in the shell will kill the shell and its supervisor In-Reply-To: <76BB7F270C366D47AA79851BB0B39D8102945331@exchg02.propel.com> References: <4d08db370904200614k6f8041fawbd041e4331d6ec51@mail.gmail.com> <76BB7F270C366D47AA79851BB0B39D8102945331@exchg02.propel.com> Message-ID: <4d08db370904200905x57609c9fld4a6c8cba6562e0c@mail.gmail.com> It is not about number of C's. It should compute even E=D*D*D*D*D*D*D*D*D*D*D*D*D*D,ok. but what I mean that your statements cause print out each result. (Notice coma instead of dot.) Your terminal can be slow for printing or there can be issue with erlang io subsystem. I have tested that in Konsole (KDE on my Linux) I wait several seconds to print out E but for examle in vim it will be crash reasonably. I don't know which console werl and erl uses but I think there may be big difference. On Mon, Apr 20, 2009 at 5:51 PM, Steve Kirsch wrote: > sure, it works with "fewer" C's in the computation. I already knew that. > > What do you meean a problem with io speed? > > I'm not trying to make this computation, I was only doing it for fun and > was amazed I could crash the shell and its supervisor and nobody restarted > anything doing something as simple as a multiply. > > Why does this happen and why does it happen only with erl and not werl on > the same windows machine? > > ------------------------------ > *From:* Hynek Vychodil [mailto:vychodil.hynek@REDACTED] > *Sent:* Monday, April 20, 2009 6:15 AM > *To:* Steve Kirsch > *Cc:* erlang-questions@REDACTED > *Subject:* Re: [erlang-questions] A simple multiply in the shell will kill > the shell and its supervisor > > Try do this: > B=A*A*A*A*A,C=B*B*B*B*B*B*B*B*B*B*B,D=C*C*C*C*C*C*C*C*C*C*C,ok. > > There can be problem is with io speed. > > On Mon, Apr 20, 2009 at 9:32 AM, Steve Kirsch wrote: > >> This only seems to kill erlang's shell permanently using erl on Windows. >> werl on the same machine works fine. >> >> Startup erl on windows. >> >> type in one line: >> A=7480957234592457928345982345987234857923589723485728347598245927385724 >> 852984. B=A*A*A*A*A. C=B*B*B*B*B*B*B*B*B*B*B. D=C*C*C*C*C*C*C*C*C*C*C. >> >> then your erl will stop responding. It isn't in a loop and it isn't >> using up cpu or crash dumping. >> >> It is just completely dead. >> >> I've tried this on two completely different PC's running windows XP Pro >> with the same result. You do it on werl on the same machine, everything >> is fine. Do it from erl, and it hangs. >> >> i am using R12B. >> >> inspection via a remote shell reveals that these processes have >> disappeared from i() listing: >> <0.26.0> supervisor_bridge:user_sup/1 233 >> 81 0 >> gen_server:loop/6 9 >> >> <0.28.0> user:server/2 377 >> 600 0 >> user user:get_chars/7 21 >> >> <0.29.0> erlang:apply/2 4181 >> 4649 0 >> shell:get_command1/5 16 >> >> <0.35.0> erlang:apply/2 1597 >> 2550 0 >> shell:eval_loop/3 6 >> >> >> why is this happening? >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve.kirsch@REDACTED Mon Apr 20 18:21:00 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Mon, 20 Apr 2009 09:21:00 -0700 Subject: [erlang-questions] A simple multiply in the shell will kill the shell and its supervisor In-Reply-To: <4d08db370904200905x57609c9fld4a6c8cba6562e0c@mail.gmail.com> Message-ID: <76BB7F270C366D47AA79851BB0B39D8102945333@exchg02.propel.com> I don't mind slow. but why is the shell and it's supervisor crashing when I do this. This sounds like a bug, isn't it? I tried it with commas and you are right. It does compute correctly and it returns ok. When I do: C. it works fine and prints the value. When I do: D. erlang almost immediately stops responding to all console input and the processes are dead so typing does nothing and there is no CPU usage. ________________________________ From: Hynek Vychodil [mailto:vychodil.hynek@REDACTED] Sent: Monday, April 20, 2009 9:06 AM To: Steve Kirsch Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] A simple multiply in the shell will kill the shell and its supervisor It is not about number of C's. It should compute even E=D*D*D*D*D*D*D*D*D*D*D*D*D*D,ok. but what I mean that your statements cause print out each result. (Notice coma instead of dot.) Your terminal can be slow for printing or there can be issue with erlang io subsystem. I have tested that in Konsole (KDE on my Linux) I wait several seconds to print out E but for examle in vim it will be crash reasonably. I don't know which console werl and erl uses but I think there may be big difference. On Mon, Apr 20, 2009 at 5:51 PM, Steve Kirsch wrote: sure, it works with "fewer" C's in the computation. I already knew that. What do you meean a problem with io speed? I'm not trying to make this computation, I was only doing it for fun and was amazed I could crash the shell and its supervisor and nobody restarted anything doing something as simple as a multiply. Why does this happen and why does it happen only with erl and not werl on the same windows machine? ________________________________ From: Hynek Vychodil [mailto:vychodil.hynek@REDACTED] Sent: Monday, April 20, 2009 6:15 AM To: Steve Kirsch Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] A simple multiply in the shell will kill the shell and its supervisor Try do this: B=A*A*A*A*A,C=B*B*B*B*B*B*B*B*B*B*B,D=C*C*C*C*C*C*C*C*C*C*C,ok. There can be problem is with io speed. On Mon, Apr 20, 2009 at 9:32 AM, Steve Kirsch wrote: This only seems to kill erlang's shell permanently using erl on Windows. werl on the same machine works fine. Startup erl on windows. type in one line: A=7480957234592457928345982345987234857923589723485728347598245927385724 852984. B=A*A*A*A*A. C=B*B*B*B*B*B*B*B*B*B*B. D=C*C*C*C*C*C*C*C*C*C*C. then your erl will stop responding. It isn't in a loop and it isn't using up cpu or crash dumping. It is just completely dead. I've tried this on two completely different PC's running windows XP Pro with the same result. You do it on werl on the same machine, everything is fine. Do it from erl, and it hangs. i am using R12B. inspection via a remote shell reveals that these processes have disappeared from i() listing: <0.26.0> supervisor_bridge:user_sup/1 233 81 0 gen_server:loop/6 9 <0.28.0> user:server/2 377 600 0 user user:get_chars/7 21 <0.29.0> erlang:apply/2 4181 4649 0 shell:get_command1/5 16 <0.35.0> erlang:apply/2 1597 2550 0 shell:eval_loop/3 6 why is this happening? _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From public-mail@REDACTED Mon Apr 20 18:28:15 2009 From: public-mail@REDACTED (alekciy) Date: Mon, 20 Apr 2009 20:28:15 +0400 Subject: [erlang-questions] Install R13A to Debian Message-ID: I try compile R13A (in repository no package): debian:~/erlang/otp_src_R13A# gcc --version gcc (Debian 4.3.2-1.1) 4.3.2 debian:~/erlang/otp_src_R13A# ./configure --without-termcap Configure end ok. debian:~/erlang/otp_src_R13A# make ... drivers/unix/ttsl_drv.c:214: error: expected ???=???, ???,???, ???;???, ???asm??? or ???__attribute__??? before ???utf8buf??? drivers/unix/ttsl_drv.c: In function ???ttysl_init???: drivers/unix/ttsl_drv.c:237: warning: implicit declaration of function ???DEBUGLOG??? make[3]: *** [obj/i686-pc-linux-gnu/opt/smp/ttsl_drv.o] Error 1 make[3]: Leaving directory `/root/erlang/otp_src_R13A/erts/emulator' make[2]: *** [opt] Error 2 make[2]: Leaving directory `/root/erlang/otp_src_R13A/erts/emulator' make[1]: *** [smp] Error 2 make[1]: Leaving directory `/root/erlang/otp_src_R13A/erts' make: *** [emulator] Error 2 debian:~/erlang/otp_src_R13A# Why this? From gleber.p@REDACTED Mon Apr 20 20:54:29 2009 From: gleber.p@REDACTED (Gleb Peregud) Date: Mon, 20 Apr 2009 20:54:29 +0200 Subject: [erlang-questions] Install R13A to Debian In-Reply-To: References: Message-ID: <14f0e3620904201154k1352105yf1ac7363d0b21c46@mail.gmail.com> There are Erlang R13A packages for Debian. Though they are in "experimental" suite: http://packages.debian.org/experimental/erlang-base On Mon, Apr 20, 2009 at 18:28, alekciy wrote: > I try compile R13A (in repository no package): > > debian:~/erlang/otp_src_R13A# gcc --version > gcc (Debian 4.3.2-1.1) 4.3.2 > > debian:~/erlang/otp_src_R13A# ./configure --without-termcap > Configure end ok. > > debian:~/erlang/otp_src_R13A# make > ... > drivers/unix/ttsl_drv.c:214: error: expected ???=???, > ???,???, ???;???, ???asm??? or > ???__attribute__??? before ???utf8buf??? > drivers/unix/ttsl_drv.c: In function ???ttysl_init???: > drivers/unix/ttsl_drv.c:237: warning: implicit declaration of function > ???DEBUGLOG??? > make[3]: *** [obj/i686-pc-linux-gnu/opt/smp/ttsl_drv.o] Error 1 > make[3]: Leaving directory `/root/erlang/otp_src_R13A/erts/emulator' > make[2]: *** [opt] Error 2 > make[2]: Leaving directory `/root/erlang/otp_src_R13A/erts/emulator' > make[1]: *** [smp] Error 2 > make[1]: Leaving directory `/root/erlang/otp_src_R13A/erts' > make: *** [emulator] Error 2 > debian:~/erlang/otp_src_R13A# > > Why this? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From exta7@REDACTED Mon Apr 20 21:41:37 2009 From: exta7@REDACTED (Zvi) Date: Mon, 20 Apr 2009 12:41:37 -0700 (PDT) Subject: [erlang-questions] Graphing options in erlang In-Reply-To: References: Message-ID: <23143513.post@talk.nabble.com> OTP has a hidden Erlang binding for GD graphics library, in percept application. Look at egd module: http://erlang.org/doc/man/egd.html Zvi Tom Malone-2 wrote: > > Is there a good graphing/charting library in erlang, I will want to do an > x/y scatter graph, with a time based y axis and a log scale on the x axis, > i > have had a google and can't find one. I hoped i missed something. > > Thanks in advance > > Tom > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://www.nabble.com/Graphing-options-in-erlang-tp23127285p23143513.html Sent from the Erlang Questions mailing list archive at Nabble.com. From exta7@REDACTED Mon Apr 20 21:45:27 2009 From: exta7@REDACTED (Zvi) Date: Mon, 20 Apr 2009 12:45:27 -0700 (PDT) Subject: [erlang-questions] A simple multiply in the shell will kill the shell and its supervisor In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810294531E@exchg02.propel.com> References: <68646767-DFF7-4BBA-9831-91FA6462B5E2@cs.otago.ac.nz> <76BB7F270C366D47AA79851BB0B39D810294531E@exchg02.propel.com> Message-ID: <23143580.post@talk.nabble.com> this work great on my machine. Steve Kirsch wrote: > > This only seems to kill erlang's shell permanently using erl on Windows. > werl on the same machine works fine. > > Startup erl on windows. > > type in one line: > A=7480957234592457928345982345987234857923589723485728347598245927385724 > 852984. B=A*A*A*A*A. C=B*B*B*B*B*B*B*B*B*B*B. D=C*C*C*C*C*C*C*C*C*C*C. > > then your erl will stop responding. It isn't in a loop and it isn't > using up cpu or crash dumping. > > It is just completely dead. > > I've tried this on two completely different PC's running windows XP Pro > with the same result. You do it on werl on the same machine, everything > is fine. Do it from erl, and it hangs. > > i am using R12B. > > inspection via a remote shell reveals that these processes have > disappeared from i() listing: > <0.26.0> supervisor_bridge:user_sup/1 233 > 81 0 > gen_server:loop/6 9 > > <0.28.0> user:server/2 377 > 600 0 > user user:get_chars/7 21 > > <0.29.0> erlang:apply/2 4181 > 4649 0 > shell:get_command1/5 16 > > <0.35.0> erlang:apply/2 1597 > 2550 0 > shell:eval_loop/3 6 > > > why is this happening? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/Graphing-options-in-erlang-tp23127285p23143580.html Sent from the Erlang Questions mailing list archive at Nabble.com. From exta7@REDACTED Mon Apr 20 22:00:59 2009 From: exta7@REDACTED (Zvi) Date: Mon, 20 Apr 2009 13:00:59 -0700 (PDT) Subject: [erlang-questions] fread() for numbers - beginner question In-Reply-To: <649666.56623.qm@web59203.mail.re1.yahoo.com> References: <437871.42937.qm@web59203.mail.re1.yahoo.com> <6a3ae47e0904200357w7f45e543q6b835b35d4ac2b15@mail.gmail.com> <649666.56623.qm@web59203.mail.re1.yahoo.com> Message-ID: <23143824.post@talk.nabble.com> if you don't want to use catch, then you may try read it as a string and parse yourself later: 1> io_lib:fread("~s", "1"). {ok,["1"],[]} 2> io_lib:fread("~s", "1.0"). {ok,["1.0"],[]} 3> i.e. str2float(Str) -> FloatStr = case lists:member($. ,Str) of true -> S; false -> S++".0" end, {ok,[Float],_} = io_lib:fread("~f", FloatStr), Float. Zvi BranchingFactor wrote: > > Thanks for the quick reply,?? Robbi.??? I was hoping to avoid the > try-and-try-again approach b/c it doesn't extend so nicely to scanning > multiple items from a string.? Does Erlang provide any way to read what > many other programming languages consider to be the printed representation > of a number? > > --- On Mon, 4/20/09, Robert Raschke wrote: > From: Robert Raschke > Subject: Re: [erlang-questions] fread() for numbers - beginner question > To: branchingfactor@REDACTED > Cc: erlang-questions@REDACTED > Date: Monday, April 20, 2009, 6:57 AM > > On Mon, Apr 20, 2009 at 10:43 AM, BranchingFactor > wrote: >> I'd like to io_lib:fread() a number from a string.? Unfortunately, if > I use >> "~f" for floating point number, then fread rejects numbers that > don't have >> fractional parts: >> >>> io_lib:fread("~f", "1"). >> {error,{fread,float}} >>> io_lib:fread("~f", "1."). >> {error,{fread,float}} >> >> (I find this very strange, since both 1 and 1. can be represented in a >> floating point number.) >> And if I use "~d" for decimal integers, then fread won't > read past the >> decimal point: >> >>> io_lib:fread("~d", "1.0"). >> {ok,[1],".0"} >> >> What is the easiest way to scan a number from a string in erlang?? > Ideally >> it would scan any number in any input format and return an Erlang object >> that satisfied the is_number() predicate. > > scan_number(S) -> > case io_lib:fread("~f", S) of > {error, _} -> io_lib:fread("~d", S); > Result -> Result > end. > > This doesn't handle 16#ffff and friends though. but you can extend it > according to you needs. > > And "1." is not a valid Erlang number. > > Robby > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://www.nabble.com/fread%28%29-for-numbers---beginner-question-tp23134368p23143824.html Sent from the Erlang Questions mailing list archive at Nabble.com. From steven.charles.davis@REDACTED Mon Apr 20 22:10:55 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 20 Apr 2009 13:10:55 -0700 (PDT) Subject: [erlang-questions] A simple multiply in the shell will kill the shell and its supervisor In-Reply-To: <23143580.post@talk.nabble.com> References: <68646767-DFF7-4BBA-9831-91FA6462B5E2@cs.otago.ac.nz> <76BB7F270C366D47AA79851BB0B39D810294531E@exchg02.propel.com> <23143580.post@talk.nabble.com> Message-ID: <5cd80c61-a2e0-4af1-9390-ecc8cb8d2fe2@s20g2000vbp.googlegroups.com> Seems fine on my laptop too (XP3SP3/AMD64/R13A). On Apr 20, 2:45?pm, Zvi wrote: > this work great on my machine. > > Steve Kirsch wrote: > > > This only seems to kill erlang's shell permanently using erl on Windows. > > werl on the same machine works fine. > > > Startup erl on windows. > > > type in one line: > > A=7480957234592457928345982345987234857923589723485728347598245927385724 > > 852984. B=A*A*A*A*A. C=B*B*B*B*B*B*B*B*B*B*B. D=C*C*C*C*C*C*C*C*C*C*C. > From andrewmmc@REDACTED Mon Apr 20 22:13:29 2009 From: andrewmmc@REDACTED (andrew mmc) Date: Mon, 20 Apr 2009 22:13:29 +0200 Subject: [erlang-questions] fread() for numbers - beginner question In-Reply-To: <649666.56623.qm@web59203.mail.re1.yahoo.com> References: <6a3ae47e0904200357w7f45e543q6b835b35d4ac2b15@mail.gmail.com> <649666.56623.qm@web59203.mail.re1.yahoo.com> Message-ID: Hello, Where's the data from? I recently had a similar problem, which was solved by ensuring the data was in floating point format. I was using data in .csv files. I opened the file in excel, formatted the columns as a number with a decimal point, and re-saved as a csv... all the formatting was intact and it solved the problem. Altering the data source might be your best option...if you can! On Mon, Apr 20, 2009 at 6:02 PM, BranchingFactor wrote: > Thanks for the quick reply, Robbi. I was hoping to avoid the > try-and-try-again approach b/c it doesn't extend so nicely to scanning > multiple items from a string. Does Erlang provide any way to read what many > other programming languages consider to be the printed representation of a > number? > > --- On *Mon, 4/20/09, Robert Raschke * wrote: > > From: Robert Raschke > Subject: Re: [erlang-questions] fread() for numbers - beginner question > To: branchingfactor@REDACTED > Cc: erlang-questions@REDACTED > Date: Monday, April 20, 2009, 6:57 AM > > > On Mon, Apr 20, 2009 at 10:43 AM, BranchingFactor > > wrote: > > I'd like to io_lib:fread() a number from a string. Unfortunately, if > I use > > "~f" for floating point number, then fread rejects numbers that > don't have > > fractional parts: > > > >> io_lib:fread("~f", "1"). > > {error,{fread,float}} > >> io_lib:fread("~f", "1."). > > {error,{fread,float}} > > > > (I find this very strange, since both 1 and 1. can be represented in a > > floating point number.) > > And if I use "~d" for decimal integers, then fread won't > read past the > > decimal point: > > > >> io_lib:fread("~d", "1.0"). > > {ok,[1],".0"} > > > > What is the easiest way to scan a number from a string in erlang? > Ideally > > it would scan any number in any input format and return an Erlang object > > that satisfied the is_number() predicate. > > scan_number(S) -> > case io_lib:fread("~f", S) of > {error, _} > -> io_lib:fread("~d", S); > Result -> Result > end. > > This doesn't handle 16#ffff and friends though. but you can extend it > according to you needs. > > And "1." is not a valid Erlang number. > > Robby > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin@REDACTED Tue Apr 21 00:08:18 2009 From: kevin@REDACTED (Kevin A. Smith) Date: Mon, 20 Apr 2009 18:08:18 -0400 Subject: [erlang-questions] Hands-On Erlang, Chicago Edition Message-ID: <77A6A423-23A7-4699-BDE3-11BB5E6E1FFB@hypotheticalabs.com> I'm putting on a two-day Erlang training class on 7/15 - 7/16 in Chicago, IL. The class is targeted at developers who want to get up to speed quickly on Erlang and have some prior programming experience. If you've worked with Python, Ruby, Java, or even C/C++ and are having a hard time figuring out how to apply Erlang in your own projects this is the course for you. More information about the class, topics covered and location along with the registration form is available at: http://handsonerlangchicago.eventbrite.com Thanks, Kevin From kunthar@REDACTED Tue Apr 21 00:26:56 2009 From: kunthar@REDACTED (Kunthar) Date: Tue, 21 Apr 2009 01:26:56 +0300 Subject: [erlang-questions] Install R13A to Debian In-Reply-To: References: Message-ID: <9a09ca9a0904201526ic983376obba36a68e086d74c@mail.gmail.com> Could you set your bash LANG env. variable to C or pure en_US.UTF-8? $ export LANG=en_US.UTF-8 I had some weird results with language var before with Turkish. On Mon, Apr 20, 2009 at 7:28 PM, alekciy wrote: > I try compile R13A (in repository no package): > > debian:~/erlang/otp_src_R13A# gcc --version > gcc (Debian 4.3.2-1.1) 4.3.2 > > debian:~/erlang/otp_src_R13A# ./configure --without-termcap > Configure end ok. > > debian:~/erlang/otp_src_R13A# make > ... > drivers/unix/ttsl_drv.c:214: error: expected ???=???, > ???,???, ???;???, ???asm??? or > ???__attribute__??? before ???utf8buf??? > drivers/unix/ttsl_drv.c: In function ???ttysl_init???: > drivers/unix/ttsl_drv.c:237: warning: implicit declaration of function > ???DEBUGLOG??? > make[3]: *** [obj/i686-pc-linux-gnu/opt/smp/ttsl_drv.o] Error 1 > make[3]: Leaving directory `/root/erlang/otp_src_R13A/erts/emulator' > make[2]: *** [opt] Error 2 > make[2]: Leaving directory `/root/erlang/otp_src_R13A/erts/emulator' > make[1]: *** [smp] Error 2 > make[1]: Leaving directory `/root/erlang/otp_src_R13A/erts' > make: *** [emulator] Error 2 > debian:~/erlang/otp_src_R13A# > > Why this? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From public-mail@REDACTED Tue Apr 21 00:28:29 2009 From: public-mail@REDACTED (alekciy) Date: Tue, 21 Apr 2009 02:28:29 +0400 Subject: [erlang-questions] Install R13A to Debian In-Reply-To: <14f0e3620904201154k1352105yf1ac7363d0b21c46@mail.gmail.com> References: <14f0e3620904201154k1352105yf1ac7363d0b21c46@mail.gmail.com> Message-ID: <50b5ea1571f5f61688169c75a236b7cd@mail.vline.ru> On Mon, 20 Apr 2009 20:54:29 +0200, Gleb Peregud wrote: > There are Erlang R13A packages for Debian. Though they are in > "experimental" suite: > > http://packages.debian.org/experimental/erlang-base Great thanks! From steve.kirsch@REDACTED Tue Apr 21 00:44:10 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Mon, 20 Apr 2009 15:44:10 -0700 Subject: [erlang-questions] A simple multiply in the shell will kill theshell and its supervisor In-Reply-To: <5cd80c61-a2e0-4af1-9390-ecc8cb8d2fe2@s20g2000vbp.googlegroups.com> References: <68646767-DFF7-4BBA-9831-91FA6462B5E2@cs.otago.ac.nz><76BB7F270C366D47AA79851BB0B39D810294531E@exchg02.propel.com> <23143580.post@talk.nabble.com> <5cd80c61-a2e0-4af1-9390-ecc8cb8d2fe2@s20g2000vbp.googlegroups.com> Message-ID: <76BB7F270C366D47AA79851BB0B39D810294536D@exchg02.propel.com> i'm using R12B and I've tested on three completely different windows machines all running windows XP Pro and they all hang. On Unix and using werl, things work fine. so I'm not surprised that for most configurations it works fine. -----Original Message----- From: Steve Davis [mailto:steven.charles.davis@REDACTED] Sent: Monday, April 20, 2009 1:11 PM To: erlang-questions@REDACTED Subject: Re: [erlang-questions] A simple multiply in the shell will kill theshell and its supervisor Seems fine on my laptop too (XP3SP3/AMD64/R13A). On Apr 20, 2:45?pm, Zvi wrote: > this work great on my machine. > > Steve Kirsch wrote: > > > This only seems to kill erlang's shell permanently using erl on Windows. > > werl on the same machine works fine. > > > Startup erl on windows. > > > type in one line: > > A=748095723459245792834598234598723485792358972348572834759824592738 > > 5724 852984. B=A*A*A*A*A. C=B*B*B*B*B*B*B*B*B*B*B. > > D=C*C*C*C*C*C*C*C*C*C*C. > _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From public-mail@REDACTED Tue Apr 21 00:58:52 2009 From: public-mail@REDACTED (alekciy) Date: Tue, 21 Apr 2009 02:58:52 +0400 Subject: [erlang-questions] Install R13A to Debian In-Reply-To: <9a09ca9a0904201526ic983376obba36a68e086d74c@mail.gmail.com> References: <9a09ca9a0904201526ic983376obba36a68e086d74c@mail.gmail.com> Message-ID: On Tue, 21 Apr 2009 01:26:56 +0300, Kunthar wrote: > Could you set your bash LANG env. variable to C or pure en_US.UTF-8? > > $ export LANG=en_US.UTF-8 > > I had some weird results with language var before with Turkish. No work. I install from http://ftp.ru.debian.org/debian/pool/main/e/erlang/erlang-base_13.a-dfsg-1_i386.deb. It's work )) From v@REDACTED Tue Apr 21 01:15:03 2009 From: v@REDACTED (Valentin Micic) Date: Tue, 21 Apr 2009 01:15:03 +0200 Subject: [erlang-questions] : sctp_peeloff() support in OTP In-Reply-To: <20090420123844.GB8817@erix.ericsson.se> Message-ID: <200904202305.n3KN51Rc019325@mail.pharos-avantgard.com> One thing puzzles me: is there support for {active, once} in gen_sctp, as it would assume head-of-line blocking? Or maybe I should ask a different question: if {active, once} is to be supported, how one could go about implementing it without defeating the purpose behind SCTP? I am thinking: (1) {active, [once, StreamNo, TargetPID]} {active, [once, default, TargetPID]} As well as: (2) {active, [true, StreamNo, TargetPID]} {active, [true, default, TargetPID]} Where: - StreamNo represents a stream of interest; - TargetPID, a PID to which traffic received over StreamNo should be forwarded to. - default specify what to do with streams that are not explicitly referenced. Wouldn't this imply SCTP peel-off functionality? V. PS In a case you're already doing this -- my apologies for reinventing a hot water. -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Raimo Niskanen Sent: 20 April 2009 02:39 PM To: Maxim Treskin; erlang-questions@REDACTED Subject: Re: [erlang-questions] : sctp_peeloff() support in OTP On Mon, Apr 20, 2009 at 07:07:03PM +0700, Maxim Treskin wrote: > What is active mode? If socket port sends messages to process without > gen_sctp:recv is active mode, then it works now. May be it is something > another? Well, what do you know, I had already fixed it but forgot all about it. But our test suites really could test it much more... What about you open source users. Is active mode working fine for you? Under heavy load? In that case Peeloff is a possible next large feature to implement, if not the only missing large feature...? Anybody missing something other important? > > -- > Maxim Treskin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From exta7@REDACTED Tue Apr 21 02:32:59 2009 From: exta7@REDACTED (Zvi) Date: Mon, 20 Apr 2009 17:32:59 -0700 (PDT) Subject: [erlang-questions] A simple multiply in the shell will kill theshell and its supervisor In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810294536D@exchg02.propel.com> References: <68646767-DFF7-4BBA-9831-91FA6462B5E2@cs.otago.ac.nz> <76BB7F270C366D47AA79851BB0B39D810294531E@exchg02.propel.com> <23143580.post@talk.nabble.com> <5cd80c61-a2e0-4af1-9390-ecc8cb8d2fe2@s20g2000vbp.googlegroups.com> <76BB7F270C366D47AA79851BB0B39D810294536D@exchg02.propel.com> Message-ID: <23147413.post@talk.nabble.com> sorry, you are right it works in werl, but stuck on erl.exe - 0% CPU Steve Kirsch wrote: > > i'm using R12B and I've tested on three completely different windows > machines all running windows XP Pro and they all hang. > > On Unix and using werl, things work fine. > > so I'm not surprised that for most configurations it works fine. > > -----Original Message----- > From: Steve Davis [mailto:steven.charles.davis@REDACTED] > Sent: Monday, April 20, 2009 1:11 PM > To: erlang-questions@REDACTED > Subject: Re: [erlang-questions] A simple multiply in the shell will kill > theshell and its supervisor > > Seems fine on my laptop too (XP3SP3/AMD64/R13A). > > On Apr 20, 2:45?pm, Zvi wrote: >> this work great on my machine. >> >> Steve Kirsch wrote: >> >> > This only seems to kill erlang's shell permanently using erl on >> Windows. >> > werl on the same machine works fine. >> >> > Startup erl on windows. >> >> > type in one line: >> > A=748095723459245792834598234598723485792358972348572834759824592738 >> > 5724 852984. B=A*A*A*A*A. C=B*B*B*B*B*B*B*B*B*B*B. >> > D=C*C*C*C*C*C*C*C*C*C*C. >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/Graphing-options-in-erlang-tp23127285p23147413.html Sent from the Erlang Questions mailing list archive at Nabble.com. From raimo+erlang-questions@REDACTED Tue Apr 21 09:38:12 2009 From: raimo+erlang-questions@REDACTED ('Raimo Niskanen') Date: Tue, 21 Apr 2009 09:38:12 +0200 Subject: [erlang-questions] : : sctp_peeloff() support in OTP In-Reply-To: <200904202305.n3KN51Rc019325@mail.pharos-avantgard.com> References: <20090420123844.GB8817@erix.ericsson.se> <200904202305.n3KN51Rc019325@mail.pharos-avantgard.com> Message-ID: <20090421073812.GA5345@erix.ericsson.se> On Tue, Apr 21, 2009 at 01:15:03AM +0200, Valentin Micic wrote: > One thing puzzles me: is there support for {active, once} in gen_sctp, as it > would assume head-of-line blocking? Or maybe I should ask a different > question: if {active, once} is to be supported, how one could go about > implementing it without defeating the purpose behind SCTP? Could you elaborate...? I guess {active, once} today would simply be flow control of all streams towards the port owner. You can not choose which streams to control. > > I am thinking: > > (1) {active, [once, StreamNo, TargetPID]} > {active, [once, default, TargetPID]} > > As well as: > > (2) {active, [true, StreamNo, TargetPID]} > {active, [true, default, TargetPID]} > > Where: > - StreamNo represents a stream of interest; > - TargetPID, a PID to which traffic received over StreamNo should be > forwarded to. > - default specify what to do with streams that are not explicitly > referenced. > > Wouldn't this imply SCTP peel-off functionality? Yes it would, sort of. With this solution one Port would deliver messages to several PIDs, so it would have to remember those relations. Many PIDs would use the same Port for sending, so the normal port lock would probably be inadequate, the SCTP driver (which is the same as the TCP/UDP driver aka inet_drv) would have to do its own locking and since the code is shared between SCTP/TCP/UDP the question is how it would complicate the driver or how it will affect TCP/UDP. Many PIDs would receive messages from the Port, but one PId would be the owner and the only one notified if the Port is killed. Those are the first reasons I remember why I think an sctp_peeloff() that creates a new Port that uses the new file descriptor optained from sctp_peeloff() (if i remember correctly it works that way) would be a more fitting model. But I have not had time to think it through thoroughly - trying to implement it and see how it goes would probably be the best way. > > V. > > PS > In a case you're already doing this -- my apologies for reinventing a hot > water. > > > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Raimo Niskanen > Sent: 20 April 2009 02:39 PM > To: Maxim Treskin; erlang-questions@REDACTED > Subject: Re: [erlang-questions] : sctp_peeloff() support in OTP > > On Mon, Apr 20, 2009 at 07:07:03PM +0700, Maxim Treskin wrote: > > What is active mode? If socket port sends messages to process without > > gen_sctp:recv is active mode, then it works now. May be it is something > > another? > > Well, what do you know, I had already fixed it but forgot > all about it. But our test suites really could test it > much more... > > What about you open source users. Is active mode working > fine for you? Under heavy load? > > In that case Peeloff is a possible next large feature to implement, > if not the only missing large feature...? Anybody missing > something other important? > > > > > -- > > Maxim Treskin > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From egil@REDACTED Tue Apr 21 10:07:50 2009 From: egil@REDACTED (=?ISO-8859-1?Q?Bj=F6rn-Egil_Dahlberg?=) Date: Tue, 21 Apr 2009 10:07:50 +0200 Subject: [erlang-questions] Graphing options in erlang In-Reply-To: <23143513.post@talk.nabble.com> References: <23143513.post@talk.nabble.com> Message-ID: <49ED7ED6.10708@erix.ericsson.se> Zvi wrote: > OTP has a hidden Erlang binding for GD graphics library, in percept > application. > Look at egd module: > > http://erlang.org/doc/man/egd.html Actually egd is not bindings to GDlib. In the first implementation this was true, but now everything is implemented in erlang with no external dependencies and with no ties to gd. Only the name remains the same. // Bj?rn-Egil Erlang/OTP > > Zvi > > > Tom Malone-2 wrote: >> Is there a good graphing/charting library in erlang, I will want to do an >> x/y scatter graph, with a time based y axis and a log scale on the x axis, >> i >> have had a google and can't find one. I hoped i missed something. >> >> Thanks in advance >> >> Tom >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From zerthurd@REDACTED Tue Apr 21 14:58:13 2009 From: zerthurd@REDACTED (Maxim Treskin) Date: Tue, 21 Apr 2009 19:58:13 +0700 Subject: [erlang-questions] Beams dependency tool Message-ID: <200904211958.14197.zerthurd@gmail.com> Hello How I can get list of beams which used by my application? I need smallest system to deploy on embedded hardware (ARM) and do not want to take unused beams. I know that there may be implicit module usage, like Mod = list_to_atom("somemodule"), Mod:somefun() but it is not big problem. So, is there any tool for this? May be some actions with dialyzer? Thank you -- Maxim Treskin From oscar@REDACTED Tue Apr 21 15:15:44 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Tue, 21 Apr 2009 14:15:44 +0100 Subject: [erlang-questions] Beams dependency tool In-Reply-To: <200904211958.14197.zerthurd@gmail.com> References: <200904211958.14197.zerthurd@gmail.com> Message-ID: <49EDC700.7070309@erlang-consulting.com> Hi, Check out the xref module in the tools application [1]. AFAIK Dialyzer will warn you for undefined functions, but you'd need to build a PLT with all the applications you are using. I'm also not sure that it can output exactly which modules that seem to be used. Another approach could be to try cover, also part of the tools application. http://erlang.org/doc/apps/tools/ Maxim Treskin wrote: > Hello > > How I can get list of beams which used by my application? > I need smallest system to deploy on embedded hardware (ARM) and do not want to > take unused beams. I know that there may be implicit module usage, like > > Mod = list_to_atom("somemodule"), > Mod:somefun() > > but it is not big problem. > So, is there any tool for this? May be some actions with dialyzer? > > Thank you > > Best regards -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From rtrlists@REDACTED Tue Apr 21 15:56:13 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Tue, 21 Apr 2009 14:56:13 +0100 Subject: [erlang-questions] Beams dependency tool In-Reply-To: <200904211958.14197.zerthurd@gmail.com> References: <200904211958.14197.zerthurd@gmail.com> Message-ID: <6a3ae47e0904210656v4198b166k4d8e0c30f79eaf75@mail.gmail.com> On Tue, Apr 21, 2009 at 1:58 PM, Maxim Treskin wrote: > Hello > > How I can get list of beams which used by my application? > I need smallest system to deploy on embedded hardware (ARM) and do not want to > take unused beams. I know that there may be implicit module usage, like > > Mod = list_to_atom("somemodule"), > Mod:somefun() > > but it is not big problem. > So, is there any tool for this? May be some actions with dialyzer? > > Thank you > > -- > Maxim Treskin The low tech approach would be to use the function code:all_loaded() to give you a list of all the beams that have been loaded. If you start erl in interactive mode (see Section 1.4 of http://www.erlang.org/doc/system_principles/part_frame.html) and make sure your app is fully running (has touched all the functions it'll ever use, which might be tricky in practice) then code:all_loaded() should give you all the beams that are actually used. Robby From nick@REDACTED Tue Apr 21 15:59:02 2009 From: nick@REDACTED (Niclas Eklund) Date: Tue, 21 Apr 2009 15:59:02 +0200 (CEST) Subject: [erlang-questions] Beams dependency tool In-Reply-To: <49EDC700.7070309@erlang-consulting.com> References: <200904211958.14197.zerthurd@gmail.com> <49EDC700.7070309@erlang-consulting.com> Message-ID: Hello! See also http://www.erlang.org/doc/apps/reltool/index.html Best Regards Niclas @ Erlang/OTP On Tue, 21 Apr 2009, Oscar Hellstr?m wrote: > Hi, > > Check out the xref module in the tools application [1]. AFAIK Dialyzer > will warn you for undefined functions, but you'd need to build a PLT > with all the applications you are using. I'm also not sure that it can > output exactly which modules that seem to be used. Another approach > could be to try cover, also part of the tools application. > > http://erlang.org/doc/apps/tools/ > > Maxim Treskin wrote: >> Hello >> >> How I can get list of beams which used by my application? >> I need smallest system to deploy on embedded hardware (ARM) and do not want to >> take unused beams. I know that there may be implicit module usage, like >> >> Mod = list_to_atom("somemodule"), >> Mod:somefun() >> >> but it is not big problem. >> So, is there any tool for this? May be some actions with dialyzer? >> >> Thank you >> >> > > Best regards > > -- > Oscar Hellstr?m, oscar@REDACTED > Office: +44 20 7655 0337 > Mobile: +44 798 45 44 773 > Erlang Training and Consulting Ltd > http://www.erlang-consulting.com/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang@REDACTED Tue Apr 21 16:37:49 2009 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 21 Apr 2009 16:37:49 +0200 Subject: [erlang-questions] fread() for numbers - beginner question In-Reply-To: <437871.42937.qm@web59203.mail.re1.yahoo.com> References: <437871.42937.qm@web59203.mail.re1.yahoo.com> Message-ID: <9b08084c0904210737p505e3351yc9b5bd8b7bbfe82f@mail.gmail.com> How about using the tokeniser that Erlang uses? > erl_scan:string("pi,is,3.14159,\"strings\",1e10,1234"). {ok,[{atom,1,pi}, {',',1}, {atom,1,is}, {',',1}, {float,1,3.14159}, {',',1}, {string,1,"strings"}, {',',1}, {integer,1,1}, {atom,1,e10}, {',',1}, {integer,1,1234}], 1} > {ok, [{float,_,F}], _} = erl_scan:string("3.14159"). {ok,[{float,1,3.14159}],1} > F. 3.14159 etc. /Joe On Mon, Apr 20, 2009 at 11:43 AM, BranchingFactor wrote: > I'd like to io_lib:fread() a number from a string.? Unfortunately, if I use > "~f" for floating point number, then fread rejects numbers that don't have > fractional parts: > >> io_lib:fread("~f", "1"). > {error,{fread,float}} >> io_lib:fread("~f", "1."). > {error,{fread,float}} > > (I find this very strange, since both 1 and 1. can be represented in a > floating point number.) > And if I use "~d" for decimal integers, then fread won't read past the > decimal point: > >> io_lib:fread("~d", "1.0"). > {ok,[1],".0"} > > What is the easiest way to scan a number from a string in erlang?? Ideally > it would scan any number in any input format and return an Erlang object > that satisfied the is_number() predicate. > > Thank you, > > BF > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From bgustavsson@REDACTED Tue Apr 21 16:50:43 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Tue, 21 Apr 2009 16:50:43 +0200 Subject: [erlang-questions] Erlang/OTP R13B has been released Message-ID: <6672d0160904210750n7f474ec3n82facd0420d39a2d@mail.gmail.com> Major relese : otp_src_R13B Build date : 2009-04-21 R13B is a major new (non-beta) release of Erlang/OTP. You can download the full source distribution from http://www.erlang.org/download/otp_src_R13B.tar.gz http://www.erlang.org/download/otp_src_R13B.readme Note: To unpack the TAR archive you need a GNU TAR compatible program. For installation instructions please read the README that is part of the distribution. The Windows binary distribution can be downloaded from http://www.erlang.org/download/otp_win32_R13B.exe 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_R13B.tar.gz http://www.erlang.org/download/otp_doc_man_R13B.tar.gz We also want to thank those that sent us patches, suggestions and bug reports, The OTP Team -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From keith.irwin@REDACTED Tue Apr 21 17:42:46 2009 From: keith.irwin@REDACTED (Keith Irwin) Date: Tue, 21 Apr 2009 08:42:46 -0700 Subject: [erlang-questions] gen_tcp server won't release sockets? Message-ID: <8aff81590904210842y44ad634ahcb94933ff2873bba@mail.gmail.com> Folks-- I've implemented a gen_tcp server based on the example at the end of the gen_tcp man page. In other words, it spawns 5 processes for a process pool. Each process blocks on an accept call to a listen socket, reads an incoming request, responds with a response, then loops around to block on the accept again. The thing is, each of these processes in the process pool seems to hold a link to a port, as in, <#Port 0.123> (or something like that). I know this because I can start up the appmon, click on the process in the pool, and see an ever growing list of Ports inside the { links } tuple. When a certain limit is reached, I get an "enfile" or "emfile" error, the process dies, the ports (or whatever they are), are reclaimed. I then spawn_link a new process to add to the pool, and off I go. Is there some reason a process which loops over an "gen_tcp:accept" would keep holding on to the connections it gets in its link table? Another wrinkle: I'm running the gen_tcp server from within a gen_server instance. The gen_service:init creates the listen socket, then spawns the process pool (via spawn_link). I use handle_info to trap a call to EXIT to spawn a new process pool instance if one of the existing ones dies. (Mac OSX 10.5.6, Erlang R12B-5 via MacPorts) Keith -------------- next part -------------- An HTML attachment was scrubbed... URL: From v@REDACTED Tue Apr 21 17:58:47 2009 From: v@REDACTED (Valentin Micic) Date: Tue, 21 Apr 2009 17:58:47 +0200 Subject: [erlang-questions] : : sctp_peeloff() support in OTP In-Reply-To: <20090421073812.GA5345@erix.ericsson.se> Message-ID: <200904211548.n3LFmbRc023499@mail.pharos-avantgard.com> >> implementing it without defeating the purpose behind SCTP? > Could you elaborate...? Let me try by saying that TCP was not adequate for "multiplexing", a traffic case where a bunch of things on one machine wants to talk to a bunch of things on another using the same connection. The SCTP addressed this issue on a number of levels, but most importantly -- by eliminating a head-of-line blocking bottleneck (someone mentioned a year or two ago that SCTP would be far better protocol for Erlang distribution). The reasoning behind SCTP is to provide for a minimal latency, where processing of one stream should not create a processing delay on another. Having the same port owner responsible for all the processing is at odds with this design goal. In other words, {active, once} would effectively reintroduce head-of-line blocking, by serializing all the traffic and forcing it through a single process. Not so well thought through approach to active socket processing: ----------------------------------------------------------------- Maybe one may mitigate this by creating a number of Erlang processes as there are streams (call it stream processors), and route upstream traffic to a particular stream processor? Then, if there is an "external process" requesting {active, [once|true, StramNo, PID]} that relationship may be remembered by that particular "stream processor". The stream processor may also be responsible for queuing, etc. If there no "external process", requesting the traffic, it may be routed to the port-owner... Down-stream traffic may always be forced through port-owner, thus avoiding port locking problems (See below). +-------------------------------+ | +-----------+ | | | | | V V | | +-----+ +--+ +--+ |Owner| <--+ |P1|<----+ |Pn|<------+ +-----+ | +--+ | +--+ | | | | | | | | | | +----------+ +----------+ +----------+ | |StrmProc#1| |StrmProc#2| |StrmProc#n| | +----------+ +----------+ +----------+ | A A A V | | | +-----------+ | | |Port Driver|============+-------------+ +-----------+ Where: Owner - Port Owner StrmProc#n - Stream Processor n Pn - External Process n Kind Regards, V. From keith.irwin@REDACTED Tue Apr 21 18:58:44 2009 From: keith.irwin@REDACTED (Keith Irwin) Date: Tue, 21 Apr 2009 09:58:44 -0700 Subject: [erlang-questions] gen_tcp server won't release sockets? In-Reply-To: <8aff81590904210842y44ad634ahcb94933ff2873bba@mail.gmail.com> References: <8aff81590904210842y44ad634ahcb94933ff2873bba@mail.gmail.com> Message-ID: <8aff81590904210958k6bbe9b3ehc9ceac5ea0611f72@mail.gmail.com> On Tue, Apr 21, 2009 at 8:42 AM, Keith Irwin wrote: > Folks-- > I've implemented a gen_tcp server based on the example at the end of the > gen_tcp man page. In other words, it spawns 5 processes for a process pool. > Each process blocks on an accept call to a listen socket, reads an incoming > request, responds with a response, then loops around to block on the accept > again. > The thing is, each of these processes in the process pool seems to hold a > link to a port, as in, <#Port 0.123> (or something like that). I know this > because I can start up the appmon, click on the process in the pool, and see > an ever growing list of Ports inside the { links } tuple. > When a certain limit is reached, I get an "enfile" or "emfile" error, the > process dies, the ports (or whatever they are), are reclaimed. I then > spawn_link a new process to add to the pool, and off I go. > Is there some reason a process which loops over an "gen_tcp:accept" would > keep holding on to the connections it gets in its link table? > Another wrinkle: I'm running the gen_tcp server from within a gen_server > instance. The gen_service:init creates the listen socket, then spawns the > process pool (via spawn_link). I use handle_info to trap a call to EXIT to > spawn a new process pool instance if one of the existing ones dies. > (Mac OSX 10.5.6, Erlang R12B-5 via MacPorts) > Keith Here's an example of the process info provided by appmon for one of these pooled processes: Node: nonode@REDACTED, Process: <0.133.0> [{current_function,{prim_inet,accept0,2}}, {initial_call,{erlang,apply,2}}, {status,waiting}, {message_queue_len,0}, {messages,[]}, {links,[#Port<0.4256>,#Port<0.4394>,#Port<0.4510>,#Port<0.4575>, #Port<0.4590>,<0.131.0>,#Port<0.4587>,#Port<0.4540>,#Port<0.4557>, #Port<0.4548>,#Port<0.4529>,#Port<0.4522>,#Port<0.4456>, #Port<0.4474>,#Port<0.4495>,#Port<0.4486>,#Port<0.4468>, #Port<0.4464>,#Port<0.4432>,#Port<0.4452>,#Port<0.4438>, #Port<0.4428>,#Port<0.4414>,#Port<0.4312>,#Port<0.4364>, #Port<0.4384>,#Port<0.4376>,#Port<0.4356>,#Port<0.4350>, #Port<0.4286>,#Port<0.4302>,#Port<0.4292>,#Port<0.4276>, #Port<0.4266>,#Port<0.4008>,#Port<0.4133>,#Port<0.4196>, #Port<0.4226>,#Port<0.4246>,#Port<0.4236>,#Port<0.4216>, #Port<0.4206>,#Port<0.4154>,#Port<0.4172>,#Port<0.4162>, #Port<0.4146>,#Port<0.4139>,#Port<0.4069>,#Port<0.4096>, #Port<0.4129>,#Port<0.4124>,#Port<0.4084>,#Port<0.4074>, #Port<0.4038>,#Port<0.4056>,#Port<0.4040>,#Port<0.4028>, #Port<0.4022>,#Port<0.3884>,#Port<0.3940>,#Port<0.3978>, #Port<0.3996>,#Port<0.3990>,#Port<0.3970>,#Port<0.3947>, #Port<0.3914>,#Port<0.3929>,#Port<0.3924>,#Port<0.3902>, #Port<0.3894>,#Port<0.3824>,#Port<0.3854>,#Port<0.3879>, #Port<0.3864>,#Port<0.3844>,#Port<0.3834>,#Port<0.3794>, #Port<0.3814>,#Port<0.3804>,#Port<0.3784>,#Port<0.3774>]}, {dictionary,[]}, {trap_exit,false}, {error_handler,error_handler}, {priority,normal}, {group_leader,<0.33.0>}, {total_heap_size,10946}, {heap_size,4181}, {stack_size,10}, {reductions,1231748}, {garbage_collection,[{fullsweep_after,65535},{minor_gcs,13}]}, {suspending,[]}] The Ports in the links list keep growing until (I suspect) I run out of file handles. Any reason those aren't being collected? I even issue a gen_tcp:close(Socket) on the socket I get from the accept call. No good. Keith From keith.irwin@REDACTED Tue Apr 21 20:51:17 2009 From: keith.irwin@REDACTED (Keith Irwin) Date: Tue, 21 Apr 2009 11:51:17 -0700 Subject: [erlang-questions] gen_tcp server won't release sockets? In-Reply-To: <8aff81590904210958k6bbe9b3ehc9ceac5ea0611f72@mail.gmail.com> References: <8aff81590904210842y44ad634ahcb94933ff2873bba@mail.gmail.com> <8aff81590904210958k6bbe9b3ehc9ceac5ea0611f72@mail.gmail.com> Message-ID: <8aff81590904211151i2f981009j95ccaa47eb6fc1b8@mail.gmail.com> On Tue, Apr 21, 2009 at 9:58 AM, Keith Irwin wrote: > On Tue, Apr 21, 2009 at 8:42 AM, Keith Irwin wrote: >> Folks-- >> I've implemented a gen_tcp server based on the example at the end of the >> gen_tcp man page. In other words, it spawns 5 processes for a process pool. >> Each process blocks on an accept call to a listen socket, reads an incoming >> request, responds with a response, then loops around to block on the accept >> again. >> The thing is, each of these processes in the process pool seems to hold a >> link to a port, as in, <#Port 0.123> (or something like that). I know this >> because I can start up the appmon, click on the process in the pool, and see >> an ever growing list of Ports inside the { links } tuple. >> When a certain limit is reached, I get an "enfile" or "emfile" error, the >> process dies, the ports (or whatever they are), are reclaimed. I then >> spawn_link a new process to add to the pool, and off I go. >> Is there some reason a process which loops over an "gen_tcp:accept" would >> keep holding on to the connections it gets in its link table? >> Another wrinkle: I'm running the gen_tcp server from within a gen_server >> instance. The gen_service:init creates the listen socket, then spawns the >> process pool (via spawn_link). I use handle_info to trap a call to EXIT to >> spawn a new process pool instance if one of the existing ones dies. >> (Mac OSX 10.5.6, Erlang R12B-5 via MacPorts) >> Keith > > Here's an example of the process info provided by appmon for one of > these pooled processes: > > Node: nonode@REDACTED, Process: <0.133.0> > [{current_function,{prim_inet,accept0,2}}, > ?{initial_call,{erlang,apply,2}}, > ?{status,waiting}, > ?{message_queue_len,0}, > ?{messages,[]}, > ?{links,[#Port<0.4256>,#Port<0.4394>,#Port<0.4510>,#Port<0.4575>, > ? ? ? ? #Port<0.4590>,<0.131.0>,#Port<0.4587>,#Port<0.4540>,#Port<0.4557>, > ? ? ? ? #Port<0.4548>,#Port<0.4529>,#Port<0.4522>,#Port<0.4456>, > ? ? ? ? #Port<0.4474>,#Port<0.4495>,#Port<0.4486>,#Port<0.4468>, > ? ? ? ? #Port<0.4464>,#Port<0.4432>,#Port<0.4452>,#Port<0.4438>, > ? ? ? ? #Port<0.4428>,#Port<0.4414>,#Port<0.4312>,#Port<0.4364>, > ? ? ? ? #Port<0.4384>,#Port<0.4376>,#Port<0.4356>,#Port<0.4350>, > ? ? ? ? #Port<0.4286>,#Port<0.4302>,#Port<0.4292>,#Port<0.4276>, > ? ? ? ? #Port<0.4266>,#Port<0.4008>,#Port<0.4133>,#Port<0.4196>, > ? ? ? ? #Port<0.4226>,#Port<0.4246>,#Port<0.4236>,#Port<0.4216>, > ? ? ? ? #Port<0.4206>,#Port<0.4154>,#Port<0.4172>,#Port<0.4162>, > ? ? ? ? #Port<0.4146>,#Port<0.4139>,#Port<0.4069>,#Port<0.4096>, > ? ? ? ? #Port<0.4129>,#Port<0.4124>,#Port<0.4084>,#Port<0.4074>, > ? ? ? ? #Port<0.4038>,#Port<0.4056>,#Port<0.4040>,#Port<0.4028>, > ? ? ? ? #Port<0.4022>,#Port<0.3884>,#Port<0.3940>,#Port<0.3978>, > ? ? ? ? #Port<0.3996>,#Port<0.3990>,#Port<0.3970>,#Port<0.3947>, > ? ? ? ? #Port<0.3914>,#Port<0.3929>,#Port<0.3924>,#Port<0.3902>, > ? ? ? ? #Port<0.3894>,#Port<0.3824>,#Port<0.3854>,#Port<0.3879>, > ? ? ? ? #Port<0.3864>,#Port<0.3844>,#Port<0.3834>,#Port<0.3794>, > ? ? ? ? #Port<0.3814>,#Port<0.3804>,#Port<0.3784>,#Port<0.3774>]}, > ?{dictionary,[]}, > ?{trap_exit,false}, > ?{error_handler,error_handler}, > ?{priority,normal}, > ?{group_leader,<0.33.0>}, > ?{total_heap_size,10946}, > ?{heap_size,4181}, > ?{stack_size,10}, > ?{reductions,1231748}, > ?{garbage_collection,[{fullsweep_after,65535},{minor_gcs,13}]}, > ?{suspending,[]}] > > > The Ports in the links list keep growing until (I suspect) I run out > of file handles. Any reason those aren't being collected? I even issue > a gen_tcp:close(Socket) on the socket I get from the accept call. No > good. To add another detail, the above #Port<0.1234> style numbers are all one less than the number of the socket I get from the accept call. Keith From richardc@REDACTED Tue Apr 21 20:57:17 2009 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 21 Apr 2009 20:57:17 +0200 Subject: [erlang-questions] patch for eunit in R13B Message-ID: <49EE170D.6060500@it.uu.se> I was in a panic to put together a new eunit version for R13B in time for the surprise early release, so there was no time for OTP to actually test the combination, and of course there was a problem. The attached patch should fix it, for now. Sorry for the inconvenience. /Richard -------------- next part -------------- A non-text attachment was scrubbed... Name: eunit.diff Type: text/x-patch Size: 1237 bytes Desc: not available URL: From tony@REDACTED Tue Apr 21 20:35:13 2009 From: tony@REDACTED (Tony Rogvall) Date: Tue, 21 Apr 2009 20:35:13 +0200 Subject: [erlang-questions] Geek Gang Signs Message-ID: http://www.joeydevilla.com/2008/05/29/geek-gang-signs/ Please rehearse before the next Erlang User Group meeting ;-) /Tony From rpettit@REDACTED Tue Apr 21 21:42:28 2009 From: rpettit@REDACTED (Rick Pettit) Date: Tue, 21 Apr 2009 14:42:28 -0500 (CDT) Subject: [erlang-questions] mnesia:dirty_slot/2 returns [] for non-empty table? Message-ID: <51350.192.168.129.36.1240342948.squirrel@squirrelmail.vail> I am maintaining yaws code which presents a user with a list of local mnesia tables, presenting them with an HTML link for each table. Upon clicking the link for a given table, the user is either presented with a dump of the entire table (for "small" tables in which size <= 50), or a dump of the first "slot" (i.e. slot 0). This code has worked well for quite some time. Recently, however, someone brought it to my attention that for a particular table the "slot 0" display showed [] (even though the table was non-empty). Here's some poking around I did at the shell: (foo_rel@REDACTED)1> mnesia:table_info(test_tab,size). 4430 (foo_rel@REDACTED)2> mnesia:dirty_slot(test_tab,0). [] (foo_rel@REDACTED)3> mnesia:dirty_first(test_tab). 1453 (foo_rel@REDACTED)4> ets:slot(test_tab,0). [] (foo_rel@REDACTED)5> ets:first(test_tab). 1453 === I've just begun digging through the mnesia source code, so it is probably a bit premature to ask, but does anyone have an idea why mnesia:dirty_slot/2 might be returning [] in this case (i.e. where the table is non-empty and where mnesia:dirty_first/1 returns a Key) ? -Rick From james.hague@REDACTED Tue Apr 21 21:45:03 2009 From: james.hague@REDACTED (James Hague) Date: Tue, 21 Apr 2009 14:45:03 -0500 Subject: [erlang-questions] Still problems with open_port({spawn, XYZ}, ...) under Windows? Message-ID: Looks like it's still not possible to spawn a program with spaces in the name, even in R13B. True? With quoting acrobatics, os:cmd works, but it does bring cmd.exe or the shell of your choice into the picture, which isn't always a good thing. James From peter@REDACTED Tue Apr 21 21:45:17 2009 From: peter@REDACTED (Peter Sabaini) Date: Tue, 21 Apr 2009 21:45:17 +0200 Subject: [erlang-questions] patch for eunit in R13B In-Reply-To: <49EE170D.6060500@it.uu.se> References: <49EE170D.6060500@it.uu.se> Message-ID: <1240343117.21069.4.camel@gram.local> Whew! Thanks, I was beginning do think I unwittingly might have attracted the ire of the Gods Of Unicode :-) peter. On Tue, 2009-04-21 at 20:57 +0200, Richard Carlsson wrote: > I was in a panic to put together a new eunit version for R13B in > time for the surprise early release, so there was no time for OTP > to actually test the combination, and of course there was a problem. > The attached patch should fix it, for now. Sorry for the inconvenience. > > /Richard > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part URL: From keith.irwin@REDACTED Tue Apr 21 21:56:57 2009 From: keith.irwin@REDACTED (Keith Irwin) Date: Tue, 21 Apr 2009 12:56:57 -0700 Subject: [erlang-questions] gen_tcp server won't release sockets? In-Reply-To: <8aff81590904211151i2f981009j95ccaa47eb6fc1b8@mail.gmail.com> References: <8aff81590904210842y44ad634ahcb94933ff2873bba@mail.gmail.com> <8aff81590904210958k6bbe9b3ehc9ceac5ea0611f72@mail.gmail.com> <8aff81590904211151i2f981009j95ccaa47eb6fc1b8@mail.gmail.com> Message-ID: <8aff81590904211256s1b729cb4m58a562774f57c7db@mail.gmail.com> I solved this issue. The handler was calling code which did (basically) an HTTP get, but my HTTP get class was not closing the socket when it was done. Keith On Tue, Apr 21, 2009 at 11:51 AM, Keith Irwin wrote: > On Tue, Apr 21, 2009 at 9:58 AM, Keith Irwin wrote: >> On Tue, Apr 21, 2009 at 8:42 AM, Keith Irwin wrote: >>> Folks-- >>> I've implemented a gen_tcp server based on the example at the end of the >>> gen_tcp man page. In other words, it spawns 5 processes for a process pool. >>> Each process blocks on an accept call to a listen socket, reads an incoming >>> request, responds with a response, then loops around to block on the accept >>> again. >>> The thing is, each of these processes in the process pool seems to hold a >>> link to a port, as in, <#Port 0.123> (or something like that). I know this >>> because I can start up the appmon, click on the process in the pool, and see >>> an ever growing list of Ports inside the { links } tuple. >>> When a certain limit is reached, I get an "enfile" or "emfile" error, the >>> process dies, the ports (or whatever they are), are reclaimed. I then >>> spawn_link a new process to add to the pool, and off I go. >>> Is there some reason a process which loops over an "gen_tcp:accept" would >>> keep holding on to the connections it gets in its link table? >>> Another wrinkle: I'm running the gen_tcp server from within a gen_server >>> instance. The gen_service:init creates the listen socket, then spawns the >>> process pool (via spawn_link). I use handle_info to trap a call to EXIT to >>> spawn a new process pool instance if one of the existing ones dies. >>> (Mac OSX 10.5.6, Erlang R12B-5 via MacPorts) >>> Keith >> >> Here's an example of the process info provided by appmon for one of >> these pooled processes: >> >> Node: nonode@REDACTED, Process: <0.133.0> >> [{current_function,{prim_inet,accept0,2}}, >> ?{initial_call,{erlang,apply,2}}, >> ?{status,waiting}, >> ?{message_queue_len,0}, >> ?{messages,[]}, >> ?{links,[#Port<0.4256>,#Port<0.4394>,#Port<0.4510>,#Port<0.4575>, >> ? ? ? ? #Port<0.4590>,<0.131.0>,#Port<0.4587>,#Port<0.4540>,#Port<0.4557>, >> ? ? ? ? #Port<0.4548>,#Port<0.4529>,#Port<0.4522>,#Port<0.4456>, >> ? ? ? ? #Port<0.4474>,#Port<0.4495>,#Port<0.4486>,#Port<0.4468>, >> ? ? ? ? #Port<0.4464>,#Port<0.4432>,#Port<0.4452>,#Port<0.4438>, >> ? ? ? ? #Port<0.4428>,#Port<0.4414>,#Port<0.4312>,#Port<0.4364>, >> ? ? ? ? #Port<0.4384>,#Port<0.4376>,#Port<0.4356>,#Port<0.4350>, >> ? ? ? ? #Port<0.4286>,#Port<0.4302>,#Port<0.4292>,#Port<0.4276>, >> ? ? ? ? #Port<0.4266>,#Port<0.4008>,#Port<0.4133>,#Port<0.4196>, >> ? ? ? ? #Port<0.4226>,#Port<0.4246>,#Port<0.4236>,#Port<0.4216>, >> ? ? ? ? #Port<0.4206>,#Port<0.4154>,#Port<0.4172>,#Port<0.4162>, >> ? ? ? ? #Port<0.4146>,#Port<0.4139>,#Port<0.4069>,#Port<0.4096>, >> ? ? ? ? #Port<0.4129>,#Port<0.4124>,#Port<0.4084>,#Port<0.4074>, >> ? ? ? ? #Port<0.4038>,#Port<0.4056>,#Port<0.4040>,#Port<0.4028>, >> ? ? ? ? #Port<0.4022>,#Port<0.3884>,#Port<0.3940>,#Port<0.3978>, >> ? ? ? ? #Port<0.3996>,#Port<0.3990>,#Port<0.3970>,#Port<0.3947>, >> ? ? ? ? #Port<0.3914>,#Port<0.3929>,#Port<0.3924>,#Port<0.3902>, >> ? ? ? ? #Port<0.3894>,#Port<0.3824>,#Port<0.3854>,#Port<0.3879>, >> ? ? ? ? #Port<0.3864>,#Port<0.3844>,#Port<0.3834>,#Port<0.3794>, >> ? ? ? ? #Port<0.3814>,#Port<0.3804>,#Port<0.3784>,#Port<0.3774>]}, >> ?{dictionary,[]}, >> ?{trap_exit,false}, >> ?{error_handler,error_handler}, >> ?{priority,normal}, >> ?{group_leader,<0.33.0>}, >> ?{total_heap_size,10946}, >> ?{heap_size,4181}, >> ?{stack_size,10}, >> ?{reductions,1231748}, >> ?{garbage_collection,[{fullsweep_after,65535},{minor_gcs,13}]}, >> ?{suspending,[]}] >> >> >> The Ports in the links list keep growing until (I suspect) I run out >> of file handles. Any reason those aren't being collected? I even issue >> a gen_tcp:close(Socket) on the socket I get from the accept call. No >> good. > > To add another detail, the above #Port<0.1234> style numbers are all > one less than the number of the socket I get from the accept call. > > Keith > From richardc@REDACTED Tue Apr 21 22:21:47 2009 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 21 Apr 2009 22:21:47 +0200 Subject: [erlang-questions] patch for eunit in R13B In-Reply-To: <1240343117.21069.4.camel@gram.local> References: <49EE170D.6060500@it.uu.se> <1240343117.21069.4.camel@gram.local> Message-ID: <49EE2ADB.9090601@it.uu.se> Peter Sabaini wrote: > Whew! Thanks, I was beginning do think I unwittingly might have > attracted the ire of the Gods Of Unicode :-) No, that was me. And verily did they smite me. :-( /R From lfeiman888@REDACTED Wed Apr 22 02:03:11 2009 From: lfeiman888@REDACTED (feiman) Date: Tue, 21 Apr 2009 17:03:11 -0700 (PDT) Subject: [erlang-questions] Help! a log dump function from C. Message-ID: hi,All I have a function from C,which print out detail hex information about a buffer,who can help me "translate" it into Erlang? when I run const char *teststr = "teststr1234567890abcd"; dump_hex((const unsigned char *)teststr,strlen(teststr)); it print out 00000000: 74 65 73 74 73 74 72 31 32 33 34 35 36 37 38 39 - teststr123456789 00000010: 30 61 62 63 64 - 0abcd thanks all in advance void dump_hex( const unsigned char *buf, int len) { int i; int nlocal; const unsigned char *pc; char *out; const unsigned char *start; char c; char line[100]; start = buf; while (len > 0) { sprintf(line, "%08x: ", buf - start); out = line + 10; for (i = 0, pc = buf, nlocal = len; i < 16; i++, pc++) { if (nlocal > 0) { c = *pc; *out++ = NIBBLE((c >> 4) & 0xF); *out++ = NIBBLE(c & 0xF); nlocal--; } else { *out++ = ' '; *out++ = ' '; } /* end else */ *out++ = ' '; } /* end for */ *out++ = '-'; *out++ = ' '; for (i = 0, pc = buf, nlocal = len; (i < 16) && (nlocal > 0); i++, pc++, nlocal--) { c = *pc; if ((c < ' ') || (c >= 126)) { c = '.'; } *out++ = c; } /* end for */ *out++ = 0; llog(L_NOTICE,"%s", line); buf += 16; len -= 16; } /* end while */ } /* end dump */ From erlangy@REDACTED Wed Apr 22 05:18:52 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Tue, 21 Apr 2009 20:18:52 -0700 Subject: [erlang-questions] Help! a log dump function from C. In-Reply-To: References: Message-ID: <20090422031851.GN29268@delora.autosys.us> lists:foldl( fun(X, Acc) -> io:fwrite("~.16B ", [X]) end, "", "teststr" ). On Tue, Apr 21, 2009 at 05:03:11PM -0700, feiman wrote: > hi,All > I have a function from C,which print out detail hex information > about a buffer,who can help me "translate" it into Erlang? > > when I run > const char *teststr = "teststr1234567890abcd"; > > dump_hex((const unsigned char *)teststr,strlen(teststr)); > > it print out > > 00000000: 74 65 73 74 73 74 72 31 32 33 34 35 36 37 38 39 - > teststr123456789 > 00000010: 30 61 62 63 64 - 0abcd > > thanks all in advance > > void dump_hex( const unsigned char *buf, int len) > { > int i; > int nlocal; > const unsigned char *pc; > char *out; > const unsigned char *start; > char c; > char line[100]; > > start = buf; > > while (len > 0) > { > sprintf(line, "%08x: ", buf - start); > out = line + 10; > > for (i = 0, pc = buf, nlocal = len; i < 16; i++, pc++) > { > if (nlocal > 0) > { > c = *pc; > > *out++ = NIBBLE((c >> 4) & 0xF); > *out++ = NIBBLE(c & 0xF); > > nlocal--; > } > else > { > *out++ = ' '; > *out++ = ' '; > } /* end else */ > > *out++ = ' '; > } /* end for */ > > *out++ = '-'; > *out++ = ' '; > > for (i = 0, pc = buf, nlocal = len; > (i < 16) && (nlocal > 0); > i++, pc++, nlocal--) > { > c = *pc; > > if ((c < ' ') || (c >= 126)) > { > c = '.'; > } > > *out++ = c; > } /* end for */ > > *out++ = 0; > > llog(L_NOTICE,"%s", line); > > buf += 16; > len -= 16; > } /* end while */ > } /* end dump */ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://trip.autosys.us http://autosys.us http://mmcdaniel.com/erlview From hayeah@REDACTED Wed Apr 22 08:36:07 2009 From: hayeah@REDACTED (Howard Yeh) Date: Tue, 21 Apr 2009 23:36:07 -0700 Subject: [erlang-questions] type declarations Message-ID: Hi, I read the dialyzer on wrangler paper, and it looks really neat. I am trying to annotate my code with type declarations, but I am getting syntax errors. For the simple declaration, -spec test() -> 'ok'. I get, syntax error before: test Is there a flag i need to throw? I am using R12B Thanks, Howard From bengt.kleberg@REDACTED Wed Apr 22 08:45:16 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 22 Apr 2009 08:45:16 +0200 Subject: [erlang-questions] type declarations In-Reply-To: References: Message-ID: <1240382717.4671.0.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, You can not use -spec in R12B. bengt On Tue, 2009-04-21 at 23:36 -0700, Howard Yeh wrote: > Hi, > > I read the dialyzer on wrangler paper, and it looks really neat. > > I am trying to annotate my code with type declarations, but I am > getting syntax errors. > > For the simple declaration, > > -spec test() -> 'ok'. > > I get, > > syntax error before: test > > > Is there a flag i need to throw? I am using R12B > > Thanks, > Howard > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From kostis@REDACTED Wed Apr 22 09:00:47 2009 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 22 Apr 2009 10:00:47 +0300 Subject: [erlang-questions] type declarations In-Reply-To: References: Message-ID: <49EEC09F.3090009@cs.ntua.gr> Howard Yeh wrote: > Hi, > > I read the dialyzer on wrangler paper, and it looks really neat. Thanks! > I am trying to annotate my code with type declarations, but I am > getting syntax errors. > > For the simple declaration, > > -spec test() -> 'ok'. > > I get, > > syntax error before: test > > Is there a flag i need to throw? I am using R12B. If I am not mistaken, -spec works starting with R12B-5 (and most probably also in R12B-4) but not in earlier R12B versions. In any case, I suggest you upgrade to the recently released R13B. There are more reasons to do so besides -specs. Best, Kostis From vychodil.hynek@REDACTED Wed Apr 22 09:27:29 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 22 Apr 2009 09:27:29 +0200 Subject: [erlang-questions] Help! a log dump function from C. In-Reply-To: References: Message-ID: <4d08db370904220027v71565296vda99cac23eb251ef@mail.gmail.com> There are many many approaches to do this, one that doesn't use io or io_lib follows: -module(dump_hex). -compile(inline). -export([dump_hex/1]). dump_hex(L) -> lists:reverse(dump_hex(0, L, [])). dump_hex(_, [pad | _], R) -> R; dump_hex(_, [], R) -> R; dump_hex(N, [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16 | T], R) -> dump_hex(N + 16, T, [[addr(N), $:, [[$\s | hex(X)] || X <- [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16]], " - ", [print(X) || X <- [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16]], $\n] | R]); dump_hex(N, L, R) -> dump_hex(N, L ++ [pad, pad, pad, pad, pad, pad, pad, pad, pad, pad, pad, pad, pad, pad, pad, pad], R). addr(X) -> [nibble(X bsr 28), nibble(X bsr 24), nibble(X bsr 20), nibble(X bsr 16), nibble(X bsr 12), nibble(X bsr 8), nibble(X bsr 4), nibble(X)]. hex(pad) -> " "; hex(X) -> [nibble(X bsr 4), nibble(X)]. nibble(X) -> nibble_(X band 15). nibble_(X) when X < 10 -> X + $0; nibble_(X) -> X + $a. print(pad) -> []; print(X) when X < $\s, X > 126 -> $.; print(X) -> X. Usage: 1> c(dump_hex). {ok,dump_hex} 2> io:put_chars(dump_hex:dump_hex("teststr1234567890abcd")). 00000000: 74 65 73 74 73 74 72 31 32 33 34 35 36 37 38 39 - teststr123456789 00000010: 30 61 62 63 64 - 0abcd ok On Wed, Apr 22, 2009 at 2:03 AM, feiman wrote: > hi,All > I have a function from C,which print out detail hex information > about a buffer,who can help me "translate" it into Erlang? > > when I run > const char *teststr = "teststr1234567890abcd"; > > dump_hex((const unsigned char *)teststr,strlen(teststr)); > > it print out > > 00000000: 74 65 73 74 73 74 72 31 32 33 34 35 36 37 38 39 - > teststr123456789 > 00000010: 30 61 62 63 64 - 0abcd > > thanks all in advance > > void dump_hex( const unsigned char *buf, int len) > { > int i; > int nlocal; > const unsigned char *pc; > char *out; > const unsigned char *start; > char c; > char line[100]; > > start = buf; > > while (len > 0) > { > sprintf(line, "%08x: ", buf - start); > out = line + 10; > > for (i = 0, pc = buf, nlocal = len; i < 16; i++, pc++) > { > if (nlocal > 0) > { > c = *pc; > > *out++ = NIBBLE((c >> 4) & 0xF); > *out++ = NIBBLE(c & 0xF); > > nlocal--; > } > else > { > *out++ = ' '; > *out++ = ' '; > } /* end else */ > > *out++ = ' '; > } /* end for */ > > *out++ = '-'; > *out++ = ' '; > > for (i = 0, pc = buf, nlocal = len; > (i < 16) && (nlocal > 0); > i++, pc++, nlocal--) > { > c = *pc; > > if ((c < ' ') || (c >= 126)) > { > c = '.'; > } > > *out++ = c; > } /* end for */ > > *out++ = 0; > > llog(L_NOTICE,"%s", line); > > buf += 16; > len -= 16; > } /* end while */ > } /* end dump */ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From hayeah@REDACTED Wed Apr 22 10:15:02 2009 From: hayeah@REDACTED (Howard Yeh) Date: Wed, 22 Apr 2009 01:15:02 -0700 Subject: [erlang-questions] type declarations In-Reply-To: <49EEC09F.3090009@cs.ntua.gr> References: <49EEC09F.3090009@cs.ntua.gr> Message-ID: > In any case, I suggest > you upgrade to the recently released R13B. ?There are more reasons to do so > besides -specs. works now! thanks so much : ) From chaitanya.chalasani@REDACTED Wed Apr 22 10:17:24 2009 From: chaitanya.chalasani@REDACTED (chaitanya Chalasani) Date: Wed, 22 Apr 2009 13:47:24 +0530 Subject: [erlang-questions] Clustering through Multicast Message-ID: <1240388244.3918.9.camel@chaitanya.laptop> Hi, May be the solution exists, but the idea just popped and want to clarify if it really works this way. Instead of the regular cluster node and unicast load balance to multiple worker nodes, if we use the IP multicast to a group of servers with replicated mnesia and let each node attempt to start a transaction and only one node gets to act on it, based on the mnesia transaction write lock, will there be less latency in distributing the transactions. And also it might help in some cases wherein the delay in identifying dead node would not effect the transactions within. ------ CHAITANYA CHALASANI -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Wed Apr 22 09:16:53 2009 From: tony@REDACTED (Tony Rogvall) Date: Wed, 22 Apr 2009 09:16:53 +0200 Subject: [erlang-questions] Help! a log dump function from C. In-Reply-To: References: Message-ID: <71DA6B5E-F6BE-46EE-8444-4E733667FF88@rogvall.se> I just needed one myself ;-) dump(Binary) -> dump(0, Binary). dump(A, <>) -> A1 = dump_chunk(A, B), dump(A1, Rest); dump(A, B) -> dump_chunk(A, B). dump_chunk(A, B) -> Xs = [io_lib:format("~2.16.0B ", [X]) || <> <= B ], Cs = [(if C >= 126; C < $\s -> $.; true -> C end) || <> <= B], io:format("~8.16.0B: ~-48s- ~s\n", [A,Xs,Cs]), A+size(B). You can modify this if you want to avoid one extra line when binary size is a multiple of 16 It worked nicely on my jpeg file .... /Tony On 22 apr 2009, at 02.03, feiman wrote: > hi,All > I have a function from C,which print out detail hex information > about a buffer,who can help me "translate" it into Erlang? > > when I run > const char *teststr = "teststr1234567890abcd"; > > dump_hex((const unsigned char *)teststr,strlen(teststr)); > > it print out > > 00000000: 74 65 73 74 73 74 72 31 32 33 34 35 36 37 38 39 - > teststr123456789 > 00000010: 30 61 62 63 64 - 0abcd > > thanks all in advance > > void dump_hex( const unsigned char *buf, int len) > { > int i; > int nlocal; > const unsigned char *pc; > char *out; > const unsigned char *start; > char c; > char line[100]; > > start = buf; > > while (len > 0) > { > sprintf(line, "%08x: ", buf - start); > out = line + 10; > > for (i = 0, pc = buf, nlocal = len; i < 16; i++, pc++) > { > if (nlocal > 0) > { > c = *pc; > > *out++ = NIBBLE((c >> 4) & 0xF); > *out++ = NIBBLE(c & 0xF); > > nlocal--; > } > else > { > *out++ = ' '; > *out++ = ' '; > } /* end else */ > > *out++ = ' '; > } /* end for */ > > *out++ = '-'; > *out++ = ' '; > > for (i = 0, pc = buf, nlocal = len; > (i < 16) && (nlocal > 0); > i++, pc++, nlocal--) > { > c = *pc; > > if ((c < ' ') || (c >= 126)) > { > c = '.'; > } > > *out++ = c; > } /* end for */ > > *out++ = 0; > > llog(L_NOTICE,"%s", line); > > buf += 16; > len -= 16; > } /* end while */ > } /* end dump */ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From hakan@REDACTED Wed Apr 22 09:31:16 2009 From: hakan@REDACTED (Hakan Mattsson) Date: Wed, 22 Apr 2009 09:31:16 +0200 (CEST) Subject: [erlang-questions] mnesia:dirty_slot/2 returns [] for non-empty table? In-Reply-To: <51350.192.168.129.36.1240342948.squirrel@squirrelmail.vail> References: <51350.192.168.129.36.1240342948.squirrel@squirrelmail.vail> Message-ID: On Tue, 21 Apr 2009, Rick Pettit wrote: > I've just begun digging through the mnesia source code, so it is probably > a bit premature to ask, but does anyone have an idea why > mnesia:dirty_slot/2 might be returning [] in this case (i.e. where the > table is non-empty and where mnesia:dirty_first/1 returns a Key) ? The man page for ets:slot/2 explains how the function works: This function is mostly for debugging purposes, Normally one should use first/next or last/prev instead. Returns all objects in the I:th slot of the table Tab. A table can be traversed by repeatedly calling the function, starting with the first slot I=0 and ending when '$end_of_table' is returned. The function will fail with reason badarg if the I argument is out of range. /H?kan --- H?kan Mattsson (uabhams) Erlang/OTP, Ericsson AB From amit.murthy@REDACTED Wed Apr 22 10:35:14 2009 From: amit.murthy@REDACTED (Amit Murthy) Date: Wed, 22 Apr 2009 14:05:14 +0530 Subject: [erlang-questions] disk_log question Message-ID: <4f5fdb630904220135r5da2ba7bk6a355fafd05cd4ba@mail.gmail.com> Hi, I want to use disk_log with an external format for application info logging. I was experimenting with disk_log in the console and I found the following behavior: On an opened (opened via the open() call) log , once any of the functions in the module return any, and I mean ANY error, the log gets closed and is no longer available. All subsequent calls return {error,no_such_log}. Even an error like "** exception error: undefined function disk_log:xxxxx/2" results in the same behavior. I wanted to open a single log at startup and use it for logging in all the other functions. Now, this may not be right way to do it, since if any of the logging calls return an error, the log gets effectively closed. Is there any explanation for this? Or is there a better way to implement application error/info logging? Amit -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Wed Apr 22 10:35:59 2009 From: raimo+erlang-questions@REDACTED ('Raimo Niskanen') Date: Wed, 22 Apr 2009 10:35:59 +0200 Subject: [erlang-questions] : : : sctp_peeloff() support in OTP In-Reply-To: <200904211548.n3LFmbRc023499@mail.pharos-avantgard.com> References: <20090421073812.GA5345@erix.ericsson.se> <200904211548.n3LFmbRc023499@mail.pharos-avantgard.com> Message-ID: <20090422083559.GA1705@erix.ericsson.se> On Tue, Apr 21, 2009 at 05:58:47PM +0200, Valentin Micic wrote: > > >> implementing it without defeating the purpose behind SCTP? > > > Could you elaborate...? > > Let me try by saying that TCP was not adequate for "multiplexing", a traffic > case where a bunch of things on one machine wants to talk to a bunch of > things on another using the same connection. The SCTP addressed this issue > on a number of levels, but most importantly -- by eliminating a head-of-line > blocking bottleneck (someone mentioned a year or two ago that SCTP would be > far better protocol for Erlang distribution). > > The reasoning behind SCTP is to provide for a minimal latency, where > processing of one stream should not create a processing delay on another. > Having the same port owner responsible for all the processing is at odds > with this design goal. In other words, {active, once} would effectively > reintroduce head-of-line blocking, by serializing all the traffic and > forcing it through a single process. > Thank you for the explanation. The term "head-of-line blocking" was new to me. Unfortunately I just realized that when the driver calls recvmsg() it can not choose which stream to receive from. So {active,once} must introduce head-of-line blocking in some form. And introducing {active,StreamNo,Pid} would have to imply {active,true}, just dispatching the streams. I think the only thing that solves the head-of-line blocking problem is branched-off associations (sctp_peeloff()) because then you get a new filedescriptor to poll() and recvmsg() as you choose from, in a new port driver instance (Port). Correct me if I am wrong. > Not so well thought through approach to active socket processing: > ----------------------------------------------------------------- > Maybe one may mitigate this by creating a number of Erlang processes as > there are streams (call it stream processors), and route upstream traffic to > a particular stream processor? Then, if there is an "external process" > requesting {active, [once|true, StramNo, PID]} that relationship may be > remembered by that particular "stream processor". The stream processor may > also be responsible for queuing, etc. If there no "external process", > requesting the traffic, it may be routed to the port-owner... > > Down-stream traffic may always be forced through port-owner, thus avoiding > port locking problems (See below). > > +-------------------------------+ > | +-----------+ | > | | | | > V V | | > +-----+ +--+ +--+ > |Owner| <--+ |P1|<----+ |Pn|<------+ > +-----+ | +--+ | +--+ | > | | | | > | | | | > | +----------+ +----------+ +----------+ > | |StrmProc#1| |StrmProc#2| |StrmProc#n| > | +----------+ +----------+ +----------+ > | A A A > V | | | > +-----------+ | | > |Port Driver|============+-------------+ > +-----------+ > > Where: > Owner - Port Owner > StrmProc#n - Stream Processor n > Pn - External Process n > > Kind Regards, > V. I see no obvious gain with respect to the simple approach (as you suggested first (as I understood it)), that would be: +------+ +----+ +----+ | | | | | | +-----+ | | +--+ | +--+ |Owner| | | |P1| | |Pn| +-----+ | | +--+ | +--+ | A A | A | V | | V | V +---------------------------------+ | Port Driver | +---------------------------------+ The port lock is just an efficiency problem. All processes simultaneously sending to a port will compete for the same lock. Passing all downstream data through the port owner will only introduce copying. The port driver will in both cases have to know (have a lookup table) of where to deliver messages on a given stream. This is a currently missing feature. Having erlang processes in the upstream data path will also introduce copying. The only advantage I see with the StrmProc processes is that they can be created and maintained through library code that can solve the problem of notifying them if the port gets killed. This problem can maybe just as well be solved by documenting and by e.g an API function that when registering a PID for a given stream will also set a monitor on the port. Would not sctp_peeloff() solve the right problems? Or would it waste filedescriptors? Is it necessary to have the possibility to multiplex streams on one SCTP file descriptor even though it implies {active,true}. +------+ +----+ +----+ | | | | | | +-----+ | | +--+ | +--+ |Owner| | | |P1| | |Pn| +-----+ | | +--+ | +--+ | A A | A | V | | V | V +-----------+ +-----------+ +-----------+ |Port Driver| |Port Driver| |Port Driver| +-----------+ +-----------+ +-----------+ | A | A | A V | V | V | +-----------+ +--------+ +--------+ | Main FD | | FD 1 | | FD n | +-----------+--+--------+----+--------+ | SCTP endpoint | +-------------------------------------+ Also, stream multiplexing with passive sockets would only be possible with sctp_peeloff(). -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From nesrait@REDACTED Wed Apr 22 10:56:48 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Wed, 22 Apr 2009 09:56:48 +0100 Subject: [erlang-questions] Building erl_interface with mingw (an unfinished tale) Message-ID: <523869a70904220156l2f79d0cdh2f63eb74b3973fa8@mail.gmail.com> Hi there! I was (almost) able to compile erl_interface using mingw (with some unhealthy hacks along the way) and I'd like to get your feedback on whether this would be the correct way to go. Actually, since I have no *useful* experience using gcc and related tools I'm prepared to have someone telling me that I really didn't had to recompile erl_interface. Either way, this might be useful for others that might be thinking of taking the same path... :) My setup: Windows XP, OTP_R13B (I started off with OTP_R13A so paths will vary), MSYS + MinGW. I started off following the erl_interface tutorial ( http://erlang.org/doc/tutorial/erl_interface.html) and things broke when I tried to compile: Davide@REDACTED /c/Projectos/eNotify/src/native/port $ gcc.exe ei.c erl_comm.c -o extprg.exe -Ic:/erl5.7/lib/erl_interface-3.6/include -Lc:/erl5.7/lib/erl_interface-3.6/lib -lei -lerl_interface Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized c:/erl5.7/lib/erl_interface-3.6/lib/erl_interface.lib(C:/cygwin/ldisk/daily_build/otp_build_win32_r13a.2009-03-16_22/otp_src_R13A/lib/erl_interface/ obj.mt/win32/erl_malloc.o):(.text+0x47): undefined reference to `ei_malloc' c:/erl5.7/lib/erl_interface-3.6/lib/erl_interface.lib(C:/cygwin/ldisk/daily_build/otp_build_win32_r13a.2009-03-16_22/otp_src_R13A/lib/erl_interface/ obj.mt/win32/erl_malloc.o):(.text+0x7c): undefined reference to `ei_realloc' (...) c:/erl5.7/lib/erl_interface-3.6/lib/erl_interface.lib(C:/cygwin/ldisk/daily_build/otp_build_win32_r13a.2009-03-16_22/otp_src_R13A/lib/erl_interface/ obj.mt/win32/erl_error.o):(.text+0xa2): more undefined references to `__iob_func' follow collect2: ld returned 1 exit status ??? :| The ei.lib and erl_interface.lib files were in c:/erl5.7/lib/erl_interface-3.6/lib so I was expecting this to work. :\ A little online research ( http://erlang.org/pipermail/erlang-questions/2003-September/009854.html) lead me think that the .lib files weren't GCC-compliant (and what I needed were .a files). So it would be a simple matter of getting the source and compiling erl_interface again (famous last words). This is were someone can come in and say "No! No! No! You just had to do XPTO." Considering no XPTO existed I went along to try and build erl_interface. First I tried to just build it using the files that were available on the windows binary distribution but it failed complaining about a missing /make/ target.mk. So I: - got the otp_src_R13A sourcecode - did a ./configure - exported ERL_TOP=c:/otp_src_R13A - IIRC - got something about a missing c:/otp_src_R13A/make/i686-pc-mingw32/ otp.mk folder - which I copied and renamed from c:/otp_src_R13A/make/otp.mk.in (I'm guessing something is responsible for this step) - added the necessary LIBS = -lwsock32 to c:/otp_src_R13A/lib/erl_interface/src/i686-pc-mingw32/Makefile - did a successful build - which resulted in two files: libei.a and liberl_interface.a getting placed in c:/otp_src_R13A/lib/erl_interface/obj.debug/i686-pc-mingw32/ - I created a folder c:/otp_src_R13A/lib/erl_interface/lib - and copied the two files there I then tried using those two files to build the erl_interface tutorial program with this result: Davide@REDACTED /c/Projectos/eNotify/src/native/port $ gcc.exe ei.c erl_comm.c -o extprg.exe -Ic:/otp_src_R13A/lib/erl_interface/include -Lc:/otp_src_R13A/lib/erl_interface/lib -lei -lerl_interface c:/otp_src_R13A/lib/erl_interface/lib/liberl_interface.a(erl_malloc.o): In function `erl_malloc': c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_malloc.c:221: undefined reference to `ei_malloc' c:/otp_src_R13A/lib/erl_interface/lib/liberl_interface.a(erl_malloc.o): In function `erl_realloc': c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_malloc.c:231: undefined reference to `ei_realloc' c:/otp_src_R13A/lib/erl_interface/lib/liberl_interface.a(erl_malloc.o): In function `erl_free': c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_malloc.c:238: undefined reference to `ei_free' ... c:/otp_src_R13A/lib/erl_interface/lib/liberl_interface.a(erl_fix_alloc.o): In function `erl_eterm_alloc': c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_fix_alloc.c:111: undefined reference to `__erl_errno_place' collect2: ld returned 1 exit status Which (other than the initial warnings) is exactly the same problem as the one I got with the original compilation. Here I took a look at the build process and realized that the erl_interface build process had also produced a bunch of .o files in another folder: c:/erl5.7/lib/erl_interface/obj.st.debug/i686-pc-mingw32/ Since the compiler was nagging me about missing .o files I just included them all in: Davide@REDACTED /c/Projectos/eNotify/src/native/port $ gcc.exe ei.c erl_comm.c -o extprg.exe c:/otp_src_R13A/lib/erl_interface/include/*.o -Ic:/otp_src_R13A/lib/erl_interface/include -Lc:/otp_src_R13A/lib/erl_interface/lib -lei -lerl_interface -lwsock32 c:/otp_src_R13A/lib/erl_interface/include/erl_resolve.o: In function `erl_gethostbyname_r': c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_resolve.c:58: undefined reference to `ei_gethostbyname_r' c:/otp_src_R13A/lib/erl_interface/include/erl_resolve.o: In function `erl_gethostbyaddr_r': c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_resolve.c:70: undefined reference to `ei_gethostbyaddr_r' collect2: ld returned 1 exit status :| This is another struggle. Under certain circumstances (mine) the functions ei_gethostbyname_r and ei_gethostbyaddr_r aren't included in the compilation of the ei_resolve.c file. Being completely astray from my original goal, and after figuring out that these were the reentrant versions of the same functions without the _r and that on windows the original ones are already thread safe ( http://daniel.haxx.se/projects/portability/), I just went ahead and added these *_r functions calling out to original ones (on the $ifdef __WIN32__ part ). This was the unhealthy hack part. :) Of course that worked (to shut the compiler up at least). :P Davide@REDACTED /c/Projectos/eNotify/src/native/port $ gcc.exe ei.c erl_comm.c -o extprg.exe c:/otp_src_R13A/lib/erl_interface/include/*.o -Ic:/otp_src_R13A/lib/erl_interface/include -Lc:/otp_src_R13A/lib/erl_interface/lib -lei -lerl_interface -lwsock32 Finally that got me a working extprg.exe that I was able to complete the tutorial with! I picked up were I left off: being able to compile IF including all of the .o files. Some [n00b] research -> http://en.wikipedia.org/wiki/Ar_(Unix) & http://linux.die.net/man/1/ar Got me to check if all the .o files the linker was complaining about were getting archived in the two .a files. And indeed, all of them were on libei.a. I unpacked the .o files from libeia.a and replaced it with a call to those .o: Davide@REDACTED /c/Projectos/eNotify/src/native/port $ gcc.exe -o extprg.exe ei.c erl_comm.c /c/otp_src_R13B/lib/erl_interface/obj/i686-pc-mingw32/*.o /c/otp_src_R13B/lib/erl_interface/obj/i686-pc-mingw32/liberl_interface.a -Ic:/otp_src_R13B/lib/erl_interface/include -lwsock32 And guess what... It worked! :) So what am I missing here? Is it normal that "ar"ed files don't link correctly? Is it mingw? Or is it just me? :) Any(!!!) clues are more than welcome! :) Cheers, Davide :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Wed Apr 22 10:44:21 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 22 Apr 2009 10:44:21 +0200 Subject: [erlang-questions] disk_log question In-Reply-To: <4f5fdb630904220135r5da2ba7bk6a355fafd05cd4ba@mail.gmail.com> References: <4f5fdb630904220135r5da2ba7bk6a355fafd05cd4ba@mail.gmail.com> Message-ID: <1240389861.4671.4.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, >From the documentation (http://erlang.org/doc/man/disk_log.html): "A process that opens a disk log can either be an owner or an anonymous user of the disk log. Each owner is linked to the disk log process, and the disk log is closed by the owner should the owner terminate." If you open as an owner and if your shell crashes when the module returns an error (badmatch?) the log will be closed. Could this be what is happening? bengt On Wed, 2009-04-22 at 14:05 +0530, Amit Murthy wrote: > Hi, > > I want to use disk_log with an external format for application info > logging. I was experimenting with disk_log in the console and I found > the following behavior: > > On an opened (opened via the open() call) log , once any of the > functions in the module return any, and I mean ANY error, the log gets > closed and is no longer available. > All subsequent calls return {error,no_such_log}. > > Even an error like "** exception error: undefined function > disk_log:xxxxx/2" results in the same behavior. > > I wanted to open a single log at startup and use it for logging in all > the other functions. Now, this may not be right way to do it, since if > any of the logging calls return an error, the log gets effectively > closed. > > Is there any explanation for this? Or is there a better way to > implement application error/info logging? > > Amit > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From vychodil.hynek@REDACTED Wed Apr 22 11:07:51 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 22 Apr 2009 11:07:51 +0200 Subject: [erlang-questions] Help! a log dump function from C. In-Reply-To: <4d08db370904220027v71565296vda99cac23eb251ef@mail.gmail.com> References: <4d08db370904220027v71565296vda99cac23eb251ef@mail.gmail.com> Message-ID: <4d08db370904220207t16e42c1h3b4163377ef3f2c9@mail.gmail.com> On Wed, Apr 22, 2009 at 9:27 AM, Hynek Vychodil wrote: > There are many many approaches to do this, one that doesn't use io or > io_lib follows: > > -module(dump_hex). > > -compile(inline). > > -export([dump_hex/1]). > > dump_hex(L) -> lists:reverse(dump_hex(0, L, [])). > > dump_hex(_, [pad | _], R) -> R; > dump_hex(_, [], R) -> R; > dump_hex(N, > [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, > B14, B15, B16 > | T], > R) -> > dump_hex(N + 16, T, > [[addr(N), $:, > [[$\s | hex(X)] > || X > <- [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, > B13, B14, B15, B16]], > " - ", > [print(X) > || X > <- [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, > B13, B14, B15, B16]], > $\n] > | R]); > dump_hex(N, L, R) -> > dump_hex(N, > L ++ > [pad, pad, pad, pad, pad, pad, pad, pad, pad, pad, pad, > pad, pad, pad, pad, pad], > R). > > addr(X) -> > [nibble(X bsr 28), nibble(X bsr 24), nibble(X bsr 20), > nibble(X bsr 16), nibble(X bsr 12), nibble(X bsr 8), > nibble(X bsr 4), nibble(X)]. > > hex(pad) -> " "; > hex(X) -> [nibble(X bsr 4), nibble(X)]. > > nibble(X) -> nibble_(X band 15). > > nibble_(X) when X < 10 -> X + $0; > nibble_(X) -> X + $a. There is error, It should be nibble_(X) -> X + $a - 10. > > > print(pad) -> []; > print(X) when X < $\s, X > 126 -> $.; > print(X) -> X. > > Usage: > > 1> c(dump_hex). > {ok,dump_hex} > 2> io:put_chars(dump_hex:dump_hex("teststr1234567890abcd")). > 00000000: 74 65 73 74 73 74 72 31 32 33 34 35 36 37 38 39 - > teststr123456789 > 00000010: 30 61 62 63 64 - 0abcd > ok > > > > On Wed, Apr 22, 2009 at 2:03 AM, feiman wrote: > >> hi,All >> I have a function from C,which print out detail hex information >> about a buffer,who can help me "translate" it into Erlang? >> >> when I run >> const char *teststr = "teststr1234567890abcd"; >> >> dump_hex((const unsigned char *)teststr,strlen(teststr)); >> >> it print out >> >> 00000000: 74 65 73 74 73 74 72 31 32 33 34 35 36 37 38 39 - >> teststr123456789 >> 00000010: 30 61 62 63 64 - 0abcd >> >> thanks all in advance >> >> void dump_hex( const unsigned char *buf, int len) >> { >> int i; >> int nlocal; >> const unsigned char *pc; >> char *out; >> const unsigned char *start; >> char c; >> char line[100]; >> >> start = buf; >> >> while (len > 0) >> { >> sprintf(line, "%08x: ", buf - start); >> out = line + 10; >> >> for (i = 0, pc = buf, nlocal = len; i < 16; i++, pc++) >> { >> if (nlocal > 0) >> { >> c = *pc; >> >> *out++ = NIBBLE((c >> 4) & 0xF); >> *out++ = NIBBLE(c & 0xF); >> >> nlocal--; >> } >> else >> { >> *out++ = ' '; >> *out++ = ' '; >> } /* end else */ >> >> *out++ = ' '; >> } /* end for */ >> >> *out++ = '-'; >> *out++ = ' '; >> >> for (i = 0, pc = buf, nlocal = len; >> (i < 16) && (nlocal > 0); >> i++, pc++, nlocal--) >> { >> c = *pc; >> >> if ((c < ' ') || (c >= 126)) >> { >> c = '.'; >> } >> >> *out++ = c; >> } /* end for */ >> >> *out++ = 0; >> >> llog(L_NOTICE,"%s", line); >> >> buf += 16; >> len -= 16; >> } /* end while */ >> } /* end dump */ >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Wed Apr 22 11:11:47 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 22 Apr 2009 11:11:47 +0200 Subject: [erlang-questions] Help! a log dump function from C. In-Reply-To: <4d08db370904220027v71565296vda99cac23eb251ef@mail.gmail.com> References: <4d08db370904220027v71565296vda99cac23eb251ef@mail.gmail.com> Message-ID: <4d08db370904220211q1b892b7ai6bf986afd71a578d@mail.gmail.com> On Wed, Apr 22, 2009 at 9:27 AM, Hynek Vychodil wrote: > There are many many approaches to do this, one that doesn't use io or > io_lib follows: > > -module(dump_hex). > > -compile(inline). > > -export([dump_hex/1]). > > dump_hex(L) -> lists:reverse(dump_hex(0, L, [])). > > dump_hex(_, [pad | _], R) -> R; > dump_hex(_, [], R) -> R; > dump_hex(N, > [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, > B14, B15, B16 > | T], > R) -> > dump_hex(N + 16, T, > [[addr(N), $:, > [[$\s | hex(X)] > || X > <- [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, > B13, B14, B15, B16]], > " - ", > [print(X) > || X > <- [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, > B13, B14, B15, B16]], > $\n] > | R]); > dump_hex(N, L, R) -> > dump_hex(N, > L ++ > [pad, pad, pad, pad, pad, pad, pad, pad, pad, pad, pad, > pad, pad, pad, pad, pad], > R). > > addr(X) -> > [nibble(X bsr 28), nibble(X bsr 24), nibble(X bsr 20), > nibble(X bsr 16), nibble(X bsr 12), nibble(X bsr 8), > nibble(X bsr 4), nibble(X)]. > > hex(pad) -> " "; > hex(X) -> [nibble(X bsr 4), nibble(X)]. > > nibble(X) -> nibble_(X band 15). > > nibble_(X) when X < 10 -> X + $0; > nibble_(X) -> X + $a. > > print(pad) -> []; > print(X) when X < $\s, X > 126 -> $.; and another bug, it should be print(X) when X < $\s; X > 126 -> $.; > > print(X) -> X. > > Usage: > > 1> c(dump_hex). > {ok,dump_hex} > 2> io:put_chars(dump_hex:dump_hex("teststr1234567890abcd")). > 00000000: 74 65 73 74 73 74 72 31 32 33 34 35 36 37 38 39 - > teststr123456789 > 00000010: 30 61 62 63 64 - 0abcd > ok > > > > On Wed, Apr 22, 2009 at 2:03 AM, feiman wrote: > >> hi,All >> I have a function from C,which print out detail hex information >> about a buffer,who can help me "translate" it into Erlang? >> >> when I run >> const char *teststr = "teststr1234567890abcd"; >> >> dump_hex((const unsigned char *)teststr,strlen(teststr)); >> >> it print out >> >> 00000000: 74 65 73 74 73 74 72 31 32 33 34 35 36 37 38 39 - >> teststr123456789 >> 00000010: 30 61 62 63 64 - 0abcd >> >> thanks all in advance >> >> void dump_hex( const unsigned char *buf, int len) >> { >> int i; >> int nlocal; >> const unsigned char *pc; >> char *out; >> const unsigned char *start; >> char c; >> char line[100]; >> >> start = buf; >> >> while (len > 0) >> { >> sprintf(line, "%08x: ", buf - start); >> out = line + 10; >> >> for (i = 0, pc = buf, nlocal = len; i < 16; i++, pc++) >> { >> if (nlocal > 0) >> { >> c = *pc; >> >> *out++ = NIBBLE((c >> 4) & 0xF); >> *out++ = NIBBLE(c & 0xF); >> >> nlocal--; >> } >> else >> { >> *out++ = ' '; >> *out++ = ' '; >> } /* end else */ >> >> *out++ = ' '; >> } /* end for */ >> >> *out++ = '-'; >> *out++ = ' '; >> >> for (i = 0, pc = buf, nlocal = len; >> (i < 16) && (nlocal > 0); >> i++, pc++, nlocal--) >> { >> c = *pc; >> >> if ((c < ' ') || (c >= 126)) >> { >> c = '.'; >> } >> >> *out++ = c; >> } /* end for */ >> >> *out++ = 0; >> >> llog(L_NOTICE,"%s", line); >> >> buf += 16; >> len -= 16; >> } /* end while */ >> } /* end dump */ >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From buricchio@REDACTED Wed Apr 22 11:27:29 2009 From: buricchio@REDACTED (Andrey) Date: Wed, 22 Apr 2009 12:27:29 +0300 Subject: [erlang-questions] no crypto Erlang/OTP R13B Windows binary In-Reply-To: <6672d0160904210750n7f474ec3n82facd0420d39a2d@mail.gmail.com> References: <6672d0160904210750n7f474ec3n82facd0420d39a2d@mail.gmail.com> Message-ID: <49EEE301.4070008@gmail.com> Hi! crypto module is absent in Erlang/OTP R13B Windows binary distro (only docs). Is it possible to add it? Andrew. From amit.murthy@REDACTED Wed Apr 22 11:45:48 2009 From: amit.murthy@REDACTED (Amit Murthy) Date: Wed, 22 Apr 2009 15:15:48 +0530 Subject: [erlang-questions] disk_log question Message-ID: <4f5fdb630904220245s3348aacdj1389d022a91c01ce@mail.gmail.com> I think you are right. Thanks, Amit > Greetings, > > >*From the documentation (http://erlang.org/doc/man/disk_log.html): > * > "A process that opens a disk log can either be an owner or an anonymous > > > user of the disk log. Each owner is linked to the disk log process, and > the disk log is closed by the owner should the owner terminate." > > If you open as an owner and if your shell crashes when the module > > > returns an error (badmatch?) the log will be closed. > Could this be what is happening? > > > bengt > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Wed Apr 22 11:57:47 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 22 Apr 2009 11:57:47 +0200 Subject: [erlang-questions] Help! a log dump function from C. In-Reply-To: References: Message-ID: <4d08db370904220257s347cb269se345e3010ca1b3cd@mail.gmail.com> Here is one which using io_lib extensively: dump_hex2(L) -> dump_hex2(0, L, []). dump_hex2(_, [], R) -> lists:reverse(R); dump_hex2(N, [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16 | T], R) -> Line = dump_line(N, [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16]), dump_hex2(N + 16, T, [Line | R]); dump_hex2(N, L, R) -> Line = dump_line(N, L), dump_hex2(N, [], [Line | R]). dump_line(N, L) -> io_lib:format("~8.16.0b:~-48s - ~s~n", [N, [io_lib:format(" ~2.16.0b", [X]) || X <- L], [if X < $\s; X > 126 -> $.; true -> X end || X <- L]]). On Wed, Apr 22, 2009 at 2:03 AM, feiman wrote: > hi,All > I have a function from C,which print out detail hex information > about a buffer,who can help me "translate" it into Erlang? > > when I run > const char *teststr = "teststr1234567890abcd"; > > dump_hex((const unsigned char *)teststr,strlen(teststr)); > > it print out > > 00000000: 74 65 73 74 73 74 72 31 32 33 34 35 36 37 38 39 - > teststr123456789 > 00000010: 30 61 62 63 64 - 0abcd > > thanks all in advance > > void dump_hex( const unsigned char *buf, int len) > { > int i; > int nlocal; > const unsigned char *pc; > char *out; > const unsigned char *start; > char c; > char line[100]; > > start = buf; > > while (len > 0) > { > sprintf(line, "%08x: ", buf - start); > out = line + 10; > > for (i = 0, pc = buf, nlocal = len; i < 16; i++, pc++) > { > if (nlocal > 0) > { > c = *pc; > > *out++ = NIBBLE((c >> 4) & 0xF); > *out++ = NIBBLE(c & 0xF); > > nlocal--; > } > else > { > *out++ = ' '; > *out++ = ' '; > } /* end else */ > > *out++ = ' '; > } /* end for */ > > *out++ = '-'; > *out++ = ' '; > > for (i = 0, pc = buf, nlocal = len; > (i < 16) && (nlocal > 0); > i++, pc++, nlocal--) > { > c = *pc; > > if ((c < ' ') || (c >= 126)) > { > c = '.'; > } > > *out++ = c; > } /* end for */ > > *out++ = 0; > > llog(L_NOTICE,"%s", line); > > buf += 16; > len -= 16; > } /* end while */ > } /* end dump */ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Wed Apr 22 12:31:41 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 22 Apr 2009 12:31:41 +0200 Subject: [erlang-questions] no crypto Erlang/OTP R13B Windows binary In-Reply-To: <49EEE301.4070008@gmail.com> References: <6672d0160904210750n7f474ec3n82facd0420d39a2d@mail.gmail.com> <49EEE301.4070008@gmail.com> Message-ID: Hi, We will publish a corrected Windows binary distribution as soon as we have found out where and why crypto got lost, it was not intentional. /Regards Kenneth, Erlang/OTP Ericsson On Wed, Apr 22, 2009 at 11:27 AM, Andrey wrote: > Hi! > > crypto module is absent in Erlang/OTP R13B Windows binary distro (only > docs). > Is it possible to add it? > > Andrew. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From kenneth.lundin@REDACTED Wed Apr 22 12:36:41 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 22 Apr 2009 12:36:41 +0200 Subject: [erlang-questions] patch for eunit in R13B In-Reply-To: <49EE2ADB.9090601@it.uu.se> References: <49EE170D.6060500@it.uu.se> <1240343117.21069.4.camel@gram.local> <49EE2ADB.9090601@it.uu.se> Message-ID: Hi, We will publish a corrected source distribution for R13B including a corrected Eunit as soon as we can. /Regards Kenneth, Erlang/OTP Ericsson On Tue, Apr 21, 2009 at 10:21 PM, Richard Carlsson wrote: > Peter Sabaini wrote: >> Whew! Thanks, I was beginning do think I unwittingly might have >> attracted the ire of the Gods Of Unicode :-) > > No, that was me. And verily did they smite me. :-( > > ? ?/R > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf.wiger@REDACTED Wed Apr 22 13:03:53 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 22 Apr 2009 13:03:53 +0200 Subject: [erlang-questions] Stockholm Erlounge 23 April Message-ID: <49EEF999.3070601@erlang-consulting.com> Registrations have been coming in for the Erlang User Group meeting in ?lvsj? tomorrow. We have decided on a venue for the Erlounge afterwards. It will be at the Bishop's Arms, Vasagatan, at approximately 8 pm. http://www.bishopsarms.com/Stockholm___Vasagatan_Presentation_DXNI-105463_.aspx Tables will be reserved for those who have registered for the Erlounge. If you want to join us, we can reserve more tables if you let us know in advance. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From anttipoi@REDACTED Wed Apr 22 13:13:03 2009 From: anttipoi@REDACTED (Teemu Antti-Poika) Date: Wed, 22 Apr 2009 14:13:03 +0300 Subject: [erlang-questions] Problems with Mnesia and failure situations Message-ID: <301dfe9f0904220413p7764867r9832589f2ebbe93a@mail.gmail.com> Hello world, we're in the process of adopting Erlang as a part of our project and we've run into a problem with Mnesia's High Availability features. I'd very much appreciate any insights you may have on where we go wrong. Our setup is a two-node cluster and the intention is to have, among other things, replicated mnesia tables. Both nodes read/write from the tables. The assumption is that if one node goes down the other one continues alone until the failover problem is fixed. Our failover tests failed horribly: when one node was taken out, the other died as well. I've managed to isolate the problem to a one-file test below: == 8< === Test code begins -module(jb_testing). -include_lib("stdlib/include/qlc.hrl"). -compile(export_all). -record(message, {id, state}). %% run once setup(Nodes) -> create_table(message, [{type, set}, {ram_copies, Nodes}, {attributes, record_info(fields, message)}]), ok = mnesia:wait_for_tables([message], 30000). create_table(Table, TableDefinition) -> case mnesia:create_table(Table, TableDefinition) of {atomic, ok} -> error_logger:info_msg("Created table ~p~n", [Table]), ok; {aborted, {already_exists, Table}} -> ok; {aborted, Reason} -> exit(Reason) end. load_mnesia() -> F = fun() -> C = qlc:cursor(qlc:q([M || M <- mnesia:table(message), M#message.state =:= new ])), case qlc:next_answers(C, 1) of [] -> none; [_M] -> none end, ok = qlc:delete_cursor(C) end, mnesia:transaction(F), % timer:sleep(100), load_mnesia(). == 8< === Test code ends Here's how I run the code to demonstrate the problem (node names are examples): - On server1: create_schema([egw@REDACTED, egw@REDACTED]) - On both nodes: mnesia:start(). - On server1: jb_testing:setup([egw@REDACTED, egw@REDACTED]). - On server2: jb_testing:load_mnesia(). This starts busy-looping and creating load for mnesia from current process, i.e. locks up your shell. - On server1: halt(). After a short while server2 reports mnesia as crashed. Some sample logging from server2, with mnesia debugging enabled: Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.1 (abort with ^G) (egw@REDACTED)1> mnesia:start(). Mnesia('egw@REDACTED'): mnesia_monitor starting: <0.69.0> Mnesia('egw@REDACTED'): Version: "4.4.9" [...lines of non-interesting start-up logging removed for brevity...] Mnesia('egw@REDACTED'): Mnesia started, 0 seconds ok (egw@REDACTED)2> Mnesia('egw@REDACTED'): Transaction log dump skipped (optional): schema_prepare Mnesia('egw@REDACTED'): Logging mnesia_up 'egw@REDACTED' (egw@REDACTED)3> Mnesia('egw@REDACTED'): write performed by {tid,4,<3261.108.0>} on record: {schema,message, [{name,message}, {type,set}, {ram_copies,['egw@REDACTED', 'egw@REDACTED']}, {disc_copies,[]}, {disc_only_copies,[]}, {load_order,0}, {access_mode,read_write}, {index,[]}, {snmp,[]}, {local_content,false}, {record_name,message}, {attributes,[id,state]}, {user_properties,[]}, {frag_properties,[]}, {cookie,{{1240,390114,462850},'egw@REDACTED'}}, {version,{{2,0},[]}}]} Mnesia('egw@REDACTED'): Transaction log dump skipped (optional): schema_prepare Mnesia('egw@REDACTED'): write performed by {tid,4,<3261.108.0>} on record: {schema,message, [{name,message}, {type,set}, {ram_copies,['egw@REDACTED', 'egw@REDACTED']}, {disc_copies,[]}, {disc_only_copies,[]}, {load_order,0}, {access_mode,read_write}, {index,[]}, {snmp,[]}, {local_content,false}, {record_name,message}, {attributes,[id,state]}, {user_properties,[]}, {frag_properties,[]}, {cookie,{{1240,390114,462850},'egw@REDACTED'}}, {version,{{2,0},[]}}]} Mnesia('egw@REDACTED'): Getting table message (ram_copies) from disc: {dumper, create_table} (egw@REDACTED)3> (egw@REDACTED)3> jb_testing:ping_mnesia(). Mnesia('egw@REDACTED'): Logging mnesia_down 'egw@REDACTED' Mnesia('egw@REDACTED'): Got mnesia_down from 'egw@REDACTED', reconfiguring... Mnesia('egw@REDACTED'): mnesia_monitor got FATAL ERROR from: <0.73.0> =ERROR REPORT==== 22-Apr-2009::11:49:17 === Mnesia('egw@REDACTED'): ** ERROR ** (core dumped to file: "/home/jetbet/MnesiaCore.egw@REDACTED") ** FATAL ** mnesia_tm crashed: {badarg, [{mnesia_tm,send_to_pids,2}, {mnesia_tm,reconfigure_coordinators,2}, {mnesia_tm,doit_loop,1}, {mnesia_sp,init_proc,4}, {proc_lib,init_p_do_apply,3}]} state: [<0.68.0>] Mnesia('egw@REDACTED'): mnesia_controller terminated: shutdown =ERROR REPORT==== 22-Apr-2009::11:49:27 === ** Generic server mnesia_monitor terminating ** Last message in was {'EXIT',<0.68.0>,killed} ** When Server state == {state,<0.68.0>,[], ['egw@REDACTED'], true,[],undefined,[]} ** Reason for termination == ** killed =ERROR REPORT==== 22-Apr-2009::11:49:27 === ** Generic server mnesia_recover terminating ** Last message in was {'EXIT',<0.68.0>,killed} ** When Server state == {state,<0.68.0>,undefined,undefined,undefined,0,true, []} ** Reason for termination == ** killed ** exception exit: killed (egw@REDACTED)4> =INFO REPORT==== 22-Apr-2009::11:49:27 === application: mnesia exited: killed type: temporary Produced core dump is not recognized by crashdump_viewer ("...is not an Erlang crash dump"). Some notes: - Erlang version info: Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] - Same problem occurs with R13A - Our OS is Centos (RedHat) linux, SMP-enabled 64-bit 2.6.18 kernel on Intel. - if we reduce the load for mnesia by introducing sleep (100 ms) in the test loop, the problem goes away or is at least less likely to appear. - we're using RAM tables in the example. Changing tables to disc_copies makes no difference. - changing the data lookup to the form F = fun() -> '$end_of_table' = mnesia:first(message) end, works: halt() on another node does not bring the busy one down. Any ideas? Thank you already in advance, Teemu Antti-Poika From dgud@REDACTED Wed Apr 22 14:03:02 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Wed, 22 Apr 2009 14:03:02 +0200 Subject: [erlang-questions] Problems with Mnesia and failure situations In-Reply-To: <301dfe9f0904220413p7764867r9832589f2ebbe93a@mail.gmail.com> References: <301dfe9f0904220413p7764867r9832589f2ebbe93a@mail.gmail.com> Message-ID: <49EF0776.2060803@erix.ericsson.se> That is bug, happens when using qlc inside a mnesia_transaction and a another node goes down. Patch: ct diff -diff_format -pre src/mnesia_tm.erl 2197c2197 < send_to_pids([Tid#tid.pid | get_elements(friends,Store)], Msg). --- > send_to_pids([Tid#tid.pid | [Pid || Pid <- get_elements(friends,Store), is_pid(Pid)], Msg). /Dan Teemu Antti-Poika wrote: > Hello world, > > we're in the process of adopting Erlang as a part of our project and > we've run into a problem with Mnesia's High Availability features. I'd > very much appreciate any insights you may have on where we go wrong. > > Our setup is a two-node cluster and the intention is to have, among > other things, replicated mnesia tables. Both nodes read/write from the > tables. The assumption is that if one node goes down the other one > continues alone until the failover problem is fixed. > > Our failover tests failed horribly: when one node was taken out, the > other died as well. I've managed to isolate the problem to a one-file > test below: > > > == 8< === Test code begins > -module(jb_testing). > -include_lib("stdlib/include/qlc.hrl"). > > -compile(export_all). > > -record(message, {id, > state}). > > %% run once > setup(Nodes) -> > create_table(message, [{type, set}, {ram_copies, Nodes}, > {attributes, record_info(fields, message)}]), > ok = mnesia:wait_for_tables([message], 30000). > > create_table(Table, TableDefinition) -> > case mnesia:create_table(Table, TableDefinition) of > {atomic, ok} -> > error_logger:info_msg("Created table ~p~n", [Table]), > ok; > {aborted, {already_exists, Table}} -> > ok; > {aborted, Reason} -> > exit(Reason) > end. > > load_mnesia() -> > F = fun() -> > C = qlc:cursor(qlc:q([M || M <- mnesia:table(message), > M#message.state =:= new ])), > case qlc:next_answers(C, 1) of > [] -> > none; > [_M] -> > none > end, > ok = qlc:delete_cursor(C) > > end, > mnesia:transaction(F), > % timer:sleep(100), > load_mnesia(). > > == 8< === Test code ends > > Here's how I run the code to demonstrate the problem (node names are examples): > - On server1: create_schema([egw@REDACTED, > egw@REDACTED]) > - On both nodes: mnesia:start(). > - On server1: jb_testing:setup([egw@REDACTED, > egw@REDACTED]). > - On server2: jb_testing:load_mnesia(). This starts busy-looping and > creating load for mnesia from current process, i.e. locks up your > shell. > - On server1: halt(). > > After a short while server2 reports mnesia as crashed. Some sample > logging from server2, with mnesia debugging enabled: > > Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7.1 (abort with ^G) > (egw@REDACTED)1> mnesia:start(). > Mnesia('egw@REDACTED'): mnesia_monitor starting: <0.69.0> > Mnesia('egw@REDACTED'): Version: "4.4.9" > [...lines of non-interesting start-up logging removed for brevity...] > Mnesia('egw@REDACTED'): Mnesia started, 0 seconds > ok > (egw@REDACTED)2> Mnesia('egw@REDACTED'): > Transaction log dump skipped (optional): schema_prepare > Mnesia('egw@REDACTED'): Logging mnesia_up 'egw@REDACTED' > > (egw@REDACTED)3> Mnesia('egw@REDACTED'): write > performed by {tid,4,<3261.108.0>} on record: > {schema,message, > [{name,message}, > {type,set}, > {ram_copies,['egw@REDACTED', > 'egw@REDACTED']}, > {disc_copies,[]}, > {disc_only_copies,[]}, > {load_order,0}, > {access_mode,read_write}, > {index,[]}, > {snmp,[]}, > {local_content,false}, > {record_name,message}, > {attributes,[id,state]}, > {user_properties,[]}, > {frag_properties,[]}, > {cookie,{{1240,390114,462850},'egw@REDACTED'}}, > {version,{{2,0},[]}}]} > Mnesia('egw@REDACTED'): Transaction log dump skipped > (optional): schema_prepare > Mnesia('egw@REDACTED'): write performed by > {tid,4,<3261.108.0>} on record: > {schema,message, > [{name,message}, > {type,set}, > {ram_copies,['egw@REDACTED', > 'egw@REDACTED']}, > {disc_copies,[]}, > {disc_only_copies,[]}, > {load_order,0}, > {access_mode,read_write}, > {index,[]}, > {snmp,[]}, > {local_content,false}, > {record_name,message}, > {attributes,[id,state]}, > {user_properties,[]}, > {frag_properties,[]}, > {cookie,{{1240,390114,462850},'egw@REDACTED'}}, > {version,{{2,0},[]}}]} > Mnesia('egw@REDACTED'): Getting table message (ram_copies) > from disc: {dumper, > > create_table} > > (egw@REDACTED)3> > (egw@REDACTED)3> jb_testing:ping_mnesia(). > Mnesia('egw@REDACTED'): Logging mnesia_down > 'egw@REDACTED' > Mnesia('egw@REDACTED'): Got mnesia_down from > 'egw@REDACTED', reconfiguring... > Mnesia('egw@REDACTED'): mnesia_monitor got FATAL ERROR > from: <0.73.0> > > =ERROR REPORT==== 22-Apr-2009::11:49:17 === > Mnesia('egw@REDACTED'): ** ERROR ** (core dumped to file: > "/home/jetbet/MnesiaCore.egw@REDACTED") > ** FATAL ** mnesia_tm crashed: {badarg, > [{mnesia_tm,send_to_pids,2}, > {mnesia_tm,reconfigure_coordinators,2}, > {mnesia_tm,doit_loop,1}, > {mnesia_sp,init_proc,4}, > {proc_lib,init_p_do_apply,3}]} > state: [<0.68.0>] > Mnesia('egw@REDACTED'): mnesia_controller terminated: shutdown > > =ERROR REPORT==== 22-Apr-2009::11:49:27 === > ** Generic server mnesia_monitor terminating > ** Last message in was {'EXIT',<0.68.0>,killed} > ** When Server state == {state,<0.68.0>,[], > ['egw@REDACTED'], > true,[],undefined,[]} > ** Reason for termination == > ** killed > > =ERROR REPORT==== 22-Apr-2009::11:49:27 === > ** Generic server mnesia_recover terminating > ** Last message in was {'EXIT',<0.68.0>,killed} > ** When Server state == {state,<0.68.0>,undefined,undefined,undefined,0,true, > []} > ** Reason for termination == > ** killed > ** exception exit: killed > (egw@REDACTED)4> > =INFO REPORT==== 22-Apr-2009::11:49:27 === > application: mnesia > exited: killed > type: temporary > > > Produced core dump is not recognized by crashdump_viewer ("...is not > an Erlang crash dump"). > > Some notes: > - Erlang version info: Erlang R13B (erts-5.7.1) [source] [64-bit] > [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] > - Same problem occurs with R13A > - Our OS is Centos (RedHat) linux, SMP-enabled 64-bit 2.6.18 kernel on Intel. > > - if we reduce the load for mnesia by introducing sleep (100 ms) in > the test loop, the problem goes away or is at least less likely to > appear. > - we're using RAM tables in the example. Changing tables to > disc_copies makes no difference. > - changing the data lookup to the form > F = fun() -> > '$end_of_table' = mnesia:first(message) > end, > works: halt() on another node does not bring the busy one down. > > Any ideas? > > Thank you already in advance, > Teemu Antti-Poika > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dgud@REDACTED Wed Apr 22 14:34:56 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Wed, 22 Apr 2009 14:34:56 +0200 Subject: [erlang-questions] Problems with Mnesia and failure situations In-Reply-To: <49EF0776.2060803@erix.ericsson.se> References: <301dfe9f0904220413p7764867r9832589f2ebbe93a@mail.gmail.com> <49EF0776.2060803@erix.ericsson.se> Message-ID: <49EF0EF0.5090403@erix.ericsson.se> Note to self compile the code before sending patches all over the world. A tested version will be included in the next patch release :-) /Dan faenor:mnesia> ct diff -diff_format -pre src/mnesia_tm.erl 2197c2197 < send_to_pids([Tid#tid.pid | get_elements(friends,Store)], Msg). --- > send_to_pids([Tid#tid.pid | [Pid || Pid <- get_elements(friends,Store), is_pid(Pid)]], Msg). Dan Gudmundsson wrote: > That is bug, happens when using qlc inside a mnesia_transaction and a > another node goes down. > > Patch: > > ct diff -diff_format -pre src/mnesia_tm.erl > 2197c2197 > < send_to_pids([Tid#tid.pid | get_elements(friends,Store)], Msg). > --- > > send_to_pids([Tid#tid.pid | [Pid || Pid <- > get_elements(friends,Store), is_pid(Pid)], Msg). > > /Dan > > Teemu Antti-Poika wrote: >> Hello world, >> >> we're in the process of adopting Erlang as a part of our project and >> we've run into a problem with Mnesia's High Availability features. I'd >> very much appreciate any insights you may have on where we go wrong. >> >> Our setup is a two-node cluster and the intention is to have, among >> other things, replicated mnesia tables. Both nodes read/write from the >> tables. The assumption is that if one node goes down the other one >> continues alone until the failover problem is fixed. >> >> Our failover tests failed horribly: when one node was taken out, the >> other died as well. I've managed to isolate the problem to a one-file >> test below: >> >> >> == 8< === Test code begins >> -module(jb_testing). >> -include_lib("stdlib/include/qlc.hrl"). >> >> -compile(export_all). >> >> -record(message, {id, >> state}). >> >> %% run once >> setup(Nodes) -> >> create_table(message, [{type, set}, {ram_copies, Nodes}, >> {attributes, record_info(fields, >> message)}]), >> ok = mnesia:wait_for_tables([message], 30000). >> >> create_table(Table, TableDefinition) -> >> case mnesia:create_table(Table, TableDefinition) of >> {atomic, ok} -> >> error_logger:info_msg("Created table ~p~n", [Table]), >> ok; >> {aborted, {already_exists, Table}} -> >> ok; >> {aborted, Reason} -> >> exit(Reason) >> end. >> >> load_mnesia() -> >> F = fun() -> >> C = qlc:cursor(qlc:q([M || M <- mnesia:table(message), >> M#message.state =:= new ])), >> case qlc:next_answers(C, 1) of >> [] -> >> none; >> [_M] -> >> none >> end, >> ok = qlc:delete_cursor(C) >> >> end, >> mnesia:transaction(F), >> % timer:sleep(100), >> load_mnesia(). >> >> == 8< === Test code ends >> >> Here's how I run the code to demonstrate the problem (node names are >> examples): >> - On server1: create_schema([egw@REDACTED, >> egw@REDACTED]) >> - On both nodes: mnesia:start(). >> - On server1: jb_testing:setup([egw@REDACTED, >> egw@REDACTED]). >> - On server2: jb_testing:load_mnesia(). This starts busy-looping and >> creating load for mnesia from current process, i.e. locks up your >> shell. >> - On server1: halt(). >> >> After a short while server2 reports mnesia as crashed. Some sample >> logging from server2, with mnesia debugging enabled: >> >> Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] >> [async-threads:0] [hipe] [kernel-poll:false] >> >> Eshell V5.7.1 (abort with ^G) >> (egw@REDACTED)1> mnesia:start(). >> Mnesia('egw@REDACTED'): mnesia_monitor starting: <0.69.0> >> Mnesia('egw@REDACTED'): Version: "4.4.9" >> [...lines of non-interesting start-up logging removed for brevity...] >> Mnesia('egw@REDACTED'): Mnesia started, 0 seconds >> ok >> (egw@REDACTED)2> Mnesia('egw@REDACTED'): >> Transaction log dump skipped (optional): schema_prepare >> Mnesia('egw@REDACTED'): Logging mnesia_up >> 'egw@REDACTED' >> >> (egw@REDACTED)3> Mnesia('egw@REDACTED'): write >> performed by {tid,4,<3261.108.0>} on record: >> {schema,message, >> [{name,message}, >> {type,set}, >> {ram_copies,['egw@REDACTED', >> 'egw@REDACTED']}, >> {disc_copies,[]}, >> {disc_only_copies,[]}, >> {load_order,0}, >> {access_mode,read_write}, >> {index,[]}, >> {snmp,[]}, >> {local_content,false}, >> {record_name,message}, >> {attributes,[id,state]}, >> {user_properties,[]}, >> {frag_properties,[]}, >> >> {cookie,{{1240,390114,462850},'egw@REDACTED'}}, >> {version,{{2,0},[]}}]} >> Mnesia('egw@REDACTED'): Transaction log dump skipped >> (optional): schema_prepare >> Mnesia('egw@REDACTED'): write performed by >> {tid,4,<3261.108.0>} on record: >> {schema,message, >> [{name,message}, >> {type,set}, >> {ram_copies,['egw@REDACTED', >> 'egw@REDACTED']}, >> {disc_copies,[]}, >> {disc_only_copies,[]}, >> {load_order,0}, >> {access_mode,read_write}, >> {index,[]}, >> {snmp,[]}, >> {local_content,false}, >> {record_name,message}, >> {attributes,[id,state]}, >> {user_properties,[]}, >> {frag_properties,[]}, >> >> {cookie,{{1240,390114,462850},'egw@REDACTED'}}, >> {version,{{2,0},[]}}]} >> Mnesia('egw@REDACTED'): Getting table message (ram_copies) >> from disc: {dumper, >> >> create_table} >> >> (egw@REDACTED)3> >> (egw@REDACTED)3> jb_testing:ping_mnesia(). >> Mnesia('egw@REDACTED'): Logging mnesia_down >> 'egw@REDACTED' >> Mnesia('egw@REDACTED'): Got mnesia_down from >> 'egw@REDACTED', reconfiguring... >> Mnesia('egw@REDACTED'): mnesia_monitor got FATAL ERROR >> from: <0.73.0> >> >> =ERROR REPORT==== 22-Apr-2009::11:49:17 === >> Mnesia('egw@REDACTED'): ** ERROR ** (core dumped to file: >> "/home/jetbet/MnesiaCore.egw@REDACTED") >> ** FATAL ** mnesia_tm crashed: {badarg, >> [{mnesia_tm,send_to_pids,2}, >> >> {mnesia_tm,reconfigure_coordinators,2}, >> {mnesia_tm,doit_loop,1}, >> {mnesia_sp,init_proc,4}, >> {proc_lib,init_p_do_apply,3}]} >> state: [<0.68.0>] >> Mnesia('egw@REDACTED'): mnesia_controller terminated: >> shutdown >> >> =ERROR REPORT==== 22-Apr-2009::11:49:27 === >> ** Generic server mnesia_monitor terminating >> ** Last message in was {'EXIT',<0.68.0>,killed} >> ** When Server state == {state,<0.68.0>,[], >> ['egw@REDACTED'], >> true,[],undefined,[]} >> ** Reason for termination == >> ** killed >> >> =ERROR REPORT==== 22-Apr-2009::11:49:27 === >> ** Generic server mnesia_recover terminating >> ** Last message in was {'EXIT',<0.68.0>,killed} >> ** When Server state == >> {state,<0.68.0>,undefined,undefined,undefined,0,true, >> []} >> ** Reason for termination == >> ** killed >> ** exception exit: killed >> (egw@REDACTED)4> >> =INFO REPORT==== 22-Apr-2009::11:49:27 === >> application: mnesia >> exited: killed >> type: temporary >> >> >> Produced core dump is not recognized by crashdump_viewer ("...is not >> an Erlang crash dump"). >> >> Some notes: >> - Erlang version info: Erlang R13B (erts-5.7.1) [source] [64-bit] >> [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] >> - Same problem occurs with R13A >> - Our OS is Centos (RedHat) linux, SMP-enabled 64-bit 2.6.18 kernel on >> Intel. >> >> - if we reduce the load for mnesia by introducing sleep (100 ms) in >> the test loop, the problem goes away or is at least less likely to >> appear. >> - we're using RAM tables in the example. Changing tables to >> disc_copies makes no difference. >> - changing the data lookup to the form >> F = fun() -> >> '$end_of_table' = mnesia:first(message) >> end, >> works: halt() on another node does not bring the busy one down. >> >> Any ideas? >> >> Thank you already in advance, >> Teemu Antti-Poika >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From karol.skocik@REDACTED Wed Apr 22 14:44:59 2009 From: karol.skocik@REDACTED (karol skocik) Date: Wed, 22 Apr 2009 14:44:59 +0200 Subject: [erlang-questions] httpd 13B - removed ssl_certificate_key_file option from configuration? Message-ID: Hi, while testing the possibility to upgrade to 13B today, I have found that our SSL server is not working - all inets SSL connections connect to the server but nothing is received, the log shows this: [22/Apr/2009:14:10:51 +0200] server crash for 192.168.1.100, reason: "Error reading request:The client did not send the whole request before theserver side timeout" For local testing I use to add exception in firefox, but firefox can't receive the certificate from the SSL server. I can see in the 13B manual of httpd here: http://erlang.org/doc/man/httpd.html that the ssl_certificate_key_file option is not mentioned there. Our previously working httpd_ssl.config looks like this: [{bind_address, {0, 0, 0, 0}}, {port, 9234}, {server_name, "localhost"}, {server_root, "priv/log/httpd"}, {document_root, "priv/htdocs/"}, {com_type, ssl}, {ssl_certificate_file, "priv/cert/site.crt"}, {http://erlang.org/doc/man/httpd.html, "priv/cert/site.key"}, {ssl_verify_client, 1}, {ssl_verify_depth, 2}, {ssl_ciphers, "DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-DSS-CAMELLIA256-SHA:CAMELLIA256-SHA:EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DES-CBC3-SHA:DES-CBC3-MD5:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:AES128-SHA:DHE-RSA-CAMELLIA128-SHA:DHE-DSS-CAMELLIA128-SHA:CAMELLIA128-SHA:IDEA-CBC-SHA:IDEA-CBC-MD5:RC2-CBC-MD5:RC4-SHA:RC4-MD5:RC4-MD5:EDH-RSA-DES-CBC-SHA:EDH-DSS-DES-CBC-SHA:DES-CBC-SHA:DES-CBC-MD5:EXP-EDH-RSA-DES-CBC-SHA:EXP-EDH-DSS-DES-CBC-SHA:EXP-DES-CBC-SHA:EXP-RC2-CBC-MD5:EXP-RC2-CBC-MD5:EXP-RC4-MD5:EXP-RC4-MD5"}, {modules, [mod_disp_ssl, mod_get, mod_log]}, {directory_index, ["index.html"]}, {error_log, "httpd_ssl_error.log"}, {security_log, "httpd_ssl_security.log"}, {transfer_log, "httpd_ssl_transfer.log"}]. Anybody got any idea what's wrong, and how to fix that? Thanks, Karol From bgustavsson@REDACTED Wed Apr 22 15:08:11 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Wed, 22 Apr 2009 15:08:11 +0200 Subject: [erlang-questions] no crypto Erlang/OTP R13B Windows binary In-Reply-To: <49EEE301.4070008@gmail.com> References: <6672d0160904210750n7f474ec3n82facd0420d39a2d@mail.gmail.com> <49EEE301.4070008@gmail.com> Message-ID: <6672d0160904220608q1c546a08xef6a36f1edd462d6@mail.gmail.com> On Wed, Apr 22, 2009 at 11:27 AM, Andrey wrote: > Hi! > > crypto module is absent in Erlang/OTP R13B Windows binary distro (only > docs). > Is it possible to add it? > It was my fault. I uploaded a Windows installer built on a new daily-build machine that did not have any OpenSSL libraries installed. I have now uploaded the correct Windows installer with crypto included from the correct build machine. Make sure to empty the web browser cache in the browser before downloading it. Sorry for any inconvenience. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From vychodil.hynek@REDACTED Wed Apr 22 15:55:28 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 22 Apr 2009 15:55:28 +0200 Subject: [erlang-questions] Clustering through Multicast In-Reply-To: <1240388244.3918.9.camel@chaitanya.laptop> References: <1240388244.3918.9.camel@chaitanya.laptop> Message-ID: <4d08db370904220655u3be4d1f0n1d79fd18b37a9dd3@mail.gmail.com> It sounds more like paxos protocol works. Look at scalaris ( http://code.google.com/p/scalaris/). On Wed, Apr 22, 2009 at 10:17 AM, chaitanya Chalasani < chaitanya.chalasani@REDACTED> wrote: > Hi, > > May be the solution exists, but the idea just popped and want to clarify if > it really works this way. > > Instead of the regular cluster node and unicast load balance to multiple > worker nodes, if we use the IP multicast to a group of servers with > replicated mnesia and let each node attempt to start a transaction and only > one node gets to act on it, based on the mnesia transaction write lock, will > there be less latency in distributing the transactions. And also it might > help in some cases wherein the delay in identifying dead node would not > effect the transactions within. > *------* > *CHAITANYA CHALASANI* > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From anttipoi@REDACTED Wed Apr 22 16:47:30 2009 From: anttipoi@REDACTED (Teemu Antti-Poika) Date: Wed, 22 Apr 2009 17:47:30 +0300 Subject: [erlang-questions] Problems with Mnesia and failure situations In-Reply-To: <301dfe9f0904220746l612ad39didcbbc1115fec6312@mail.gmail.com> References: <301dfe9f0904220413p7764867r9832589f2ebbe93a@mail.gmail.com> <49EF0776.2060803@erix.ericsson.se> <49EF0EF0.5090403@erix.ericsson.se> <301dfe9f0904220746l612ad39didcbbc1115fec6312@mail.gmail.com> Message-ID: <301dfe9f0904220747g20eced55mbd323c944fbc1503@mail.gmail.com> [Oops, forgot to CC the list - sending a copy] Thanks, Dan! This solves the issue. This database has an excellent support response time :) Apparently mnesia timing out on node A when I unplug/shutdown node B is a necessary evil? Since my process controlling the mnesia bound data is timing out on remote communications, it cannot react to orders to dump tables on disk. Eventually it is forcefully shut down by the supervisor, causing RAM-resident data be lost, I think? Teemu On Wed, Apr 22, 2009 at 3:34 PM, Dan Gudmundsson wrote: > > Note to self compile the code before sending patches all over the world. > A tested version will be included in the next patch release :-) > > /Dan > > faenor:mnesia> ct diff -diff_format -pre src/mnesia_tm.erl > 2197c2197 > < ? ? send_to_pids([Tid#tid.pid | get_elements(friends,Store)], Msg). > --- >> ? ? send_to_pids([Tid#tid.pid | [Pid || Pid <- >> get_elements(friends,Store), is_pid(Pid)]], Msg). > > Dan Gudmundsson wrote: >> >> That is bug, ?happens when using qlc inside a mnesia_transaction and a >> another node goes down. >> >> Patch: >> >> ct diff -diff_format -pre src/mnesia_tm.erl >> 2197c2197 >> < ? ? send_to_pids([Tid#tid.pid | get_elements(friends,Store)], Msg). >> --- >> ?> ? ? send_to_pids([Tid#tid.pid | [Pid || Pid <- >> get_elements(friends,Store), is_pid(Pid)], Msg). >> >> /Dan >> >> Teemu Antti-Poika wrote: >>> >>> Hello world, >>> >>> we're in the process of adopting Erlang as a part of our project and >>> we've run into a problem with Mnesia's High Availability features. I'd >>> very much appreciate any insights you may have on where we go wrong. >>> >>> Our setup is a two-node cluster and the intention is to have, among >>> other things, replicated mnesia tables. Both nodes read/write from the >>> tables. The assumption is that if one node goes down the other one >>> continues alone until the failover problem is fixed. >>> >>> Our failover tests failed horribly: when one node was taken out, the >>> other died as well. I've managed to isolate the problem to a one-file >>> test below: >>> >>> >>> == 8< === Test code begins >>> -module(jb_testing). >>> -include_lib("stdlib/include/qlc.hrl"). >>> >>> -compile(export_all). >>> >>> -record(message, {id, >>> ? ? ? ? ? ? ? ? ?state}). >>> >>> %% run once >>> setup(Nodes) -> >>> ? ?create_table(message, [{type, set}, {ram_copies, Nodes}, >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?{attributes, record_info(fields, >>> message)}]), >>> ? ?ok = mnesia:wait_for_tables([message], 30000). >>> >>> create_table(Table, TableDefinition) -> >>> ? ?case mnesia:create_table(Table, TableDefinition) of >>> ? ? ? ?{atomic, ok} -> >>> ? ? ? ? ? ?error_logger:info_msg("Created table ~p~n", [Table]), >>> ? ? ? ? ? ?ok; >>> ? ? ? ?{aborted, {already_exists, Table}} -> >>> ? ? ? ? ? ?ok; >>> ? ? ? ?{aborted, Reason} -> >>> ? ? ? ? ? ?exit(Reason) >>> ? ?end. >>> >>> load_mnesia() -> >>> ? ?F = fun() -> >>> ? ? ? ? ? ? ? ?C = qlc:cursor(qlc:q([M || M <- mnesia:table(message), >>> M#message.state =:= new ])), >>> ? ? ? ? ? ? ? ?case qlc:next_answers(C, 1) of >>> ? ? ? ? ? ? ? ? ? ?[] -> >>> ? ? ? ? ? ? ? ? ? ? ? ?none; >>> ? ? ? ? ? ? ? ? ? ?[_M] -> >>> ? ? ? ? ? ? ? ? ? ? ? ?none >>> ? ? ? ? ? ? ? ?end, >>> ? ? ? ? ? ? ? ?ok = qlc:delete_cursor(C) >>> >>> ? ? ? ?end, >>> ? ?mnesia:transaction(F), >>> % ? ?timer:sleep(100), >>> ? ?load_mnesia(). >>> >>> == 8< === Test code ends >>> >>> Here's how I run the code to demonstrate the problem (node names are >>> examples): >>> - On server1: create_schema([egw@REDACTED, >>> egw@REDACTED]) >>> - On both nodes: mnesia:start(). >>> - On server1: jb_testing:setup([egw@REDACTED, >>> egw@REDACTED]). >>> - On server2: jb_testing:load_mnesia(). This starts busy-looping and >>> creating load for mnesia from current process, i.e. locks up your >>> shell. >>> - On server1: halt(). >>> >>> After a short while server2 reports mnesia as crashed. Some sample >>> logging from server2, with mnesia debugging enabled: >>> >>> Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] >>> [async-threads:0] [hipe] [kernel-poll:false] >>> >>> Eshell V5.7.1 ?(abort with ^G) >>> (egw@REDACTED)1> mnesia:start(). >>> Mnesia('egw@REDACTED'): mnesia_monitor starting: <0.69.0> >>> Mnesia('egw@REDACTED'): Version: "4.4.9" >>> [...lines of non-interesting start-up logging removed for brevity...] >>> Mnesia('egw@REDACTED'): Mnesia started, 0 seconds >>> ok >>> (egw@REDACTED)2> Mnesia('egw@REDACTED'): >>> Transaction log dump skipped (optional): schema_prepare >>> Mnesia('egw@REDACTED'): Logging mnesia_up >>> 'egw@REDACTED' >>> >>> (egw@REDACTED)3> Mnesia('egw@REDACTED'): write >>> performed by {tid,4,<3261.108.0>} on record: >>> ? ? ? ?{schema,message, >>> ? ? ? ? ? ? ? ?[{name,message}, >>> ? ? ? ? ? ? ? ? {type,set}, >>> ? ? ? ? ? ? ? ? {ram_copies,['egw@REDACTED', >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'egw@REDACTED']}, >>> ? ? ? ? ? ? ? ? {disc_copies,[]}, >>> ? ? ? ? ? ? ? ? {disc_only_copies,[]}, >>> ? ? ? ? ? ? ? ? {load_order,0}, >>> ? ? ? ? ? ? ? ? {access_mode,read_write}, >>> ? ? ? ? ? ? ? ? {index,[]}, >>> ? ? ? ? ? ? ? ? {snmp,[]}, >>> ? ? ? ? ? ? ? ? {local_content,false}, >>> ? ? ? ? ? ? ? ? {record_name,message}, >>> ? ? ? ? ? ? ? ? {attributes,[id,state]}, >>> ? ? ? ? ? ? ? ? {user_properties,[]}, >>> ? ? ? ? ? ? ? ? {frag_properties,[]}, >>> >>> {cookie,{{1240,390114,462850},'egw@REDACTED'}}, >>> ? ? ? ? ? ? ? ? {version,{{2,0},[]}}]} >>> Mnesia('egw@REDACTED'): Transaction log dump skipped >>> (optional): schema_prepare >>> Mnesia('egw@REDACTED'): write performed by >>> {tid,4,<3261.108.0>} on record: >>> ? ? ? ?{schema,message, >>> ? ? ? ? ? ? ? ?[{name,message}, >>> ? ? ? ? ? ? ? ? {type,set}, >>> ? ? ? ? ? ? ? ? {ram_copies,['egw@REDACTED', >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'egw@REDACTED']}, >>> ? ? ? ? ? ? ? ? {disc_copies,[]}, >>> ? ? ? ? ? ? ? ? {disc_only_copies,[]}, >>> ? ? ? ? ? ? ? ? {load_order,0}, >>> ? ? ? ? ? ? ? ? {access_mode,read_write}, >>> ? ? ? ? ? ? ? ? {index,[]}, >>> ? ? ? ? ? ? ? ? {snmp,[]}, >>> ? ? ? ? ? ? ? ? {local_content,false}, >>> ? ? ? ? ? ? ? ? {record_name,message}, >>> ? ? ? ? ? ? ? ? {attributes,[id,state]}, >>> ? ? ? ? ? ? ? ? {user_properties,[]}, >>> ? ? ? ? ? ? ? ? {frag_properties,[]}, >>> >>> {cookie,{{1240,390114,462850},'egw@REDACTED'}}, >>> ? ? ? ? ? ? ? ? {version,{{2,0},[]}}]} >>> Mnesia('egw@REDACTED'): Getting table message (ram_copies) >>> from disc: {dumper, >>> >>> ? ? ? ? ? ?create_table} >>> >>> (egw@REDACTED)3> >>> (egw@REDACTED)3> jb_testing:ping_mnesia(). >>> Mnesia('egw@REDACTED'): Logging mnesia_down >>> 'egw@REDACTED' >>> Mnesia('egw@REDACTED'): Got mnesia_down from >>> 'egw@REDACTED', reconfiguring... >>> Mnesia('egw@REDACTED'): mnesia_monitor got FATAL ERROR >>> from: <0.73.0> >>> >>> =ERROR REPORT==== 22-Apr-2009::11:49:17 === >>> Mnesia('egw@REDACTED'): ** ERROR ** (core dumped to file: >>> "/home/jetbet/MnesiaCore.egw@REDACTED") >>> ?** FATAL ** mnesia_tm crashed: {badarg, >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?[{mnesia_tm,send_to_pids,2}, >>> >>> {mnesia_tm,reconfigure_coordinators,2}, >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {mnesia_tm,doit_loop,1}, >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {mnesia_sp,init_proc,4}, >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {proc_lib,init_p_do_apply,3}]} >>> state: [<0.68.0>] >>> Mnesia('egw@REDACTED'): mnesia_controller terminated: >>> shutdown >>> >>> =ERROR REPORT==== 22-Apr-2009::11:49:27 === >>> ** Generic server mnesia_monitor terminating >>> ** Last message in was {'EXIT',<0.68.0>,killed} >>> ** When Server state == {state,<0.68.0>,[], >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ['egw@REDACTED'], >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? true,[],undefined,[]} >>> ** Reason for termination == >>> ** killed >>> >>> =ERROR REPORT==== 22-Apr-2009::11:49:27 === >>> ** Generic server mnesia_recover terminating >>> ** Last message in was {'EXIT',<0.68.0>,killed} >>> ** When Server state == >>> {state,<0.68.0>,undefined,undefined,undefined,0,true, >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? []} >>> ** Reason for termination == >>> ** killed >>> ** exception exit: killed >>> (egw@REDACTED)4> >>> =INFO REPORT==== 22-Apr-2009::11:49:27 === >>> ? ?application: mnesia >>> ? ?exited: killed >>> ? ?type: temporary >>> >>> >>> Produced core dump is not recognized by crashdump_viewer ("...is not >>> an Erlang crash dump"). >>> >>> Some notes: >>> - Erlang version info: Erlang R13B (erts-5.7.1) [source] [64-bit] >>> [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] >>> - Same problem occurs with R13A >>> - Our OS is Centos (RedHat) linux, SMP-enabled 64-bit 2.6.18 kernel on >>> Intel. >>> >>> - if we reduce the load for mnesia by introducing sleep (100 ms) in >>> the test loop, the problem goes away or is at least less likely to >>> appear. >>> - we're using RAM tables in the example. Changing tables to >>> disc_copies makes no difference. >>> - changing the data lookup to the form >>> ? ?F = fun() -> >>> ? ? ? ? ? ? ? ?'$end_of_table' = mnesia:first(message) >>> ? ? ? ?end, >>> ?works: halt() on another node does not bring the busy one down. >>> >>> Any ideas? >>> >>> Thank you already in advance, >>> Teemu Antti-Poika >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> > From hakan@REDACTED Wed Apr 22 17:56:05 2009 From: hakan@REDACTED (Hakan Mattsson) Date: Wed, 22 Apr 2009 17:56:05 +0200 (CEST) Subject: [erlang-questions] Problems with Mnesia and failure situations In-Reply-To: <301dfe9f0904220747g20eced55mbd323c944fbc1503@mail.gmail.com> References: <301dfe9f0904220413p7764867r9832589f2ebbe93a@mail.gmail.com> <49EF0776.2060803@erix.ericsson.se> <49EF0EF0.5090403@erix.ericsson.se> <301dfe9f0904220746l612ad39didcbbc1115fec6312@mail.gmail.com> <301dfe9f0904220747g20eced55mbd323c944fbc1503@mail.gmail.com> Message-ID: On Wed, 22 Apr 2009, Teemu Antti-Poika wrote: > Apparently mnesia timing out on node A when I unplug/shutdown node B > is a necessary evil? What is timing out? Mnesia on node A should just reconfigure itself and recover those transactions that involved node B. > Since my process controlling the mnesia bound data is timing out on > remote communications, it cannot react to orders to dump tables on > disk. Eventually it is forcefully shut down by the supervisor, causing > RAM-resident data be lost, I think? Why do you dump the tables manually, instead of using disc_copies? If you use disc_copies, Mnesia will keep the table updated on disk for you. /H?kan From v@REDACTED Wed Apr 22 18:00:25 2009 From: v@REDACTED (Valentin Micic) Date: Wed, 22 Apr 2009 18:00:25 +0200 Subject: [erlang-questions] : : : sctp_peeloff() support in OTP In-Reply-To: <20090422083559.GA1705@erix.ericsson.se> Message-ID: <200904221550.n3MFoFRc027632@mail.pharos-avantgard.com> One of the problems that I see with SCTP is that, unlike TCP where you have no choice but to send the reply over the same stream you've received request through; SCTP AFAIK does not regulate this -- you could receive a request over, say, stream 6 and send a reply using stream 54. Whilst this problem exists irrespective on how one implement stream separation, using separate file descriptor may look a bit wasteful from local resources point of view. If it was up to me, I would invest a bit more time in attempt to avoid usage of multiple file descriptors. Could one have a number of "pseudo-ports" mapped to the same "real" port/file descriptor? Best V. -----Original Message----- From: 'Raimo Niskanen' [mailto:raimo+erlang-questions@REDACTED] Sent: 22 April 2009 10:36 AM To: Valentin Micic; erlang-questions@REDACTED Subject: Re: : : [erlang-questions] : sctp_peeloff() support in OTP On Tue, Apr 21, 2009 at 05:58:47PM +0200, Valentin Micic wrote: > > >> implementing it without defeating the purpose behind SCTP? > > > Could you elaborate...? > > Let me try by saying that TCP was not adequate for "multiplexing", a traffic > case where a bunch of things on one machine wants to talk to a bunch of > things on another using the same connection. The SCTP addressed this issue > on a number of levels, but most importantly -- by eliminating a head-of-line > blocking bottleneck (someone mentioned a year or two ago that SCTP would be > far better protocol for Erlang distribution). > > The reasoning behind SCTP is to provide for a minimal latency, where > processing of one stream should not create a processing delay on another. > Having the same port owner responsible for all the processing is at odds > with this design goal. In other words, {active, once} would effectively > reintroduce head-of-line blocking, by serializing all the traffic and > forcing it through a single process. > Thank you for the explanation. The term "head-of-line blocking" was new to me. Unfortunately I just realized that when the driver calls recvmsg() it can not choose which stream to receive from. So {active,once} must introduce head-of-line blocking in some form. And introducing {active,StreamNo,Pid} would have to imply {active,true}, just dispatching the streams. I think the only thing that solves the head-of-line blocking problem is branched-off associations (sctp_peeloff()) because then you get a new filedescriptor to poll() and recvmsg() as you choose from, in a new port driver instance (Port). Correct me if I am wrong. > Not so well thought through approach to active socket processing: > ----------------------------------------------------------------- > Maybe one may mitigate this by creating a number of Erlang processes as > there are streams (call it stream processors), and route upstream traffic to > a particular stream processor? Then, if there is an "external process" > requesting {active, [once|true, StramNo, PID]} that relationship may be > remembered by that particular "stream processor". The stream processor may > also be responsible for queuing, etc. If there no "external process", > requesting the traffic, it may be routed to the port-owner... > > Down-stream traffic may always be forced through port-owner, thus avoiding > port locking problems (See below). > > +-------------------------------+ > | +-----------+ | > | | | | > V V | | > +-----+ +--+ +--+ > |Owner| <--+ |P1|<----+ |Pn|<------+ > +-----+ | +--+ | +--+ | > | | | | > | | | | > | +----------+ +----------+ +----------+ > | |StrmProc#1| |StrmProc#2| |StrmProc#n| > | +----------+ +----------+ +----------+ > | A A A > V | | | > +-----------+ | | > |Port Driver|============+-------------+ > +-----------+ > > Where: > Owner - Port Owner > StrmProc#n - Stream Processor n > Pn - External Process n > > Kind Regards, > V. I see no obvious gain with respect to the simple approach (as you suggested first (as I understood it)), that would be: +------+ +----+ +----+ | | | | | | +-----+ | | +--+ | +--+ |Owner| | | |P1| | |Pn| +-----+ | | +--+ | +--+ | A A | A | V | | V | V +---------------------------------+ | Port Driver | +---------------------------------+ The port lock is just an efficiency problem. All processes simultaneously sending to a port will compete for the same lock. Passing all downstream data through the port owner will only introduce copying. The port driver will in both cases have to know (have a lookup table) of where to deliver messages on a given stream. This is a currently missing feature. Having erlang processes in the upstream data path will also introduce copying. The only advantage I see with the StrmProc processes is that they can be created and maintained through library code that can solve the problem of notifying them if the port gets killed. This problem can maybe just as well be solved by documenting and by e.g an API function that when registering a PID for a given stream will also set a monitor on the port. Would not sctp_peeloff() solve the right problems? Or would it waste filedescriptors? Is it necessary to have the possibility to multiplex streams on one SCTP file descriptor even though it implies {active,true}. +------+ +----+ +----+ | | | | | | +-----+ | | +--+ | +--+ |Owner| | | |P1| | |Pn| +-----+ | | +--+ | +--+ | A A | A | V | | V | V +-----------+ +-----------+ +-----------+ |Port Driver| |Port Driver| |Port Driver| +-----------+ +-----------+ +-----------+ | A | A | A V | V | V | +-----------+ +--------+ +--------+ | Main FD | | FD 1 | | FD n | +-----------+--+--------+----+--------+ | SCTP endpoint | +-------------------------------------+ Also, stream multiplexing with passive sockets would only be possible with sctp_peeloff(). -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From raimo+erlang-questions@REDACTED Wed Apr 22 18:15:56 2009 From: raimo+erlang-questions@REDACTED ('Raimo Niskanen') Date: Wed, 22 Apr 2009 18:15:56 +0200 Subject: [erlang-questions] : : : : sctp_peeloff() support in OTP In-Reply-To: <200904221550.n3MFoFRc027632@mail.pharos-avantgard.com> References: <20090422083559.GA1705@erix.ericsson.se> <200904221550.n3MFoFRc027632@mail.pharos-avantgard.com> Message-ID: <20090422161556.GA8674@erix.ericsson.se> On Wed, Apr 22, 2009 at 06:00:25PM +0200, Valentin Micic wrote: > One of the problems that I see with SCTP is that, unlike TCP where you have > no choice but to send the reply over the same stream you've received request > through; SCTP AFAIK does not regulate this -- you could receive a request > over, say, stream 6 and send a reply using stream 54. Whilst this problem > exists irrespective on how one implement stream separation, using separate > file descriptor may look a bit wasteful from local resources point of view. > > If it was up to me, I would invest a bit more time in attempt to avoid usage > of multiple file descriptors. Could one have a number of "pseudo-ports" > mapped to the same "real" port/file descriptor? Possible. But what I think is needed is a solution for the head-of-line blocking problem. That is: flow control per stream. In what way is it useful to dispatch messages from the driver level onto a PID dedicated for a streams if you do not get flow control per stream? > > Best > V. > > -----Original Message----- > From: 'Raimo Niskanen' [mailto:raimo+erlang-questions@REDACTED] > Sent: 22 April 2009 10:36 AM > To: Valentin Micic; erlang-questions@REDACTED > Subject: Re: : : [erlang-questions] : sctp_peeloff() support in OTP > > On Tue, Apr 21, 2009 at 05:58:47PM +0200, Valentin Micic wrote: > > > > >> implementing it without defeating the purpose behind SCTP? > > > > > Could you elaborate...? > > > > Let me try by saying that TCP was not adequate for "multiplexing", a > traffic > > case where a bunch of things on one machine wants to talk to a bunch of > > things on another using the same connection. The SCTP addressed this issue > > on a number of levels, but most importantly -- by eliminating a > head-of-line > > blocking bottleneck (someone mentioned a year or two ago that SCTP would > be > > far better protocol for Erlang distribution). > > > > The reasoning behind SCTP is to provide for a minimal latency, where > > processing of one stream should not create a processing delay on another. > > Having the same port owner responsible for all the processing is at odds > > with this design goal. In other words, {active, once} would effectively > > reintroduce head-of-line blocking, by serializing all the traffic and > > forcing it through a single process. > > > > Thank you for the explanation. The term "head-of-line blocking" > was new to me. > > Unfortunately I just realized that when the driver calls recvmsg() > it can not choose which stream to receive from. So {active,once} > must introduce head-of-line blocking in some form. And introducing > {active,StreamNo,Pid} would have to imply {active,true}, > just dispatching the streams. > > I think the only thing that solves the head-of-line blocking > problem is branched-off associations (sctp_peeloff()) because > then you get a new filedescriptor to poll() and recvmsg() as > you choose from, in a new port driver instance (Port). > Correct me if I am wrong. > > > Not so well thought through approach to active socket processing: > > ----------------------------------------------------------------- > > Maybe one may mitigate this by creating a number of Erlang processes as > > there are streams (call it stream processors), and route upstream traffic > to > > a particular stream processor? Then, if there is an "external process" > > requesting {active, [once|true, StramNo, PID]} that relationship may be > > remembered by that particular "stream processor". The stream processor may > > also be responsible for queuing, etc. If there no "external process", > > requesting the traffic, it may be routed to the port-owner... > > > > Down-stream traffic may always be forced through port-owner, thus avoiding > > port locking problems (See below). > > > > +-------------------------------+ > > | +-----------+ | > > | | | | > > V V | | > > +-----+ +--+ +--+ > > |Owner| <--+ |P1|<----+ |Pn|<------+ > > +-----+ | +--+ | +--+ | > > | | | | > > | | | | > > | +----------+ +----------+ +----------+ > > | |StrmProc#1| |StrmProc#2| |StrmProc#n| > > | +----------+ +----------+ +----------+ > > | A A A > > V | | | > > +-----------+ | | > > |Port Driver|============+-------------+ > > +-----------+ > > > > Where: > > Owner - Port Owner > > StrmProc#n - Stream Processor n > > Pn - External Process n > > > > Kind Regards, > > V. > > I see no obvious gain with respect to the simple approach > (as you suggested first (as I understood it)), that would be: > > +------+ +----+ +----+ > | | | | | | > +-----+ | | +--+ | +--+ > |Owner| | | |P1| | |Pn| > +-----+ | | +--+ | +--+ > | A A | A | > V | | V | V > +---------------------------------+ > | Port Driver | > +---------------------------------+ > > The port lock is just an efficiency problem. All processes > simultaneously sending to a port will compete for the same lock. > Passing all downstream data through the port owner will only > introduce copying. > > The port driver will in both cases have to know > (have a lookup table) of where to deliver messages > on a given stream. This is a currently missing feature. > > Having erlang processes in the upstream data path will > also introduce copying. The only advantage I see with > the StrmProc processes is that they can be created and > maintained through library code that can solve the > problem of notifying them if the port gets killed. > This problem can maybe just as well be solved by > documenting and by e.g an API function that when > registering a PID for a given stream will also set a > monitor on the port. > > Would not sctp_peeloff() solve the right problems? > Or would it waste filedescriptors? Is it necessary > to have the possibility to multiplex streams on one > SCTP file descriptor even though it implies {active,true}. > > +------+ +----+ +----+ > | | | | | | > +-----+ | | +--+ | +--+ > |Owner| | | |P1| | |Pn| > +-----+ | | +--+ | +--+ > | A A | A | > V | | V | V > +-----------+ +-----------+ +-----------+ > |Port Driver| |Port Driver| |Port Driver| > +-----------+ +-----------+ +-----------+ > | A | A | A > V | V | V | > +-----------+ +--------+ +--------+ > | Main FD | | FD 1 | | FD n | > +-----------+--+--------+----+--------+ > | SCTP endpoint | > +-------------------------------------+ > > Also, stream multiplexing with passive sockets > would only be possible with sctp_peeloff(). > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From magnus@REDACTED Wed Apr 22 18:57:56 2009 From: magnus@REDACTED (Magnus Henoch) Date: Wed, 22 Apr 2009 17:57:56 +0100 Subject: [erlang-questions] R13B prefers reference() to ref() Message-ID: <847i1c62y3.fsf@linux-b2a3.site> I found that R13B has a different opinion on the correct type name for references than both R12B-5 and R13A: the former accepts only 'reference()', while the latter accept only 'ref()'. Is this intentional? Is there a way to write a type specification that works in both compilers, apart from using 'any()'? Example - this compiles with R12B-5 but doesn't compile in R13B: -module(foo). -record(foo, {bar :: ref()}). -- Magnus Henoch, magnus@REDACTED Erlang Training and Consulting http://www.erlang-consulting.com/ From kostis@REDACTED Wed Apr 22 19:10:26 2009 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 22 Apr 2009 20:10:26 +0300 Subject: [erlang-questions] R13B prefers reference() to ref() In-Reply-To: <847i1c62y3.fsf@linux-b2a3.site> References: <847i1c62y3.fsf@linux-b2a3.site> Message-ID: <49EF4F82.8040905@cs.ntua.gr> Magnus Henoch wrote: > I found that R13B has a different opinion on the correct type name for > references than both R12B-5 and R13A: the former accepts only > 'reference()', while the latter accept only 'ref()'. Is this > intentional? Is there a way to write a type specification that works in > both compilers, apart from using 'any()'? > > Example - this compiles with R12B-5 but doesn't compile in R13B: > > -module(foo). > -record(foo, {bar :: ref()}). > Half an hour ago, I sent more or less the following answer to another user who asked the same thing in a private e-mail. Sorry about this incompatibility, but it was pointed out to us that the use of ref() as type is inconsistent with the rest of the language (all primitive types, e.g. atom(), pid(), binary(), are such that they map to is_* guards, and there is no is_ref/1 guard, but is_reference/1). Also, using ref() is inconsistent with Edoc that also uses reference(). So we changed this. The best thing for users would be to just convert to using reference() throughout. If one really wants to be able to compile with both R12B-5 and R13B-*, one can add the declaration: -type ref() :: reference(). and protect it with an appropriate -ifdef(R13B) or similar. Kostis From james.hague@REDACTED Wed Apr 22 21:00:33 2009 From: james.hague@REDACTED (James Hague) Date: Wed, 22 Apr 2009 14:00:33 -0500 Subject: [erlang-questions] Still problems with open_port({spawn, XYZ}, ...) under Windows? In-Reply-To: References: Message-ID: > Looks like it's still not possible to spawn a program with spaces in > the name, even in R13B. ?True? To answer my own question, yes. This works: open_port({spawn,"d:\\tools\\unzip.exe"}, [exit_status,stderr_to_stdout]). #Port<0.437> Then I renamed the tools directory to "t ools" (space after the "t"): open_port({spawn,"d:\\t ools\\unzip.exe"}, [exit_status,stderr_to_stdout]). ** exception error: einval in function open_port/2 called as open_port({spawn,"d:\\t ools\\unzip.exe"}, [exit_status,stderr_to_stdout]) Surrounding the pathname with escaped quotes doesn't work. Digging through the code, however, it looks like there is support for quoted paths, but it appears to not be working. James From jebenitez@REDACTED Wed Apr 22 21:51:56 2009 From: jebenitez@REDACTED (Jose Enrique Benitez Jimenez) Date: Wed, 22 Apr 2009 15:51:56 -0400 Subject: [erlang-questions] Get a large string by socket Message-ID: Hello friends, This code receive a string by socket ( {tcp, Socket_, Bin} ), but the string is too large so it just get a piece of it, but I need get it all, Do any of you have an idea for do that in a simple way? net_loop(Socket, Function, State, From)-> receive {connect, Host, Port}-> {ok, Socket_} = gen_tcp:connect(Host, Port, [list, {packet, 0}]), net_loop(Socket_, Function, connected, From); {send, Data, From_}-> gen_tcp:send(Socket, Data), net_loop(Socket, Function, State, From_); {tcp, Socket_, Bin} -> From ! {respuesta,Bin}, net_loop(Socket_, Function, State, From); {tcp_closed, Socket_}-> gen_tcp:close(Socket_) end. % Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Wed Apr 22 22:23:00 2009 From: rvirding@REDACTED (Robert Virding) Date: Wed, 22 Apr 2009 22:23:00 +0200 Subject: [erlang-questions] R13B incompatibility crashes LFE compiler Message-ID: <3dbc6d1c0904221323n24b46da2kd9540a0ca8b86d59@mail.gmail.com> There is an undocumented and incompatible change in R13B to Core Erlang which both makes it impossible to compile the file lfe_comp.erl, and crashes the LFE compiler. This affects all versions of LFE. I will try to release a fix to the latest version on github tomorrow. Sorry about that, Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From v@REDACTED Wed Apr 22 22:37:21 2009 From: v@REDACTED (Valentin Micic) Date: Wed, 22 Apr 2009 22:37:21 +0200 Subject: [erlang-questions] : : : : sctp_peeloff() support in OTP In-Reply-To: <20090422161556.GA8674@erix.ericsson.se> Message-ID: <200904222027.n3MKRBRc028375@mail.pharos-avantgard.com> > In what way is it useful to dispatch messages from the > driver level onto a PID dedicated for a streams if > you do not get flow control per stream? Not sure if it would be useful, and not sure if that is what I've been trying to say/ask. Forget about my "stream processor" (*) suggestion, it is irrelevant, and I prefer the implementation at the driver level anyway. I was only wondering if there is a way to achieve a stream separation without utilizing additional file descriptors. I think yes, but the driver may end up too complex and difficult to maintain, etc. I would be very grateful if you implement this feature whichever way you find fit :-). BR V. (*) I did say that stream processor can do queuing, though. This would imply some basic flow control vis-?-vis target PID, but not necessarily with respect to remote peer. :-) From colm.dougan@REDACTED Wed Apr 22 22:58:01 2009 From: colm.dougan@REDACTED (Colm Dougan) Date: Wed, 22 Apr 2009 21:58:01 +0100 Subject: [erlang-questions] Help diagnosing memory usage Message-ID: <24d4f39c0904221358g4fe9d5ecm53146d6d8d7cb864@mail.gmail.com> Hi, I'm trying to reconcile the output of erlang:memory() vs ets:i() and I seem to have quite a big discrepancy. If I run erlang:memory() I get the following: 20> erlang:memory(). [{total,949026552}, {processes,1089932}, {processes_used,1080612}, {system,947936620}, {atom,742857}, {atom_used,737735}, {binary,27760}, {code,6016281}, {ets,929695484}] This matches top which says I am using around 940MB of memory. It seems the majority of memory is being used by the ETS tables. So If I run ets:i() I get: 21> ets:i(). id name type size mem owner ---------------------------------------------------------------------------- 9 cookies set 0 288 auth 4108 code set 463 36286 code_server 8205 code_names set 55 5071 code_server 12302 shell_records ordered_set 0 81 <0.32.0> 20497 ssl_pid_to_file bag 0 288 ssl_manager 24594 ssl_otp_session_cache set 0 288 ssl_manager 32792 dets duplicate_bag 11 413 dets 36894 mnesia_subscr duplicate_bag 1 298 mnesia_subscr 40991 mnesia_transient_decision set 2 318 mnesia_recover 53288 cache_manager set 1 462 cache_manager 57385 mnesia_index bag 3796177 51598879 mnesia_monitor 61482 recv_list ordered_set 567969 11359461 <0.148.0> 65579 send_list ordered_set 3228208 54879617 <0.148.0> 69684 ca_cert_table set 203 63539 ca_certificate_manager 73782 yaws_code set 2 308 <0.206.0> 77879 ign_requests set 0 288 inet_gethost_native 81976 ign_req_index set 0 288 inet_gethost_native 86074 handler_db set 0 288 httpc_manager 90171 http_session_cookie_db bag 0 288 httpc_manager '+rGSE56USZ99aOORq46fZA==_index' '+rGSE56USZ99aOORq46fZA==_index' bag 3796177 81968295 mnesia_monitor ac_tab ac_tab set 121 5568 application_controller bfmc_table bfmc_table set 0 288 bfmc cache_stats cache_stats set 1 364 cache_stats caches caches set 1 347 mnesia_monitor client_config_table client_config_table set 0 288 client_config_mgr dets_owners dets_owners set 6 348 dets dets_registry dets_registry set 6 354 dets disk_log_names disk_log_names set 1 299 disk_log_server disk_log_pids disk_log_pids set 1 298 disk_log_server file_io_servers file_io_servers set 1 358 file_server_2 global_locks global_locks set 0 288 global_name_server global_names global_names set 0 288 global_name_server global_names_ext global_names_ext set 0 288 global_name_server global_pid_ids global_pid_ids bag 0 288 global_name_server global_pid_names global_pid_names bag 0 288 global_name_server httpc_manager_session_db httpc_manager_session_db set 0 288 httpc_manager inet_cache inet_cache bag 0 288 inet_db inet_db inet_db set 21 510 inet_db inet_hosts inet_hosts set 0 288 inet_db mnesia_decision mnesia_decision set 1 299 mnesia_recover mnesia_gvar mnesia_gvar set 173 3521 mnesia_monitor mnesia_held_locks mnesia_held_locks bag 0 288 mnesia_monitor mnesia_lock_counter mnesia_lock_counter set 0 288 mnesia_monitor mnesia_lock_queue mnesia_lock_queue bag 0 288 mnesia_monitor mnesia_sticky_locks mnesia_sticky_locks set 0 288 mnesia_monitor mnesia_tid_locks mnesia_tid_locks bag 0 288 mnesia_monitor queue_table queue_table ordered_set 1 92 writer_service schema schema set 4 732 mnesia_monitor user_stats_collector_client_connection_log user_stats_collector_client_connection_log bag 0 288 user_stats_collector user_stats_collector_client_stats user_stats_collector_client_stats set 1 349 user_stats_collector user_stats_collector_current_dataplane_stats user_stats_collector_current_dataplane_stats bag 0 288 user_stats_collector user_stats_collector_historic_client_stats user_stats_collector_historic_client_stats set 74 5246 user_stats_collector ssl_file_to_ref ssl_file_to_ref set 0 288 ssl_manager ssl_otp_certificate_db ssl_otp_certificate_db set 0 288 ssl_manager stats_collector_live_stats_table stats_collector_live_stats_table set 1 1512 stats_collector sys_dist sys_dist set 0 288 net_kernel timer_interval_tab timer_interval_tab set 6 456 timer_server timer_tab timer_tab ordered_set 7 312 timer_server block_delete_table block_delete_table set 0 288 mnesia_monitor yaws_session_server yaws_session_server set 0 288 yaws_session_server ok >From ets:i() I only get about 200MB used! I can't seem to reconcile the other 740MB. Can anyone point out what I'm missing? Thanks, Colm From per@REDACTED Thu Apr 23 00:09:10 2009 From: per@REDACTED (Per Hedeland) Date: Thu, 23 Apr 2009 00:09:10 +0200 (CEST) Subject: [erlang-questions] Help diagnosing memory usage In-Reply-To: <24d4f39c0904221358g4fe9d5ecm53146d6d8d7cb864@mail.gmail.com> Message-ID: <200904222209.n3MM9A3M080010@pluto.hedeland.org> Colm Dougan wrote: > >>From ets:i() I only get about 200MB used! > >I can't seem to reconcile the other 740MB. Can anyone point out what >I'm missing? ets(3): * Item=memory, Value=int() The number of words allocated to the table. ^^^^^ 1 word == 4 bytes (on 32-bit system). Still 100+ MB missing though. --Per Hedeland From pablo.polvorin@REDACTED Thu Apr 23 01:43:48 2009 From: pablo.polvorin@REDACTED (Pablo Polvorin) Date: Wed, 22 Apr 2009 20:43:48 -0300 Subject: [erlang-questions] Get a large string by socket In-Reply-To: References: Message-ID: <1ffe809c0904221643we957a09vbf330c42319163b7@mail.gmail.com> Hi, for your description it is difficult to see if you are having problems with erlang, or with the TCP semantics in general. Supposing that your problems are with erlang, the question is, basically, how large is too large?. if you know in advance how long each string is going to be, then use gen_tcp in passive mode and gen_tcp:recv specifying the desired length might be an option for you. If each of the those "large" strings are preceded by its size, then check if one of the packet types in inet fit your needs. If not, implement the packet buffering by yourself. If your "string" use some other way for framing, you have to detect it yourself. If your protocol doesn't implement any form of packet framing, and still you want to read an "entire" string at a time, you are hitting against TCP, not erlang. cheers, pablo. 2009/4/22 Jose Enrique Benitez Jimenez : > Hello friends, > > This code receive a string by socket ( {tcp, Socket_, Bin} ), but the string > is too large so it just get a piece of it, but I need get it all, Do any of > you have an idea for do that in a simple way? > > > > net_loop(Socket, Function, State, From)-> > > ??????????????? receive > > ?????????????????????????????? {connect, Host, Port}-> > > ?????????????????????????????????????????????? {ok, Socket_} = > gen_tcp:connect(Host, Port, [list, {packet, 0}]), > > ?????????????????????????????????????????????? net_loop(Socket_, Function, > connected, From); > > ?????????????????????????????? {send, Data, From_}-> > > ?????????????????????????????????????????????? gen_tcp:send(Socket, Data), > > ?????????????????????????????????????????????? net_loop(Socket, Function, > State, From_); > > ?????????????????????????????? {tcp, Socket_, Bin} -> > > ?????????????????????????????????????????????? From ! {respuesta,Bin}, > > ?????????????????????????????????????????????? net_loop(Socket_, Function, > State, From); > > ?????????????????????????????? {tcp_closed, Socket_}-> > > > gen_tcp:close(Socket_) > > ??????????????? end. > > > > % Thanks > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From zerthurd@REDACTED Thu Apr 23 04:52:52 2009 From: zerthurd@REDACTED (Maxim Treskin) Date: Thu, 23 Apr 2009 09:52:52 +0700 Subject: [erlang-questions] : : : sctp_peeloff() support in OTP In-Reply-To: <200904221550.n3MFoFRc027632@mail.pharos-avantgard.com> References: <20090422083559.GA1705@erix.ericsson.se> <200904221550.n3MFoFRc027632@mail.pharos-avantgard.com> Message-ID: I think that possibility of sending different streams to different processes is unnecessary, but same with associations (not streams) is cool thing, because we can to distinguish connected clients by associations. Not so? -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: From nesrait@REDACTED Thu Apr 23 05:43:57 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Thu, 23 Apr 2009 04:43:57 +0100 Subject: [erlang-questions] Building erl_interface with mingw (an unfinished tale) In-Reply-To: <523869a70904220156l2f79d0cdh2f63eb74b3973fa8@mail.gmail.com> References: <523869a70904220156l2f79d0cdh2f63eb74b3973fa8@mail.gmail.com> Message-ID: <523869a70904222043k59699ee6hd11107747ea9b8fe@mail.gmail.com> Hi again! I just did a fresh R13B install on an linux box and came across the same problem while compiling the erl_interface tutorial example. If I try this: nonroot@REDACTED:~/port$ gcc -o extprg erl_comm.c ei.c -lei -lerl_interface -I/usr/local/lib/erlang/lib/erl_interface-3.6.1/include/ -L/usr/local/lib/erlang/lib/erl_interface-3.6.1/lib/ I get a bunch of "undefined reference" warnings: /usr/local/lib/erlang/lib/erl_interface-3.6.1/lib//liberl_interface.a(erl_eterm.o): In function `erl_mk_var': /home/nonroot/otp_src_R13B/lib/erl_interface/src/legacy/erl_eterm.c:498: undefined reference to `__erl_errno_place' ... the list continues ... (I did forgot -lpthread there.) But if I unpack the contents of libei.a and include the .o files instead of adding the -lei flag then the linking succeeds and the program works perfectly: nonroot@REDACTED:~/port$ gcc -o extprg erl_comm.c ei.c lib_ei_extracted/*.o -lerl_interface -lpthread -I/usr/local/lib/erlang/lib/erl_interface-3.6.1/include/ -L/usr/local/lib/erlang/lib/erl_interface-3.6.1/lib/ nonroot@REDACTED:~/port$ erl Erlang R13B (erts-5.7.1) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.1 (abort with ^G) 1> complex:start("./extprg"). <0.35.0> 2> complex:foo(1). 1 What am I missing here? :| It must be something really trivial but I'm fresh out of ideas on what it might be. Cheers, Davide :) 2009/4/22 Davide Marqu?s > Hi there! > > I was (almost) able to compile erl_interface using mingw (with some > unhealthy hacks along the way) and I'd like to get your feedback on whether > this would be the correct way to go. > Actually, since I have no *useful* experience using gcc and related tools > I'm prepared to have someone telling me that I really didn't had to > recompile erl_interface. > Either way, this might be useful for others that might be thinking of > taking the same path... :) > > My setup: Windows XP, OTP_R13B (I started off with OTP_R13A so paths will > vary), MSYS + MinGW. > > I started off following the erl_interface tutorial ( > http://erlang.org/doc/tutorial/erl_interface.html) and things broke when I > tried to compile: > Davide@REDACTED /c/Projectos/eNotify/src/native/port > $ gcc.exe ei.c erl_comm.c -o extprg.exe > -Ic:/erl5.7/lib/erl_interface-3.6/include > -Lc:/erl5.7/lib/erl_interface-3.6/lib -lei -lerl_interface > Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" > /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized > Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" > /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized > Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" > /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized > Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" > /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized > Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" > /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized > > c:/erl5.7/lib/erl_interface-3.6/lib/erl_interface.lib(C:/cygwin/ldisk/daily_build/otp_build_win32_r13a.2009-03-16_22/otp_src_R13A/lib/erl_interface/ > obj.mt/win32/erl_malloc.o):(.text+0x47): > undefined reference to `ei_malloc' > > c:/erl5.7/lib/erl_interface-3.6/lib/erl_interface.lib(C:/cygwin/ldisk/daily_build/otp_build_win32_r13a.2009-03-16_22/otp_src_R13A/lib/erl_interface/ > obj.mt/win32/erl_malloc.o):(.text+0x7c): > undefined reference to `ei_realloc' > (...) > > > c:/erl5.7/lib/erl_interface-3.6/lib/erl_interface.lib(C:/cygwin/ldisk/daily_build/otp_build_win32_r13a.2009-03-16_22/otp_src_R13A/lib/erl_interface/ > obj.mt/win32/erl_error.o):(.text+0xa2): > more undefined references to `__iob_func' follow > collect2: ld returned 1 exit status > > ??? :| > The ei.lib and erl_interface.lib files were in > c:/erl5.7/lib/erl_interface-3.6/lib so I was expecting this to work. :\ > > A little online research ( > http://erlang.org/pipermail/erlang-questions/2003-September/009854.html) > lead me think that the .lib files weren't GCC-compliant (and what I needed > were .a files). > So it would be a simple matter of getting the source and compiling > erl_interface again (famous last words). > > This is were someone can come in and say "No! No! No! You just had to do > XPTO." > Considering no XPTO existed I went along to try and build erl_interface. > > First I tried to just build it using the files that were available on the > windows binary distribution but it failed complaining about a missing /make/ > target.mk. > So I: > > - got the otp_src_R13A sourcecode > - did a ./configure > - exported ERL_TOP=c:/otp_src_R13A > - IIRC > - got something about a missing > c:/otp_src_R13A/make/i686-pc-mingw32/otp.mk folder > - which I copied and renamed from c:/otp_src_R13A/make/otp.mk.in(I'm guessing something is responsible for this step) > - added the necessary LIBS = -lwsock32 to > c:/otp_src_R13A/lib/erl_interface/src/i686-pc-mingw32/Makefile > - did a successful build > - which resulted in two files: libei.a and liberl_interface.a > getting placed in > c:/otp_src_R13A/lib/erl_interface/obj.debug/i686-pc-mingw32/ > - I created a folder c:/otp_src_R13A/lib/erl_interface/lib > - and copied the two files there > > I then tried using those two files to build the erl_interface tutorial > program with this result: > Davide@REDACTED /c/Projectos/eNotify/src/native/port > $ gcc.exe ei.c erl_comm.c -o extprg.exe > -Ic:/otp_src_R13A/lib/erl_interface/include > -Lc:/otp_src_R13A/lib/erl_interface/lib -lei -lerl_interface > > c:/otp_src_R13A/lib/erl_interface/lib/liberl_interface.a(erl_malloc.o): In > function `erl_malloc': > c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_malloc.c:221: > undefined reference to `ei_malloc' > > c:/otp_src_R13A/lib/erl_interface/lib/liberl_interface.a(erl_malloc.o): In > function `erl_realloc': > c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_malloc.c:231: > undefined reference to `ei_realloc' > > c:/otp_src_R13A/lib/erl_interface/lib/liberl_interface.a(erl_malloc.o): In > function `erl_free': > c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_malloc.c:238: > undefined reference to `ei_free' > ... > > c:/otp_src_R13A/lib/erl_interface/lib/liberl_interface.a(erl_fix_alloc.o): > In function `erl_eterm_alloc': > c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_fix_alloc.c:111: > undefined reference to `__erl_errno_place' > collect2: ld returned 1 exit status > > Which (other than the initial warnings) is exactly the same problem as the > one I got with the original compilation. > Here I took a look at the build process and realized that the erl_interface > build process had also produced a bunch of .o files in another folder: > c:/erl5.7/lib/erl_interface/obj.st.debug/i686-pc-mingw32/ > > Since the compiler was nagging me about missing .o files I just included > them all in: > Davide@REDACTED /c/Projectos/eNotify/src/native/port > $ gcc.exe ei.c erl_comm.c -o extprg.exe > c:/otp_src_R13A/lib/erl_interface/include/*.o > -Ic:/otp_src_R13A/lib/erl_interface/include > -Lc:/otp_src_R13A/lib/erl_interface/lib -lei -lerl_interface -lwsock32 > c:/otp_src_R13A/lib/erl_interface/include/erl_resolve.o: In > function `erl_gethostbyname_r': > c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_resolve.c:58: > undefined reference to `ei_gethostbyname_r' > c:/otp_src_R13A/lib/erl_interface/include/erl_resolve.o: In > function `erl_gethostbyaddr_r': > c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_resolve.c:70: > undefined reference to `ei_gethostbyaddr_r' > collect2: ld returned 1 exit status > > :| This is another struggle. > Under certain circumstances (mine) the functions ei_gethostbyname_r and > ei_gethostbyaddr_r aren't included in the compilation of the ei_resolve.c > file. > Being completely astray from my original goal, and after figuring out that > these were the reentrant versions of the same functions without the _r and > that on windows the original ones are already thread safe ( > http://daniel.haxx.se/projects/portability/), I just went ahead and added > these *_r functions calling out to original ones (on the $ifdef __WIN32__ > part ). This was the unhealthy hack part. :) > Of course that worked (to shut the compiler up at least). :P > Davide@REDACTED /c/Projectos/eNotify/src/native/port > $ gcc.exe ei.c erl_comm.c -o extprg.exe > c:/otp_src_R13A/lib/erl_interface/include/*.o > -Ic:/otp_src_R13A/lib/erl_interface/include > -Lc:/otp_src_R13A/lib/erl_interface/lib -lei -lerl_interface -lwsock32 > > Finally that got me a working extprg.exe that I was able to complete the > tutorial with! > > > > I picked up were I left off: being able to compile IF including all of the > .o files. > Some [n00b] research -> http://en.wikipedia.org/wiki/Ar_(Unix)& > http://linux.die.net/man/1/ar > Got me to check if all the .o files the linker was complaining about were > getting archived in the two .a files. > And indeed, all of them were on libei.a. > > I unpacked the .o files from libeia.a and replaced it with a call to those > .o: > Davide@REDACTED /c/Projectos/eNotify/src/native/port > $ gcc.exe -o extprg.exe ei.c erl_comm.c > /c/otp_src_R13B/lib/erl_interface/obj/i686-pc-mingw32/*.o > /c/otp_src_R13B/lib/erl_interface/obj/i686-pc-mingw32/liberl_interface.a > -Ic:/otp_src_R13B/lib/erl_interface/include -lwsock32 > > And guess what... It worked! :) > > So what am I missing here? Is it normal that "ar"ed files don't link > correctly? Is it mingw? Or is it just me? :) > Any(!!!) clues are more than welcome! :) > > Cheers, > Davide :) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chaitanya.chalasani@REDACTED Thu Apr 23 07:46:53 2009 From: chaitanya.chalasani@REDACTED (chaitanya Chalasani) Date: Thu, 23 Apr 2009 11:16:53 +0530 Subject: [erlang-questions] Clustering through Multicast In-Reply-To: <4d08db370904220655u3be4d1f0n1d79fd18b37a9dd3@mail.gmail.com> References: <1240388244.3918.9.camel@chaitanya.laptop> <4d08db370904220655u3be4d1f0n1d79fd18b37a9dd3@mail.gmail.com> Message-ID: <1240465613.4106.1.camel@chaitanya.laptop> Thank you for the link. I will run through the pasox protocol documentation. On Wed, 2009-04-22 at 15:55 +0200, Hynek Vychodil wrote: > It sounds more like paxos protocol works. Look at scalaris > (http://code.google.com/p/scalaris/). > > > On Wed, Apr 22, 2009 at 10:17 AM, chaitanya Chalasani > wrote: > > Hi, > > May be the solution exists, but the idea just popped and want > to clarify if it really works this way. > > Instead of the regular cluster node and unicast load balance > to multiple worker nodes, if we use the IP multicast to a > group of servers with replicated mnesia and let each node > attempt to start a transaction and only one node gets to act > on it, based on the mnesia transaction write lock, will there > be less latency in distributing the transactions. And also it > might help in some cases wherein the delay in identifying dead > node would not effect the transactions within. > ------ > CHAITANYA CHALASANI > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill > your boss. Be a data hero! > Try Good Data now for free: www.gooddata.com ------ CHAITANYA CHALASANI -------------- next part -------------- An HTML attachment was scrubbed... URL: From anttipoi@REDACTED Thu Apr 23 08:08:23 2009 From: anttipoi@REDACTED (Teemu Antti-Poika) Date: Thu, 23 Apr 2009 09:08:23 +0300 Subject: [erlang-questions] Problems with Mnesia and failure situations In-Reply-To: References: <301dfe9f0904220413p7764867r9832589f2ebbe93a@mail.gmail.com> <49EF0776.2060803@erix.ericsson.se> <49EF0EF0.5090403@erix.ericsson.se> <301dfe9f0904220746l612ad39didcbbc1115fec6312@mail.gmail.com> <301dfe9f0904220747g20eced55mbd323c944fbc1503@mail.gmail.com> Message-ID: <301dfe9f0904222308t17bcee96pfffa6286eaa9fef7@mail.gmail.com> On Wed, Apr 22, 2009 at 6:56 PM, Hakan Mattsson wrote: > On Wed, 22 Apr 2009, Teemu Antti-Poika wrote: > >> Apparently mnesia timing out on node A when I unplug/shutdown node B >> is a necessary evil? > > What is timing out? Mnesia on node A should just reconfigure itself > and recover those transactions that involved node B. Mnesia itself survived, so my worry below is not justified (data is safe). In my application using mnesia the mnesia transactions timed out, eventually causing the supervisors to react. But I guess that is to be expected. >> Since my process controlling the mnesia bound data is timing out on >> remote communications, it cannot react to orders to dump tables on >> disk. Eventually it is forcefully shut down by the supervisor, causing >> RAM-resident data be lost, I think? > > Why do you dump the tables manually, instead of using disc_copies? > If you use disc_copies, Mnesia will keep the table updated on disk for you. That is/was just a premature optimization (minimizing disk i/o). I've changed the tables to disc_copies without observable change in performance. Teemu A-P From v@REDACTED Thu Apr 23 08:55:24 2009 From: v@REDACTED (Valentin Micic) Date: Thu, 23 Apr 2009 08:55:24 +0200 Subject: [erlang-questions] : : : sctp_peeloff() support in OTP In-Reply-To: Message-ID: <200904230645.n3N6jERc030783@mail.pharos-avantgard.com> Well, if the same process is responsible for processing of different streams, what's the point of having different streams? V. _____ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Maxim Treskin Sent: 23 April 2009 04:53 AM To: erlang-questions@REDACTED Subject: Re: [erlang-questions] : : : sctp_peeloff() support in OTP I think that possibility of sending different streams to different processes is unnecessary, but same with associations (not streams) is cool thing, because we can to distinguish connected clients by associations. Not so? -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: From hakan@REDACTED Thu Apr 23 09:22:40 2009 From: hakan@REDACTED (Hakan Mattsson) Date: Thu, 23 Apr 2009 09:22:40 +0200 (CEST) Subject: [erlang-questions] Problems with Mnesia and failure situations In-Reply-To: <301dfe9f0904222308t17bcee96pfffa6286eaa9fef7@mail.gmail.com> References: <301dfe9f0904220413p7764867r9832589f2ebbe93a@mail.gmail.com> <49EF0776.2060803@erix.ericsson.se> <49EF0EF0.5090403@erix.ericsson.se> <301dfe9f0904220746l612ad39didcbbc1115fec6312@mail.gmail.com> <301dfe9f0904220747g20eced55mbd323c944fbc1503@mail.gmail.com> <301dfe9f0904222308t17bcee96pfffa6286eaa9fef7@mail.gmail.com> Message-ID: On Thu, 23 Apr 2009, Teemu Antti-Poika wrote: > On Wed, Apr 22, 2009 at 6:56 PM, Hakan Mattsson wrote: > > > On Wed, 22 Apr 2009, Teemu Antti-Poika wrote: > > > >> Apparently mnesia timing out on node A when I unplug/shutdown node B > >> is a necessary evil? > > > > What is timing out? Mnesia on node A should just reconfigure itself > > and recover those transactions that involved node B. > > Mnesia itself survived, so my worry below is not justified (data is > safe). In my application using mnesia the mnesia transactions timed > out, eventually causing the supervisors to react. But I guess that is > to be expected. Mnesia should reconfigure itself rather quickly when node B is shutdown, but the ongoing transactions will have to pay a little penalty when this happens. Depending on which phase that the transaction is in, different actions are taken. What is the purpose of shutting down your application if a Mnesia transaction takes too long time? Are you trying to implement hard real-time behavior on top of Mnesia? /H?kan --- H?kan Mattsson (uabhams) Erlang/OTP, Ericsson AB From anttipoi@REDACTED Thu Apr 23 09:46:38 2009 From: anttipoi@REDACTED (Teemu Antti-Poika) Date: Thu, 23 Apr 2009 10:46:38 +0300 Subject: [erlang-questions] Problems with Mnesia and failure situations In-Reply-To: References: <301dfe9f0904220413p7764867r9832589f2ebbe93a@mail.gmail.com> <49EF0776.2060803@erix.ericsson.se> <49EF0EF0.5090403@erix.ericsson.se> <301dfe9f0904220746l612ad39didcbbc1115fec6312@mail.gmail.com> <301dfe9f0904220747g20eced55mbd323c944fbc1503@mail.gmail.com> <301dfe9f0904222308t17bcee96pfffa6286eaa9fef7@mail.gmail.com> Message-ID: <301dfe9f0904230046m231b2f8eubad2bb154530c706@mail.gmail.com> On Thu, Apr 23, 2009 at 10:22 AM, Hakan Mattsson wrote: > On Thu, 23 Apr 2009, Teemu Antti-Poika wrote: > >> On Wed, Apr 22, 2009 at 6:56 PM, Hakan Mattsson wrote: > > Mnesia should reconfigure itself rather quickly when node B is > shutdown, but the ongoing transactions will have to pay a little > penalty when this happens. Depending on which phase that the > transaction is in, different actions are taken. > > What is the purpose of shutting down your application if a Mnesia > transaction takes too long time? Are you trying to implement hard > real-time behavior on top of Mnesia? No, we're not going for real-time. In this case application was trying to react to the failover by terminating a part of the supervision tree. Since one of the supervised processes was stuck waiting for a mnesia transaction to finish, it could not respond to the exit signal. I'm afraid I no longer have the logs left from the occasion, so I cannot check the above (why would the termination of the supervisor itself fail here?). In any case the application recovered via the main supervisor and that's the important thing. I may have the time to repeat the experiment tomorrow, but today I cannot make it. Teemu A-P From anttipoi@REDACTED Thu Apr 23 10:01:33 2009 From: anttipoi@REDACTED (Teemu Antti-Poika) Date: Thu, 23 Apr 2009 11:01:33 +0300 Subject: [erlang-questions] Problems with Mnesia and failure situations In-Reply-To: <301dfe9f0904230046m231b2f8eubad2bb154530c706@mail.gmail.com> References: <301dfe9f0904220413p7764867r9832589f2ebbe93a@mail.gmail.com> <49EF0776.2060803@erix.ericsson.se> <49EF0EF0.5090403@erix.ericsson.se> <301dfe9f0904220746l612ad39didcbbc1115fec6312@mail.gmail.com> <301dfe9f0904220747g20eced55mbd323c944fbc1503@mail.gmail.com> <301dfe9f0904222308t17bcee96pfffa6286eaa9fef7@mail.gmail.com> <301dfe9f0904230046m231b2f8eubad2bb154530c706@mail.gmail.com> Message-ID: <301dfe9f0904230101x198903a5j785047a26532e346@mail.gmail.com> Updating myself a bit: I crashed it quickly and re-checked: On Thu, Apr 23, 2009 at 10:46 AM, Teemu Antti-Poika wrote: > >> What is the purpose of shutting down your application if a Mnesia >> transaction takes too long time? Are you trying to implement hard >> real-time behavior on top of Mnesia? > > No, we're not going for real-time. Ignore the previous attempt for an explanation. What happened was that another process simply timed out in gen_server:call (with default timeout of 5000 ms) when calling the mnesia -related process, which was taking time to recover from failover. Teemu From erlang@REDACTED Thu Apr 23 10:24:21 2009 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 23 Apr 2009 10:24:21 +0200 Subject: [erlang-questions] Get a large string by socket In-Reply-To: References: Message-ID: <9b08084c0904230124t505d7353ica63cf88538ff133@mail.gmail.com> If both the client and server are in erlang then it's easy open the socket at both ends with a {packet,4} option. (read the gen_tcp manual page) Then when you do gen_server:send(Socket, Data) the data will be preceded by a 4 byte length header. The receiving end will perform any necessary recombination of the data (if fragmented) and deliver the data as a single message. If the server is not in erlang, then you will have to read the length header and perform recombination yourself. If the data is really large you might have to rethink this. For small strings this is fine - What is small depends on your hardware. Typically transferring up to a few tens of MBytes should not be a problem, just send and receive them in a single call. If you're talking GB then you should probably rethink this - for large strings *don't* use strings use binaries! Cheers /Joe 2009/4/22 Jose Enrique Benitez Jimenez : > Hello friends, > > This code receive a string by socket ( {tcp, Socket_, Bin} ), but the string > is too large so it just get a piece of it, but I need get it all, Do any of > you have an idea for do that in a simple way? > > > > net_loop(Socket, Function, State, From)-> > > ??????????????? receive > > ?????????????????????????????? {connect, Host, Port}-> > > ?????????????????????????????????????????????? {ok, Socket_} = > gen_tcp:connect(Host, Port, [list, {packet, 0}]), > > ?????????????????????????????????????????????? net_loop(Socket_, Function, > connected, From); > > ?????????????????????????????? {send, Data, From_}-> > > ?????????????????????????????????????????????? gen_tcp:send(Socket, Data), > > ?????????????????????????????????????????????? net_loop(Socket, Function, > State, From_); > > ?????????????????????????????? {tcp, Socket_, Bin} -> > > ?????????????????????????????????????????????? From ! {respuesta,Bin}, > > ?????????????????????????????????????????????? net_loop(Socket_, Function, > State, From); > > ?????????????????????????????? {tcp_closed, Socket_}-> > > > gen_tcp:close(Socket_) > > ??????????????? end. > > > > % Thanks > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From gamoto@REDACTED Thu Apr 23 11:31:34 2009 From: gamoto@REDACTED (Gamoto) Date: Thu, 23 Apr 2009 11:31:34 +0200 Subject: [erlang-questions] upgrading to a new version Message-ID: <200904231131339483360@bluewin.ch> I am running the R12B-5 version. What are your advices for upgrading to R13B ? (delete, new dir, ...) From gamoto@REDACTED Thu Apr 23 11:35:19 2009 From: gamoto@REDACTED (Gamoto) Date: Thu, 23 Apr 2009 11:35:19 +0200 Subject: [erlang-questions] werl.exe slow Message-ID: <200904231135195930738@bluewin.ch> When I start werl.exe on windows 2003 server, the time before to have the ">" is around 10 seconds ! Why is it so slow ? normal ? solutions for enhancement ? From raimo+erlang-questions@REDACTED Thu Apr 23 11:56:52 2009 From: raimo+erlang-questions@REDACTED ('Raimo Niskanen') Date: Thu, 23 Apr 2009 11:56:52 +0200 Subject: [erlang-questions] : : : : : sctp_peeloff() support in OTP In-Reply-To: <200904222027.n3MKRBRc028375@mail.pharos-avantgard.com> References: <20090422161556.GA8674@erix.ericsson.se> <200904222027.n3MKRBRc028375@mail.pharos-avantgard.com> Message-ID: <20090423095652.GA32586@erix.ericsson.se> On Wed, Apr 22, 2009 at 10:37:21PM +0200, Valentin Micic wrote: > > In what way is it useful to dispatch messages from the > > driver level onto a PID dedicated for a streams if > > you do not get flow control per stream? > > Not sure if it would be useful, and not sure if that is what I've been > trying to say/ask. Forget about my "stream processor" (*) suggestion, it is > irrelevant, and I prefer the implementation at the driver level anyway. > I was only wondering if there is a way to achieve a stream separation > without utilizing additional file descriptors. I think yes, but the driver > may end up too complex and difficult to maintain, etc. If it is useful it may be worth the complexification... But I am now under the assumption that a stream separation that does not utilize additional file descriptors (as you ask for) can not do per-stream flow control (with respect to remote peer) and therefore is not useful. Prove me wrong and I might do it. > I would be very grateful if you implement this feature whichever way you > find fit :-). > > BR > > V. > > (*) I did say that stream processor can do queuing, though. This would imply > some basic flow control vis-?-vis target PID, but not necessarily with > respect to remote peer. :-) > -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From nesrait@REDACTED Thu Apr 23 12:29:10 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Thu, 23 Apr 2009 11:29:10 +0100 Subject: [erlang-questions] Building erl_interface with mingw (an unfinished tale) In-Reply-To: <523869a70904222043k59699ee6hd11107747ea9b8fe@mail.gmail.com> References: <523869a70904220156l2f79d0cdh2f63eb74b3973fa8@mail.gmail.com> <523869a70904222043k59699ee6hd11107747ea9b8fe@mail.gmail.com> Message-ID: <523869a70904230329q67a96f8cof8dac13a374f5bcc@mail.gmail.com> Hi again! Found the solution (and indeed... it was trivial)! :) It was simply a matter of changing the order used to link the ei and erl_interface libraries!! (didn't have a clue that mattered :)) This works perfectly: $ gcc -o extprg.exe *.c -I/c/otp_src_R13B/lib/erl_interface/include/ -L/c/otp_src_R13B/lib/erl_interface/obj/i686-pc-mingw32/ -lei -lerl_interface -lwsock32 Now... to determine if all this trouble was worth it I went back to the .lib files included in the windows distribution to see if those worked. $ gcc -o extprg.exe *.c -I/c/erl5.7.1/lib/erl_interface-3.6.1/include/ -L/c/erl5.7.1/lib/erl_interface-3.6.1/lib/ -lerl_interface -lei -lwsock32 But (luckily for my mental health) it didn't work... some of dependencies were indeed fixed but not all of then. I got a bunch of these warnings: Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized And these undefined references: c:/erl5.7.1/lib/erl_interface-3.6.1/lib//erl_interface.lib(C:/cygwin/ldisk/daily_build/otp_build_win32_r13b.2009-04-20_20/otp_src_R13B/lib/erl_interface/ obj.mt/win32/erl_marshal.o):(.text+0xf4): undefined reference to `__security_cookie' (and: @__security_check_cookie@REDACTED, __security_cookie, @__security_check_cookie@REDACTED, __iob_func, _tls_index, _tls_array) While the .lib files aren't working, it's possible to build erl_interface using mingw and get working libei.a and liberl_interface.a libraries. :) Hope that's useful for someone out there. Cheers, Davide :) 2009/4/23 Davide Marqu?s > Hi again! > > I just did a fresh R13B install on an linux box and came across > the same problem while compiling the erl_interface tutorial example. > > If I try this: > nonroot@REDACTED:~/port$ gcc -o extprg erl_comm.c ei.c -lei > -lerl_interface -I/usr/local/lib/erlang/lib/erl_interface-3.6.1/include/ > -L/usr/local/lib/erlang/lib/erl_interface-3.6.1/lib/ > > I get a bunch of "undefined reference" warnings: > > /usr/local/lib/erlang/lib/erl_interface-3.6.1/lib//liberl_interface.a(erl_eterm.o): > In function `erl_mk_var': > > /home/nonroot/otp_src_R13B/lib/erl_interface/src/legacy/erl_eterm.c:498: > undefined reference to `__erl_errno_place' > ... the list continues ... > > (I did forgot -lpthread there.) > > But if I unpack the contents of libei.a and include the .o files instead of > adding the -lei flag then the linking succeeds and the program works > perfectly: > > nonroot@REDACTED:~/port$ gcc -o extprg erl_comm.c ei.c > lib_ei_extracted/*.o -lerl_interface -lpthread > -I/usr/local/lib/erlang/lib/erl_interface-3.6.1/include/ > -L/usr/local/lib/erlang/lib/erl_interface-3.6.1/lib/ > nonroot@REDACTED:~/port$ erl > Erlang R13B (erts-5.7.1) [source] [rq:1] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.7.1 (abort with ^G) > 1> complex:start("./extprg"). > <0.35.0> > 2> complex:foo(1). > 1 > > What am I missing here? :| > It must be something really trivial but I'm fresh out of ideas on what it > might be. > > Cheers, > Davide :) > > 2009/4/22 Davide Marqu?s > > Hi there! >> >> I was (almost) able to compile erl_interface using mingw (with some >> unhealthy hacks along the way) and I'd like to get your feedback on whether >> this would be the correct way to go. >> Actually, since I have no *useful* experience using gcc and related tools >> I'm prepared to have someone telling me that I really didn't had to >> recompile erl_interface. >> Either way, this might be useful for others that might be thinking of >> taking the same path... :) >> >> My setup: Windows XP, OTP_R13B (I started off with OTP_R13A so paths will >> vary), MSYS + MinGW. >> >> I started off following the erl_interface tutorial ( >> http://erlang.org/doc/tutorial/erl_interface.html) and things broke when >> I tried to compile: >> Davide@REDACTED /c/Projectos/eNotify/src/native/port >> $ gcc.exe ei.c erl_comm.c -o extprg.exe >> -Ic:/erl5.7/lib/erl_interface-3.6/include >> -Lc:/erl5.7/lib/erl_interface-3.6/lib -lei -lerl_interface >> Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" >> /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized >> Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" >> /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized >> Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" >> /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized >> Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" >> /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized >> Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" >> /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized >> >> c:/erl5.7/lib/erl_interface-3.6/lib/erl_interface.lib(C:/cygwin/ldisk/daily_build/otp_build_win32_r13a.2009-03-16_22/otp_src_R13A/lib/erl_interface/ >> obj.mt/win32/erl_malloc.o):(.text+0x47): >> undefined reference to `ei_malloc' >> >> c:/erl5.7/lib/erl_interface-3.6/lib/erl_interface.lib(C:/cygwin/ldisk/daily_build/otp_build_win32_r13a.2009-03-16_22/otp_src_R13A/lib/erl_interface/ >> obj.mt/win32/erl_malloc.o):(.text+0x7c): >> undefined reference to `ei_realloc' >> (...) >> >> >> c:/erl5.7/lib/erl_interface-3.6/lib/erl_interface.lib(C:/cygwin/ldisk/daily_build/otp_build_win32_r13a.2009-03-16_22/otp_src_R13A/lib/erl_interface/ >> obj.mt/win32/erl_error.o):(.text+0xa2): >> more undefined references to `__iob_func' follow >> collect2: ld returned 1 exit status >> >> ??? :| >> The ei.lib and erl_interface.lib files were in >> c:/erl5.7/lib/erl_interface-3.6/lib so I was expecting this to work. :\ >> >> A little online research ( >> http://erlang.org/pipermail/erlang-questions/2003-September/009854.html) >> lead me think that the .lib files weren't GCC-compliant (and what I needed >> were .a files). >> So it would be a simple matter of getting the source and compiling >> erl_interface again (famous last words). >> >> This is were someone can come in and say "No! No! No! You just had to do >> XPTO." >> Considering no XPTO existed I went along to try and build erl_interface. >> >> First I tried to just build it using the files that were available on the >> windows binary distribution but it failed complaining about a missing /make/ >> target.mk. >> So I: >> >> - got the otp_src_R13A sourcecode >> - did a ./configure >> - exported ERL_TOP=c:/otp_src_R13A >> - IIRC >> - got something about a missing >> c:/otp_src_R13A/make/i686-pc-mingw32/otp.mk folder >> - which I copied and renamed from c:/otp_src_R13A/make/otp.mk.in(I'm guessing something is responsible for this step) >> - added the necessary LIBS = -lwsock32 to >> c:/otp_src_R13A/lib/erl_interface/src/i686-pc-mingw32/Makefile >> - did a successful build >> - which resulted in two files: libei.a and liberl_interface.a >> getting placed in >> c:/otp_src_R13A/lib/erl_interface/obj.debug/i686-pc-mingw32/ >> - I created a folder c:/otp_src_R13A/lib/erl_interface/lib >> - and copied the two files there >> >> I then tried using those two files to build the erl_interface tutorial >> program with this result: >> Davide@REDACTED /c/Projectos/eNotify/src/native/port >> $ gcc.exe ei.c erl_comm.c -o extprg.exe >> -Ic:/otp_src_R13A/lib/erl_interface/include >> -Lc:/otp_src_R13A/lib/erl_interface/lib -lei -lerl_interface >> >> c:/otp_src_R13A/lib/erl_interface/lib/liberl_interface.a(erl_malloc.o): In >> function `erl_malloc': >> c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_malloc.c:221: >> undefined reference to `ei_malloc' >> >> c:/otp_src_R13A/lib/erl_interface/lib/liberl_interface.a(erl_malloc.o): In >> function `erl_realloc': >> c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_malloc.c:231: >> undefined reference to `ei_realloc' >> >> c:/otp_src_R13A/lib/erl_interface/lib/liberl_interface.a(erl_malloc.o): In >> function `erl_free': >> c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_malloc.c:238: >> undefined reference to `ei_free' >> ... >> >> c:/otp_src_R13A/lib/erl_interface/lib/liberl_interface.a(erl_fix_alloc.o): >> In function `erl_eterm_alloc': >> c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_fix_alloc.c:111: >> undefined reference to `__erl_errno_place' >> collect2: ld returned 1 exit status >> >> Which (other than the initial warnings) is exactly the same problem as the >> one I got with the original compilation. >> Here I took a look at the build process and realized that the >> erl_interface build process had also produced a bunch of .o files in another >> folder: >> c:/erl5.7/lib/erl_interface/obj.st.debug/i686-pc-mingw32/ >> >> Since the compiler was nagging me about missing .o files I just included >> them all in: >> Davide@REDACTED /c/Projectos/eNotify/src/native/port >> $ gcc.exe ei.c erl_comm.c -o extprg.exe >> c:/otp_src_R13A/lib/erl_interface/include/*.o >> -Ic:/otp_src_R13A/lib/erl_interface/include >> -Lc:/otp_src_R13A/lib/erl_interface/lib -lei -lerl_interface -lwsock32 >> c:/otp_src_R13A/lib/erl_interface/include/erl_resolve.o: In >> function `erl_gethostbyname_r': >> c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_resolve.c:58: >> undefined reference to `ei_gethostbyname_r' >> c:/otp_src_R13A/lib/erl_interface/include/erl_resolve.o: In >> function `erl_gethostbyaddr_r': >> c:/otp_src_R13A/lib/erl_interface/src/legacy/erl_resolve.c:70: >> undefined reference to `ei_gethostbyaddr_r' >> collect2: ld returned 1 exit status >> >> :| This is another struggle. >> Under certain circumstances (mine) the functions ei_gethostbyname_r and >> ei_gethostbyaddr_r aren't included in the compilation of the ei_resolve.c >> file. >> Being completely astray from my original goal, and after figuring out that >> these were the reentrant versions of the same functions without the _r and >> that on windows the original ones are already thread safe ( >> http://daniel.haxx.se/projects/portability/), I just went ahead and added >> these *_r functions calling out to original ones (on the $ifdef __WIN32__ >> part ). This was the unhealthy hack part. :) >> Of course that worked (to shut the compiler up at least). :P >> Davide@REDACTED /c/Projectos/eNotify/src/native/port >> $ gcc.exe ei.c erl_comm.c -o extprg.exe >> c:/otp_src_R13A/lib/erl_interface/include/*.o >> -Ic:/otp_src_R13A/lib/erl_interface/include >> -Lc:/otp_src_R13A/lib/erl_interface/lib -lei -lerl_interface -lwsock32 >> >> Finally that got me a working extprg.exe that I was able to complete the >> tutorial with! >> >> >> >> I picked up were I left off: being able to compile IF including all of the >> .o files. >> Some [n00b] research -> http://en.wikipedia.org/wiki/Ar_(Unix)& >> http://linux.die.net/man/1/ar >> Got me to check if all the .o files the linker was complaining about were >> getting archived in the two .a files. >> And indeed, all of them were on libei.a. >> >> I unpacked the .o files from libeia.a and replaced it with a call to those >> .o: >> Davide@REDACTED /c/Projectos/eNotify/src/native/port >> $ gcc.exe -o extprg.exe ei.c erl_comm.c >> /c/otp_src_R13B/lib/erl_interface/obj/i686-pc-mingw32/*.o >> /c/otp_src_R13B/lib/erl_interface/obj/i686-pc-mingw32/liberl_interface.a >> -Ic:/otp_src_R13B/lib/erl_interface/include -lwsock32 >> >> And guess what... It worked! :) >> >> So what am I missing here? Is it normal that "ar"ed files don't link >> correctly? Is it mingw? Or is it just me? :) >> Any(!!!) clues are more than welcome! :) >> >> Cheers, >> Davide :) >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar@REDACTED Thu Apr 23 13:31:08 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Thu, 23 Apr 2009 12:31:08 +0100 Subject: [erlang-questions] About erlang:statistics/1 and timeout values Message-ID: <49F0517C.5000007@erlang-consulting.com> Hi, I was looking at statistics in the erlang module and found that statistics(runtime) and statistics(wall_clock) returns something called Time_Sinse_Last_Call. I assume that this is "since last call by the calling process" and not a globally kept value. It also seems like this is the case due to the following output: 22> statistics(wall_clock),statistics(wall_clock). {1360432955,0} 23> spawn(fun() -> statistics(wall_clock) end), statistics(wall_clock). {1360438144,5189} Should this be pointed out in the manual? Essentially, what I want to achieve is to have a timeout value which I can easily recalculate between calls to several blocking functions so that the total timeout never is more than the specified. So, for instance I'd have a timeout value that I decrease with the element(2,statistics(wall_clock)), each time I need to pass it to a function such as gen_tcp:recv/3. Would there be a better way of doing this than using statistics(wall_clock)? I've looked at the erlang:start_timer/3, but it send a message, which isn't very useful if the process is stuck in a blocking call. It however allows me to use erlang:read_timer/1, which would give me the timeout value without having to calculate it from total elapsed time between calls... Best regards -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From johannes.govaerts@REDACTED Thu Apr 23 13:42:47 2009 From: johannes.govaerts@REDACTED (Johannes Govaerts) Date: Thu, 23 Apr 2009 13:42:47 +0200 Subject: [erlang-questions] server state output in gen_server error logging Message-ID: <20090423134247.0c04ae1e@jgo-laptop> Hello, I have a gen_server which has binary data in its state (a queue with several binaries of around 1500 bytes). When an error occurs, logging is flooded with an error report listing all these binaries under "Server state". Is it possible to configure error logging in a way that server state output is limited or disabled? Thanks, Johannes From masse@REDACTED Thu Apr 23 13:48:08 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 23 Apr 2009 13:48:08 +0200 Subject: [erlang-questions] About erlang:statistics/1 and timeout values In-Reply-To: <49F0517C.5000007@erlang-consulting.com> ("Oscar =?iso-8859-1?Q?Hellstr=F6m=22's?= message of "Thu\, 23 Apr 2009 12\:31\:08 +0100") References: <49F0517C.5000007@erlang-consulting.com> Message-ID: <87ws9bzj47.fsf@sterlett.hq.kred> Oscar Hellstr?m writes: > Hi, > > I was looking at statistics in the erlang module and found that > statistics(runtime) and statistics(wall_clock) returns something called > Time_Sinse_Last_Call. I assume that this is "since last call by the > calling process" and not a globally kept value. AFAIK, time since last call is per emulator, not per process. Thus, it is worse than useless. mats From ulf.wiger@REDACTED Thu Apr 23 14:04:54 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 23 Apr 2009 14:04:54 +0200 Subject: [erlang-questions] About erlang:statistics/1 and timeout values In-Reply-To: <87ws9bzj47.fsf@sterlett.hq.kred> References: <49F0517C.5000007@erlang-consulting.com> <87ws9bzj47.fsf@sterlett.hq.kred> Message-ID: <49F05966.5050007@erlang-consulting.com> mats cronqvist wrote: > Oscar Hellstr?m writes: > >> Hi, >> >> I was looking at statistics in the erlang module and found that >> statistics(runtime) and statistics(wall_clock) returns something called >> Time_Sinse_Last_Call. I assume that this is "since last call by the >> calling process" and not a globally kept value. > > AFAIK, time since last call is per emulator, not per process. Thus, > it is worse than useless. The relevant functions are elapsed_time_both(), and wall_clock_elapsed_time_both() in erts/emulator/beam/erl_time_sup.c ...and Mats is right. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From vychodil.hynek@REDACTED Thu Apr 23 14:08:45 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 23 Apr 2009 14:08:45 +0200 Subject: [erlang-questions] : : : : : sctp_peeloff() support in OTP In-Reply-To: <20090423095652.GA32586@erix.ericsson.se> References: <20090422161556.GA8674@erix.ericsson.se> <200904222027.n3MKRBRc028375@mail.pharos-avantgard.com> <20090423095652.GA32586@erix.ericsson.se> Message-ID: <4d08db370904230508ta9e5b13qfed515b289c4321c@mail.gmail.com> Hello, can you please use some mail client that supports threading? It's fourth thread about "sctp_peeloff() support in OTP". Best regards Hynek On Thu, Apr 23, 2009 at 11:56 AM, Raimo Niskanen < raimo+erlang-questions@REDACTED > wrote: > On Wed, Apr 22, 2009 at 10:37:21PM +0200, Valentin Micic wrote: > > > In what way is it useful to dispatch messages from the > > > driver level onto a PID dedicated for a streams if > > > you do not get flow control per stream? > > > > Not sure if it would be useful, and not sure if that is what I've been > > trying to say/ask. Forget about my "stream processor" (*) suggestion, it > is > > irrelevant, and I prefer the implementation at the driver level anyway. > > I was only wondering if there is a way to achieve a stream separation > > without utilizing additional file descriptors. I think yes, but the > driver > > may end up too complex and difficult to maintain, etc. > > If it is useful it may be worth the complexification... > > But I am now under the assumption that a stream separation > that does not utilize additional file descriptors > (as you ask for) can not do per-stream flow control > (with respect to remote peer) and therefore is not useful. > > Prove me wrong and I might do it. > > > I would be very grateful if you implement this feature whichever way you > > find fit :-). > > > > BR > > > > V. > > > > (*) I did say that stream processor can do queuing, though. This would > imply > > some basic flow control vis-?-vis target PID, but not necessarily with > > respect to remote peer. :-) > > > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar@REDACTED Thu Apr 23 14:22:42 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Thu, 23 Apr 2009 13:22:42 +0100 Subject: [erlang-questions] About erlang:statistics/1 and timeout values In-Reply-To: <87ws9bzj47.fsf@sterlett.hq.kred> References: <49F0517C.5000007@erlang-consulting.com> <87ws9bzj47.fsf@sterlett.hq.kred> Message-ID: <49F05D92.5030509@erlang-consulting.com> mats cronqvist wrote: > Oscar Hellstr?m writes: > > >> Hi, >> >> I was looking at statistics in the erlang module and found that >> statistics(runtime) and statistics(wall_clock) returns something called >> Time_Sinse_Last_Call. I assume that this is "since last call by the >> calling process" and not a globally kept value. >> > > AFAIK, time since last call is per emulator, not per process. Thus, > it is worse than useless. > > mats > Yes, you're right. The call from the spawned process probably happened after the call from the shell process. This shows the actual behaviour: 29> spawn(fun() -> statistics(wall_clock) end), timer:sleep(10), statistics(wall_clock). {1363798390,14} This is sad though, since it really does make it worse than useless. So, back to (part of) the original question, how would we go about decrementing a timeout value between blocking calls. I could use now diffs, or erlang:start_timer/3... are there better ways? BTW, what is the difference between erlang:start_timer/3 and erlang:send_after/3. The documentation looks identical except a weird detail in the type specification: erlang:send_after(Time, Dest, Msg) -> TimerRef ... Dest = pid() | RegName LocalPid = pid() (of a process, alive or dead, on the local node) Here LocalPid is never mentioned before... erlang:start_timer(Time, Dest, Msg) -> TimerRef ... Dest = LocalPid | RegName LocalPid = pid() (of a process, alive or dead, on the local node) This seems to want to say the same thing, but does it correctly. Thanks -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From mazen.harake@REDACTED Thu Apr 23 13:39:56 2009 From: mazen.harake@REDACTED (Mazen Harake) Date: Thu, 23 Apr 2009 13:39:56 +0200 Subject: [erlang-questions] Too many processes In-Reply-To: <23097100.post@talk.nabble.com> References: <23097100.post@talk.nabble.com> Message-ID: <49F0538C.6020604@erlang-consulting.com> Try http://www.erlang.org/doc/man/erl.html Check out Emulator Flags (+P...) maybe that helps, cheers, /Mazen http://www.erlang-consulting.com http://www.erlang-factory.com/ marmll wrote: > Hi, > > i have the following problem: > > My error_logger tells me that I?am having ?Too many processes? and the > erlang engine crashed. > When I?am starting the gen_server I?am checking the > erlang:system_info(process_count) and they tells me 80 processes. > > Codesnip from init: > F = fun(Sock) -> parse_packet(Sock, Client) end, > tcp_server:stop(Port), > {ok, _} = tcp_server:start_raw_server(Port, F, 10240,2048), > > And here my parse_packet: > > parse_packet(Socket, Client) -> > receive > {tcp, Socket, Bin} -> > io:format("--> ~w~n", [Bin]); > {tcp_closed, Socket} -> > error_logger:error_report([{module, ?MODULE},{line, > ?LINE},{message, "tcpclosed"},{call, "tcp_closed aus > receive"},{now,now()}]); > {packet, Packet} -> > io:format("<-- ~w~n", [Packet]), > parse_packet(Socket, Client) > end. > > With every connect to the server my process_count is increasing 1 ! > > How can I handle the process_count ? I think the the tail recursion at > parse_packet is not good. > > Please help me > Thanks > > From masse@REDACTED Thu Apr 23 14:54:24 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 23 Apr 2009 14:54:24 +0200 Subject: [erlang-questions] About erlang:statistics/1 and timeout values In-Reply-To: <49F05D92.5030509@erlang-consulting.com> ("Oscar =?iso-8859-1?Q?Hellstr=F6m=22's?= message of "Thu\, 23 Apr 2009 13\:22\:42 +0100") References: <49F0517C.5000007@erlang-consulting.com> <87ws9bzj47.fsf@sterlett.hq.kred> <49F05D92.5030509@erlang-consulting.com> Message-ID: <87r5zjzg1r.fsf@sterlett.hq.kred> Oscar Hellstr?m writes: > mats cronqvist wrote: >> Oscar Hellstr?m writes: >> >> >>> Hi, >>> >>> I was looking at statistics in the erlang module and found that >>> statistics(runtime) and statistics(wall_clock) returns something called >>> Time_Sinse_Last_Call. I assume that this is "since last call by the >>> calling process" and not a globally kept value. >>> >> >> AFAIK, time since last call is per emulator, not per process. Thus, >> it is worse than useless. >> >> mats >> > Yes, you're right. The call from the spawned process probably happened > after the call from the shell process. This shows the actual behaviour: > 29> spawn(fun() -> statistics(wall_clock) end), timer:sleep(10), > statistics(wall_clock). > {1363798390,14} > > This is sad though, since it really does make it worse than useless. Making it undocumented would probably be the best. Then at least people wouldn't waste time trying to figure it out. mats From matthias@REDACTED Thu Apr 23 14:54:53 2009 From: matthias@REDACTED (Matthias Lang) Date: Thu, 23 Apr 2009 14:54:53 +0200 Subject: [erlang-questions] server state output in gen_server error logging In-Reply-To: <20090423134247.0c04ae1e@jgo-laptop> References: <20090423134247.0c04ae1e@jgo-laptop> Message-ID: <20090423125453.GA5102@contorpis.lisalinda.com> On Thursday, April 23, Johannes Govaerts wrote: > I have a gen_server which has binary data in its state (a queue with > several binaries of around 1500 bytes). When an error occurs, > logging is flooded with an error report listing all these binaries > under "Server state". > > Is it possible to configure error logging in a way that server state > output is limited or disabled? I don't understand how _any_ production systems can work with the default error logging setup*. On the other hand, you're only the third person I've come across who agrees it's a problem, so maybe there's a simple solution I'm unaware of. The solution I use in production: replace the standard error logger with a custom one which uses an alternative IO formatter to limit the length of terms when they're printed. Taking that one step at a time: 1. Enable your own error logger: ok = error_logger:add_report_handler(gth_log). 2. Disable the standard error loggers: Assuming you've started Erlang with SASL (i.e. -boot start_sasl): gen_event:delete_handler(error_logger, sasl_report_tty_h, unused_arg). gen_event:delete_handler(error_logger, error_logger_tty_h, unused_arg). Your own error logger, i.e. gth_log.erl in step 1, needs to follow the gen_event behaviour. The important part is gth_log:handle_event, which could be something like: handle_event(Event, State) -> io:fwrite("got event ~p\n", [Event]), {ok, State}. Your original problem was that printing out the event from a crashed gen_server filled up your logs. So you want to avoid io:fwrite in favour of something which limits the logs to a certain maximum length. I use trunc_io to do that: http://www.corelatus.com/~matthias/trunc_io.erl it lets you specify an approximate maximum number of characters an error report may take (and, obviously, it doesn't just use io_lib:fwrite to print the term and then shorten it...). With that, handle_event becomes something like: handle_event(Event, State) -> {String, _} = trunc_io:print(Event, 100), io:put_chars(String), {ok, State}. More sophisticated approaches are possible, i.e. you can format known types of error report in a less ugly way. Matt * i.e. in a crash, arbitrary terms get printed and they can be huge. The problems with 'huge' are (a) the logs get filled up, rotating out useful information, (b) creating those huge logs can eat huge amounts of RAM, so much that on memory-limited systems the VM can terminate with out-of-memory and (c) creating those huge logs eats huge amounts of CPU, which slows down recovery from a fault. From raimo+erlang-questions@REDACTED Thu Apr 23 14:40:07 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 23 Apr 2009 14:40:07 +0200 Subject: [erlang-questions] : : : : : : sctp_peeloff() support in OTP In-Reply-To: <4d08db370904230508ta9e5b13qfed515b289c4321c@mail.gmail.com> References: <20090422161556.GA8674@erix.ericsson.se> <200904222027.n3MKRBRc028375@mail.pharos-avantgard.com> <20090423095652.GA32586@erix.ericsson.se> <4d08db370904230508ta9e5b13qfed515b289c4321c@mail.gmail.com> Message-ID: <20090423124007.GA2035@erix.ericsson.se> On Thu, Apr 23, 2009 at 02:08:45PM +0200, Hynek Vychodil wrote: > Hello, > can you please use some mail client that supports threading? It's fourth > thread about "sctp_peeloff() support in OTP". > Best regards > Hynek Well, at least my mail client supports its own mail threading; I have only two threads. One singelton message is Valentin Mimic's Message-Id: <200904230917.n3N9HURc031237@REDACTED> that it did not manage to sort out. The others are fine. I use User-Agent: Mutt/1.5.9i. It has been around very long and works finefor me. As you see it supplies both In-Reply-To: and References: headers, and gmail as you use is mostly very good at tracking threads. It is strange that you are experiencing problems. > > On Thu, Apr 23, 2009 at 11:56 AM, Raimo Niskanen < > raimo+erlang-questions@REDACTED > > wrote: > > > On Wed, Apr 22, 2009 at 10:37:21PM +0200, Valentin Micic wrote: > > > > In what way is it useful to dispatch messages from the > > > > driver level onto a PID dedicated for a streams if > > > > you do not get flow control per stream? > > > > > > Not sure if it would be useful, and not sure if that is what I've been > > > trying to say/ask. Forget about my "stream processor" (*) suggestion, it > > is > > > irrelevant, and I prefer the implementation at the driver level anyway. > > > I was only wondering if there is a way to achieve a stream separation > > > without utilizing additional file descriptors. I think yes, but the > > driver > > > may end up too complex and difficult to maintain, etc. > > > > If it is useful it may be worth the complexification... > > > > But I am now under the assumption that a stream separation > > that does not utilize additional file descriptors > > (as you ask for) can not do per-stream flow control > > (with respect to remote peer) and therefore is not useful. > > > > Prove me wrong and I might do it. > > > > > I would be very grateful if you implement this feature whichever way you > > > find fit :-). > > > > > > BR > > > > > > V. > > > > > > (*) I did say that stream processor can do queuing, though. This would > > imply > > > some basic flow control vis-?-vis target PID, but not necessarily with > > > respect to remote peer. :-) > > > > > > > -- > > > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From raimo+erlang-questions@REDACTED Thu Apr 23 16:06:59 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 23 Apr 2009 16:06:59 +0200 Subject: [erlang-questions] : : : : : : sctp_peeloff() support in OTP In-Reply-To: <6a3ae47e0904230614m1965ef74k6f8a9cb49b1b6463@mail.gmail.com> References: <20090422161556.GA8674@erix.ericsson.se> <200904222027.n3MKRBRc028375@mail.pharos-avantgard.com> <20090423095652.GA32586@erix.ericsson.se> <4d08db370904230508ta9e5b13qfed515b289c4321c@mail.gmail.com> <20090423124007.GA2035@erix.ericsson.se> <6a3ae47e0904230614m1965ef74k6f8a9cb49b1b6463@mail.gmail.com> Message-ID: <20090423140659.GA2989@erix.ericsson.se> On Thu, Apr 23, 2009 at 02:14:22PM +0100, Robert Raschke wrote: > On Thu, Apr 23, 2009 at 1:40 PM, Raimo Niskanen > wrote: > > On Thu, Apr 23, 2009 at 02:08:45PM +0200, Hynek Vychodil wrote: > >> Hello, > >> can you please use some mail client that supports threading? It's fourth > >> thread about "sctp_peeloff() support in OTP". > >> Best regards > >> ? ?Hynek > > > > Well, at least my mail client supports its own mail threading; > > I have only two threads. One singelton message is Valentin Mimic's > > Message-Id: <200904230917.n3N9HURc031237@REDACTED> > > that it did not manage to sort out. The others are fine. > > > > I use User-Agent: Mutt/1.5.9i. It has been around very long > > and works finefor me. As you see it supplies both In-Reply-To: > > and References: headers, and gmail as you use is mostly > > very good at tracking threads. > > > > It is strange that you are experiencing problems. > > > > It is because the subject line is growing colons. For some reason, > when Raimo replies, an additional colon is introduced into the subject > line. That confuses mail readers like gmail that don't follow the > rules of threading based on headers, but thread instead on the subject > text. > > Robby Oh. I will browse around the settings and see if it is my client that adds colons, or if it is tha mailing list itself. I see Valentin Micic gets colons before [erlang-questions] and I get them after... -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From daveb@REDACTED Thu Apr 23 16:19:25 2009 From: daveb@REDACTED (Dave Bryson) Date: Thu, 23 Apr 2009 09:19:25 -0500 Subject: [erlang-questions] Pure Ruby to Erlang node handshake problem Message-ID: <2958A427-8CAE-45A9-B43F-F863134B6761@miceda.org> I'm creating a pure ruby 'node' that can talk to an Erlang node similar to what the jinterface provides. So far I have most of the initial handshake working properly but am getting the following error from the Erlang side when I send the challenge reply: * Connection attempt from disallowed node 'ruby_client@REDACTED' ** (note: I manually set the cookie on both sides) Here are the handshake steps I'm taking: 1. Send Name information 2. Receive status 3. Receive challenge 4. Send challenge Everything up to 4 is working fine and the data received from the Erlang node seems to be correct (I'm parsing it correctly) I'm sending the challenge reply like this: content = erlang_node_challenge concatenated with my_cookie digest = MD5.hexdigest(content) my_challenge = randomly generated number With the outbound message in this format: Bytes | Message 2 | 21 (length of the message) 1 | 'r' (tag) 4 | my_challenge 16 | digest This seems to be correct according to the distributed handshake docs and the code in jinterface. Any ideas why the Erlang node is rejecting my challenge reply? Note: I'm using 12b-5 Thanks! Dave From oscar@REDACTED Thu Apr 23 16:33:17 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Thu, 23 Apr 2009 15:33:17 +0100 Subject: [erlang-questions] About erlang:statistics/1 and timeout values In-Reply-To: <49F05D92.5030509@erlang-consulting.com> References: <49F0517C.5000007@erlang-consulting.com> <87ws9bzj47.fsf@sterlett.hq.kred> <49F05D92.5030509@erlang-consulting.com> Message-ID: <49F07C2D.9030506@erlang-consulting.com> Oscar Hellstr?m wrote: > mats cronqvist wrote: > >> Oscar Hellstr?m writes: >> >> >> >>> Hi, >>> >>> I was looking at statistics in the erlang module and found that >>> statistics(runtime) and statistics(wall_clock) returns something called >>> Time_Sinse_Last_Call. I assume that this is "since last call by the >>> calling process" and not a globally kept value. >>> >>> >> AFAIK, time since last call is per emulator, not per process. Thus, >> it is worse than useless. >> >> mats >> >> > Yes, you're right. The call from the spawned process probably happened > after the call from the shell process. This shows the actual behaviour: > 29> spawn(fun() -> statistics(wall_clock) end), timer:sleep(10), > statistics(wall_clock). > {1363798390,14} > > This is sad though, since it really does make it worse than useless. So, > back to (part of) the original question, how would we go about > decrementing a timeout value between blocking calls. I could use now > diffs, or erlang:start_timer/3... are there better ways? > > BTW, what is the difference between erlang:start_timer/3 and > erlang:send_after/3. The documentation looks identical except a weird > detail in the type specification: > erlang:send_after(Time, Dest, Msg) -> TimerRef > ... > Dest = pid() | RegName > LocalPid = pid() (of a process, alive or dead, on the local node) > > Here LocalPid is never mentioned before... > > erlang:start_timer(Time, Dest, Msg) -> TimerRef > ... > Dest = LocalPid | RegName > LocalPid = pid() (of a process, alive or dead, on the local node) > > This seems to want to say the same thing, but does it correctly. > Well, start_timer(Time, Dest, Msg) sends the message: {timeout, TimerRef, Msg} while send_after(Time, Dest, Msg) sends the message: Msg It however be useful to be able to start a timer which doesn't send a message, but makes it possible to know how many ms (or us) has passed since the timer was started (maybe this isn't really a timer, but a counter). Wall clock etc. is a bit risky I guess, since time could change. > Thanks > > Best regards -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From raimo+erlang-questions@REDACTED Thu Apr 23 16:49:38 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 23 Apr 2009 16:49:38 +0200 Subject: [erlang-questions] : : : : : : sctp_peeloff() support in OTP In-Reply-To: <4d08db370904230709q4ada5bc7j333c268c62727748@mail.gmail.com> References: <20090422161556.GA8674@erix.ericsson.se> <200904222027.n3MKRBRc028375@mail.pharos-avantgard.com> <20090423095652.GA32586@erix.ericsson.se> <4d08db370904230508ta9e5b13qfed515b289c4321c@mail.gmail.com> <20090423124007.GA2035@erix.ericsson.se> <4d08db370904230709q4ada5bc7j333c268c62727748@mail.gmail.com> Message-ID: <20090423144938.GA3993@erix.ericsson.se> Error on my side! I had a broken regexp in .muttrc that nobody noticed before. And I also got some help from colleagues that as we say in swedish likes to "write it on my nose" (rub it in). It should be fixed now. Thank you for pointing it out! On Thu, Apr 23, 2009 at 04:09:49PM +0200, Hynek Vychodil wrote: > I can see in your mail headers: > > Date: Thu, 23 Apr 2009 14:40:07 +0200 > From: Raimo Niskanen > > > To: Hynek Vychodil , erlang-questions@REDACTED > > Cc: Valentin Micic > Subject: Re: : [erlang-questions] : : : : : sctp_peeloff() support in OTP > Message-ID: <20090423124007.GA2035@REDACTED> > > > Mail-Followup-To: Hynek Vychodil , > erlang-questions@REDACTED, > > Valentin Micic > > References: <20090422161556.GA8674@REDACTED> > <200904222027.n3MKRBRc028375@REDACTED> > <20090423095652.GA32586@REDACTED> > <4d08db370904230508ta9e5b13qfed515b289c4321c@REDACTED> > > > Mime-Version: 1.0 > Content-Type: text/plain; charset=iso-8859-1 > Content-Disposition: inline > Content-Transfer-Encoding: 8bit > In-Reply-To: <4d08db370904230508ta9e5b13qfed515b289c4321c@REDACTED> > > > User-Agent: Mutt/1.5.9i > X-OriginalArrivalTime: 23 Apr 2009 12:40:09.0355 (UTC) > FILETIME=[A33685B0:01C9C410] > X-Brightmail-Tracker: AAAAAA== > > W hen I try press Reply button it start reply to "Hynek Vychodil < > vychodil.hynek@REDACTED>, erlang-questions@REDACTED, Valentin Micic < > v@REDACTED>" that is exactly content of Mail-Followup-To. I have > observed that thread is broken each time by your mail. It seems that issue > should be in your mailer but I can be wrong. There are two reasons: reply I see... > works wrong, threads are broken. Another possibility that gmail is broken > seems less probably form me. Example headers which works fine follows: > > Message-Id: <200904221550.n3MFoFRc027632@REDACTED> > From: "Valentin Micic" > > To: "'Raimo Niskanen'" >, > > > Date: Wed, 22 Apr 2009 18:00:25 +0200 > MIME-Version: 1.0 > X-Mailer: Microsoft Office Outlook, Build 11.0.5510 > In-Reply-To: <20090422083559.GA1705@REDACTED> > > X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 > Thread-Index: AcnDJpmaVTDmZaUrSd+2jrLViPSL6QAOVgnQ > Subject: Re: [erlang-questions] : : : sctp_peeloff() support in OTP > X-BeenThere: erlang-questions@REDACTED > > X-Mailman-Version: 2.1.9 > > In-Reply-To: <200904221550.n3MFoFRc027632@REDACTED> > References: <20090422083559.GA1705@REDACTED> > > <200904221550.n3MFoFRc027632@REDACTED> > Date: Thu, 23 Apr 2009 09:52:52 +0700 > Message-ID: > > From: Maxim Treskin > To: "erlang-questions@REDACTED" > > Subject: Re: [erlang-questions] : : : sctp_peeloff() support in OTP > X-BeenThere: erlang-questions@REDACTED > X-Mailman-Version: 2.1.9 > > But it seems that gmail ignores all except Subject to detect threads as > mentioned Robert Raschke. > > On Thu, Apr 23, 2009 at 2:40 PM, Raimo Niskanen < > raimo+erlang-questions@REDACTED > > wrote: > > > On Thu, Apr 23, 2009 at 02:08:45PM +0200, Hynek Vychodil wrote: > > > Hello, > > > can you please use some mail client that supports threading? It's fourth > > > thread about "sctp_peeloff() support in OTP". > > > Best regards > > > Hynek > > > > Well, at least my mail client supports its own mail threading; > > I have only two threads. One singelton message is Valentin Mimic's > > Message-Id: <200904230917.n3N9HURc031237@REDACTED> > > that it did not manage to sort out. The others are fine. > > > > I use User-Agent: Mutt/1.5.9i. It has been around very long > > and works finefor me. As you see it supplies both In-Reply-To: > > and References: headers, and gmail as you use is mostly > > very good at tracking threads. > > > > It is strange that you are experiencing problems. > > > > > > > > On Thu, Apr 23, 2009 at 11:56 AM, Raimo Niskanen < > > > raimo+erlang-questions@REDACTED > > > > > > > > > wrote: > > > > > > > On Wed, Apr 22, 2009 at 10:37:21PM +0200, Valentin Micic wrote: > > > > > > In what way is it useful to dispatch messages from the > > > > > > driver level onto a PID dedicated for a streams if > > > > > > you do not get flow control per stream? > > > > > > > > > > Not sure if it would be useful, and not sure if that is what I've > > been > > > > > trying to say/ask. Forget about my "stream processor" (*) suggestion, > > it > > > > is > > > > > irrelevant, and I prefer the implementation at the driver level > > anyway. > > > > > I was only wondering if there is a way to achieve a stream separation > > > > > without utilizing additional file descriptors. I think yes, but the > > > > driver > > > > > may end up too complex and difficult to maintain, etc. > > > > > > > > If it is useful it may be worth the complexification... > > > > > > > > But I am now under the assumption that a stream separation > > > > that does not utilize additional file descriptors > > > > (as you ask for) can not do per-stream flow control > > > > (with respect to remote peer) and therefore is not useful. > > > > > > > > Prove me wrong and I might do it. > > > > > > > > > I would be very grateful if you implement this feature whichever way > > you > > > > > find fit :-). > > > > > > > > > > BR > > > > > > > > > > V. > > > > > > > > > > (*) I did say that stream processor can do queuing, though. This > > would > > > > imply > > > > > some basic flow control vis-?-vis target PID, but not necessarily > > with > > > > > respect to remote peer. :-) > > > > > > > > > > > > > -- > > > > > > > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questions@REDACTED > > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > -- > > > --Hynek (Pichi) Vychodil > > > > > > Analyze your data in minutes. Share your insights instantly. Thrill your > > > boss. Be a data hero! > > > Try Good Data now for free: www.gooddata.com > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -- > > > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From raimo+erlang-questions@REDACTED Thu Apr 23 17:58:47 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 23 Apr 2009 17:58:47 +0200 Subject: [erlang-questions] : : : : : : sctp_peeloff() support in OTP In-Reply-To: <4d08db370904230835i427e4a03u7766f26f1318f93c@mail.gmail.com> References: <20090422161556.GA8674@erix.ericsson.se> <200904222027.n3MKRBRc028375@mail.pharos-avantgard.com> <20090423095652.GA32586@erix.ericsson.se> <4d08db370904230508ta9e5b13qfed515b289c4321c@mail.gmail.com> <20090423124007.GA2035@erix.ericsson.se> <4d08db370904230709q4ada5bc7j333c268c62727748@mail.gmail.com> <20090423144938.GA3993@erix.ericsson.se> <4d08db370904230835i427e4a03u7766f26f1318f93c@mail.gmail.com> Message-ID: <20090423155847.GA4905@erix.ericsson.se> On Thu, Apr 23, 2009 at 05:35:55PM +0200, Hynek Vychodil wrote: > You are welcome ;-) but there is still some issue with Mail-Followup-To: > which works same as Reply-To: in gmail. I don't know which one is broken > gmail or your configuration. Well I had a quick look. I will not waste too much time on it. If I stumble on a solution I will fix it :-) > > On Thu, Apr 23, 2009 at 4:49 PM, Raimo Niskanen < > raimo+erlang-questions@REDACTED > > wrote: > > > Error on my side! I had a broken regexp in .muttrc that nobody > > noticed before. And I also got some help from colleagues that > > as we say in swedish likes to "write it on my nose" (rub it in). > > > > It should be fixed now. Thank you for pointing it out! > > > > > > > > On Thu, Apr 23, 2009 at 04:09:49PM +0200, Hynek Vychodil wrote: > > > I can see in your mail headers: > > > > > > Date: Thu, 23 Apr 2009 14:40:07 +0200 > > > From: Raimo Niskanen > > > > > >> > > > > > > To: Hynek Vychodil , > > erlang-questions@REDACTED > > > > > > Cc: Valentin Micic > > > Subject: Re: : [erlang-questions] : : : : : sctp_peeloff() support in OTP > > > Message-ID: <20090423124007.GA2035@REDACTED> > > > > > > > > > Mail-Followup-To: Hynek Vychodil , > > > erlang-questions@REDACTED, > > > > > > Valentin Micic > > > > > > References: <20090422161556.GA8674@REDACTED> > > > <200904222027.n3MKRBRc028375@REDACTED> > > > <20090423095652.GA32586@REDACTED> > > > <4d08db370904230508ta9e5b13qfed515b289c4321c@REDACTED> > > > > > > > > > Mime-Version: 1.0 > > > Content-Type: text/plain; charset=iso-8859-1 > > > Content-Disposition: inline > > > Content-Transfer-Encoding: 8bit > > > In-Reply-To: <4d08db370904230508ta9e5b13qfed515b289c4321c@REDACTED > > > > > > > > > > > > User-Agent: Mutt/1.5.9i > > > X-OriginalArrivalTime: 23 Apr 2009 12:40:09.0355 (UTC) > > > FILETIME=[A33685B0:01C9C410] > > > X-Brightmail-Tracker: AAAAAA== > > > > > > W hen I try press Reply button it start reply to "Hynek Vychodil < > > > vychodil.hynek@REDACTED>, erlang-questions@REDACTED, Valentin Micic < > > > v@REDACTED>" that is exactly content of Mail-Followup-To. I > > have > > > observed that thread is broken each time by your mail. It seems that > > issue > > > should be in your mailer but I can be wrong. There are two reasons: reply > > > > I see... > > > > > works wrong, threads are broken. Another possibility that gmail is broken > > > seems less probably form me. Example headers which works fine follows: > > > > > > Message-Id: <200904221550.n3MFoFRc027632@REDACTED> > > > From: "Valentin Micic" > > > > > > To: "'Raimo Niskanen'" > > > > > >>, > > > > > > > > > Date: Wed, 22 Apr 2009 18:00:25 +0200 > > > MIME-Version: 1.0 > > > X-Mailer: Microsoft Office Outlook, Build 11.0.5510 > > > In-Reply-To: <20090422083559.GA1705@REDACTED> > > > > > > X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 > > > Thread-Index: AcnDJpmaVTDmZaUrSd+2jrLViPSL6QAOVgnQ > > > Subject: Re: [erlang-questions] : : : sctp_peeloff() support in OTP > > > X-BeenThere: erlang-questions@REDACTED > > > > > > X-Mailman-Version: 2.1.9 > > > > > > In-Reply-To: <200904221550.n3MFoFRc027632@REDACTED> > > > References: <20090422083559.GA1705@REDACTED> > > > > > > <200904221550.n3MFoFRc027632@REDACTED> > > > Date: Thu, 23 Apr 2009 09:52:52 +0700 > > > Message-ID: > > > > > > > > From: Maxim Treskin > > > To: "erlang-questions@REDACTED" > > > > > > Subject: Re: [erlang-questions] : : : sctp_peeloff() support in OTP > > > X-BeenThere: erlang-questions@REDACTED > > > X-Mailman-Version: 2.1.9 > > > > > > But it seems that gmail ignores all except Subject to detect threads as > > > mentioned Robert Raschke. > > > > > > On Thu, Apr 23, 2009 at 2:40 PM, Raimo Niskanen < > > > raimo+erlang-questions@REDACTED > > > > > > > > > wrote: > > > > > > > On Thu, Apr 23, 2009 at 02:08:45PM +0200, Hynek Vychodil wrote: > > > > > Hello, > > > > > can you please use some mail client that supports threading? It's > > fourth > > > > > thread about "sctp_peeloff() support in OTP". > > > > > Best regards > > > > > Hynek > > > > > > > > Well, at least my mail client supports its own mail threading; > > > > I have only two threads. One singelton message is Valentin Mimic's > > > > Message-Id: <200904230917.n3N9HURc031237@REDACTED> > > > > that it did not manage to sort out. The others are fine. > > > > > > > > I use User-Agent: Mutt/1.5.9i. It has been around very long > > > > and works finefor me. As you see it supplies both In-Reply-To: > > > > and References: headers, and gmail as you use is mostly > > > > very good at tracking threads. > > > > > > > > It is strange that you are experiencing problems. > > > > > > > > > > > > > > On Thu, Apr 23, 2009 at 11:56 AM, Raimo Niskanen < > > > > > raimo+erlang-questions@REDACTED > > > > > > > > > > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > On Wed, Apr 22, 2009 at 10:37:21PM +0200, Valentin Micic wrote: > > > > > > > > In what way is it useful to dispatch messages from the > > > > > > > > driver level onto a PID dedicated for a streams if > > > > > > > > you do not get flow control per stream? > > > > > > > > > > > > > > Not sure if it would be useful, and not sure if that is what I've > > > > been > > > > > > > trying to say/ask. Forget about my "stream processor" (*) > > suggestion, > > > > it > > > > > > is > > > > > > > irrelevant, and I prefer the implementation at the driver level > > > > anyway. > > > > > > > I was only wondering if there is a way to achieve a stream > > separation > > > > > > > without utilizing additional file descriptors. I think yes, but > > the > > > > > > driver > > > > > > > may end up too complex and difficult to maintain, etc. > > > > > > > > > > > > If it is useful it may be worth the complexification... > > > > > > > > > > > > But I am now under the assumption that a stream separation > > > > > > that does not utilize additional file descriptors > > > > > > (as you ask for) can not do per-stream flow control > > > > > > (with respect to remote peer) and therefore is not useful. > > > > > > > > > > > > Prove me wrong and I might do it. > > > > > > > > > > > > > I would be very grateful if you implement this feature whichever > > way > > > > you > > > > > > > find fit :-). > > > > > > > > > > > > > > BR > > > > > > > > > > > > > > V. > > > > > > > > > > > > > > (*) I did say that stream processor can do queuing, though. This > > > > would > > > > > > imply > > > > > > > some basic flow control vis-?-vis target PID, but not necessarily > > > > with > > > > > > > respect to remote peer. :-) > > > > > > > > > > > > > > > > > > > -- > > > > > > > > > > > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > > > > > _______________________________________________ > > > > > > erlang-questions mailing list > > > > > > erlang-questions@REDACTED > > > > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > --Hynek (Pichi) Vychodil > > > > > > > > > > Analyze your data in minutes. Share your insights instantly. Thrill > > your > > > > > boss. Be a data hero! > > > > > Try Good Data now for free: www.gooddata.com > > > > > > > > > _______________________________________________ > > > > > erlang-questions mailing list > > > > > erlang-questions@REDACTED > > > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > -- > > > > > > > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > > > > > > > > > > > > > > > -- > > > --Hynek (Pichi) Vychodil > > > > > > Analyze your data in minutes. Share your insights instantly. Thrill your > > > boss. Be a data hero! > > > Try Good Data now for free: www.gooddata.com > > > > -- > > > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From v@REDACTED Thu Apr 23 19:15:16 2009 From: v@REDACTED (Valentin Micic) Date: Thu, 23 Apr 2009 19:15:16 +0200 Subject: [erlang-questions] : : : : : sctp_peeloff() support in OTP In-Reply-To: <20090423095652.GA32586@erix.ericsson.se> Message-ID: <200904231705.n3NH56Rc032601@mail.pharos-avantgard.com> > But I am now under the assumption that a stream separation > that does not utilize additional file descriptors > (as you ask for) can not do per-stream flow control > (with respect to remote peer) and therefore is not useful. > Prove me wrong and I might do it. Proving you wrong may take some time. :-) AFAIK, flow control is explicitly defined only at association level. Having said that, please note that each data-chunk (hence stream traffic) has to be individually acknowledged -- if acknowledge is not received, sender will not send more data for a given stream. Unfortunately, this will not prevent sender to send the same data chunk again, confusing a lack of acknowledgement for a loss of a chunk... I need to read a bit about it, however, not sure if any amount of reading can help me here. But more importantly than proving you wrong: I know that you would be able to use a separate file descriptor to move a specific association from one-to-many to one-to-one socket. That association may have more than one stream (which would typically be a case), so you're back to where you were with respect to {active, once} and head-of-line blocking. Don't know how this can be done for individual stream (assuming that file descriptor = socket). Regards, V. From tobbe@REDACTED Thu Apr 23 22:45:25 2009 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Thu, 23 Apr 2009 22:45:25 +0200 Subject: [erlang-questions] New google group for LFE Message-ID: FYI: I've just created a google group for discussions, questions, etc, regarding LFE (Lisp Flavoured Erlang). http://groups.google.com/group/lisp-flavoured-erlang Other relevant links: http://github.com/rvirding/lfe/tree/master http://github.com/cadar/lfeweb/tree/master Cheers, Tobbe From exta7@REDACTED Thu Apr 23 23:19:53 2009 From: exta7@REDACTED (Zvi) Date: Thu, 23 Apr 2009 14:19:53 -0700 (PDT) Subject: [erlang-questions] no crypto Erlang/OTP R13B Windows binary In-Reply-To: <6672d0160904220608q1c546a08xef6a36f1edd462d6@mail.gmail.com> References: <6672d0160904210750n7f474ec3n82facd0420d39a2d@mail.gmail.com> <49EEE301.4070008@gmail.com> <6672d0160904220608q1c546a08xef6a36f1edd462d6@mail.gmail.com> Message-ID: <23203296.post@talk.nabble.com> Bjorn, does this updated version also includes eunit patch ? Zvi Bjorn Gustavsson-2 wrote: > > On Wed, Apr 22, 2009 at 11:27 AM, Andrey wrote: >> Hi! >> >> crypto module is absent in Erlang/OTP R13B Windows binary distro (only >> docs). >> Is it possible to add it? >> > > It was my fault. I uploaded a Windows installer built on a new > daily-build machine > that did not have any OpenSSL libraries installed. > > I have now uploaded the correct Windows installer with crypto included > from the > correct build machine. > > Make sure to empty the web browser cache in the browser before downloading > it. > > Sorry for any inconvenience. > > /Bjorn > > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/Erlang-OTP-R13B-has-been-released-tp23157957p23203296.html Sent from the Erlang Questions mailing list archive at Nabble.com. From james.hague@REDACTED Fri Apr 24 00:45:07 2009 From: james.hague@REDACTED (James Hague) Date: Thu, 23 Apr 2009 17:45:07 -0500 Subject: [erlang-questions] werl.exe slow In-Reply-To: <200904231135195930738@bluewin.ch> References: <200904231135195930738@bluewin.ch> Message-ID: On Thu, Apr 23, 2009 at 4:35 AM, Gamoto wrote: > When I start werl.exe on windows 2003 server, the time before to have the ">" is around 10 seconds ! > Why is it so slow ? normal ? solutions for enhancement ? Under 64-bit Vista it's almost instantaneous for me. James From per.melin@REDACTED Fri Apr 24 01:20:14 2009 From: per.melin@REDACTED (Per Melin) Date: Fri, 24 Apr 2009 01:20:14 +0200 Subject: [erlang-questions] About erlang:statistics/1 and timeout values In-Reply-To: <49F05D92.5030509@erlang-consulting.com> References: <49F0517C.5000007@erlang-consulting.com> <87ws9bzj47.fsf@sterlett.hq.kred> <49F05D92.5030509@erlang-consulting.com> Message-ID: Oscar Hellstr?m: > back to (part of) the original question, how would we go about > decrementing a timeout value between blocking calls. I could use now > diffs, or erlang:start_timer/3... are there better ways? Can it really be simpler than now_diff/2? loop(Timeout) when Timeout > 0 -> Before = now(), receive X -> % Do whatever loop(Timeout - timer:now_diff(now(), Before) div 1000) after Timeout -> loop(0) end; loop(_) -> timeout. (If I needed millisecond precision I would do it a little different just to be sure.) From rvirding@REDACTED Fri Apr 24 02:05:44 2009 From: rvirding@REDACTED (Robert Virding) Date: Fri, 24 Apr 2009 02:05:44 +0200 Subject: [erlang-questions] R13B incompatibility crashes LFE compiler In-Reply-To: <3dbc6d1c0904221323n24b46da2kd9540a0ca8b86d59@mail.gmail.com> References: <3dbc6d1c0904221323n24b46da2kd9540a0ca8b86d59@mail.gmail.com> Message-ID: <3dbc6d1c0904231705i369dece3t78dbaf5ffb8471fb@mail.gmail.com> I have now added a quick fix for this to github. This fix is incompatible for both R12B and R13B, see the README for notes on how to handle this. It is really easy. I will load down a better fix soon. We apologize for the inconvenience, Robert 2009/4/22 Robert Virding > There is an undocumented and incompatible change in R13B to Core Erlang > which both makes it impossible to compile the file lfe_comp.erl, and crashes > the LFE compiler. This affects all versions of LFE. I will try to release a > fix to the latest version on github tomorrow. > > Sorry about that, > > Robert > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmitry.kakurin@REDACTED Fri Apr 24 07:32:00 2009 From: dmitry.kakurin@REDACTED (Dmitry Kakurin) Date: Thu, 23 Apr 2009 22:32:00 -0700 Subject: [erlang-questions] How do things like module dict impleented to work fast? Message-ID: Newbie question. When I append something to a dictionary a new copy is returned and the old copy is still valid (the functional nature of Erlang). I've assumed that there is some kind of clever trick to create an appearance of copy without actual data duplication. However after looking at dict sources it looks like it does a simple copy. Am I missing something or there is no trick? - Dmitry From ckawatak@REDACTED Fri Apr 24 08:31:05 2009 From: ckawatak@REDACTED (Kawatake Chiharu) Date: Fri, 24 Apr 2009 15:31:05 +0900 Subject: [erlang-questions] A specification or a bug of io:get_line ? Message-ID: <8033176c0904232331i38a84640w9cbe9d6d019b634a@mail.gmail.com> Hi, I have just started learning Erlang by myself and came across this. I searched for this in the past questions, but I was not able to find anything that might be related this. So please let me ask about this. I am using R13B on Windows. But this also occurred on Linux. I wrote fragments of code that read a file and print its content like the following. ---------- -module(rw). -export([for_each_line/4, print/3, main/1]). for_each_line(Filename, [_, {encoding, Encoding}]=Mode, F, Args) -> case file:open(Filename, Mode) of {ok, Device} -> F(Device, Encoding, Args); {error, Reason} -> erlang:error(Reason) end. print(Device, Encoding, Args) -> case io:get_line(Device, "") of {error, Reason} -> erlang:error(Reason), file:close(Device); eof -> file:close(Device); Data -> io:format("~s~n", [unicode:characters_to_binary(Data, Encoding)]), print(Device, Encoding, Args) end. main(Args) -> [Filename] = Args, for_each_line(Filename, [read, {encoding, utf8}], fun rw:print/3, []). ------------ I made files encoded in utf-8 and tried to print its content. This worked fine to some extent. However, when I tried to read files that contained Japanese characters, I got an error saying that ------------ $ erl -noshell -s rw main test.txt {"init terminating in do_boot",{collect_line,[{rw,print,3},{init,start_it,1},{init,start_em,1}]}} Crash dump was written to: erl_crash.dump init terminating in do_boot () ------------ After I looked into this for a while, I found that it seemed that if a line started with three consecutive ASCII characters following some Japanese characters, this error could occur. For example, ..????,????,????,????,????,,,????,,????,????,????,????,????,,, which starts with two dots following Japanese characters, was ok. But ...????,????,????,????,????,,,????,,????,????,????,????,????,,, where a dot "." was added at the head of the line, got the error. If my code has some problem, which might be so more likely, please advise me. Please let me know if there is someone who has come across something similar to this. I will post the dump file later if necessary. Best regards. Chiharu -------------- next part -------------- An HTML attachment was scrubbed... URL: From michal.ptaszek@REDACTED Fri Apr 24 09:19:58 2009 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Fri, 24 Apr 2009 08:19:58 +0100 (BST) Subject: [erlang-questions] Hiding user input in escript In-Reply-To: <18828135.120831240557471922.JavaMail.root@zimbra> Message-ID: <3045479.120851240557598730.JavaMail.root@zimbra> Hello All, Is it possible to disable echo while reading the data from the stdin in escript? What I would like to achieve is something similar to `stty -echo` in Unix shells. Best regards, -- Michal Ptaszek www.erlang-consulting.com From raimo+erlang-questions@REDACTED Fri Apr 24 09:22:06 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 24 Apr 2009 09:22:06 +0200 Subject: [erlang-questions] werl.exe slow In-Reply-To: <200904231135195930738@bluewin.ch> References: <200904231135195930738@bluewin.ch> Message-ID: <20090424072206.GB26820@erix.ericsson.se> On Thu, Apr 23, 2009 at 11:35:19AM +0200, Gamoto wrote: > When I start werl.exe on windows 2003 server, the time before to have the ">" is around 10 seconds ! > Why is it so slow ? normal ? solutions for enhancement ? That is ususally the symptom of some network configuration problem. Things like this has happened in the past when werl.exe could not look up its own hostname and waited for a DNS timeout. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From rvirding@REDACTED Fri Apr 24 09:27:39 2009 From: rvirding@REDACTED (Robert Virding) Date: Fri, 24 Apr 2009 09:27:39 +0200 Subject: [erlang-questions] How do things like module dict impleented to work fast? In-Reply-To: References: Message-ID: <3dbc6d1c0904240027g68b1c346p61f9160f2c9ef10a@mail.gmail.com> There is no trick as such, as you saw dict is written in normal erlang. Although some effort has been made to ensure that as much as possible of the "old" dict is reused without copying, only the bits which contain new data are actually created new. One way of doing this is to break up the big table into a tree of smaller bits. There are a few other small tricks which help to improve garbage collection, but they are still all normal erlang. Gb_trees and array use the same techniques of building trees so that only small bits need to be rebuilt. Robert 2009/4/24 Dmitry Kakurin > Newbie question. > When I append something to a dictionary a new copy is returned and the > old copy is still valid (the functional nature of Erlang). > I've assumed that there is some kind of clever trick to create an > appearance of copy without actual data duplication. > However after looking at dict sources it looks like it does a simple copy. > Am I missing something or there is no trick? > > - Dmitry > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Fri Apr 24 09:19:58 2009 From: raimo+erlang-questions@REDACTED ('Raimo Niskanen') Date: Fri, 24 Apr 2009 09:19:58 +0200 Subject: [erlang-questions] : : : : : sctp_peeloff() support in OTP In-Reply-To: <200904231705.n3NH56Rc032601@mail.pharos-avantgard.com> References: <20090423095652.GA32586@erix.ericsson.se> <200904231705.n3NH56Rc032601@mail.pharos-avantgard.com> Message-ID: <20090424071958.GA26820@erix.ericsson.se> On Thu, Apr 23, 2009 at 07:15:16PM +0200, Valentin Micic wrote: > > But I am now under the assumption that a stream separation > > that does not utilize additional file descriptors > > (as you ask for) can not do per-stream flow control > > (with respect to remote peer) and therefore is not useful. > > > Prove me wrong and I might do it. > > Proving you wrong may take some time. :-) I am starting to realize I have mixed the stream and the association concepts a bit in my head... > > AFAIK, flow control is explicitly defined only at association level. Having > said that, please note that each data-chunk (hence stream traffic) has to be > individually acknowledged -- if acknowledge is not received, sender will not > send more data for a given stream. Unfortunately, this will not prevent > sender to send the same data chunk again, confusing a lack of > acknowledgement for a loss of a chunk... > I need to read a bit about it, however, not sure if any amount of reading > can help me here. So, we can get per association flow control, and that is the best flow control we can get. By implementing branched-off associations (sctp_peeloff()). > > But more importantly than proving you wrong: > I know that you would be able to use a separate file descriptor to move a > specific association from one-to-many to one-to-one socket. That association > may have more than one stream (which would typically be a case), so you're > back to where you were with respect to {active, once} and head-of-line > blocking. Don't know how this can be done for individual stream (assuming > that file descriptor = socket). > I hope I never actually suggested to use one file descriptor per stream, I do not think it is possible; one file descriptor per association can be done. In that case, is there any way to avoid head-of-line blocking within an association? So far I have heard of none. In fact I have heard that streams are mostly avoided due to their pecularities. So we can get a (socket) driver that dispatches streams or association:stream for one-to-many sockets to registered processes on reception, and probably that sets association:stream when a registered process sends. But it will only work for {active,true}. A more advanced variant would be to simulate {active,once} and {active,false} by receiving and buffering any amount of messages until all registered stream processors do not want any message. Is stream dispatching for only {active,true} useful? Is stream dispatching with emulated {active,true|false} that may have to buffer any amount of messages (or rather application dependent amount) under the hood useful? > > Regards, > > V. -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From bgustavsson@REDACTED Fri Apr 24 10:53:47 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 24 Apr 2009 10:53:47 +0200 Subject: [erlang-questions] no crypto Erlang/OTP R13B Windows binary In-Reply-To: <23203296.post@talk.nabble.com> References: <6672d0160904210750n7f474ec3n82facd0420d39a2d@mail.gmail.com> <49EEE301.4070008@gmail.com> <6672d0160904220608q1c546a08xef6a36f1edd462d6@mail.gmail.com> <23203296.post@talk.nabble.com> Message-ID: <6672d0160904240153h12ec9995r5687b0cea22ba734@mail.gmail.com> On Thu, Apr 23, 2009 at 11:19 PM, Zvi wrote: > > Bjorn, > > does this updated version also includes eunit patch ? No. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From gamoto@REDACTED Fri Apr 24 11:22:20 2009 From: gamoto@REDACTED (Gamoto) Date: Fri, 24 Apr 2009 11:22:20 +0200 Subject: [erlang-questions] werl.exe slow References: <200904231135195930738@bluewin.ch>, <20090424072206.GB26820@erix.ericsson.se> Message-ID: <200904241122201778604@bluewin.ch> Thank you Ramo for this answer. But how to probe it ? I have no special events in the Events Observer. John >On Thu, Apr 23, 2009 at 11:35:19AM +0200, Gamoto wrote: >> When I start werl.exe on windows 2003 server, the time before to have the ">" is around 10 seconds ! >> Why is it so slow ? normal ? solutions for enhancement ? > >That is ususally the symptom of some network configuration >problem. Things like this has happened in the past >when werl.exe could not look up its own hostname >and waited for a DNS timeout. > >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > >-- > >/ Raimo Niskanen, Erlang/OTP, Ericsson AB From bgustavsson@REDACTED Fri Apr 24 11:30:43 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 24 Apr 2009 11:30:43 +0200 Subject: [erlang-questions] Hiding user input in escript In-Reply-To: <3045479.120851240557598730.JavaMail.root@zimbra> References: <18828135.120831240557471922.JavaMail.root@zimbra> <3045479.120851240557598730.JavaMail.root@zimbra> Message-ID: <6672d0160904240230n62b25eb4h2675ea9d54c9c09a@mail.gmail.com> On Fri, Apr 24, 2009 at 9:19 AM, Michal Ptaszek wrote: > Hello All, > > Is it possible to disable echo while reading the data > from the stdin in escript? > io:get_password/0 /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From pan+eq@REDACTED Fri Apr 24 12:09:42 2009 From: pan+eq@REDACTED (pan+eq@REDACTED) Date: Fri, 24 Apr 2009 12:09:42 +0200 (CEST) Subject: [erlang-questions] A specification or a bug of io:get_line ? In-Reply-To: <8033176c0904232331i38a84640w9cbe9d6d019b634a@mail.gmail.com> References: <8033176c0904232331i38a84640w9cbe9d6d019b634a@mail.gmail.com> Message-ID: Hi! First, a small reflection about your program: I'm not sure what your io:format in print/3 is supposed to do, it will output UTF-8 "as is" which will work for an UTF-8 terminal in oldshell (and default latin1) mode, but will output strange things on other combinations (like in werl). Better to set the standard output in unicode mode and print with io:format("~ts~n",[Data]) instead, which will work as long as you have an unicode aware terminal (like werl on windows and most modern terminals on Linux). However, the real problem is that I've let through a bug in the file_io_server in kernel, causing the error... I've attached a patch for the source tree, hope you can apply that and rebuild kernel. We will of course fix it in the next service release. Cheers, /Patrik, OTP On Fri, 24 Apr 2009, Kawatake Chiharu wrote: > Hi, > > I have just started learning Erlang by myself and came across this. I > searched for this in the past questions, but I was not able to find anything > that might be related this. So please let me ask about this. I am using R13B > on Windows. But this also occurred on Linux. > > I wrote fragments of code that read a file and print its content like the > following. > > ---------- > > -module(rw). > > -export([for_each_line/4, print/3, main/1]). > > for_each_line(Filename, [_, {encoding, Encoding}]=Mode, F, Args) -> > case file:open(Filename, Mode) of > {ok, Device} -> > F(Device, Encoding, Args); > {error, Reason} -> > erlang:error(Reason) > end. > > print(Device, Encoding, Args) -> > case io:get_line(Device, "") of > {error, Reason} -> > erlang:error(Reason), > file:close(Device); > eof -> > file:close(Device); > Data -> > io:format("~s~n", [unicode:characters_to_binary(Data, > Encoding)]), > print(Device, Encoding, Args) > end. > > main(Args) -> > [Filename] = Args, > for_each_line(Filename, [read, {encoding, utf8}], fun rw:print/3, []). > > ------------ > > I made files encoded in utf-8 and tried to print its content. This worked > fine to some extent. > However, when I tried to read files that contained Japanese characters, I > got an error saying that > > ------------ > > $ erl -noshell -s rw main test.txt > {"init terminating in > do_boot",{collect_line,[{rw,print,3},{init,start_it,1},{init,start_em,1}]}} > > Crash dump was written to: erl_crash.dump > init terminating in do_boot () > > ------------ > > After I looked into this for a while, I found that it seemed that if a line > started with three consecutive ASCII characters following some Japanese > characters, this error could occur. > For example, > > ..????????,????????,????????,????????,????????,,,????????,,????????,????????,????????,????????,????????,,, > > which starts with two dots following Japanese characters, was ok. But > > ...????????,????????,????????,????????,????????,,,????????,,????????,????????,????????,????????,????????,,, > > where a dot "." was added at the head of the line, got the error. > > If my code has some problem, which might be so more likely, please advise > me. > Please let me know if there is someone who has come across something similar > to this. > > I will post the dump file later if necessary. > > Best regards. > > Chiharu > -------------- next part -------------- A non-text attachment was scrubbed... Name: unicode_get_line.diff Type: text/x-patch Size: 773 bytes Desc: Patch for OTP-7974 URL: From michal.ptaszek@REDACTED Fri Apr 24 12:40:06 2009 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Fri, 24 Apr 2009 11:40:06 +0100 (BST) Subject: [erlang-questions] Hiding user input in escript In-Reply-To: <6672d0160904240230n62b25eb4h2675ea9d54c9c09a@mail.gmail.com> Message-ID: <21102368.121791240569606300.JavaMail.root@zimbra> ----- "Bjorn Gustavsson" wrote: > On Fri, Apr 24, 2009 at 9:19 AM, Michal Ptaszek > wrote: > > Hello All, > > > > Is it possible to disable echo while reading the data > > from the stdin in escript? > > > > io:get_password/0 > It seems it does not like me: cat pass.erl #!/usr/bin/env escript main(_) -> io:format("Password: "), A = io:get_password(), io:format("A = ~p~n", [A]). ./pass.erl: Password: A = {error,{request,get_password}} When it is running inside the Erlang shell, works perfectly. What am I doing wrong? BR -- Michal Ptaszek www.erlang-consulting.com From vladdu55@REDACTED Fri Apr 24 14:34:45 2009 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 24 Apr 2009 14:34:45 +0200 Subject: [erlang-questions] werl.exe slow In-Reply-To: <20090424072206.GB26820@erix.ericsson.se> References: <200904231135195930738@bluewin.ch> <20090424072206.GB26820@erix.ericsson.se> Message-ID: <95be1d3b0904240534y7431d9b4n1f5c483df1f4ebb2@mail.gmail.com> On Fri, Apr 24, 2009 at 09:22, Raimo Niskanen wrote: > On Thu, Apr 23, 2009 at 11:35:19AM +0200, Gamoto wrote: >> When I start werl.exe on windows 2003 server, the time before to have the ">" is around 10 seconds ! >> Why is it so slow ? normal ? solutions for enhancement ? > > That is ususally the symptom of some network configuration > problem. Things like this has happened in the past > when werl.exe could not look up its own hostname > and waited for a DNS timeout. >From a separate message from John, this delay happens even when simply starting "erl.exe", not distributed. There should not be any DNS lookup in that case? On the other hand, starting even "erl -name abc@REDACTED" takes much longer than the case above. For me it works just fine, so it's probably a configuration issue. regards, Vlad From rtrlists@REDACTED Fri Apr 24 14:52:58 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Fri, 24 Apr 2009 13:52:58 +0100 Subject: [erlang-questions] werl.exe slow In-Reply-To: <95be1d3b0904240534y7431d9b4n1f5c483df1f4ebb2@mail.gmail.com> References: <200904231135195930738@bluewin.ch> <20090424072206.GB26820@erix.ericsson.se> <95be1d3b0904240534y7431d9b4n1f5c483df1f4ebb2@mail.gmail.com> Message-ID: <6a3ae47e0904240552vcdd8242ka21f345e817d41fe@mail.gmail.com> On Fri, Apr 24, 2009 at 1:34 PM, Vlad Dumitrescu wrote: > On Fri, Apr 24, 2009 at 09:22, Raimo Niskanen > wrote: >> On Thu, Apr 23, 2009 at 11:35:19AM +0200, Gamoto wrote: >>> When I start werl.exe on windows 2003 server, the time before to have the ">" is around 10 seconds ! >>> Why is it so slow ? normal ? solutions for enhancement ? >> >> That is ususally the symptom of some network configuration >> problem. Things like this has happened in the past >> when werl.exe could not look up its own hostname >> and waited for a DNS timeout. > > >From a separate message from John, this delay happens even when simply > starting "erl.exe", not distributed. There should not be any DNS > lookup in that case? > On the other hand, starting even "erl -name abc@REDACTED" takes much > longer than the case above. > > For me it works just fine, so it's probably a configuration issue. > > regards, > Vlad You could have a look in C:\WINDOWS\system32\drivers\etc\hosts (or wherever W2003 expects it) to see if localhost is there. If not, try adding a line like 127.0.0.1 localhost Might speed things up in some cases. Robby From bgustavsson@REDACTED Fri Apr 24 14:53:49 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 24 Apr 2009 14:53:49 +0200 Subject: [erlang-questions] Hiding user input in escript In-Reply-To: <21102368.121791240569606300.JavaMail.root@zimbra> References: <6672d0160904240230n62b25eb4h2675ea9d54c9c09a@mail.gmail.com> <21102368.121791240569606300.JavaMail.root@zimbra> Message-ID: <6672d0160904240553j1934b2c3rb8662d044fcfa37b@mail.gmail.com> On Fri, Apr 24, 2009 at 12:40 PM, Michal Ptaszek wrote: > > ----- "Bjorn Gustavsson" wrote: > >> On Fri, Apr 24, 2009 at 9:19 AM, Michal Ptaszek >> wrote: >> > Hello All, >> > >> > Is it possible to disable echo while reading the data >> > from the stdin in escript? >> > >> >> io:get_password/0 >> > > It seems it does not like me: > > cat pass.erl > #!/usr/bin/env escript > > main(_) -> > io:format("Password: "), > A = io:get_password(), > io:format("A = ~p~n", [A]). > > > ./pass.erl: > Password: A = {error,{request,get_password}} > > When it is running inside the Erlang shell, works perfectly. > What am I doing wrong? Sorry, I only tested it inside an Erlang shell, not in escript. The problem seems to be that escript uses the old shell, which does not support any way to control the terminal. We'll have a look at escript for the next release and see whether it would be possible to have it run with the standard shell. /Bjorn > > BR > -- > Michal Ptaszek > www.erlang-consulting.com > -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From raimo+erlang-questions@REDACTED Fri Apr 24 15:09:18 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 24 Apr 2009 15:09:18 +0200 Subject: [erlang-questions] werl.exe slow In-Reply-To: <95be1d3b0904240534y7431d9b4n1f5c483df1f4ebb2@mail.gmail.com> References: <200904231135195930738@bluewin.ch> <20090424072206.GB26820@erix.ericsson.se> <95be1d3b0904240534y7431d9b4n1f5c483df1f4ebb2@mail.gmail.com> Message-ID: <20090424130918.GA30655@erix.ericsson.se> On Fri, Apr 24, 2009 at 02:34:45PM +0200, Vlad Dumitrescu wrote: > On Fri, Apr 24, 2009 at 09:22, Raimo Niskanen > wrote: > > On Thu, Apr 23, 2009 at 11:35:19AM +0200, Gamoto wrote: > >> When I start werl.exe on windows 2003 server, the time before to have the ">" is around 10 seconds ! > >> Why is it so slow ? normal ? solutions for enhancement ? > > > > That is ususally the symptom of some network configuration > > problem. Things like this has happened in the past > > when werl.exe could not look up its own hostname > > and waited for a DNS timeout. > > >From a separate message from John, this delay happens even when simply > starting "erl.exe", not distributed. There should not be any DNS > lookup in that case? The starting emulator always tries to find out its hostname, by asking gethostname(), and then it verifies that the name can be looked up with the normal hostname resolver functions. So if you have e.g a DNS misconfiguration it may manifest itself like this. When the emulator has started try these: 1> {ok,N} = inet:gethostname(). 2> inet:gethostbyname(N). 3> inet_gethost_native:gethostbyname(N). 4> inet_db:res_option(lookup). > On the other hand, starting even "erl -name abc@REDACTED" takes much > longer than the case above. > > For me it works just fine, so it's probably a configuration issue. > > regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From v@REDACTED Fri Apr 24 15:27:53 2009 From: v@REDACTED (Valentin Micic) Date: Fri, 24 Apr 2009 15:27:53 +0200 Subject: [erlang-questions] : : : : : sctp_peeloff() support in OTP In-Reply-To: <20090424071958.GA26820@erix.ericsson.se> Message-ID: <200904241317.n3ODHkRc004637@mail.pharos-avantgard.com> > So, we can get per association flow control, and > that is the best flow control we can get. By implementing > branched-off associations (sctp_peeloff()). If I may add: there is a much more traditional way to implement one-to-one socket, and that is by implementing accept() socket call (see paragraph 4.1.4 of http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13 ). The sctp_peeloff() is an advanced SCTP specific call, hence not so intuitive for a "traditional" socket programmer. Whilst this might not be a problem, there is one feature of sctp_peeloff which bothers me about it. Unlike accept(), which can guarantee that all the traffic is exchanged between two intended SCTP endpoints (one-to-one socket); with sctp_peeloff() nothing can ensure that port owner, which was handling one-to-many socket before peeloff happened; did not handle a bit of the traffic itself. Wouldn't it make more sense to implement accept before (or alongside) sctp_peeloff? > I hope I never actually suggested to use one file descriptor per > stream, I do not think it is possible; one file descriptor per > association can be done. I do not think you did... I could have made that association (no pun intended) myself, as I've been trying to talk about streams within particular association and regardless of association identifier and/or socket style used. > In that case, is there any way to avoid head-of-line blocking > within an association? So far I have heard of none. Remember that SCTP driver already prevents head-of-line blocking. The problem was that {active, once} issued against port would reintroduce it if the port owner is to process all the messages, thus creating processing delay. Funny thing is, after all that has been said I'm thinking: so what if it does... One may have a port owner that only dispatches the traffic to-and-from the port, and how much of the processing delay that may really create? In that respect, {active, once} is still useful, as it would protect run-time from uncontrollable process message queue build-up, which degrades erts performance. And the best thing is -- all of that may be achieved without messing with the driver. Sorry to take up so much of your time. > In fact I have heard that streams are mostly avoided > due to their pecularities. If you remove "S" from "SCTP" you're left with "CTP", which looks like a TCP with letters arriving out of order. What would be the point of SCTP support if we do not use what it was designed for? V From chaitanya.chalasani@REDACTED Fri Apr 24 16:23:19 2009 From: chaitanya.chalasani@REDACTED (chaitanya Chalasani) Date: Fri, 24 Apr 2009 19:53:19 +0530 Subject: [erlang-questions] Low disk logging performance in SMP Message-ID: <1240582999.17613.35.camel@chaitanya.laptop> Hi, I am facing performance issue with my file logger. The file logger is an event handler holding the file reference is its state. The performance of the module is way ahead in the smp disabled erl shell compared with default smp enabled erl shell. I tried ... case#1 Erlang R13B (erts-5.7.1) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.1 (abort with ^G) 1> testLogger:start("test.log"). true 2> testLogger:write("Testing...",1000000). {ok,done} 3> and case#2 Erlang R13B (erts-5.7.1) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.1 (abort with ^G) 1> testLogger:start("test.log"). true 2> testLogger:write("Testing...",1000000). {ok,done} 3> What I observed was - Case 1: 1. The testLogger:write("Testing...",1000000) did not return back the control to the shell until all the messages are written to log. 2. The data was written at 400 KB/s Case 2: 1. The testLogger:write("Testing...",1000000) return back the control to the shell with {ok, done} after a short while but the messages where being written to log even after that. 2. The data was written at 4 KB/s 3. I checked in the pman tool it shows current funtion as io:wait_io_mon_reply/2 and the messages in the message pool are about 880k. Below is the code which I tested. start(Filename) -> register(testLogger,spawn(testLogger,listener,[Filename])). listener(Filename) -> case file:open(Filename,[append]) of {ok,Fd} -> listener(Fd,0); {error,Reason} -> error_logger:error_msg(Reason) end. listener(Fd,N) -> receive {data,Data} -> file:write(Fd,Data), listener(Fd,N+1); {count,From} -> From ! {count,N}, listener(Fd,N); {stop,From} -> From ! {stop,success} end. write(_Data,0) -> {ok,done}; write(Data,N) -> testLogger ! {data,Data}, write(Data,N-1). Is there a problem with my code or is it a known issue? ------ CHAITANYA CHALASANI -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Fri Apr 24 16:58:02 2009 From: roberto@REDACTED (robbie13) Date: Fri, 24 Apr 2009 07:58:02 -0700 (PDT) Subject: [erlang-questions] cannot send messages to a C-node Message-ID: <23218139.post@talk.nabble.com> hi all, i cannot find a way to send messages to an erlang c-node. i create the c-node with the following: ------------------------------------------ struct in_addr addr; addr.s_addr = inet_addr("127.0.0.1"); if (erl_connect_xinit("rob.loc", "http_cnode", "http_cnode@REDACTED", &addr, "secretcookie", 0) == -1) erl_err_quit("erl_connect_xinit"); if (erl_connect("http@REDACTED") == -1) erl_err_quit("erl_connect"); ------------------------------------------ rob.loc is configured in my /etc/hosts file to point to 127.0.0.1. i do get connected, and as i can see from my http@REDACTED erlang shell: ------------------------------------------ (http@REDACTED)21> nodes(hidden). ['http_cnode@REDACTED'] ------------------------------------------ the code i have to receive messages is the typical: ------------------------------------------ unsigned char buf[BUFSIZE]; /* Buffer for incoming message */ ErlMessage emsg; /* Incoming message */ while (1) { fprintf(stderr, "start\n\r"); got = erl_receive_msg(fd, buf, BUFSIZE, &emsg); fprintf(stderr, "GOT MESSAGE\n\r"); if (got == ERL_TICK) { continue; ... ------------------------------------------ if i send a message to the node: ------------------------------------------ (http@REDACTED)22> {any, http_cnode@REDACTED} ! {test, "hello!"}. {test, "hello!"} ------------------------------------------ the code of the c-node never gets to the GOT MESSAGE printout. instead, if i initialize the c-node with: ------------------------------------------ if (erl_connect_init(1, "secretcookie", 0) == -1) erl_err_quit("erl_connect_init"); if ((fd = erl_connect("http@REDACTED")) < 0) erl_err_quit("erl_connect"); ------------------------------------------ everything works correctly, but i cannot specify an hostname for the c-node. any kind soul would have a clue to this? thank you in advance.. r. -- View this message in context: http://www.nabble.com/cannot-send-messages-to-a-C-node-tp23218139p23218139.html Sent from the Erlang Questions mailing list archive at Nabble.com. From gamoto@REDACTED Fri Apr 24 17:32:17 2009 From: gamoto@REDACTED (Gamoto) Date: Fri, 24 Apr 2009 17:32:17 +0200 Subject: [erlang-questions] float number rounded/truncated Message-ID: <200904241732173688139@bluewin.ch> I have the string representation of a float number: "1234.5678" I want to transform like this: "12.345678" I do: N1 = list_to_float(Number)/100, N2 = float_to_list(N1) But the result is: "1.2345678000....e+001" My method is bad ;-( How to round or trunc a float number in Erlang and to not have a EEE representation ? From pablo.polvorin@REDACTED Fri Apr 24 17:39:38 2009 From: pablo.polvorin@REDACTED (Pablo Polvorin) Date: Fri, 24 Apr 2009 12:39:38 -0300 Subject: [erlang-questions] cannot send messages to a C-node In-Reply-To: <23218139.post@talk.nabble.com> References: <23218139.post@talk.nabble.com> Message-ID: <1ffe809c0904240839t3041b466od745cd6f699f3761@mail.gmail.com> Have you tried the ei_* API instead?, (http://erlang.org/doc/apps/erl_interface/index.html) ei has a number of advantages, I think it is the preferred way to write c code, 2009/4/24 robbie13 : > > hi all, > > i cannot find a way to send messages to an erlang c-node. i create the > c-node with the following: > > ------------------------------------------ > struct in_addr addr; > addr.s_addr = inet_addr("127.0.0.1"); > if (erl_connect_xinit("rob.loc", "http_cnode", "http_cnode@REDACTED", &addr, > "secretcookie", 0) == -1) > ? ? ? ?erl_err_quit("erl_connect_xinit"); > if (erl_connect("http@REDACTED") == -1) > ? ? ? ?erl_err_quit("erl_connect"); > ------------------------------------------ > rob.loc is configured in my /etc/hosts file to point to 127.0.0.1. > > i do get connected, and as i can see from my http@REDACTED erlang shell: > ------------------------------------------ > (http@REDACTED)21> nodes(hidden). > ['http_cnode@REDACTED'] > ------------------------------------------ > > the code i have to receive messages is the typical: > ------------------------------------------ > unsigned char buf[BUFSIZE]; ? ? ? ? ? ? ?/* Buffer for incoming message */ > ErlMessage emsg; ? ? ? ? ? ? ? ? ? ? ? ? /* Incoming message */ > > while (1) { > ? ? ? ?fprintf(stderr, "start\n\r"); > ? ? ? ?got = erl_receive_msg(fd, buf, BUFSIZE, &emsg); > ? ? ? ?fprintf(stderr, "GOT MESSAGE\n\r"); > ? ? ? ?if (got == ERL_TICK) { > ? ? ? ? ? ? ? ?continue; > ? ? ? ?... > ------------------------------------------ > > if i send a message to the node: > ------------------------------------------ > (http@REDACTED)22> {any, http_cnode@REDACTED} ! {test, "hello!"}. > {test, "hello!"} > ------------------------------------------ > the code of the c-node never gets to the GOT MESSAGE printout. > > instead, if i initialize the c-node with: > ------------------------------------------ > if (erl_connect_init(1, "secretcookie", 0) == -1) > ? ? ? ?erl_err_quit("erl_connect_init"); > if ((fd = erl_connect("http@REDACTED")) < 0) > ? ? ? ?erl_err_quit("erl_connect"); > ------------------------------------------ > everything works correctly, but i cannot specify an hostname for the c-node. > > any kind soul would have a clue to this? thank you in advance.. > > r. > -- > View this message in context: http://www.nabble.com/cannot-send-messages-to-a-C-node-tp23218139p23218139.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From per.melin@REDACTED Fri Apr 24 18:06:53 2009 From: per.melin@REDACTED (Per Melin) Date: Fri, 24 Apr 2009 18:06:53 +0200 Subject: [erlang-questions] Low disk logging performance in SMP In-Reply-To: <1240582999.17613.35.camel@chaitanya.laptop> References: <1240582999.17613.35.camel@chaitanya.laptop> Message-ID: chaitanya Chalasani: > I am facing performance issue with my file logger. The file logger is an > event handler holding the file reference is its state. The performance of > the module is way ahead in the smp disabled erl shell compared with default > smp enabled erl shell. [...] > Is there a problem with my code or is it a known issue? It is known that once you queue up a few tens of thousand messages into a mailbox your performance drops noticeably for doing a receive. With SMP you will send your one million messages much, much faster than the logger can process them and the mailbox will immediately fill up to a point where it will just go slower and slower. From roux.viljoen@REDACTED Fri Apr 24 18:09:23 2009 From: roux.viljoen@REDACTED (Roux Viljoen) Date: Fri, 24 Apr 2009 17:09:23 +0100 Subject: [erlang-questions] float number rounded/truncated In-Reply-To: <200904241732173688139@bluewin.ch> References: <200904241732173688139@bluewin.ch> Message-ID: <49F1E433.4090802@erlang-consulting.com> Gamoto wrote: > I have the string representation of a float number: "1234.5678" > I want to transform like this: "12.345678" > I do: N1 = list_to_float(Number)/100, N2 = float_to_list(N1) > But the result is: "1.2345678000....e+001" > > My method is bad ;-( > How to round or trunc a float number in Erlang and to not have a EEE representation ? > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > is this what your looking for? io_lib:format("~.4f",[N1]). Roux Viljoen Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From raimo+erlang-questions@REDACTED Fri Apr 24 17:36:24 2009 From: raimo+erlang-questions@REDACTED ('Raimo Niskanen') Date: Fri, 24 Apr 2009 17:36:24 +0200 Subject: [erlang-questions] : : : : : sctp_peeloff() support in OTP In-Reply-To: <200904241317.n3ODHkRc004637@mail.pharos-avantgard.com> References: <20090424071958.GA26820@erix.ericsson.se> <200904241317.n3ODHkRc004637@mail.pharos-avantgard.com> Message-ID: <20090424153624.GA31837@erix.ericsson.se> On Fri, Apr 24, 2009 at 03:27:53PM +0200, Valentin Micic wrote: > > > So, we can get per association flow control, and > > that is the best flow control we can get. By implementing > > branched-off associations (sctp_peeloff()). > > If I may add: there is a much more traditional way to implement one-to-one > socket, and that is by implementing accept() socket call (see paragraph > 4.1.4 of http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13 ). The > sctp_peeloff() is an advanced SCTP specific call, hence not so intuitive for > a "traditional" socket programmer. Whilst this might not be a problem, there > is one feature of sctp_peeloff which bothers me about it. Unlike accept(), > which can guarantee that all the traffic is exchanged between two intended > SCTP endpoints (one-to-one socket); with sctp_peeloff() nothing can ensure > that port owner, which was handling one-to-many socket before peeloff > happened; did not handle a bit of the traffic itself. Wouldn't it make more > sense to implement accept before (or alongside) sctp_peeloff? Yes it would. Thank you for the pointout. Nobody has claimed much interest in SCTP accept() before. > > > I hope I never actually suggested to use one file descriptor per > > stream, I do not think it is possible; one file descriptor per > > association can be done. > > I do not think you did... I could have made that association (no pun Phew! > intended) myself, as I've been trying to talk about streams within > particular association and regardless of association identifier and/or > socket style used. > > > In that case, is there any way to avoid head-of-line blocking > > within an association? So far I have heard of none. > > Remember that SCTP driver already prevents head-of-line blocking. The > problem was that {active, once} issued against port would reintroduce it if > the port owner is to process all the messages, thus creating processing > delay. Funny thing is, after all that has been said I'm thinking: so what if > it does... One may have a port owner that only dispatches the traffic > to-and-from the port, and how much of the processing delay that may really > create? > In that respect, {active, once} is still useful, as it would protect > run-time from uncontrollable process message queue build-up, which degrades {active,once} with message dispatching in the port owner process is probably sufficient for most cases. Combining it with branched-off associations would make flow control not affect unrelated associations. And {active,Stream,Pid} would optimise message dispatching, loosing flow control. The question remains if {active,true|false|once,Stream,Pid} with the side effect that while any stream processor is active data flows in on all streams and is buffered in the dispatcher (Port or PID) - only if all stream processors are passive would the flow be blocked, would be useful? That would be a complicated concept. What do you think? > erts performance. And the best thing is -- all of that may be achieved > without messing with the driver. Sorry to take up so much of your time. I need to discuss this to get branched off associations (and streams) right, so thank you for your input. It is so easy to accidentaly choose a model that eventually proves to destroy the best model for a later feature introduction... > > > In fact I have heard that streams are mostly avoided > > due to their pecularities. > > If you remove "S" from "SCTP" you're left with "CTP", which looks like a TCP > with letters arriving out of order. What would be the point of SCTP support > if we do not use what it was designed for? ... One-to-many associations. Multi-homed endpoints. Packeted messages... Those would be important for the Distributed Erlang protocol. It is unclear if the streams would be useful. > > V -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From roberto@REDACTED Fri Apr 24 17:52:00 2009 From: roberto@REDACTED (Roberto Ostinelli) Date: Fri, 24 Apr 2009 17:52:00 +0200 Subject: [erlang-questions] cannot send messages to a C-node In-Reply-To: <1ffe809c0904240839t3041b466od745cd6f699f3761@mail.gmail.com> References: <23218139.post@talk.nabble.com> <1ffe809c0904240839t3041b466od745cd6f699f3761@mail.gmail.com> Message-ID: <645D7BC7-3697-4022-B11D-0E550138E068@ostinelli.net> i haven't tried that, will take a look at it. thank you, r. On 24/apr/09, at 17:39, Pablo Polvorin wrote: > Have you tried the ei_* API instead?, > (http://erlang.org/doc/apps/erl_interface/index.html) > ei has a number of advantages, I think it is the preferred way to > write c code, > > > > 2009/4/24 robbie13 : >> >> hi all, >> >> i cannot find a way to send messages to an erlang c-node. i create >> the >> c-node with the following: >> >> ------------------------------------------ >> struct in_addr addr; >> addr.s_addr = inet_addr("127.0.0.1"); >> if (erl_connect_xinit("rob.loc", "http_cnode", >> "http_cnode@REDACTED", &addr, >> "secretcookie", 0) == -1) >> erl_err_quit("erl_connect_xinit"); >> if (erl_connect("http@REDACTED") == -1) >> erl_err_quit("erl_connect"); >> ------------------------------------------ >> rob.loc is configured in my /etc/hosts file to point to 127.0.0.1. >> >> i do get connected, and as i can see from my http@REDACTED erlang >> shell: >> ------------------------------------------ >> (http@REDACTED)21> nodes(hidden). >> ['http_cnode@REDACTED'] >> ------------------------------------------ >> >> the code i have to receive messages is the typical: >> ------------------------------------------ >> unsigned char buf[BUFSIZE]; /* Buffer for incoming >> message */ >> ErlMessage emsg; /* Incoming message */ >> >> while (1) { >> fprintf(stderr, "start\n\r"); >> got = erl_receive_msg(fd, buf, BUFSIZE, &emsg); >> fprintf(stderr, "GOT MESSAGE\n\r"); >> if (got == ERL_TICK) { >> continue; >> ... >> ------------------------------------------ >> >> if i send a message to the node: >> ------------------------------------------ >> (http@REDACTED)22> {any, http_cnode@REDACTED} ! {test, "hello!"}. >> {test, "hello!"} >> ------------------------------------------ >> the code of the c-node never gets to the GOT MESSAGE printout. >> >> instead, if i initialize the c-node with: >> ------------------------------------------ >> if (erl_connect_init(1, "secretcookie", 0) == -1) >> erl_err_quit("erl_connect_init"); >> if ((fd = erl_connect("http@REDACTED")) < 0) >> erl_err_quit("erl_connect"); >> ------------------------------------------ >> everything works correctly, but i cannot specify an hostname for >> the c-node. >> >> any kind soul would have a clue to this? thank you in advance.. >> >> r. >> -- >> View this message in context: http://www.nabble.com/cannot-send-messages-to-a-C-node-tp23218139p23218139.html >> Sent from the Erlang Questions mailing list archive at Nabble.com. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vychodil.hynek@REDACTED Fri Apr 24 18:51:39 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 24 Apr 2009 18:51:39 +0200 Subject: [erlang-questions] Low disk logging performance in SMP In-Reply-To: <1240582999.17613.35.camel@chaitanya.laptop> References: <1240582999.17613.35.camel@chaitanya.laptop> Message-ID: <4d08db370904240951i27e5aba7ucb59f8f15ac3552e@mail.gmail.com> It behaves much worse on my laptop. In smp it performs 4kB in about 5 sec. It is not issue of R13B because I'm using version 5.6.5. I have suspected issue in message queue in file:write then changed listener to listener(Fd,N) -> receive {data,Data} -> Fd ! {io_request, self(), Fd, {put_chars, Data}}, listener(Fd,N+1); {count,From} -> From ! {count,N}, listener(Fd,N); {stop,From} -> From ! {stop,success}; {io_reply, Fd, ok} -> listener(Fd, N); Msg -> io:format("Unexpected message: ~p~n", [Msg]), listener(Fd, N) end. but without any effect. Than I have tried ad kernel pool and asynchronous threads (erl +K true +A 2) without any observable effect. I have also tried file:open(Filename,[append, delayed_write]). No effect. It seems that when I solve issue with message queue in testLogger:listener it happen again in file_io_server. I have end up with reasonable fast but still not good enough (it is able to fall to swapping) -define(BS, 65536). listener(Filename) -> case file:open(Filename,[append, raw]) of {ok,Fd} -> listener(Fd,0, <<>>); {error,Reason} -> error_logger:error_msg(Reason) end. listener(Fd,N, <<>> = SoFar) -> receive {data,Data} -> listener(Fd, N+1, iolist_to_binary(Data)); {count,From} -> From ! {count,N}, listener(Fd, N, SoFar); {stop,From} -> From ! {stop,success}; Msg -> io:format("Unexpected message: ~p~n", [Msg]), listener(Fd, N, SoFar) end; listener(Fd,N, SoFar) when size(SoFar) > ?BS -> file:write(Fd, SoFar), listener(Fd, N, <<>>); listener(Fd,N, SoFar) -> receive {data,Data} -> BinData = iolist_to_binary(Data), Bin = <>, listener(Fd, N+1, Bin); {count,From} -> From ! {count,N}, listener(Fd, N, SoFar); {stop,From} -> file:write(Fd, SoFar), From ! {stop,success}; Msg -> io:format("Unexpected message: ~p~n", [Msg]), listener(Fd, N, SoFar) after 0 -> file:write(Fd, SoFar), listener(Fd, N, <<>>) end. P.S.: Version with caching and asynchronnous calls to file_io_server instead prim_file (raw) consumes more memory. On Fri, Apr 24, 2009 at 4:23 PM, chaitanya Chalasani < chaitanya.chalasani@REDACTED> wrote: > Hi, > > I am facing performance issue with my file logger. The file logger is an > event handler holding the file reference is its state. The performance of > the module is way ahead in the smp disabled erl shell compared with default > smp enabled erl shell. > > I tried ... > case#1 > *Erlang R13B (erts-5.7.1) [source] [rq:1] [async-threads:0] [hipe] > [kernel-poll:false]* > > *Eshell V5.7.1 (abort with ^G)* > *1> testLogger:start("test.log").* > *true* > *2> testLogger:write("Testing...",1000000).* > *{ok,done}* > *3>* > > and > > case#2 > *Erlang R13B (erts-5.7.1) [source] [smp:2:2] [rq:2] [async-threads:0] > [hipe] [kernel-poll:false]* > > *Eshell V5.7.1 (abort with ^G)* > *1> testLogger:start("test.log").* > *true* > *2> testLogger:write("Testing...",1000000).* > *{ok,done}* > *3>* > > > What I observed was - > Case 1: > 1. The testLogger:write("Testing...",1000000) did not return back the > control to the shell until all the messages are written to log. > 2. The data was written at 400 KB/s > > Case 2: > 1. The testLogger:write("Testing...",1000000) return back the control > to the shell with {ok, done} after a short while but the messages where > being written to log even after that. > 2. The data was written at 4 KB/s > 3. I checked in the pman tool it shows current funtion as > io:wait_io_mon_reply/2 and the messages in the message pool are about 880k. > > Below is the code which I tested. > > *start(Filename) -> > register(testLogger,spawn(testLogger,listener,[Filename])).* > > *listener(Filename) ->* > * case file:open(Filename,[append]) of* > * {ok,Fd} -> listener(Fd,0);* > * {error,Reason} -> error_logger:error_msg(Reason)* > * end.* > > *listener(Fd,N) ->* > * receive* > * {data,Data} -> file:write(Fd,Data), listener(Fd,N+1);* > * {count,From} -> From ! {count,N}, listener(Fd,N);* > * {stop,From} -> From ! {stop,success}* > * end.* > > *write(_Data,0) -> {ok,done};* > *write(Data,N) -> testLogger ! {data,Data}, write(Data,N-1).* > > Is there a problem with my code or is it a known issue? > > *------* > *CHAITANYA CHALASANI* > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From anders.nygren@REDACTED Fri Apr 24 18:52:04 2009 From: anders.nygren@REDACTED (Anders Nygren) Date: Fri, 24 Apr 2009 11:52:04 -0500 Subject: [erlang-questions] Low disk logging performance in SMP In-Reply-To: References: <1240582999.17613.35.camel@chaitanya.laptop> Message-ID: On Fri, Apr 24, 2009 at 11:06 AM, Per Melin wrote: > chaitanya Chalasani: >> I am facing performance issue with my file logger. The file logger is an >> event handler holding the file reference is its state. The performance of >> the module is way ahead in the smp disabled erl shell compared with default >> smp enabled erl shell. > > [...] > >> Is there a problem with my code or is it a known issue? > > It is known that once you queue up a few tens of thousand messages > into a mailbox your performance drops noticeably for doing a receive. I hope You meant when doing a SELECTIVE receive, right. /Anders > > With SMP you will send your one million messages much, much faster > than the logger can process them and the mailbox will immediately fill > up to a point where it will just go slower and slower. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf@REDACTED Fri Apr 24 19:08:42 2009 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 24 Apr 2009 19:08:42 +0200 Subject: [erlang-questions] float number rounded/truncated In-Reply-To: <200904241732173688139@bluewin.ch> References: <200904241732173688139@bluewin.ch> Message-ID: <8209f740904241008r4ab02b5dk90c3d5c2d01ebc78@mail.gmail.com> How about 1> io_lib:fwrite("~f", [list_to_float("1234.5678")/100]). ["12.345678"] BR, Ulf W 2009/4/24 Gamoto : > I have the string representation of a float number: "1234.5678" > I want to transform like this: "12.345678" > I do: N1 = list_to_float(Number)/100, N2 = float_to_list(N1) > But the result is: ? "1.2345678000....e+001" > > My method is bad ;-( > How to round or trunc a float number in Erlang and to not have a EEE representation ? > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From oscar@REDACTED Fri Apr 24 19:05:38 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Fri, 24 Apr 2009 18:05:38 +0100 Subject: [erlang-questions] About erlang:statistics/1 and timeout values In-Reply-To: References: <49F0517C.5000007@erlang-consulting.com> <87ws9bzj47.fsf@sterlett.hq.kred> <49F05D92.5030509@erlang-consulting.com> Message-ID: <49F1F162.3080309@erlang-consulting.com> Per Melin wrote: > Oscar Hellstr?m: > >> back to (part of) the original question, how would we go about >> decrementing a timeout value between blocking calls. I could use now >> diffs, or erlang:start_timer/3... are there better ways? >> > > Can it really be simpler than now_diff/2? > > loop(Timeout) when Timeout > 0 -> > Before = now(), > receive > X -> > % Do whatever > loop(Timeout - timer:now_diff(now(), Before) div 1000) > after Timeout -> > loop(0) > end; > loop(_) -> > timeout. > > (If I needed millisecond precision I would do it a little different > just to be sure.) > It could be, and it could avoid being affected by time changes on your machine. do_x(Timeout) -> TRef = erlang:start_timer(Timeout), loop(TRef, Timeout). loop(_, false) -> timeout; loop(TRef, Timeout) -> receive X -> case done(X) of true -> ok; false -> loop(TRef, erlang:read_timer(TRef)) after Timeout -> timeout end. It could also be done with a counter counting up... which might be better? Cheers -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From per.melin@REDACTED Fri Apr 24 19:33:31 2009 From: per.melin@REDACTED (Per Melin) Date: Fri, 24 Apr 2009 19:33:31 +0200 Subject: [erlang-questions] Low disk logging performance in SMP In-Reply-To: References: <1240582999.17613.35.camel@chaitanya.laptop> Message-ID: Anders Nygren: > Per Melin: >> It is known that once you queue up a few tens of thousand messages >> into a mailbox your performance drops noticeably for doing a receive. > > I hope You meant when doing a SELECTIVE receive, right. Of course. I've been away from Erlang for too long (again). I'm really sorry for the misinformation. From vychodil.hynek@REDACTED Fri Apr 24 20:32:55 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 24 Apr 2009 20:32:55 +0200 Subject: [erlang-questions] Low disk logging performance in SMP In-Reply-To: <1240582999.17613.35.camel@chaitanya.laptop> References: <1240582999.17613.35.camel@chaitanya.laptop> Message-ID: <4d08db370904241132k71e550e1jaa81da163f58d396@mail.gmail.com> Try this one, I guess you will be surprised ;-) -define(BS, 65536). start(Filename) -> Pid = spawn(?MODULE, listener, [Filename]), register(?MODULE, Pid). listener(Filename) -> case file:open(Filename, [append, raw]) of {ok, Fd} -> listener(Fd, 0, [], 0); {error, Reason} -> error_logger:error_msg(Reason) end. listener(Fd, N, [] = SoFar, 0) -> receive {data, Data} -> listener(Fd, N + 1, [Data], iolist_size(Data)); {count, From} -> From ! {count, N}, listener(Fd, N, SoFar, 0); stop -> ok; Msg -> io:format("Unexpected message: ~p~n", [Msg]), listener(Fd, N, SoFar, 0) end; listener(Fd, N, SoFar, S) when S > (?BS) -> file:write(Fd, lists:reverse(SoFar)), listener(Fd, N, [], 0); listener(Fd, N, SoFar, S) -> receive {data, Data} -> listener(Fd, N + 1, [Data | SoFar], S + iolist_size(Data)); {count, From} -> From ! {count, N}, listener(Fd, N, SoFar, S); stop -> ok; Msg -> io:format("Unexpected message: ~p~n", [Msg]), listener(Fd, N, SoFar, S) after 0 -> file:write(Fd, lists:reverse(SoFar)), listener(Fd, N, [], 0) end. write(_Data, 0) -> ok; write(Data, N) -> (?MODULE) ! {data, Data}, write(Data, N - 1). On Fri, Apr 24, 2009 at 4:23 PM, chaitanya Chalasani < chaitanya.chalasani@REDACTED> wrote: > Hi, > > I am facing performance issue with my file logger. The file logger is an > event handler holding the file reference is its state. The performance of > the module is way ahead in the smp disabled erl shell compared with default > smp enabled erl shell. > > I tried ... > case#1 > *Erlang R13B (erts-5.7.1) [source] [rq:1] [async-threads:0] [hipe] > [kernel-poll:false]* > > *Eshell V5.7.1 (abort with ^G)* > *1> testLogger:start("test.log").* > *true* > *2> testLogger:write("Testing...",1000000).* > *{ok,done}* > *3>* > > and > > case#2 > *Erlang R13B (erts-5.7.1) [source] [smp:2:2] [rq:2] [async-threads:0] > [hipe] [kernel-poll:false]* > > *Eshell V5.7.1 (abort with ^G)* > *1> testLogger:start("test.log").* > *true* > *2> testLogger:write("Testing...",1000000).* > *{ok,done}* > *3>* > > > What I observed was - > Case 1: > 1. The testLogger:write("Testing...",1000000) did not return back the > control to the shell until all the messages are written to log. > 2. The data was written at 400 KB/s > > Case 2: > 1. The testLogger:write("Testing...",1000000) return back the control > to the shell with {ok, done} after a short while but the messages where > being written to log even after that. > 2. The data was written at 4 KB/s > 3. I checked in the pman tool it shows current funtion as > io:wait_io_mon_reply/2 and the messages in the message pool are about 880k. > > Below is the code which I tested. > > *start(Filename) -> > register(testLogger,spawn(testLogger,listener,[Filename])).* > > *listener(Filename) ->* > * case file:open(Filename,[append]) of* > * {ok,Fd} -> listener(Fd,0);* > * {error,Reason} -> error_logger:error_msg(Reason)* > * end.* > > *listener(Fd,N) ->* > * receive* > * {data,Data} -> file:write(Fd,Data), listener(Fd,N+1);* > * {count,From} -> From ! {count,N}, listener(Fd,N);* > * {stop,From} -> From ! {stop,success}* > * end.* > > *write(_Data,0) -> {ok,done};* > *write(Data,N) -> testLogger ! {data,Data}, write(Data,N-1).* > > Is there a problem with my code or is it a known issue? > > *------* > *CHAITANYA CHALASANI* > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From per.melin@REDACTED Fri Apr 24 21:08:48 2009 From: per.melin@REDACTED (Per Melin) Date: Fri, 24 Apr 2009 21:08:48 +0200 Subject: [erlang-questions] Low disk logging performance in SMP In-Reply-To: References: <1240582999.17613.35.camel@chaitanya.laptop> Message-ID: Per Melin: > Anders Nygren: >> Per Melin: >>> It is known that once you queue up a few tens of thousand messages >>> into a mailbox your performance drops noticeably for doing a receive. >> >> I hope You meant when doing a SELECTIVE receive, right. > > Of course. I've been away from Erlang for too long (again). I'm really > sorry for the misinformation. At this point I should just be quiet, but I can't help myself. The performance characteristics of this problem makes it look like there's indeed a selective recieve in there somewhere. When opening the file in raw mode I didn't expect that. But: 1) The file:write gets faster and faster as the size of the message queue shrinks. 2) If you change the writer so that it waits for an ack from the listener between each send the problem goes away. I don't have time to learn the ins and outs of the prim_file module, but I did a quick trace and I suspect prim_file:drv_get_response/1 (which does a selective receive) is the culprit. Anyway, here's a fast synchronous version of the original code: start(Filename) -> register(testLogger,spawn(testLogger,listener,[Filename])). listener(Filename) -> case file:open(Filename,[append, raw]) of {ok,Fd} -> listener(Fd,0); {error,Reason} -> error_logger:error_msg(Reason) end. listener(Fd,N) -> receive {data, From, Data} -> file:write(Fd,Data), From ! ack, listener(Fd,N+1); {count,From} -> From ! {count,N}, listener(Fd,N); {stop,From} -> From ! {stop,success} end. write(_Data,0) -> {ok,done}; write(Data,N) -> testLogger ! {data, self(), Data}, receive _ -> ok end, write(Data,N-1). From rvillalta@REDACTED Fri Apr 24 21:29:43 2009 From: rvillalta@REDACTED (Rene Villalta Soto) Date: Fri, 24 Apr 2009 15:29:43 -0400 Subject: [erlang-questions] connect Erlang with Postgre_? References: Message-ID: Hi, how I can to connect Erlang with Postgre? I have the Postgre's Server in other PC Erlang girls are too hot!!! I love this language... -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 3738 bytes Desc: not available URL: From rvillalta@REDACTED Fri Apr 24 21:49:02 2009 From: rvillalta@REDACTED (Rene Villalta Soto) Date: Fri, 24 Apr 2009 15:49:02 -0400 Subject: [erlang-questions] odbc Message-ID: Hi, some of you have some idea how to make a module that connect Erlang with any DBMS? or have make some like that? greeting Rene. From vychodil.hynek@REDACTED Fri Apr 24 21:55:51 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 24 Apr 2009 21:55:51 +0200 Subject: [erlang-questions] Low disk logging performance in SMP In-Reply-To: References: <1240582999.17613.35.camel@chaitanya.laptop> Message-ID: <4d08db370904241255x4f9eee91i49f6799f9914b114@mail.gmail.com> I have no problem with mine version, it does about 5MB/s for me. On Fri, Apr 24, 2009 at 9:08 PM, Per Melin wrote: > Per Melin: > > Anders Nygren: > >> Per Melin: > >>> It is known that once you queue up a few tens of thousand messages > >>> into a mailbox your performance drops noticeably for doing a receive. > >> > >> I hope You meant when doing a SELECTIVE receive, right. > > > > Of course. I've been away from Erlang for too long (again). I'm really > > sorry for the misinformation. > > At this point I should just be quiet, but I can't help myself. > > The performance characteristics of this problem makes it look like > there's indeed a selective recieve in there somewhere. When opening > the file in raw mode I didn't expect that. But: > > 1) The file:write gets faster and faster as the size of the message > queue shrinks. > > 2) If you change the writer so that it waits for an ack from the > listener between each send the problem goes away. > > I don't have time to learn the ins and outs of the prim_file module, > but I did a quick trace and I suspect prim_file:drv_get_response/1 > (which does a selective receive) is the culprit. > > Anyway, here's a fast synchronous version of the original code: > > start(Filename) -> > register(testLogger,spawn(testLogger,listener,[Filename])). > > listener(Filename) -> > case file:open(Filename,[append, raw]) of > {ok,Fd} -> listener(Fd,0); > {error,Reason} -> error_logger:error_msg(Reason) > end. > > listener(Fd,N) -> > receive > {data, From, Data} -> > file:write(Fd,Data), > From ! ack, > listener(Fd,N+1); > {count,From} -> From ! {count,N}, listener(Fd,N); > {stop,From} -> From ! {stop,success} > end. > > write(_Data,0) -> {ok,done}; > write(Data,N) -> > testLogger ! {data, self(), Data}, > receive > _ -> ok > end, > write(Data,N-1). > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tuncer.ayaz@REDACTED Fri Apr 24 21:56:33 2009 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Fri, 24 Apr 2009 21:56:33 +0200 Subject: [erlang-questions] odbc In-Reply-To: References: Message-ID: <4ac8254d0904241256k21e29bcfy61991cba23c20044@mail.gmail.com> On Fri, Apr 24, 2009 at 9:49 PM, Rene Villalta Soto wrote: > > Hi, some of you have some idea how to make a module that connect Erlang with any DBMS? > or have make some like that? greeting Rene. Erlang has an odbc module. Alternatively you could use JInterface with JDBC for access to a wide range of "connectors". Depending on the dbms'es you want to access using one of the existing native Erlang modules may be the best option. From steven.charles.davis@REDACTED Fri Apr 24 21:58:09 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Fri, 24 Apr 2009 12:58:09 -0700 (PDT) Subject: [erlang-questions] odbc In-Reply-To: References: Message-ID: http://www.erlang.org/doc/apps/odbc/part_frame.html On Apr 24, 2:49?pm, "Rene Villalta Soto" wrote: > Hi, some of you have some idea how to make a module that connect Erlang with any DBMS? or have make some like that? greeting Rene. > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From rvillalta@REDACTED Fri Apr 24 22:13:37 2009 From: rvillalta@REDACTED (Rene Villalta Soto) Date: Fri, 24 Apr 2009 16:13:37 -0400 Subject: [erlang-questions] (no subject) Message-ID: Hi I need some help , I have other problem now with Postgres {ok, Ref} = odbc:connect("Driver={SQL Server};Server=10.36.2.199;Port=3306;Database=testLazy;Uid=postgres;Pwd=postgres;", []). ** exception error: no match of right hand side value {error, "No SQL-driver information available. Connection to database failed."} and how I can conform connections strings to others DBMS? greetings Rene Erlang girls are too hot!!! I love this language... From vychodil.hynek@REDACTED Fri Apr 24 22:19:54 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 24 Apr 2009 22:19:54 +0200 Subject: [erlang-questions] Low disk logging performance in SMP In-Reply-To: <4d08db370904241132k71e550e1jaa81da163f58d396@mail.gmail.com> References: <1240582999.17613.35.camel@chaitanya.laptop> <4d08db370904241132k71e550e1jaa81da163f58d396@mail.gmail.com> Message-ID: <4d08db370904241319t14af9964n42ec7635957e0a7c@mail.gmail.com> It seems that block counting is not necessary. I'm taking same performance (~5MB/s measured at 10 million messages) even this version: -module(testLogger). -compile(inline). -export([listener/1, start/1, write/2]). start(Filename) -> Pid = spawn(?MODULE, listener, [Filename]), register(?MODULE, Pid). listener(Filename) -> case file:open(Filename, [append, raw]) of {ok, Fd} -> listener(Fd, 0, []); {error, Reason} -> error_logger:error_msg(Reason) end. listener(Fd, N, [] = SoFar) -> receive {data, Data} -> listener(Fd, N + 1, [Data]); {count, From} -> From ! {count, N}, listener(Fd, N, SoFar); stop -> ok; Msg -> io:format("Unexpected message: ~p~n", [Msg]), listener(Fd, N, SoFar) end; listener(Fd, N, SoFar) -> receive {data, Data} -> listener(Fd, N + 1, [Data | SoFar]); {count, From} -> From ! {count, N}, listener(Fd, N, SoFar); stop -> ok; Msg -> io:format("Unexpected message: ~p~n", [Msg]), listener(Fd, N, SoFar) after 0 -> flush(Fd, N, SoFar) end. flush(Fd, N, Data) -> file:write(Fd, lists:reverse(Data)), listener(Fd, N, []). write(_Data, 0) -> ok; write(Data, N) -> (?MODULE) ! {data, Data}, write(Data, N - 1). On Fri, Apr 24, 2009 at 8:32 PM, Hynek Vychodil wrote: > Try this one, I guess you will be surprised ;-) > > -define(BS, 65536). > > start(Filename) -> > Pid = spawn(?MODULE, listener, [Filename]), > register(?MODULE, Pid). > > listener(Filename) -> > case file:open(Filename, [append, raw]) of > {ok, Fd} -> listener(Fd, 0, [], 0); > {error, Reason} -> error_logger:error_msg(Reason) > end. > > listener(Fd, N, [] = SoFar, 0) -> > receive > {data, Data} -> > listener(Fd, N + 1, [Data], iolist_size(Data)); > {count, From} -> > From ! {count, N}, listener(Fd, N, SoFar, 0); > stop -> ok; > Msg -> > io:format("Unexpected message: ~p~n", [Msg]), > listener(Fd, N, SoFar, 0) > end; > listener(Fd, N, SoFar, S) when S > (?BS) -> > file:write(Fd, lists:reverse(SoFar)), > listener(Fd, N, [], 0); > listener(Fd, N, SoFar, S) -> > receive > {data, Data} -> > listener(Fd, N + 1, [Data | SoFar], > S + iolist_size(Data)); > {count, From} -> > From ! {count, N}, listener(Fd, N, SoFar, S); > stop -> ok; > Msg -> > io:format("Unexpected message: ~p~n", [Msg]), > listener(Fd, N, SoFar, S) > after 0 -> > file:write(Fd, lists:reverse(SoFar)), > listener(Fd, N, [], 0) > end. > > write(_Data, 0) -> ok; > write(Data, N) -> > (?MODULE) ! {data, Data}, write(Data, N - 1). > > On Fri, Apr 24, 2009 at 4:23 PM, chaitanya Chalasani < > chaitanya.chalasani@REDACTED> wrote: > >> Hi, >> >> I am facing performance issue with my file logger. The file logger is an >> event handler holding the file reference is its state. The performance of >> the module is way ahead in the smp disabled erl shell compared with default >> smp enabled erl shell. >> >> I tried ... >> case#1 >> *Erlang R13B (erts-5.7.1) [source] [rq:1] [async-threads:0] [hipe] >> [kernel-poll:false]* >> >> *Eshell V5.7.1 (abort with ^G)* >> *1> testLogger:start("test.log").* >> *true* >> *2> testLogger:write("Testing...",1000000).* >> *{ok,done}* >> *3>* >> >> and >> >> case#2 >> *Erlang R13B (erts-5.7.1) [source] [smp:2:2] [rq:2] [async-threads:0] >> [hipe] [kernel-poll:false]* >> >> *Eshell V5.7.1 (abort with ^G)* >> *1> testLogger:start("test.log").* >> *true* >> *2> testLogger:write("Testing...",1000000).* >> *{ok,done}* >> *3>* >> >> >> What I observed was - >> Case 1: >> 1. The testLogger:write("Testing...",1000000) did not return back the >> control to the shell until all the messages are written to log. >> 2. The data was written at 400 KB/s >> >> Case 2: >> 1. The testLogger:write("Testing...",1000000) return back the control >> to the shell with {ok, done} after a short while but the messages where >> being written to log even after that. >> 2. The data was written at 4 KB/s >> 3. I checked in the pman tool it shows current funtion as >> io:wait_io_mon_reply/2 and the messages in the message pool are about 880k. >> >> Below is the code which I tested. >> >> *start(Filename) -> >> register(testLogger,spawn(testLogger,listener,[Filename])).* >> >> *listener(Filename) ->* >> * case file:open(Filename,[append]) of* >> * {ok,Fd} -> listener(Fd,0);* >> * {error,Reason} -> error_logger:error_msg(Reason)* >> * end.* >> >> *listener(Fd,N) ->* >> * receive* >> * {data,Data} -> file:write(Fd,Data), listener(Fd,N+1);* >> * {count,From} -> From ! {count,N}, listener(Fd,N);* >> * {stop,From} -> From ! {stop,success}* >> * end.* >> >> *write(_Data,0) -> {ok,done};* >> *write(Data,N) -> testLogger ! {data,Data}, write(Data,N-1).* >> >> Is there a problem with my code or is it a known issue? >> >> *------* >> *CHAITANYA CHALASANI* >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvillalta@REDACTED Fri Apr 24 22:43:15 2009 From: rvillalta@REDACTED (Rene Villalta Soto) Date: Fri, 24 Apr 2009 16:43:15 -0400 Subject: [erlang-questions] odbc DBMS References: Message-ID: Hi I need some help , I have other problem now with Postgres {ok, Ref} = odbc:connect("Driver={SQL Server};Server=10.36.2.199;Port=3306;Database=testLazy;Uid=postgres;Pwd=postgres;", []). ** exception error: no match of right hand side value {error, "No SQL-driver information available. Connection to database failed."} and how I can conform connections strings to others DBMS? greetings Rene -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 3822 bytes Desc: not available URL: From per.melin@REDACTED Fri Apr 24 23:05:59 2009 From: per.melin@REDACTED (Per Melin) Date: Fri, 24 Apr 2009 23:05:59 +0200 Subject: [erlang-questions] Low disk logging performance in SMP In-Reply-To: <4d08db370904241255x4f9eee91i49f6799f9914b114@mail.gmail.com> References: <1240582999.17613.35.camel@chaitanya.laptop> <4d08db370904241255x4f9eee91i49f6799f9914b114@mail.gmail.com> Message-ID: Hynek Vychodil: > I have no problem with mine version, it does about 5MB/s for me. I would expect your version to be fast, because you empty the message queue before you write to disk and thus avoids any problems caused by selective recieves in the file modules. From mjtruog@REDACTED Sat Apr 25 03:49:32 2009 From: mjtruog@REDACTED (Michael Truog) Date: Fri, 24 Apr 2009 18:49:32 -0700 Subject: [erlang-questions] odbc DBMS In-Reply-To: References: Message-ID: <49F26C2C.2010503@gmail.com> The two main postgres drivers that are used, since they are native erlang code and less prone to errors than the C port [driver] solution seem to be: https://forge.process-one.net/browse/ejabberd-modules/pgsql http://glozer.net/code.html#epgsql The process-one driver was derived from code here (by Christian Sunesson): http://frihjul.net/pgsql You might want to avoid creating your own, since it has been done at least twice. Rene Villalta Soto wrote: > > > > Hi I need some help , I have other problem now with Postgres > > > {ok, Ref} = odbc:connect("Driver={SQL Server};Server=10.36.2.199;Port=3306;Database=testLazy;Uid=postgres;Pwd=postgres;", []). > ** exception error: no match of right hand side value {error, > "No SQL-driver information available. Connection to database failed."} > > and how I can conform connections strings to others DBMS? > > greetings Rene > > > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From v@REDACTED Sat Apr 25 10:58:23 2009 From: v@REDACTED (Valentin Micic) Date: Sat, 25 Apr 2009 10:58:23 +0200 Subject: [erlang-questions] : : : : : sctp_peeloff() support in OTP In-Reply-To: <20090424153624.GA31837@erix.ericsson.se> Message-ID: <200904250848.n3P8mGRc008077@mail.pharos-avantgard.com> > The question remains if {active,true|false|once,Stream,Pid} > with the side effect that while any stream processor is active > data flows in on all streams and is buffered in the > dispatcher (Port or PID) - only if all stream processors are > passive would the flow be blocked, would be useful? > That would be a complicated concept. What do you think? You are absolutely right -- it may be quite complicated; thus, for the time being at least, not really worth it. This becomes more obvious if you consider how easy it would be to achieve such functionality outside of a driver. There are few things regarding current implementation that would require your attention more urgently. My view is that one should start by consolidating current support and RFC describing SCTP socket API. There are few inconsistencies (in terms of semantic) that I've picked up by just sporadically reading the RFC. There is a good chance that there are more of these, should one read RFC with a bit more dedication. For example, quote: "Note, the send() and recv() calls may not be used for a one-to-many style socket" Chapter 6.1, page 44. Ibid. you would be able to find hints that send() and recv() should be used only to access basic SCTP features (e.g. call to SCTP API send() does not allow specification of the stream, thus always uses a default stream 0). I know that send() and recv() functions implemented by gen_sctp are not really the same calls as specified in RFC, but why not? We can fix this while SCTP is still relatively "young", but the main challenge is how to achieve that and still maintain vertical compatibility with existing applications. Well, maybe you should start a new implementation using a different name, and, why not: sctp? Now, let me get back to earth ;-) Or maybe not just yet: > ... One-to-many associations. > Multi-homed endpoints. Packeted messages... > Those would be important for the Distributed > Erlang protocol. It is unclear if the streams > would be useful. Let Erlang evolve. From the top of my head: authentication and connection management may be handled using a dedicated stream; and how about mnesia replication or, even better, common replication service that could be developed? Or a stream per-scheduler in SMP environment (this one requires a bit more thinking, I suppose)? Kind regards, V. From hpjcon@REDACTED Sat Apr 25 11:26:30 2009 From: hpjcon@REDACTED (Jan Jacobs) Date: Sat, 25 Apr 2009 11:26:30 +0200 Subject: [erlang-questions] connect Erlang with Postgre_? In-Reply-To: References: Message-ID: <49F2D746.60406@mweb.co.za> Hi Rene For the ODBC to work the following needs to be installed and configured on the PC (Windows or Linux Ubuntu) 1) Make sure DB is installed or have access to DB 2) Make sure ODBC driver is installed and is configured. Please have a look at the following web site: http://www.connectionstrings.com/ It has useful information about the connection strings. Postgre will have its own connection string. The one that you should be using is: (Make sure that the ODBC driver is installed first!) PostgreSQL ODBC Driver (psqlODBC) with the connection string below: Driver={PostgreSQL};Server=IP address;Port=5432;Database=myDataBase;Uid=myUsername;Pwd=myPassword; Cheers Jan Rene Villalta Soto wrote: > > > > Hi, how I can to connect Erlang with Postgre? I have the Postgre's Server in other PC > > > > > > > Erlang girls are too hot!!! I love this language... > > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From hpjcon@REDACTED Sat Apr 25 11:42:46 2009 From: hpjcon@REDACTED (Jan Jacobs) Date: Sat, 25 Apr 2009 11:42:46 +0200 Subject: [erlang-questions] odbc DBMS In-Reply-To: References: Message-ID: <49F2DB16.4090101@mweb.co.za> Hi Rene, Use the Erlang ODBC, switching between DBs is easy, just change the connection string. Look at http://www.connectionstrings.com/ for the connection strings. See examples below: SQL Server: ( MSSQL 2000, 2005 and 2008) Str = "Driver={SQL Server};Server=JAN03;Database=TestDB;Uid=test;Pwd=testpassword;". f(Ref), {ok,Ref} = (catch odbc:connect( Str, [{timeout, 75000}, {scrollable_cursors, off}] )). {selected, ColList, ValueList} = (catch odbc:sql_query( Ref, "select * from tbl_system;", 45000 )). odbc:disconnect( Ref ). MySQL: Str = "Driver={MySQL ODBC 3.51 Driver};Server=JAN03;Port=3306;Database=TestDB;User=test;Password=testpassword;Option=3;". f(Ref), {ok,Ref} = (catch odbc:connect( Str, [{timeout, 75000}, {scrollable_cursors, off}] )). {selected, ColList, ValueList} = (catch odbc:sql_query( Ref, "select * from tbl_system;", 45000 )). odbc:disconnect( Ref ). Firebird: Str = "Driver=Firebird/InterBase(r) driver;Uid=SYSDBA;Pwd=masterkey;DbName=C:\DeepBlue\TestDB.FDB". f(Ref), {ok,Ref} = (catch odbc:connect( Str, [{timeout, 75000}, {scrollable_cursors, off}] )). {selected, ColList, ValueList} = (catch odbc:sql_query( Ref, "select * from tbl_system;", 45000 )). odbc:disconnect( Ref ). Postgre: Str = "Driver={PostgreSQL ANSI};Server=JAN03;Port=5432;Database=TestDB;Uid=test;Pwd=testpassword;". f(Ref), {ok,Ref} = (catch odbc:connect( Str, [{timeout, 75000}, {scrollable_cursors, off}] )). {selected, ColList, ValueList} = (catch odbc:sql_query( Ref, "select * from tbl_system;", 45000 )). odbc:disconnect( Ref ). I actively using SQL Server, MySQL, Firebird. I occasionally use Postgre Oracle, Interbase, Access and Excel Cheers Jan Rene Villalta Soto wrote: > > > > Hi I need some help , I have other problem now with Postgres > > > {ok, Ref} = odbc:connect("Driver={SQL Server};Server=10.36.2.199;Port=3306;Database=testLazy;Uid=postgres;Pwd=postgres;", []). > ** exception error: no match of right hand side value {error, > "No SQL-driver information available. Connection to database failed."} > > and how I can conform connections strings to others DBMS? > > greetings Rene > > > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From q2h46uw02@REDACTED Sat Apr 25 19:28:04 2009 From: q2h46uw02@REDACTED (Kevin) Date: Sat, 25 Apr 2009 13:28:04 -0400 Subject: [erlang-questions] List matching, help me make this look better Message-ID: <19114-65259@sneakemail.com> As an example I want to read a file, line by line, and pass the line into a function, and it want it to match on the first 4 characters. In the example I'm matching on "aaaa", "bbbb", "cccc". Lines in the file would look like this aaaa 123 bbbb 234 cccc 345 dddd 456 ... using the functions below works fine, as well as something similar using a case statement: myfunc([$a, $a, $a, $a | _]) -> io:format("matched aaaa~n"); myfunc([$b, $b, $b, $b | _]) -> io:format("matched bbbb~n"); myfunc([$c, $c, $c, $c | _]) -> io:format("matched cccc~n"); myfunc(_) -> io:format("no matches~n"). My dissatisfaction is I'm taking the elegance of pattern matching in function params and making it ugly with $a, $a, $a, $a. Is there anyway to "explode" a list like "aaaa" (borrowing that term from ruby), or some other matching trick I'm missing?? Obviously ["aaaa"|_] won't work because its really just [ [$a, $a, $a, $a] | _ ] One thing I tried was passing in a split tuple, but that feels more like a work-around {"aaaa", _} = lists:split(4, "aaaa 1234"). I also tried converting everything to binaries but that traded ugly for ugly. Thanks, -kevin From kostis@REDACTED Sat Apr 25 19:44:51 2009 From: kostis@REDACTED (Kostis Sagonas) Date: Sat, 25 Apr 2009 20:44:51 +0300 Subject: [erlang-questions] List matching, help me make this look better In-Reply-To: <19114-65259@sneakemail.com> References: <19114-65259@sneakemail.com> Message-ID: <49F34C13.403@cs.ntua.gr> Kevin wrote: > As an example I want to read a file, line by line, and pass the line > into a function, and it want it to match > on the first 4 characters. In the example I'm matching on "aaaa", > "bbbb", "cccc". > > Lines in the file would look like this > aaaa 123 > bbbb 234 > cccc 345 > dddd 456 > ... > > > using the functions below works fine, as well as something similar using > a case statement: > > myfunc([$a, $a, $a, $a | _]) -> > io:format("matched aaaa~n"); > > myfunc([$b, $b, $b, $b | _]) -> > io:format("matched bbbb~n"); > > myfunc([$c, $c, $c, $c | _]) -> > io:format("matched cccc~n"); > > myfunc(_) -> > io:format("no matches~n"). > > My dissatisfaction is I'm taking the elegance of pattern matching in > function params and making it ugly with > $a, $a, $a, $a. Is there anyway to "explode" a list like "aaaa" > (borrowing that term from ruby), or some other matching trick I'm missing?? Yes. Write: myfunc("aaaa" ++ _) -> io:format("matched aaaa~n"); instead. Works also as: myfunc("aaaa " ++ R) -> io:format("matthed aaaa~n"), io:format("R matches 123 in your example file"); Kostis From vinoski@REDACTED Sat Apr 25 20:01:16 2009 From: vinoski@REDACTED (Steve Vinoski) Date: Sat, 25 Apr 2009 14:01:16 -0400 Subject: [erlang-questions] List matching, help me make this look better In-Reply-To: <19114-65259@sneakemail.com> References: <19114-65259@sneakemail.com> Message-ID: <65b2728e0904251101p141d55e2ud4b9afd74711fa84@mail.gmail.com> On 4/25/09, Kevin wrote: > > As an example I want to read a file, line by line, and pass the line > into a function, and it want it to match > on the first 4 characters. In the example I'm matching on "aaaa", > "bbbb", "cccc". See Kostis's reply for the answer, but I just wanted to comment on the following: > I also tried converting everything to binaries but that traded ugly for > ugly. Not sure why you'd call the binary approach ugly -- just rewriting your example a bit yields: myfunc(<<"aaaa", _/binary>>) -> io:format("matched aaaa~n"); myfunc(<<"bbbb", _/binary>>) -> io:format("matched bbbb~n"); myfunc(<<"cccc", _/binary>>) -> io:format("matched cccc~n"); myfunc(_) -> io:format("no matches~n"). --steve From exta7@REDACTED Sat Apr 25 20:49:29 2009 From: exta7@REDACTED (Zvi) Date: Sat, 25 Apr 2009 11:49:29 -0700 (PDT) Subject: [erlang-questions] why prefixing module name with '.' works? Message-ID: <23235234.post@talk.nabble.com> Notice '.' in front of 'lists' module name. Is this somehow connected to module namespaces? 1> lists:seq(1,10). [1,2,3,4,5,6,7,8,9,10] 2> .lists:seq(1,10). [1,2,3,4,5,6,7,8,9,10] 3> . lists:seq(1,10). * 1: syntax error before: '.' BR, Zvi -- View this message in context: http://www.nabble.com/why-prefixing-module-name-with-%27.%27-works--tp23235234p23235234.html Sent from the Erlang Questions mailing list archive at Nabble.com. From jarrod@REDACTED Sat Apr 25 22:05:57 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Sat, 25 Apr 2009 16:05:57 -0400 Subject: [erlang-questions] List matching, help me make this look better In-Reply-To: <49F34C13.403@cs.ntua.gr> References: <19114-65259@sneakemail.com> <49F34C13.403@cs.ntua.gr> Message-ID: > > myfunc("aaaa" ++ _) -> > io:format("matched aaaa~n"); > > instead. Works also as: > > myfunc("aaaa " ++ R) -> > io:format("matthed aaaa~n"), > io:format("R matches 123 in your example file"); can somebody explain what the ++ operator is called and is doing there? -------------- next part -------------- An HTML attachment was scrubbed... URL: From francesco@REDACTED Sat Apr 25 22:40:28 2009 From: francesco@REDACTED (Francesco Cesarini (Erlang Training and Consulting)) Date: Sat, 25 Apr 2009 21:40:28 +0100 Subject: [erlang-questions] connect Erlang with Postgre_? In-Reply-To: References: Message-ID: <49F3753C.1020904@erlang-consulting.com> You can use our PostgreSQL driver available at http://www.erlang-consulting.com/erlang/opensource.html Regards, Francesco -- http://www.erlang-consulting.com Rene Villalta Soto wrote: > > > > Hi, how I can to connect Erlang with Postgre? I have the Postgre's Server in other PC > > > > > > > Erlang girls are too hot!!! I love this language... > > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From gleber.p@REDACTED Sat Apr 25 23:10:36 2009 From: gleber.p@REDACTED (Gleb Peregud) Date: Sat, 25 Apr 2009 23:10:36 +0200 Subject: [erlang-questions] List matching, help me make this look better In-Reply-To: References: <19114-65259@sneakemail.com> <49F34C13.403@cs.ntua.gr> Message-ID: <14f0e3620904251410w7dba48a4nd6edf3f8627bf552@mail.gmail.com> On Sat, Apr 25, 2009 at 22:05, Jarrod Roberson wrote: >> ? myfunc("aaaa " ++ R) -> >> ? ? ? io:format("matthed aaaa~n"), >> ? ? ? io:format("R matches 123 in your example file"); > > can somebody explain what the ++ operator is called and is doing there? AFAIK code myfunc("abc" ++ R) -> ok. is just a syntactic sugar for the code: myfunc([$a, $b, $c | R]) -> ok. So operator ++ is just compiled into the appropriate matching code. It works everywhere where pattern matching is performed. From ulf.wiger@REDACTED Sat Apr 25 23:19:23 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 25 Apr 2009 23:19:23 +0200 Subject: [erlang-questions] List matching, help me make this look better In-Reply-To: References: <19114-65259@sneakemail.com> <49F34C13.403@cs.ntua.gr> Message-ID: <49F37E5B.2070403@erlang-consulting.com> Jarrod Roberson wrote: > myfunc("aaaa" ++ _) -> > io:format("matched aaaa~n"); > > instead. Works also as: > > myfunc("aaaa " ++ R) -> > io:format("matthed aaaa~n"), > io:format("R matches 123 in your example file"); > > > can somebody explain what the ++ operator is called and is doing there? "aaaa" ++ R is syntactic sugar for [$a,$a,$a,$a|R]. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From nesrait@REDACTED Sun Apr 26 03:18:20 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Sun, 26 Apr 2009 02:18:20 +0100 Subject: [erlang-questions] why prefixing module name with '.' works? In-Reply-To: <23235234.post@talk.nabble.com> References: <23235234.post@talk.nabble.com> Message-ID: <523869a70904251818h4d4d9b5j7e2e71f3370da233@mail.gmail.com> Hi Zvi! Your guess was right: http://erlang.org/doc/man/packages.html If you are thinking about using packages keep in mind the warning from the documentation: > Packages has since it was introduced more than 5 years ago been an experimental feature. Use it at your own risk, we do not actively maintain and develop this feature. It might however be supported some day. > In spite of this packages work quite well, but there are some known issues in tools and other parts where packages don't work well. Packages are cool :) for preventing code clashes but relying on then too much will get you to the "known issues" bit. A while back I used then to run various (erlyweb) webapps under the same webserver but it took some big chances to erlyweb itself. P.S. - One issue I did spot in the wild is/was that code:where_is_file/1 wasn't ready to lookup in subdirectories or use relative paths to find "packaged" beam files. Cheers, Davide :) On Sat, Apr 25, 2009 at 7:49 PM, Zvi wrote: > > Notice '.' in front of 'lists' module name. > Is this somehow connected to module namespaces? > > 1> lists:seq(1,10). > [1,2,3,4,5,6,7,8,9,10] > > 2> .lists:seq(1,10). > [1,2,3,4,5,6,7,8,9,10] > > 3> . lists:seq(1,10). > * 1: syntax error before: '.' > > BR, > Zvi > > -- > View this message in context: http://www.nabble.com/why-prefixing-module-name-with-%27.%27-works--tp23235234p23235234.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ljw1001@REDACTED Sun Apr 26 03:36:17 2009 From: ljw1001@REDACTED (Larry White) Date: Sat, 25 Apr 2009 21:36:17 -0400 Subject: [erlang-questions] Noob question about records Message-ID: I'm on my second day of erlang and getting a compiler error while experimenting with Records. Could someone steer me right? -module(money). -export([add/2]). -record(money, { currency = usd, amount = 0 }). add(Money1, Money2) -> #money{currency=Cur1, amount=Amt1} = Money1. #money{currency=Cur2, amount=Amt2} = Money2. %% TODO: Check to see that the currencies are the same and throw exception if not Total = Amt1 + Amt2. #money{currency=Cur1,amount=Total}. The error I get is: ./money.erl:9: syntax error before: '#' ./money.erl:11: syntax error before: Total ./money.erl:12: syntax error before: '#' The statement " #money{currency=Cur1, amount=Amt1} = Money1." seems to work fine from the command line. Also, I tried a number of variants: using a guard for example in the function header, but couldn't figure out the right syntax for two guards : when record(Money1, money) ...?... (Money2, money). Also I tried using C1 = Money1#money.currency. - but the next line caused a syntax error. Finally, apologies if this gets double posted. I sent one about 6 hours ago but i don't think my subscription was active then. -------------- next part -------------- An HTML attachment was scrubbed... URL: From thatsnotright@REDACTED Sun Apr 26 03:44:13 2009 From: thatsnotright@REDACTED (Rob Elsner) Date: Sat, 25 Apr 2009 19:44:13 -0600 Subject: [erlang-questions] Noob question about records In-Reply-To: References: Message-ID: Larry, A few notes: You have a period (.) where you need a comma (,) for both match lines. You also need a variable name add(Money1, Money2) -> M1 = #money{currency=Cur1, amount=Amt1} = Money1, M2 = #money{currency=Cur2, amount=Amt2} = Money2, On Sat, Apr 25, 2009 at 7:36 PM, Larry White wrote: > I'm on my second day of erlang and getting a compiler error while > experimenting with Records. Could someone steer me right? > > -module(money). > -export([add/2]). > > -record(money, { currency = usd, amount = 0 }). > > add(Money1, Money2) -> > ? ? ? ?#money{currency=Cur1, amount=Amt1} = Money1. > ? ? ? ?#money{currency=Cur2, amount=Amt2} = Money2. > ? ? ? ?%% TODO: Check to see that the currencies are the same and throw > exception if not > ? ? ? ?Total = Amt1 + Amt2. > ? ? ? ?#money{currency=Cur1,amount= > Total}. > > The error I get is: > ./money.erl:9: syntax error before: '#' > ./money.erl:11: syntax error before: Total > ./money.erl:12: syntax error before: '#' > > The statement " #money{currency=Cur1, amount=Amt1} = Money1." seems to > work fine from the command line. > > Also, I tried a number of variants: using a guard for example in the > function header, but couldn't figure out the right syntax for two guards : > when record(Money1, money) ...?... (Money2, money). > > Also I tried using C1 = Money1#money.currency.? - but the next line caused a > syntax error. > > Finally, apologies if this gets double posted. I sent one about 6 hours ago > but i don't think my subscription was active then. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ljw1001@REDACTED Sun Apr 26 03:45:07 2009 From: ljw1001@REDACTED (Larry White) Date: Sat, 25 Apr 2009 21:45:07 -0400 Subject: [erlang-questions] Noob question about records In-Reply-To: References: Message-ID: doh. thanks. On Sat, Apr 25, 2009 at 9:42 PM, Paul Fisher wrote: > Nothing to do with records. You need commas at the end of statements > within the function, and period on last statement. > > -- > paul > > On Apr 25, 2009, at 8:35 PM, "Larry White" wrote: > > > I'm on my second day of erlang and getting a compiler error while > > experimenting with Records. Could someone steer me right? > > > > -module(money). > > -export([add/2]). > > > > -record(money, { currency = usd, amount = 0 }). > > > > add(Money1, Money2) -> > > #money{currency=Cur1, amount=Amt1} = Money1. > > #money{currency=Cur2, amount=Amt2} = Money2. > > %% TODO: Check to see that the currencies are the same and > > throw > > exception if not > > Total = Amt1 + Amt2. > > #money{currency=Cur1,amount= > > Total}. > > > > The error I get is: > > ./money.erl:9: syntax error before: '#' > > ./money.erl:11: syntax error before: Total > > ./money.erl:12: syntax error before: '#' > > > > The statement " #money{currency=Cur1, amount=Amt1} = Money1." seems to > > work fine from the command line. > > > > Also, I tried a number of variants: using a guard for example in the > > function header, but couldn't figure out the right syntax for two > > guards : when record(Money1, money) ...?... (Money2, money). > > > > Also I tried using C1 = Money1#money.currency. - but the next line > > caused a syntax error. > > > > Finally, apologies if this gets double posted. I sent one about 6 > > hours ago but i don't think my subscription was active then. > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangy@REDACTED Sun Apr 26 03:47:09 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Sat, 25 Apr 2009 18:47:09 -0700 Subject: [erlang-questions] Noob question about records In-Reply-To: References: Message-ID: <20090426014709.GF29476@delora.autosys.us> a dot '.' is a fun terminator ; change the other '.' to be commas ',' On Sat, Apr 25, 2009 at 09:36:17PM -0400, Larry White wrote: > I'm on my second day of erlang and getting a compiler error while > experimenting with Records. Could someone steer me right? > -module(money). > -export([add/2]). > -record(money, { currency = usd, amount = 0 }). > add(Money1, Money2) -> > #money{currency=Cur1, amount=Amt1} = Money1. > #money{currency=Cur2, amount=Amt2} = Money2. > %% TODO: Check to see that the currencies are the same and throw > exception if not > Total = Amt1 + Amt2. > #money{currency=Cur1,amount= > > Total}. > The error I get is: > ./money.erl:9: syntax error before: '#' > ./money.erl:11: syntax error before: Total > ./money.erl:12: syntax error before: '#' > The statement " #money{currency=Cur1, amount=Amt1} = Money1." seems to > work fine from the command line. > Also, I tried a number of variants: using a guard for example in the > function header, but couldn't figure out the right syntax for two > guards : when record(Money1, money) ...?... (Money2, money). > Also I tried using C1 = Money1#money.currency. - but the next line > caused a syntax error. > Finally, apologies if this gets double posted. I sent one about 6 hours > ago but i don't think my subscription was active then. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://trip.autosys.us http://autosys.us http://mmcdaniel.com/erlview From thatsnotright@REDACTED Sun Apr 26 03:48:27 2009 From: thatsnotright@REDACTED (Rob Elsner) Date: Sat, 25 Apr 2009 19:48:27 -0600 Subject: [erlang-questions] Noob question about records In-Reply-To: References: Message-ID: So I need to stop using gmail because I hit the wrong button all the time and it sends an early email. Sigh! add(Money1, Money2) -> ? ? ? ?#money{currency=Cur1, amount=Amt1} = Money1, ? ? ? ?#money{currency=Cur2, amount=Amt2} = Money2, #money{currency=kre, amount=Amt1+Amt2}. My bad for the previous email. Rob >> -module(money). >> -export([add/2]). >> >> -record(money, { currency = usd, amount = 0 }). >> >> add(Money1, Money2) -> >> ? ? ? ?#money{currency=Cur1, amount=Amt1} = Money1. >> ? ? ? ?#money{currency=Cur2, amount=Amt2} = Money2. >> ? ? ? ?%% TODO: Check to see that the currencies are the same and throw >> exception if not >> ? ? ? ?Total = Amt1 + Amt2. >> ? ? ? ?#money{currency=Cur1,amount= >> Total}. >> >> The error I get is: >> ./money.erl:9: syntax error before: '#' >> ./money.erl:11: syntax error before: Total >> ./money.erl:12: syntax error before: '#' >> >> The statement " #money{currency=Cur1, amount=Amt1} = Money1." seems to >> work fine from the command line. >> >> Also, I tried a number of variants: using a guard for example in the >> function header, but couldn't figure out the right syntax for two guards : >> when record(Money1, money) ...?... (Money2, money). >> >> Also I tried using C1 = Money1#money.currency.? - but the next line caused a >> syntax error. >> >> Finally, apologies if this gets double posted. I sent one about 6 hours ago >> but i don't think my subscription was active then. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From vinoski@REDACTED Sun Apr 26 04:54:04 2009 From: vinoski@REDACTED (Steve Vinoski) Date: Sat, 25 Apr 2009 22:54:04 -0400 Subject: [erlang-questions] Noob question about records In-Reply-To: References: Message-ID: <65b2728e0904251954k77eb2b3m2e05b1007a19c2d9@mail.gmail.com> On 4/25/09, Larry White wrote: > -record(money, { currency = usd, amount = 0 }). > > add(Money1, Money2) -> > #money{currency=Cur1, amount=Amt1} = Money1. > #money{currency=Cur2, amount=Amt2} = Money2. > %% TODO: Check to see that the currencies are the same and throw > exception if not > Total = Amt1 + Amt2. > #money{currency=Cur1,amount= > Total}. Note that you don't need to check the currencies and throw an exception in the manner your comment suggests. Do this instead: add(#money{currency = C, amount = Amt1}, #money{currency = C, amount = Amt2}) -> #money{currency = C, amount = Amt1 + Amt2}. Let pattern matching do the work for you. --steve From ahmed.nawras@REDACTED Sun Apr 26 09:21:36 2009 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Sun, 26 Apr 2009 11:21:36 +0400 Subject: [erlang-questions] Low disk logging performance in SMP In-Reply-To: References: <1240582999.17613.35.camel@chaitanya.laptop> <4d08db370904241255x4f9eee91i49f6799f9914b114@mail.gmail.com> Message-ID: Hi, I guess this is similar to the findings in the blogs below. I didn't know selective receives are so slow but apparently you are right, sync processing is much better for these kind of situations. I always thought this is due to bad IO performance. http://blogtrader.net/dcaoyuan/entry/a_case_study_of_scalable http://blogtrader.net/dcaoyuan/entry/async_or_sync_log_in Having said that, I'm curious of a solution to the selective receive slowness in erlang. Does any one think a solution like appending messages to BDB-style persistent queues or memcacheq helps? This is particularly useful in cases where high load could lead to large queues and possibly a crash. I've seen such a solution in a telecom application which is working quite fine. http://log4erl.blogspot.com/2009/04/log4erl-issue-when-high-load.html Best regards, Ahmed On Sat, Apr 25, 2009 at 1:05 AM, Per Melin wrote: > Hynek Vychodil: >> I have no problem with mine version, it does about 5MB/s for me. > > I would expect your version to be fast, because you empty the message > queue before you write to disk and thus avoids any problems caused by > selective recieves in the file modules. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ljw1001@REDACTED Sun Apr 26 17:06:35 2009 From: ljw1001@REDACTED (ljw1001) Date: Sun, 26 Apr 2009 11:06:35 -0400 Subject: [erlang-questions] Noob question about records In-Reply-To: <65b2728e0904251954k77eb2b3m2e05b1007a19c2d9@mail.gmail.com> References: <65b2728e0904251954k77eb2b3m2e05b1007a19c2d9@mail.gmail.com> Message-ID: <209D5F7A-19A6-4992-92B5-98E65EB51F22@gmail.com> Ah, now that's nice code. I'm clearly not thinking in Erlang yet. Is there any advantage to learning Haskell or another functional language first? I have Joe's book, but I haven't found anything to help me get the hang of functional programming specifically for Erlang. Sent from my iPhone On Apr 25, 2009, at 10:54 PM, Steve Vinoski wrote: > On 4/25/09, Larry White wrote: >> -record(money, { currency = usd, amount = 0 }). >> >> add(Money1, Money2) -> >> #money{currency=Cur1, amount=Amt1} = Money1. >> #money{currency=Cur2, amount=Amt2} = Money2. >> %% TODO: Check to see that the currencies are the same and >> throw >> exception if not >> Total = Amt1 + Amt2. >> #money{currency=Cur1,amount= >> Total}. > > Note that you don't need to check the currencies and throw an > exception in the manner your comment suggests. Do this instead: > > add(#money{currency = C, amount = Amt1}, #money{currency = C, amount > = Amt2}) -> > #money{currency = C, amount = Amt1 + Amt2}. > > Let pattern matching do the work for you. > > --steve From jynlix@REDACTED Sun Apr 26 17:08:00 2009 From: jynlix@REDACTED (jynlix Sr.Wang) Date: Sun, 26 Apr 2009 23:08:00 +0800 Subject: [erlang-questions] BEAM details Message-ID: <37f5c42d0904260808p44bea5c4x397ba741b4562b1a@mail.gmail.com> Hi all, How BEAM preloads its modules? When I read the BEAM code, I am confused with the global "pre_loaded" because I can not find where it is initalised. Can anyone show me more instructions about BEAM? Thanks first. -- Yours jynlix Sr.Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon@REDACTED Sun Apr 26 18:05:00 2009 From: gordon@REDACTED (Gordon Guthrie) Date: Sun, 26 Apr 2009 17:05:00 +0100 Subject: [erlang-questions] Noob question about records In-Reply-To: <209D5F7A-19A6-4992-92B5-98E65EB51F22@gmail.com> References: <65b2728e0904251954k77eb2b3m2e05b1007a19c2d9@mail.gmail.com> <209D5F7A-19A6-4992-92B5-98E65EB51F22@gmail.com> Message-ID: Larry wrote: > Ah, now that's nice code. I'm clearly not thinking in Erlang yet. Is > there any advantage to learning Haskell or another functional language > first? I found going from OO to FP as hard as going from Fortran to C++ - there is no substitute for slogging it out I'm afraid. The good news is that after 3 years you will lose your ability to read OO languages like Ruby... The bad news is then you will need to build both ends of a website and the Gates Of Hell will swing open when you load Javascript into an editor... Gordon On Sun, Apr 26, 2009 at 4:06 PM, ljw1001 wrote: > Ah, now that's nice code. I'm clearly not thinking in Erlang yet. Is > there any advantage to learning Haskell or another functional language > first? I have Joe's book, but I haven't found anything to help me get > the hang of functional programming specifically for Erlang. > > Sent from my iPhone > > On Apr 25, 2009, at 10:54 PM, Steve Vinoski wrote: > >> On 4/25/09, Larry White wrote: >>> -record(money, { currency = usd, amount = 0 }). >>> >>> add(Money1, Money2) -> >>> ? ? ? ?#money{currency=Cur1, amount=Amt1} = Money1. >>> ? ? ? ?#money{currency=Cur2, amount=Amt2} = Money2. >>> ? ? ? ?%% TODO: Check to see that the currencies are the same and >>> throw >>> exception if not >>> ? ? ? ?Total = Amt1 + Amt2. >>> ? ? ? ?#money{currency=Cur1,amount= >>> Total}. >> >> Note that you don't need to check the currencies and throw an >> exception in the manner your comment suggests. Do this instead: >> >> add(#money{currency = C, amount = Amt1}, #money{currency = C, amount >> = Amt2}) -> >> ? ?#money{currency = C, amount = Amt1 + Amt2}. >> >> Let pattern matching do the work for you. >> >> --steve > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From amit.murthy@REDACTED Sun Apr 26 18:57:31 2009 From: amit.murthy@REDACTED (Amit Murthy) Date: Sun, 26 Apr 2009 22:27:31 +0530 Subject: [erlang-questions] Passing records vs Mnesia lookups Message-ID: <4f5fdb630904260957l322c58ffjf120f7bacf8718ea@mail.gmail.com> Hi, I have an optimization question. Consider the following scenario: - I have, say around 40,000 long running processes. Each represents an online user and keeps some user related data in the process dictionary. - I need each of the processes to perform some computation against a long record that I'll send as a message. - The long record (around 40 fields, mostly short strings) is also available in an mnesia RAM only table So the question is Is it better to read the record from mnesia once and send the complete record to each of the 40,000 processes or Is it better to just send the key in the message and have each of the processes do an mnesia lookup The reason, I ask this is because the Efficiency Guide explicitly states that "All data in messages between Erlang processes is copied, with the exception of refc binaries on the same Erlang node." Regards, Amit -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarrod@REDACTED Sun Apr 26 20:31:10 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Sun, 26 Apr 2009 14:31:10 -0400 Subject: [erlang-questions] Passing records vs Mnesia lookups In-Reply-To: <4f5fdb630904260957l322c58ffjf120f7bacf8718ea@mail.gmail.com> References: <4f5fdb630904260957l322c58ffjf120f7bacf8718ea@mail.gmail.com> Message-ID: > > So the question is > > Is it better to read the record from mnesia once and send the complete > record to each of the 40,000 processes > > or > > Is it better to just send the key in the message and have each of the > processes do an mnesia lookup why not do both and measure the performance and that will give you your answer. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wde@REDACTED Sun Apr 26 22:29:59 2009 From: wde@REDACTED (wde) Date: Sun, 26 Apr 2009 22:29:59 +0200 Subject: [erlang-questions] Erlang node administration in production environment Message-ID: <20090426203000.8F8597000086@msfrf2214.sfr.fr> Hello all, I have a general question about erlang node administration. In my lab, I start the nodes in interactive mode with a shell through a SSH connection to my servers. It's really useful to have an erlang shell in order to debug, run specific functions to monitor or analyze your application. My question is, how do you interact with an Erlang node in a production environment when the node is started in "detached" mode without shell ? Do you add a new node to the cluster and use RPC to remotely execute command on the target node ? Do you start a new node with a remote shell connected to a target node by using the -remsh flag ? Other options ? Thank you by advance for your responses and your feedbacks. wde From ulf@REDACTED Sun Apr 26 22:58:47 2009 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 26 Apr 2009 22:58:47 +0200 Subject: [erlang-questions] Passing records vs Mnesia lookups In-Reply-To: <4f5fdb630904260957l322c58ffjf120f7bacf8718ea@mail.gmail.com> References: <4f5fdb630904260957l322c58ffjf120f7bacf8718ea@mail.gmail.com> Message-ID: <8209f740904261358w19d9d44dj23128c5381182492@mail.gmail.com> 2009/4/26 Amit Murthy : > > So the question is > > Is it better to read the record from mnesia once and send the complete > record to each of the 40,000 processes > > or > > Is it better to just send the key in the message and have each of the > processes do an mnesia lookup > > The reason, I ask this is because the Efficiency Guide explicitly states > that > > "All data in messages between Erlang processes is copied, with the exception > of refc binaries on the same Erlang node." Reads from ets are also copying, so you end up copying in either case. However, even mnesia:dirty_read() results in more ETS reads than just the object. Mnesia has to find out where to read the object (it may not be local) and what type of storage the table has, if the table exists locally. Furthermore, ETS reads are protected by mutexes (on SMP). So is message passing, of course, but the probability of lock contention is very much smaller with message passing. BR, Ulf W From icarmenates@REDACTED Mon Apr 27 01:12:54 2009 From: icarmenates@REDACTED (Ivan Carmenates Garcia) Date: Sun, 26 Apr 2009 19:12:54 -0400 Subject: [erlang-questions] how to create user-defined guards References: Message-ID: Hi all, I have a problem if for example I have an mnesia cosult like this get_students()-> F = fun()-> mnesia:select(person_table, [{#person_table{ id ='$1', name ='$2', group ='$3', type ='$4', id_card ='$5', user ='$6'}, [{'=:=', {is_student,'$4'}, true}], ['$_']}]) end, mnesia:transaction(F). is_student(X)-> if X == "Estudiante"-> true; true-> false end. that's only accept guards, for exaple changing [{'=:=', {is_student,'$4'}, true}], by [{'=:=', {is_list,'$4'}, true}], then that work fine because is_list is a guard, but I need to check for more complex criterias, but using my own funtion criteria I just got {aborted,{badarg,[person_table, [{{person_table,'$1','$2','$3','$4','$5','$6'}, [{'=:=',{is_student,'$4'},true}], ['$5']}]]}} because is_student is not valid guard. How can I simulate or make my own guard or do something else to resolve this problem. -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 5770 bytes Desc: not available URL: From chaitanya.chalasani@REDACTED Mon Apr 27 07:36:08 2009 From: chaitanya.chalasani@REDACTED (chaitanya Chalasani) Date: Mon, 27 Apr 2009 11:06:08 +0530 Subject: [erlang-questions] Low disk logging performance in SMP In-Reply-To: <4d08db370904241319t14af9964n42ec7635957e0a7c@mail.gmail.com> References: <1240582999.17613.35.camel@chaitanya.laptop> <4d08db370904241132k71e550e1jaa81da163f58d396@mail.gmail.com> <4d08db370904241319t14af9964n42ec7635957e0a7c@mail.gmail.com> Message-ID: <1240810568.4311.9.camel@chaitanya.laptop> Thank you very much it works great. We are using gen_event with multiple file logging handlers for each module and also simultaneous logging into different files for debug, normal and panic messages. In this case we have to use selective receive. I think this suffices our logging hunger of about 1000 transactions/sec. I need to test more for further scaling. On Fri, 2009-04-24 at 22:19 +0200, Hynek Vychodil wrote: > It seems that block counting is not necessary. I'm taking same > performance (~5MB/s measured at 10 million messages) even this > version: > > -module(testLogger). > > -compile(inline). > > -export([listener/1, start/1, write/2]). > > start(Filename) -> > Pid = spawn(?MODULE, listener, [Filename]), > register(?MODULE, Pid). > > listener(Filename) -> > case file:open(Filename, [append, raw]) of > {ok, Fd} -> listener(Fd, 0, []); > {error, Reason} -> error_logger:error_msg(Reason) > end. > > listener(Fd, N, [] = SoFar) -> > receive > {data, Data} -> listener(Fd, N + 1, [Data]); > {count, From} -> > From ! {count, N}, listener(Fd, N, SoFar); > stop -> ok; > Msg -> > io:format("Unexpected message: ~p~n", [Msg]), > listener(Fd, N, SoFar) > end; > listener(Fd, N, SoFar) -> > receive > {data, Data} -> listener(Fd, N + 1, [Data | SoFar]); > {count, From} -> > From ! {count, N}, listener(Fd, N, SoFar); > stop -> ok; > Msg -> > io:format("Unexpected message: ~p~n", [Msg]), > listener(Fd, N, SoFar) > after 0 -> flush(Fd, N, SoFar) > end. > > flush(Fd, N, Data) -> > file:write(Fd, lists:reverse(Data)), > listener(Fd, N, []). > > write(_Data, 0) -> ok; > write(Data, N) -> > (?MODULE) ! {data, Data}, write(Data, N - 1). > > > On Fri, Apr 24, 2009 at 8:32 PM, Hynek Vychodil > wrote: > > Try this one, I guess you will be surprised ;-) > > -define(BS, 65536). > > start(Filename) -> > Pid = spawn(?MODULE, listener, [Filename]), > register(?MODULE, Pid). > > listener(Filename) -> > case file:open(Filename, [append, raw]) of > {ok, Fd} -> listener(Fd, 0, [], 0); > > > {error, Reason} -> error_logger:error_msg(Reason) > end. > > > > listener(Fd, N, [] = SoFar, 0) -> > receive > {data, Data} -> > listener(Fd, N + 1, [Data], iolist_size(Data)); > {count, From} -> > From ! {count, N}, listener(Fd, N, SoFar, 0); > stop -> ok; > > > Msg -> > io:format("Unexpected message: ~p~n", [Msg]), > > > listener(Fd, N, SoFar, 0) > end; > listener(Fd, N, SoFar, S) when S > (?BS) -> > file:write(Fd, lists:reverse(SoFar)), > listener(Fd, N, [], 0); > listener(Fd, N, SoFar, S) -> > receive > {data, Data} -> > listener(Fd, N + 1, [Data | SoFar], > S + iolist_size(Data)); > {count, From} -> > From ! {count, N}, listener(Fd, N, SoFar, S); > stop -> ok; > > > Msg -> > io:format("Unexpected message: ~p~n", [Msg]), > > > listener(Fd, N, SoFar, S) > after 0 -> > file:write(Fd, lists:reverse(SoFar)), > listener(Fd, N, [], 0) > end. > > write(_Data, 0) -> ok; > write(Data, N) -> > (?MODULE) ! {data, Data}, write(Data, N - 1). > > > On Fri, Apr 24, 2009 at 4:23 PM, chaitanya Chalasani > wrote: > > > Hi, > > I am facing performance issue with my file logger. The > file logger is an event handler holding the file > reference is its state. The performance of the module > is way ahead in the smp disabled erl shell compared > with default smp enabled erl shell. > > I tried ... > case#1 > Erlang R13B (erts-5.7.1) [source] [rq:1] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7.1 (abort with ^G) > 1> testLogger:start("test.log"). > true > 2> testLogger:write("Testing...",1000000). > {ok,done} > 3> > > and > > case#2 > Erlang R13B (erts-5.7.1) [source] [smp:2:2] [rq:2] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7.1 (abort with ^G) > 1> testLogger:start("test.log"). > true > 2> testLogger:write("Testing...",1000000). > {ok,done} > 3> > > > What I observed was - > Case 1: > 1. The testLogger:write("Testing...",1000000) did > not return back the control to the shell until all the > messages are written to log. > 2. The data was written at 400 KB/s > > Case 2: > 1. The testLogger:write("Testing...",1000000) > return back the control to the shell with {ok, done} > after a short while but the messages where being > written to log even after that. > 2. The data was written at 4 KB/s > 3. I checked in the pman tool it shows current > funtion as io:wait_io_mon_reply/2 and the messages in > the message pool are about 880k. > > Below is the code which I tested. > > start(Filename) -> > register(testLogger,spawn(testLogger,listener,[Filename])). > > listener(Filename) -> > case file:open(Filename,[append]) of > {ok,Fd} -> listener(Fd,0); > {error,Reason} -> error_logger:error_msg(Reason) > end. > > listener(Fd,N) -> > receive > {data,Data} -> file:write(Fd,Data), listener(Fd,N+1); > {count,From} -> From ! {count,N}, listener(Fd,N); > {stop,From} -> From ! {stop,success} > end. > > write(_Data,0) -> {ok,done}; > write(Data,N) -> testLogger ! {data,Data}, > write(Data,N-1). > > Is there a problem with my code or is it a known > issue? > > ------ > CHAITANYA CHALASANI > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. > Thrill your boss. Be a data hero! > Try Good Data now for free: www.gooddata.com > > > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill > your boss. Be a data hero! > Try Good Data now for free: www.gooddata.com ------ CHAITANYA CHALASANI -------------- next part -------------- An HTML attachment was scrubbed... URL: From amit.murthy@REDACTED Mon Apr 27 07:36:45 2009 From: amit.murthy@REDACTED (Amit Murthy) Date: Mon, 27 Apr 2009 11:06:45 +0530 Subject: [erlang-questions] Passing records vs Mnesia lookups In-Reply-To: <8209f740904261358w19d9d44dj23128c5381182492@mail.gmail.com> References: <4f5fdb630904260957l322c58ffjf120f7bacf8718ea@mail.gmail.com> <8209f740904261358w19d9d44dj23128c5381182492@mail.gmail.com> Message-ID: <4f5fdb630904262236v60d62565pae936401c3150b54@mail.gmail.com> On Mon, Apr 27, 2009 at 2:28 AM, Ulf Wiger wrote: > Reads from ets are also copying, so you end up copying in either case. > However, even mnesia:dirty_read() results in more ETS reads than just the > object. Mnesia has to find out where to read the object (it may not be > local) > and what type of storage the table has, if the table exists locally. > Furthermore, > ETS reads are protected by mutexes (on SMP). So is message passing, of > course, but the probability of lock contention is very much smaller with > message passing. > > > BR, > Ulf W > Thanks. Amit -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Mon Apr 27 09:15:51 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 27 Apr 2009 09:15:51 +0200 Subject: [erlang-questions] how to create user-defined guards In-Reply-To: References: Message-ID: <1240816551.5005.14.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, There is no way to create your own guards. Would this be acceptable instead: get_students()-> F = fun(Person, Acc)-> case Person of {#person_table{type ="Estudiante"} -> {Person|Acc]; _Else -> Acc end end, mnesia:foldl(F, [], person_table). That will give you the whole record. I have forgotten what '$_' in the match spec means (either the whole record or just all the $n things) so here is the alternative: get_students()-> F = fun(Person, Acc)-> case Person of {#person_table{type ="Estudiante", id =ID, name =Name, group =Group, id_card =ID_card, user =User}} -> {{ID, Name, Group, "Estudiante", ID_card, User}|Acc]; _Else -> Acc end end, mnesia:foldl(F, [], person_table). bengt On Mon, 2009-04-27 at 01:12 +0200, Ivan Carmenates Garcia wrote: > Hi all, > > I have a problem if for example I have an mnesia cosult like this > > get_students()-> > F = fun()-> > mnesia:select(person_table, [{#person_table{ > id ='$1', > name ='$2', > group ='$3', > type ='$4', > id_card ='$5', > user ='$6'}, > [{'=:=', {is_student,'$4'}, true}], > ['$_']}]) > end, > mnesia:transaction(F). > > is_student(X)-> > if X == "Estudiante"-> > true; > true-> > false > end. > > that's only accept guards, for exaple changing [{'=:=', > {is_student,'$4'}, true}], by [{'=:=', {is_list,'$4'}, true}], then > that work fine > > because is_list is a guard, but I need to check for more complex > criterias, but using my own funtion criteria I just got > > {aborted,{badarg,[person_table, > [{{person_table,'$1','$2','$3','$4','$5','$6'}, > [{'=:=',{is_student,'$4'},true}], > ['$5']}]]}} > > because is_student is not valid guard. > > How can I simulate or make my own guard or do something else to > resolve this problem. > From bengt.kleberg@REDACTED Mon Apr 27 09:24:40 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 27 Apr 2009 09:24:40 +0200 Subject: [erlang-questions] Erlang node administration in production environment In-Reply-To: <20090426203000.8F8597000086@msfrf2214.sfr.fr> References: <20090426203000.8F8597000086@msfrf2214.sfr.fr> Message-ID: <1240817080.5005.18.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, If you use the program run_erl (http://erlang.org/doc/man/run_erl.html) to start Erlang, you can afterward connect to the node with the program to_erl. bengt On Sun, 2009-04-26 at 22:29 +0200, wde wrote: > Hello all, > > I have a general question about erlang node administration. In my lab, I start the nodes in interactive mode with a shell through a SSH connection to my servers. > > It's really useful to have an erlang shell in order to debug, run specific functions to monitor or analyze your application. > > My question is, how do you interact with an Erlang node in a production environment when the node is started in "detached" mode without shell ? > > Do you add a new node to the cluster and use RPC to remotely execute command on the target node ? > > Do you start a new node with a remote shell connected to a target node by using the -remsh flag ? > > Other options ? > > > Thank you by advance for your responses and your feedbacks. > > > wde > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From rtrlists@REDACTED Mon Apr 27 10:49:57 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Mon, 27 Apr 2009 09:49:57 +0100 Subject: [erlang-questions] (no subject) In-Reply-To: References: Message-ID: <6a3ae47e0904270149k2f01d509y73cdd7c2ce457c04@mail.gmail.com> On Fri, Apr 24, 2009 at 9:13 PM, Rene Villalta Soto wrote: > Hi I need some help , I have other problem now with Postgres > > > {ok, Ref} = odbc:connect("Driver={SQL Server};Server=10.36.2.199;Port=3306;Database=testLazy;Uid=postgres;Pwd=postgres;", []). > ** exception error: no match of right hand side value {error, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "No SQL-driver information available. Connection to database failed."} > > and how I can conform connections strings ?to others DBMS? Have a look at http://www.connectionstrings.com/ . And you will also very likely want to specify {scrollable_cursors, off} as an option to odbc:connect(), because a lot of ODBC dirvers do not support bi-directional cursors. Robby From bernie@REDACTED Mon Apr 27 10:57:58 2009 From: bernie@REDACTED (Bernard Duggan) Date: Mon, 27 Apr 2009 18:57:58 +1000 Subject: [erlang-questions] how to create user-defined guards In-Reply-To: References: Message-ID: <49F57396.20007@m5net.com> Hi Ivan, As Bengt said, you can't make your own guards. Why not use qlc? (I'm going to assume here that you're pulling out the entire record, since it will save me some typing :-) ): get_students() -> F = fun() -> qlc:e(qlc:q( [A || A <- mnesia:table(person_table), A#person_table.student =:= "Estudiante" ])) end, mnesia:transaction(F). Apologies for any typos - doing this from memory. Cheers, Bernard Ivan Carmenates Garcia wrote: > > Hi all, > > I have a problem if for example I have an mnesia cosult like this > > get_students()-> > F = fun()-> > mnesia:select(person_table, [{#person_table{ > id ='$1', > name ='$2', > group ='$3', > type ='$4', > id_card ='$5', > user ='$6'}, > [{'=:=', {is_student,'$4'}, true}], > ['$_']}]) > end, > mnesia:transaction(F). > > is_student(X)-> > if X == "Estudiante"-> > true; > true-> > false > end. > > that's only accept guards, for exaple changing [{'=:=', > {is_student,'$4'}, true}], by [{'=:=', {is_list,'$4'}, true}], then > that work fine > > because is_list is a guard, but I need to check for more complex > criterias, but using my own funtion criteria I just got > > {aborted,{badarg,[person_table, > [{{person_table,'$1','$2','$3','$4','$5','$6'}, > [{'=:=',{is_student,'$4'},true}], > ['$5']}]]}} > > because is_student is not valid guard. > > How can I simulate or make my own guard or do something else to > resolve this problem. > From rtrlists@REDACTED Mon Apr 27 10:59:25 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Mon, 27 Apr 2009 09:59:25 +0100 Subject: [erlang-questions] Noob question about records In-Reply-To: References: <65b2728e0904251954k77eb2b3m2e05b1007a19c2d9@mail.gmail.com> <209D5F7A-19A6-4992-92B5-98E65EB51F22@gmail.com> Message-ID: <6a3ae47e0904270159ic5944f9kdb42b4f8d18ad1f3@mail.gmail.com> On Sun, Apr 26, 2009 at 5:05 PM, Gordon Guthrie wrote: > The bad news is then you will need to build both ends of a website and > the Gates Of Hell will swing open when you load Javascript into an > editor... In which case you need "JavaScript: The Good Parts" by Douglas Crockford to inject some sanity. Robby From masse@REDACTED Mon Apr 27 12:11:21 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 27 Apr 2009 12:11:21 +0200 Subject: [erlang-questions] how to create user-defined guards In-Reply-To: (Ivan Carmenates Garcia's message of "Sun\, 26 Apr 2009 19\:12\:54 -0400") References: Message-ID: <873abu5rue.fsf@sterlett.hq.kred> "Ivan Carmenates Garcia" writes: > Hi all, > > I have a problem if for example I have an mnesia cosult like this > > get_students()-> > F = fun()-> > mnesia:select(person_table, [{#person_table{ > id ='$1', > name ='$2', > group ='$3', > type ='$4', > id_card ='$5', > user ='$6'}, > [{'=:=', {is_student,'$4'}, true}], > ['$_']}]) > end, > mnesia:transaction(F). > > is_student(X)-> > if X == "Estudiante"-> > true; > true-> > false > end. > i don't know anything about this, but the obvious solution would be; {'=:=', '$4', "Estudiante"} right? or am i missing something? mats From masse@REDACTED Mon Apr 27 12:16:03 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 27 Apr 2009 12:16:03 +0200 Subject: [erlang-questions] Passing records vs Mnesia lookups In-Reply-To: <4f5fdb630904260957l322c58ffjf120f7bacf8718ea@mail.gmail.com> (Amit Murthy's message of "Sun\, 26 Apr 2009 22\:27\:31 +0530") References: <4f5fdb630904260957l322c58ffjf120f7bacf8718ea@mail.gmail.com> Message-ID: <87y6tm4d24.fsf@sterlett.hq.kred> Amit Murthy writes: > Hi, > > I have an optimization question. Consider the following scenario: > > - I have, say around 40,000 long running processes. Each represents an online > user and keeps some user related data in the process dictionary. > - I need each of the processes to perform some computation against a long > record that I'll send as a message. > - The long record (around 40 fields, mostly short strings) is also available > in an mnesia RAM only table > > So the question is > > Is it better to read the record from mnesia once and send the complete record > to each of the 40,000 processes > > or > > Is it better to just send the key in the message and have each of the > processes do an mnesia lookup if you don't need transaction semantics, AND you really need the CPU cycles, doing an ets:lookup in the mnesia RAM only table is a good option. mats From amit.murthy@REDACTED Mon Apr 27 12:58:56 2009 From: amit.murthy@REDACTED (Amit Murthy) Date: Mon, 27 Apr 2009 16:28:56 +0530 Subject: [erlang-questions] Passing records vs Mnesia lookups In-Reply-To: <87y6tm4d24.fsf@sterlett.hq.kred> References: <4f5fdb630904260957l322c58ffjf120f7bacf8718ea@mail.gmail.com> <87y6tm4d24.fsf@sterlett.hq.kred> Message-ID: <4f5fdb630904270358l892b61at92d70b3f8322a1a1@mail.gmail.com> I don't need transactions, and all the data is only on one node, but as Ulf pointed out, wouldn't an ets:lookup also result in a completely new copy of the long record and hence, as far as CPU cycles spent in data copying is concerned, will be the same as for message passing ? On Mon, Apr 27, 2009 at 3:46 PM, mats cronqvist wrote: > Amit Murthy writes: > > > Hi, > > > > I have an optimization question. Consider the following scenario: > > > > - I have, say around 40,000 long running processes. Each represents an > online > > user and keeps some user related data in the process dictionary. > > - I need each of the processes to perform some computation against a long > > record that I'll send as a message. > > - The long record (around 40 fields, mostly short strings) is also > available > > in an mnesia RAM only table > > > > So the question is > > > > Is it better to read the record from mnesia once and send the complete > record > > to each of the 40,000 processes > > > > or > > > > Is it better to just send the key in the message and have each of the > > processes do an mnesia lookup > > if you don't need transaction semantics, AND you really need the CPU > cycles, doing an ets:lookup in the mnesia RAM only table is a good > option. > > mats > -------------- next part -------------- An HTML attachment was scrubbed... URL: From freza@REDACTED Mon Apr 27 13:17:39 2009 From: freza@REDACTED (Jachym Holecek) Date: Mon, 27 Apr 2009 13:17:39 +0200 Subject: [erlang-questions] how to create user-defined guards In-Reply-To: References: Message-ID: <20090427111739.GA3703@hanele> # Ivan Carmenates Garcia 2009-04-27: > get_students()-> > F = fun()-> > mnesia:select(person_table, [{#person_table{ > id ='$1', > name ='$2', > group ='$3', > type ='$4', > id_card ='$5', > user ='$6'}, > [{'=:=', {is_student,'$4'}, true}], > ['$_']}]) > end, > mnesia:transaction(F). > > is_student(X)-> > if X == "Estudiante"-> > true; > true-> > false > end. > > [...] > > How can I simulate or make my own guard or do something else to resolve this problem. You can use arbitrary expressions in QLC queries; you could use the following as transaction function (completely untested): F = fun () -> qlc:eval(qlc:q([Item || Item <- mnesia:table(person_table), is_person(Item)])) end where is_person/1 is any Erlang function evaluating to boolean(). I don't know about QLC performance though and sure enough in a simple case like yours you can just inline the is_student/1 test into the matchspec and be done with it. HTH, -- Jachym PS: QLC needs -include_lib("stdlib/include/qlc.hrl"). From vychodil.hynek@REDACTED Mon Apr 27 13:45:28 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Mon, 27 Apr 2009 13:45:28 +0200 Subject: [erlang-questions] Erlang node administration in production environment In-Reply-To: <20090426203000.8F8597000086@msfrf2214.sfr.fr> References: <20090426203000.8F8597000086@msfrf2214.sfr.fr> Message-ID: <4d08db370904270445p2fb5f16fk9a1162bddf3bf8c2@mail.gmail.com> If nodes are connected in cluster you can connect to every of them from any of them with shell. Just pres Ctrl+G and use switching environment User switch command --> h c [nn] - connect to job i [nn] - interrupt job k [nn] - kill job j - list all jobs s [shell] - start local shell r [node [shell]] - start remote shell q - quit erlang ? | h - this message On Sun, Apr 26, 2009 at 10:29 PM, wde wrote: > Hello all, > > I have a general question about erlang node administration. In my lab, I > start the nodes in interactive mode with a shell through a SSH connection to > my servers. > > It's really useful to have an erlang shell in order to debug, run specific > functions to monitor or analyze your application. > > My question is, how do you interact with an Erlang node in a production > environment when the node is started in "detached" mode without shell ? > > Do you add a new node to the cluster and use RPC to remotely execute > command on the target node ? > > Do you start a new node with a remote shell connected to a target node by > using the -remsh flag ? > > Other options ? > > > Thank you by advance for your responses and your feedbacks. > > > wde > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Mon Apr 27 15:51:40 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 27 Apr 2009 15:51:40 +0200 Subject: [erlang-questions] Passing records vs Mnesia lookups In-Reply-To: <4f5fdb630904270358l892b61at92d70b3f8322a1a1@mail.gmail.com> (Amit Murthy's message of "Mon\, 27 Apr 2009 16\:28\:56 +0530") References: <4f5fdb630904260957l322c58ffjf120f7bacf8718ea@mail.gmail.com> <87y6tm4d24.fsf@sterlett.hq.kred> <4f5fdb630904270358l892b61at92d70b3f8322a1a1@mail.gmail.com> Message-ID: <87prey432r.fsf@sterlett.hq.kred> Amit Murthy writes: > I don't need transactions, and all the data is only on one node, but as Ulf > pointed out, wouldn't an ets:lookup also result in a completely new copy of > the long record and hence, as far as CPU cycles spent in data copying is > concerned, will be the same as for message passing ? Yes, I guess. But you'll avoid the copy when the master process reads in the long record. Having said that; I find it hard to believe that the differences in CPU is significant, or even measurable. Which of course makes all of this an exercise in silly micro-optimization. So the choice of implementation should be based on whether you want to couple the master process to the workers (by sending a message) or not. mats From michal.ptaszek@REDACTED Mon Apr 27 16:40:58 2009 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Mon, 27 Apr 2009 15:40:58 +0100 (BST) Subject: [erlang-questions] Erlang Web 1.3RC1 web framework Message-ID: <23562069.124981240843258730.JavaMail.root@zimbra> Hello All, The next version of the Erlang Web framework, Erlang Web 1.3RC1, is ready! This is the first release candidate. We think this version of the framework is full of brand new features, and hopefully it will attract a lot of attention. The changes from the previous version 1.2.1 are: * distribution support * generic annotations added * new automatic form builder implemented * CouchDB support corrected * support for other than integers primary keys added * cross-framework logger introduced * wpart_paginate improvements * Xmerl removed from wtype's handle_call functions * "rewrite" feature in dispatcher rules added * wpart_bool corrected And the more descriptive changelog: * distribution support Since Erlang Web release 1.3 has a new application child, its draft codename is eptic_fe (from eptic frontend). The new application allows users to distribute their services on a cluster of machines. The new application also provides very fast and convenient cache storage. Please see http://wiki.erlang-web.org/EpticFE for details. * generic annotations added Erlang Web's annotations are a meta-language extension that provides a possibility to define a control flow for each Erlang function. The annotations description is available at http://wiki.erlang-web.org/Annotations * new automatic form builder implemented It is now possible to have greater control of how the automatically generated form will look. The new generator is more flexible, allows building of a form based on the different HTML structures and gives a website designer a lot of freedom with building the CSS document. * CouchDB support corrected Erlang records are now mapped directly to the CouchDB document. Moreover, reading all entries from the selected domain uses CouchDB's views, since they are more efficient. * cross-framework logger introduced e_logger - is a tool for tracing the events within the framework - from the earliest phase in the lowest level server callback module, through the dispatching phase and dataflow processing parts, to the user-defined controllers. Together with the e_logger, there is a e_logger_viewer tool for analyzing the control flow for each request. * wpart_paginate improvements It is now possible to make a list of the numbered links to the pages that hold the parts of some collections. In addition, the 'trim' attribute allows developers to control the length of this list. * redirect feature in dispatcher rules added Dispatcher can now act as an Apache's mod_rewrite. Read more on http://wiki.erlang-web.org/Dispatcher * wpart_bool corrected wpart_bool will now do the same as wpart_multilist (but renders a different HTML widget): http://wiki.erlang-web.org/Wparts/BasicTypes/bool As you can see there are a lot of changes in this release which will be very helpful. The complete documentation is available on Erlang Web's wiki page: http://wiki.erlang-web.org/ The source code for Erlang Web can be found on our official bitbucket's account: http://bitbucket.org/etc/erlang-web/ The tarball containing the 1.3RC1 distribution is also available for download from: http://www.erlang-web.org/ Comments, ideas, feedback is most welcome. Download, test it, please send us your thoughts, and some feedback! Best regards, -- Michal Ptaszek www.erlang-consulting.com From dmitriid@REDACTED Mon Apr 27 17:03:41 2009 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Mon, 27 Apr 2009 18:03:41 +0300 Subject: [erlang-questions] erlang gettext examples? Message-ID: Does anyone have a working example of how to generate the initial PO file from erlang-gettext? I can't get it to work :( Thank you From jarrod@REDACTED Mon Apr 27 18:31:11 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Mon, 27 Apr 2009 12:31:11 -0400 Subject: [erlang-questions] Line Receiver example? Message-ID: I am desperately trying to convert the example code from the SHOUTCast server example in the Programming Erlang book to call a function on every line received instead of the way it works in the book. I am coming from using the Twisted framework for Python and trying to port some applications, Twisted has a "Line Receiver" protocol that calls a function when every line is detected. It makes writing basic protocols very easy. I have been unsuccessful in trying to accomplish the same thing with Erlang. -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar@REDACTED Mon Apr 27 18:37:34 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Mon, 27 Apr 2009 17:37:34 +0100 Subject: [erlang-questions] Line Receiver example? In-Reply-To: References: Message-ID: <49F5DF4E.90608@erlang-consulting.com> Hi Jarrod, I guess what you're looking for is the packet option for sockets. In case you're using a TCP socket you can either open your listen socket with the option {packet, line}, gen_tcp:listen(Port, [{packet, line}]), or you can set it to line based parsing later by issuing inet:setopts(Socket, [{packet, line}]). In case of UDP you need to open the socket with gen_upd:open(Port, [{packet, line}]). inet:setopts/2 will also work for a UDP socket. Jarrod Roberson wrote: > I am desperately trying to convert the example code from the SHOUTCast > server example in the Programming Erlang book to call a function on > every line received instead of the way it works in the book. > I am coming from using the Twisted framework for Python and trying to > port some applications, Twisted has a "Line Receiver" protocol that > calls a function when every line is detected. > It makes writing basic protocols very easy. I have been unsuccessful > in trying to accomplish the same thing with Erlang. > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Best regards -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From sgrady@REDACTED Mon Apr 27 19:30:19 2009 From: sgrady@REDACTED (Steven Grady) Date: Mon, 27 Apr 2009 10:30:19 -0700 Subject: [erlang-questions] listen() backlog limited to 16 bits? Message-ID: <5259C246-10F0-4B23-BE9B-2DC41892E23E@hi5.com> On a Linux system, the listen backlog is a 32-bit int. But both the Erlang library (prim_inet:listen/2) and the erts (inet_drv.c:tcp_inet_ctl()) constrain it to 16 bits. The documentation of gen_tcp says simply that it is an "integer", with no mention of the 16-bit limitation. As Erlang starts to reside in the world of massively-scaled web servers, 16 bits seems to be unnecessary and ill-chosen limitation. Is there any plan to fix this? Steven From jarrod@REDACTED Mon Apr 27 21:12:29 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Mon, 27 Apr 2009 15:12:29 -0400 Subject: [erlang-questions] Line Receiver example? In-Reply-To: <49F5DF4E.90608@erlang-consulting.com> References: <49F5DF4E.90608@erlang-consulting.com> Message-ID: 2009/4/27 Oscar Hellstr?m > Hi Jarrod, > > I guess what you're looking for is the packet option for sockets. In > case you're using a TCP socket you can either open your listen socket > with the option {packet, line}, gen_tcp:listen(Port, [{packet, line}]), > or you can set it to line based parsing later by issuing > inet:setopts(Socket, [{packet, line}]). In case of UDP you need to open > the socket with gen_upd:open(Port, [{packet, line}]). inet:setopts/2 > will also work for a UDP socket. > > thanks, but I still seem to be missing something. I still can't get it to print out anything when I connect and send data to my server. I think something is wrong in my get_line/1 function. Here is my code so far. -module(linereceiver). -export([start/0]). -import(lists, [reverse/1]). sleep(T) -> receive after T -> true end. start() -> spawn(fun() -> start_parallel_server(3000), sleep(infinity) end). start_parallel_server(Port) -> {ok, Listen} = gen_tcp:listen(Port, [binary, {packet,line}, {reuseaddr, true}, {active, true}]), spawn(fun() -> par_connect(Listen)end). par_connect(Listen) -> {ok, Socket} = gen_tcp:accept(Listen), spawn(fun() -> par_connect(Listen) end), inet:setopts(Socket, [{packet, line}, binary, {nodelay, true}, {active, true}]), io:format("Connection Made!~n"), get_line(Socket). get_line(Socket) -> receive {tcp, Socket, Bin} -> io:format("Received Line:~p~n", binary_to_list(Bin)), get_line(Socket); {tcp_closed, Socket} -> io:format("Connection Closed!~n") end. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarrod@REDACTED Mon Apr 27 21:23:49 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Mon, 27 Apr 2009 15:23:49 -0400 Subject: [erlang-questions] Line Receiver example? In-Reply-To: References: <49F5DF4E.90608@erlang-consulting.com> Message-ID: 2009/4/27 Jarrod Roberson > > > 2009/4/27 Oscar Hellstr?m > >> Hi Jarrod, >> >> I guess what you're looking for is the packet option for sockets. In >> case you're using a TCP socket you can either open your listen socket >> with the option {packet, line}, gen_tcp:listen(Port, [{packet, line}]), >> or you can set it to line based parsing later by issuing >> inet:setopts(Socket, [{packet, line}]). In case of UDP you need to open >> the socket with gen_upd:open(Port, [{packet, line}]). inet:setopts/2 >> will also work for a UDP socket. >> >> > thanks, but I still seem to be missing something. > I still can't get it to print out anything when I connect and send data to > my server. > I think something is wrong in my get_line/1 function. > > Here is my code so far. > > -module(linereceiver). > > -export([start/0]). > -import(lists, [reverse/1]). > > sleep(T) -> > receive > after T -> > true > end. > > start() -> > spawn(fun() -> > start_parallel_server(3000), > sleep(infinity) > end). > > start_parallel_server(Port) -> > {ok, Listen} = gen_tcp:listen(Port, [binary, {packet,line}, > {reuseaddr, true}, > {active, true}]), > spawn(fun() -> par_connect(Listen)end). > > par_connect(Listen) -> > {ok, Socket} = gen_tcp:accept(Listen), > spawn(fun() -> par_connect(Listen) end), > inet:setopts(Socket, [{packet, line}, binary, {nodelay, true}, {active, > true}]), > io:format("Connection Made!~n"), > get_line(Socket). > > get_line(Socket) -> > receive > {tcp, Socket, Bin} -> > io:format("Received Line:~p~n", binary_to_list(Bin)), > get_line(Socket); > {tcp_closed, Socket} -> > io:format("Connection Closed!~n") > end. > > also I don't get any output when connections are closed / disconnected by the client. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarrod@REDACTED Mon Apr 27 21:43:19 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Mon, 27 Apr 2009 15:43:19 -0400 Subject: [erlang-questions] Line Receiver example? In-Reply-To: References: <49F5DF4E.90608@erlang-consulting.com> Message-ID: On Mon, Apr 27, 2009 at 3:23 PM, Jarrod Roberson wrote: > >> >> get_line(Socket) -> >> receive >> {tcp, Socket, Bin} -> >> io:format("Received Line:~p~n", binary_to_list(Bin)), >> get_line(Socket); >> {tcp_closed, Socket} -> >> io:format("Connection Closed!~n") >> end. >> >> > also I don't get any output when connections are closed / disconnected by > the client. apparently I got the connection closed event working now, if I could just get it to print out the received line -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Mon Apr 27 21:44:50 2009 From: erlang@REDACTED (Joe Armstrong) Date: Mon, 27 Apr 2009 21:44:50 +0200 Subject: [erlang-questions] Line Receiver example? In-Reply-To: References: Message-ID: <9b08084c0904271244i416c6feelaf644b4445026235@mail.gmail.com> A basic server looks something like this: start_server() -> {ok, Listen} = gen_tcp:listen(2345, [binary, {packet, 4}, {active, true}]), {ok, Socket} = gen_tcp:accept(Listen), gen_tcp:close(Listen), loop(Socket). loop(Socket) -> receive {tcp, Socket, Bin} -> io:format("Server received binary = ~p~n",[Bin]), ... loop(Socket); {tcp_closed, Socket} -> io:format("Server socket closed~n") end. Now you want to call a function every time a "line" is received If the function is F you can modify the code as follows: (Compare this with the original) start_server(F) -> {ok, Listen} = gen_tcp:listen(2345, [binary, {packet, 4}, {active, true}]), {ok, Socket} = gen_tcp:accept(Listen), gen_tcp:close(Listen), loop(Socket, F). loop(Socket, F) -> receive {tcp, Socket, Bin} -> io:format("Server received binary = ~p~n",[Bin]), ... F(Bin), loop(Socket, F); {tcp_closed, Socket} -> io:format("Server socket closed~n") end. Once you see how the arguments flow it should be easy to change the examples in the book :-) To start do something like Now define your handling fun myfun(Bin) -> .... start with: spawn(fun() -> start_server(fun myfun/1). The idea of what a "line" is can be changed by setting different options when opening the socket. Cheers /Joe On Mon, Apr 27, 2009 at 6:31 PM, Jarrod Roberson wrote: > I am desperately trying to convert the example code from the SHOUTCast > server example in the Programming Erlang book to call a function on every > line received instead of the way it works in the book. > I am coming from using the Twisted framework for Python and trying to port > some applications, Twisted has a "Line Receiver" protocol that calls a > function when every line is detected. > It makes writing basic protocols very easy. I have been unsuccessful in > trying to accomplish the same thing with Erlang. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jarrod@REDACTED Mon Apr 27 21:56:21 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Mon, 27 Apr 2009 15:56:21 -0400 Subject: [erlang-questions] Line Receiver example? In-Reply-To: References: <49F5DF4E.90608@erlang-consulting.com> Message-ID: 2009/4/27 Jarrod Roberson > > get_line(Socket) -> > receive > {tcp, Socket, Bin} -> > io:format("Received Line:~p~n", binary_to_list(Bin)), > get_line(Socket); > {tcp_closed, Socket} -> > io:format("Connection Closed!~n") > end. > > thanks to something in Joe's email, I got this to work sort of. I changed the above to : get_line(Socket) -> receive {tcp, Socket, Bin} -> io:format("Received Line:~p~n", [Bin]), get_line(Socket); {tcp_closed, Socket} -> io:format("Connection Closed!~n") end. and I started getting output. question now is how do I get that binary to a list that I can manipulate? -------------- next part -------------- An HTML attachment was scrubbed... URL: From per.melin@REDACTED Mon Apr 27 21:59:48 2009 From: per.melin@REDACTED (Per Melin) Date: Mon, 27 Apr 2009 21:59:48 +0200 Subject: [erlang-questions] Line Receiver example? In-Reply-To: References: <49F5DF4E.90608@erlang-consulting.com> Message-ID: Jarrod Roberson: > io:format("Received Line:~p~n", binary_to_list(Bin)), This line is broken. Your process crashes. Do this: io:format("Received Line:~p~n", [binary_to_list(Bin)]), From jarrod@REDACTED Mon Apr 27 22:29:06 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Mon, 27 Apr 2009 16:29:06 -0400 Subject: [erlang-questions] Line Receiver example? In-Reply-To: References: <49F5DF4E.90608@erlang-consulting.com> Message-ID: On Mon, Apr 27, 2009 at 3:59 PM, Per Melin wrote: > Jarrod Roberson: > > io:format("Received Line:~p~n", binary_to_list(Bin)), > > This line is broken. Your process crashes. Do this: > > io:format("Received Line:~p~n", [binary_to_list(Bin)]), > just for future knowledge why are the [] required around the list? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ljw1001@REDACTED Mon Apr 27 22:49:01 2009 From: ljw1001@REDACTED (Larry White) Date: Mon, 27 Apr 2009 16:49:01 -0400 Subject: [erlang-questions] question regarding symmetric encryption with crypto library Message-ID: In the past the encryption libraries I've used have accepted an arbitrary string as plain text input. The des implementation in crypto (and the algorithm itself) seems to require that the the input text be some multiple of 8 bytes long. I can pad the input string with something to make it n*8 bytes long, but then when I decrypt the string, I have no way of knowing if the returned value was padded and by how much. This seems like a problem many people must have solved. What's the right way to do this here? thanks much for your help. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nem@REDACTED Mon Apr 27 22:56:11 2009 From: nem@REDACTED (Geoff Cant) Date: Mon, 27 Apr 2009 22:56:11 +0200 Subject: [erlang-questions] Line Receiver example? In-Reply-To: (Jarrod Roberson's message of "Mon, 27 Apr 2009 16:29:06 -0400") References: <49F5DF4E.90608@erlang-consulting.com> Message-ID: Jarrod Roberson writes: > On Mon, Apr 27, 2009 at 3:59 PM, Per Melin wrote: > >> Jarrod Roberson: >> > io:format("Received Line:~p~n", binary_to_list(Bin)), >> >> This line is broken. Your process crashes. Do this: >> >> io:format("Received Line:~p~n", [binary_to_list(Bin)]), >> > > just for future knowledge why are the [] required around the list? Erlang doesn't do varargs, so we use lists as arguments instead (io:format/2 takes a number of arguments depending on the format string - io:format("~p", [Arg1]), io:format("~p ~p", [Arg1, Arg2]) not io:format("~p ~p", Arg1, Arg2) as that would change the arity of the function from io:format/2 to io:format/3 which does something quite different). Cheers, -- Geoff Cant From tobbe@REDACTED Mon Apr 27 23:16:22 2009 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Mon, 27 Apr 2009 23:16:22 +0200 Subject: [erlang-questions] erlang gettext examples? In-Reply-To: References: Message-ID: Dmitrii Dimandt wrote: > Does anyone have a working example of how to generate the initial PO > file from erlang-gettext? I can't get it to work :( > > Thank you Have you had a look at the tutorial over at trapexit.org ? http://trapexit.org/Gettext_-_An_internationalization_package. --Tobbe From keith.irwin@REDACTED Tue Apr 28 00:09:04 2009 From: keith.irwin@REDACTED (Keith Irwin) Date: Mon, 27 Apr 2009 15:09:04 -0700 Subject: [erlang-questions] Erlang Reading/Writing /dev/modem? Message-ID: <8aff81590904271509n4c330776id02799145a8b5495@mail.gmail.com> Folks-- I'm interested in using Erlang to read from a modem device /dev/cu.usbmodem so that I can then send whatever I read to another Erlang service running on an Internet port. I have a point-of-sale terminal plugged into a phone-simulator, which in turn is plugged into an Apple USB Modem. When I initiate a function on the POS, it dials up. I send an "ATA" (and any other necessary init strings) to /dev/cu.usbmodem, and the modem answers. I get a "CONNECT 1200" string, which tells me that the connection is fine and established. Then the POS machine "hangs up" and tries again. Can I assume I can just read bytes from /dev/cu.usbmodem (as if it were a file), and then do something with those bytes? Is the reason the POS is hanging up is because nothing is sitting there reading from /dev/cu.usbmodem except "cat"? I have to admit, I really don't know what "usually" happens after modems negotiate with one another. I think Erlang is an excellent choice for working with this because of the pattern matching, if nothing else. Keith -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Tue Apr 28 00:53:56 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Mon, 27 Apr 2009 15:53:56 -0700 Subject: [erlang-questions] listen() backlog limited to 16 bits? In-Reply-To: <5259C246-10F0-4B23-BE9B-2DC41892E23E@hi5.com> References: <5259C246-10F0-4B23-BE9B-2DC41892E23E@hi5.com> Message-ID: On Mon, Apr 27, 2009 at 10:30 AM, Steven Grady wrote: > As Erlang starts to reside in the world of massively-scaled web > servers, 16 bits seems to be unnecessary and ill-chosen limitation. > Is there any plan to fix this? Not arguing against bumping it to 32-bits, but do you actually have servers that need to handle more than 65000 yet-unaccepted TCP connections? I would expect that if your server regularly has thousands of queued TCP connections, that it's way overloaded anyway. From sgrady@REDACTED Tue Apr 28 01:42:54 2009 From: sgrady@REDACTED (Steven Grady) Date: Mon, 27 Apr 2009 16:42:54 -0700 Subject: [erlang-questions] listen() backlog limited to 16 bits? In-Reply-To: References: <5259C246-10F0-4B23-BE9B-2DC41892E23E@hi5.com> Message-ID: On Apr 27, 2009, at 3:53 PM, Matthew Dempsky wrote: > On Mon, Apr 27, 2009 at 10:30 AM, Steven Grady wrote: >> As Erlang starts to reside in the world of massively-scaled web >> servers, 16 bits seems to be unnecessary and ill-chosen limitation. >> Is there any plan to fix this? > > Not arguing against bumping it to 32-bits, but do you actually have > servers that need to handle more than 65000 yet-unaccepted TCP > connections? I would expect that if your server regularly has > thousands of queued TCP connections, that it's way overloaded anyway. Possibly. Actually, the main problem is that if you pass in a big number, it gets masked off. if you're unlucky enough to choose a number like 65536, you'll set it to 0... In general, we are using mochiweb (modified to use gen_tcp's active mode) and are only able to handle 1,700 connections a second. We need to handle probably 5x that. But yeah, we are probably not running into the 16-bit limit (yet! :-). Any thoughts on how to increase the numbers of accepts/sec would be welcome. Steven From bbmaj7@REDACTED Tue Apr 28 02:02:47 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Mon, 27 Apr 2009 17:02:47 -0700 (PDT) Subject: [erlang-questions] Erlang Reading/Writing /dev/modem? In-Reply-To: <8aff81590904271509n4c330776id02799145a8b5495@mail.gmail.com> References: <8aff81590904271509n4c330776id02799145a8b5495@mail.gmail.com> Message-ID: <111690.64767.qm@web65513.mail.ac4.yahoo.com> When CONNECT is delivered, the modem changes to data mode (DCD modem line is typically asserted to indicate data mode). Usually in data mode the way back to command mode is to send "+++" or toggle the DTR modem line. Which one is required can depend on the modem setup (eg. AT&D). If your modem uses DTR and has AT&D=2 then this might cause the dropouts on CONECT. Try AT&D=0. You probably need to use the serial port ioctl()s to manipulate the control lines through a port program. IMO you would do well to create a port program that allows erlang to move data *and* change and monitor control lines. You are likely to hit hard-to-debug problems if you do not have the ability to control and monitor these additional out-of-band control lines. -- Rich ________________________________ From: Keith Irwin To: Erlang/OTP discussions Sent: Tuesday, 28 April, 2009 8:09:04 AM Subject: [erlang-questions] Erlang Reading/Writing /dev/modem? Folks-- I'm interested in using Erlang to read from a modem device /dev/cu.usbmodem so that I can then send whatever I read to another Erlang service running on an Internet port. I have a point-of-sale terminal plugged into a phone-simulator, which in turn is plugged into an Apple USB Modem. When I initiate a function on the POS, it dials up. I send an "ATA" (and any other necessary init strings) to /dev/cu.usbmodem, and the modem answers. I get a "CONNECT 1200" string, which tells me that the connection is fine and established. Then the POS machine "hangs up" and tries again. Can I assume I can just read bytes from /dev/cu.usbmodem (as if it were a file), and then do something with those bytes? Is the reason the POS is hanging up is because nothing is sitting there reading from /dev/cu.usbmodem except "cat"? I have to admit, I really don't know what "usually" happens after modems negotiate with one another. I think Erlang is an excellent choice for working with this because of the pattern matching, if nothing else. Keith Yahoo!7 recommends that you update your browser to the new Internet Explorer 8.Get it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Tue Apr 28 02:24:19 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Mon, 27 Apr 2009 17:24:19 -0700 Subject: [erlang-questions] listen() backlog limited to 16 bits? In-Reply-To: References: <5259C246-10F0-4B23-BE9B-2DC41892E23E@hi5.com> Message-ID: On Mon, Apr 27, 2009 at 4:42 PM, Steven Grady wrote: > Possibly. ?Actually, the main problem is that if you pass in a big > number, it gets masked off. ?if you're unlucky enough to choose a > number like 65536, you'll set it to 0... Agreed, that's definitely a problem. > In general, we are using mochiweb (modified to use gen_tcp's active > mode) and are only able to handle 1,700 connections a second. ?We need > to handle probably 5x that. ?But yeah, we are probably not running > into the 16-bit limit (yet! :-). > > Any thoughts on how to increase the numbers of accepts/sec would be > welcome. My only point is that (AFAIK) the listen backlog doesn't directly affect the number of requests per second or the number of concurrent connections you can handle. It's just the number of TCP connections that have completed the SYN/ACK handshake and not yet been accepted by user space, and I just wouldn't expect this number to get into the hundreds of thousands unless the system is heavily overloaded, and then it probably can't do anything useful with such a huge backlog anyway. (Again, just my understanding; if I'm wrong, I'd love to hear an explanation why.) From ljw1001@REDACTED Tue Apr 28 02:29:04 2009 From: ljw1001@REDACTED (jones34) Date: Mon, 27 Apr 2009 17:29:04 -0700 (PDT) Subject: [erlang-questions] question regarding symmetric encryption with crypto library In-Reply-To: References: Message-ID: Ok. Bruce Schneier's "Applied Cryptography" to the rescue. The solution is to always pad the plain text (even when it's an encrypt- able length and use the last byte to store the number of bytes added. No problem, really, but it would sure be nice if someone would add a wrapper to the crypto library so everyone didn't have to re-invent this particular wheel :-). On Apr 27, 4:49?pm, Larry White wrote: > In the past the encryption libraries I've used have accepted an arbitrary > string as plain text input. ?The des implementation in crypto (and the > algorithm itself) seems to require that the the input text be some multiple > of 8 bytes long. ?I can pad the input string with something to make it n*8 > bytes long, but then when I decrypt the string, I have no way of knowing if > the returned value was padded and by how much. > > This seems like a problem many people must have solved. ?What's the right > way to do this here? > > thanks much for your help. > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From bbmaj7@REDACTED Tue Apr 28 02:19:01 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Mon, 27 Apr 2009 17:19:01 -0700 (PDT) Subject: [erlang-questions] question regarding symmetric encryption with crypto library In-Reply-To: References: Message-ID: <917978.30187.qm@web65502.mail.ac4.yahoo.com> Read the SSL/TLS RFC for some good ideas. Basically you need out-of-band agreement so both tx and rx applications know what to expect. One possibility is the first 2 bytes of data in each encrypted message can describe the actual length of valid data; followed by some amount of random fill. ________________________________ From: Larry White To: "erlang-questions@REDACTED" Sent: Tuesday, 28 April, 2009 6:49:01 AM Subject: [erlang-questions] question regarding symmetric encryption with crypto library In the past the encryption libraries I've used have accepted an arbitrary string as plain text input. The des implementation in crypto (and the algorithm itself) seems to require that the the input text be some multiple of 8 bytes long. I can pad the input string with something to make it n*8 bytes long, but then when I decrypt the string, I have no way of knowing if the returned value was padded and by how much. This seems like a problem many people must have solved. What's the right way to do this here? thanks much for your help. Enjoy a safer web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ossareh@REDACTED Tue Apr 28 03:45:52 2009 From: ossareh@REDACTED (Michael Ossareh) Date: Mon, 27 Apr 2009 18:45:52 -0700 Subject: [erlang-questions] connect Erlang with Postgre_? In-Reply-To: <49F3753C.1020904@erlang-consulting.com> References: <49F3753C.1020904@erlang-consulting.com> Message-ID: Or as written by my co-worker: http://erlang.org/pipermail/erlang-questions/2009-March/042712.html Written to deal with the short comings of the current erlang postgresql drivers. On Sat, Apr 25, 2009 at 1:40 PM, Francesco Cesarini (Erlang Training and Consulting) wrote: > You can use our PostgreSQL driver available at > http://www.erlang-consulting.com/erlang/opensource.html > > Regards, > Francesco > -- > http://www.erlang-consulting.com > > > Rene Villalta Soto wrote: >> >> >> >> Hi, how I can to connect Erlang with Postgre? I have the Postgre's Server in other PC >> >> >> >> >> >> >> Erlang girls are too hot!!! I love this language... >> >> >> >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- god loves atheists, Fact: http://www.mrwiggleslovesyou.com/comics/rehab477.jpg From kdr2@REDACTED Tue Apr 28 03:50:44 2009 From: kdr2@REDACTED (KDr2) Date: Tue, 28 Apr 2009 09:50:44 +0800 Subject: [erlang-questions] erlix : Ruby Interface of Erlang Message-ID: I start a project called erlix to wrap the erl_interface into ruby-api, and erlix-0.2 just out, see http://code.google.com/p/erlix/ It's linux-only now. -- Best Regards, -- KDr2, at x-macro.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wolfmanjm@REDACTED Tue Apr 28 07:53:49 2009 From: wolfmanjm@REDACTED (wolfmanjm) Date: Mon, 27 Apr 2009 22:53:49 -0700 (PDT) Subject: [erlang-questions] erlix : Ruby Interface of Erlang In-Reply-To: References: Message-ID: <6050fd5a-473c-4794-99e6-d01418edabc7@n7g2000prc.googlegroups.com> I've been looking for something like this, how about some documentation in English? The samples and docs seem to be in Kanji or something. Thanks On Apr 27, 6:50?pm, KDr2 wrote: > I start ?a project called erlix to wrap the erl_interface into ruby-api, and > erlix-0.2 just out, seehttp://code.google.com/p/erlix/ > It's linux-only now. > > -- > Best Regards, > ? ?-- KDr2, at x-macro.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From matthias@REDACTED Tue Apr 28 07:54:34 2009 From: matthias@REDACTED (Matthias Lang) Date: Tue, 28 Apr 2009 07:54:34 +0200 Subject: [erlang-questions] listen() backlog limited to 16 bits? In-Reply-To: References: <5259C246-10F0-4B23-BE9B-2DC41892E23E@hi5.com> Message-ID: <20090428055434.GA2561@contorpis.lisalinda.com> On Monday, April 27, Matthew Dempsky wrote: > My only point is that (AFAIK) the listen backlog doesn't directly > affect the number of requests per second or the number of concurrent > connections you can handle. It's just the number of TCP connections > that have completed the SYN/ACK handshake and not yet been accepted by > user space, and I just wouldn't expect this number to get into the > hundreds of thousands unless the system is heavily overloaded, and > then it probably can't do anything useful with such a huge backlog > anyway. I had similar thoughts. I can imagine a short backlog limit, e.g. 5, limiting throughput, but I can only think of contrived situations where there'd be a difference between millions and thousands. The OS backlog limit has increased in linux over the years. Originally, it was five connections (BSDism?). Later (2.0/2.2/2.4?), it increased to 128. In current Linux versions it's configurable without an apparent upper limit; the default is 128. Someone thought it was worth the effort to remove the limit. I googled a bit and couldn't find the reasoning behind that. Maybe it was a "remove all arbitrary limits" mission. Matt * I've tried writing higher values to somaxconn and reading them back again. It gets a bit weird for some values: contorpis:/proc/sys/net/core# echo "2147483648" > somaxconn contorpis:/proc/sys/net/core# cat somaxconn -18446744071562067968 I also tried a C program with various backlog arguments. It feels like something strange is going on, e.g. with a call to listen(s, 1) and then sleep() forever, I can still connect several sockets, though it takes about a second per connection after the first few. I wasn't sufficiently interested to figure out why, but if someone knows, it'd be interesting to hear. From kdr2@REDACTED Tue Apr 28 08:06:47 2009 From: kdr2@REDACTED (KDr2) Date: Tue, 28 Apr 2009 14:06:47 +0800 Subject: [erlang-questions] erlix : Ruby Interface of Erlang In-Reply-To: <6050fd5a-473c-4794-99e6-d01418edabc7@n7g2000prc.googlegroups.com> References: <6050fd5a-473c-4794-99e6-d01418edabc7@n7g2000prc.googlegroups.com> Message-ID: It's Chinese, I will write some english docs an tutorial as soon as i can :) On Tue, Apr 28, 2009 at 1:53 PM, wolfmanjm wrote: > I've been looking for something like this, how about some > documentation in English? The samples and docs seem to be in Kanji or > something. > > Thanks > > On Apr 27, 6:50 pm, KDr2 wrote: > > I start a project called erlix to wrap the erl_interface into ruby-api, > and > > erlix-0.2 just out, seehttp://code.google.com/p/erlix/ > > It's linux-only now. > > > > -- > > Best Regards, > > -- KDr2, at x-macro.com. > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED:// > www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, -- KDr2, at x-macro.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From kdr2@REDACTED Tue Apr 28 09:10:30 2009 From: kdr2@REDACTED (KDr2) Date: Tue, 28 Apr 2009 15:10:30 +0800 Subject: [erlang-questions] erlix : Ruby Interface of Erlang In-Reply-To: References: <6050fd5a-473c-4794-99e6-d01418edabc7@n7g2000prc.googlegroups.com> Message-ID: The tutorial is just out : http://code.google.com/p/erlix/wiki/ErlixTutorial Enjoy it! On Tue, Apr 28, 2009 at 2:06 PM, KDr2 wrote: > It's Chinese, I will write some english docs an tutorial as soon as i can > :) > > > On Tue, Apr 28, 2009 at 1:53 PM, wolfmanjm wrote: > >> I've been looking for something like this, how about some >> documentation in English? The samples and docs seem to be in Kanji or >> something. >> >> Thanks >> >> On Apr 27, 6:50 pm, KDr2 wrote: >> > I start a project called erlix to wrap the erl_interface into ruby-api, >> and >> > erlix-0.2 just out, seehttp://code.google.com/p/erlix/ >> > It's linux-only now. >> > >> > -- >> > Best Regards, >> > -- KDr2, at x-macro.com. >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questi...@REDACTED:// >> www.erlang.org/mailman/listinfo/erlang-questions >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > Best Regards, > -- KDr2, at x-macro.com. > -- Best Regards, -- KDr2, at x-macro.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ngocdaothanh@REDACTED Tue Apr 28 11:39:18 2009 From: ngocdaothanh@REDACTED (Ngoc Dao) Date: Tue, 28 Apr 2009 18:39:18 +0900 Subject: [erlang-questions] erlix : Ruby Interface of Erlang In-Reply-To: References: <6050fd5a-473c-4794-99e6-d01418edabc7@n7g2000prc.googlegroups.com> Message-ID: <5c493e530904280239i42733f8er96c17a47652004c9@mail.gmail.com> Hi KDr2, Why not move your project to GitHub? It will be easier for others to watch, write wiki, cooperate etc. Ngoc. On Tue, Apr 28, 2009 at 4:10 PM, KDr2 wrote: > The tutorial is just out : > http://code.google.com/p/erlix/wiki/ErlixTutorial > Enjoy it! > > > On Tue, Apr 28, 2009 at 2:06 PM, KDr2 wrote: > >> It's Chinese, I will write some english docs an tutorial as soon as i can >> :) >> >> >> On Tue, Apr 28, 2009 at 1:53 PM, wolfmanjm wrote: >> >>> I've been looking for something like this, how about some >>> documentation in English? The samples and docs seem to be in Kanji or >>> something. >>> >>> Thanks >>> >>> On Apr 27, 6:50 pm, KDr2 wrote: >>> > I start a project called erlix to wrap the erl_interface into >>> ruby-api, and >>> > erlix-0.2 just out, seehttp://code.google.com/p/erlix/ >>> > It's linux-only now. >>> > >>> > -- >>> > Best Regards, >>> > -- KDr2, at x-macro.com. >>> > >>> > _______________________________________________ >>> > erlang-questions mailing list >>> > erlang-questi...@REDACTED:// >>> www.erlang.org/mailman/listinfo/erlang-questions >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> >> -- >> Best Regards, >> -- KDr2, at x-macro.com. >> > > > > -- > Best Regards, > -- KDr2, at x-macro.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ngocdaothanh@REDACTED Tue Apr 28 11:43:55 2009 From: ngocdaothanh@REDACTED (Ngoc Dao) Date: Tue, 28 Apr 2009 18:43:55 +0900 Subject: [erlang-questions] connect Erlang with Postgre_? In-Reply-To: References: <49F3753C.1020904@erlang-consulting.com> Message-ID: <5c493e530904280243w6ccabd58l4ee7f8139b64de81@mail.gmail.com> See: http://www.erlangatwork.com/2009/01/erlang-and-postgresql.html If you want a ORM-style mapping library, try ErlyDB. It works with Postgres. Ngoc. On Tue, Apr 28, 2009 at 10:45 AM, Michael Ossareh wrote: > Or as written by my co-worker: > > http://erlang.org/pipermail/erlang-questions/2009-March/042712.html > > Written to deal with the short comings of the current erlang > postgresql drivers. > > On Sat, Apr 25, 2009 at 1:40 PM, Francesco Cesarini (Erlang Training > and Consulting) wrote: > > You can use our PostgreSQL driver available at > > http://www.erlang-consulting.com/erlang/opensource.html > > > > Regards, > > Francesco > > -- > > http://www.erlang-consulting.com > > > > > > Rene Villalta Soto wrote: > >> > >> > >> > >> Hi, how I can to connect Erlang with Postgre? I have the Postgre's > Server in other PC > >> > >> > >> > >> > >> > >> > >> Erlang girls are too hot!!! I love this language... > >> > >> > >> > >> > >> > >> > >> ------------------------------------------------------------------------ > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > god loves atheists, Fact: > http://www.mrwiggleslovesyou.com/comics/rehab477.jpg > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kdr2@REDACTED Tue Apr 28 14:32:47 2009 From: kdr2@REDACTED (KDr2) Date: Tue, 28 Apr 2009 20:32:47 +0800 Subject: [erlang-questions] erlix : Ruby Interface of Erlang In-Reply-To: <5c493e530904280239i42733f8er96c17a47652004c9@mail.gmail.com> References: <6050fd5a-473c-4794-99e6-d01418edabc7@n7g2000prc.googlegroups.com> <5c493e530904280239i42733f8er96c17a47652004c9@mail.gmail.com> Message-ID: Good Idea, I will move it to http://github.com/KDr2/erlix/ thanks! On Tue, Apr 28, 2009 at 5:39 PM, Ngoc Dao wrote: > Hi KDr2, > > Why not move your project to GitHub? It will be easier for others to watch, > write wiki, cooperate etc. > > Ngoc. > > > > On Tue, Apr 28, 2009 at 4:10 PM, KDr2 wrote: > >> The tutorial is just out : >> http://code.google.com/p/erlix/wiki/ErlixTutorial >> Enjoy it! >> >> >> On Tue, Apr 28, 2009 at 2:06 PM, KDr2 wrote: >> >>> It's Chinese, I will write some english docs an tutorial as soon as i can >>> :) >>> >>> >>> On Tue, Apr 28, 2009 at 1:53 PM, wolfmanjm wrote: >>> >>>> I've been looking for something like this, how about some >>>> documentation in English? The samples and docs seem to be in Kanji or >>>> something. >>>> >>>> Thanks >>>> >>>> On Apr 27, 6:50 pm, KDr2 wrote: >>>> > I start a project called erlix to wrap the erl_interface into >>>> ruby-api, and >>>> > erlix-0.2 just out, seehttp://code.google.com/p/erlix/ >>>> > It's linux-only now. >>>> > >>>> > -- >>>> > Best Regards, >>>> > -- KDr2, at x-macro.com. >>>> > >>>> > _______________________________________________ >>>> > erlang-questions mailing list >>>> > erlang-questi...@REDACTED:// >>>> www.erlang.org/mailman/listinfo/erlang-questions >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>> >>> >>> >>> -- >>> Best Regards, >>> -- KDr2, at x-macro.com. >>> >> >> >> >> -- >> Best Regards, >> -- KDr2, at x-macro.com. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -- Best Regards, -- KDr2, at x-macro.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Tue Apr 28 14:46:11 2009 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 28 Apr 2009 14:46:11 +0200 Subject: [erlang-questions] [ANN] erlide 0.6.0 has been released Message-ID: <95be1d3b0904280546h5fa30218x56fd4742204fe8cc@mail.gmail.com> Hello everybody! We are glad to announce version 0.6.0 of erlIDE, featuring a lot of fixed bugs and also - Eclipse 3.4 only - Support for Erlang R13 - Greatly improved debugger - Refactoring with Wrangler The full changelog can be found at http://erlide.svn.sourceforge.net/viewvc/erlide/tags/REL-0.6.0.200904281124/CHANGES?revision=2574&view=markup If you encounter problems, please follow these steps: * Go to Window->Preferences->Erlang->Report problems * Fill in a summary and a description of what you did when the problem occurred * Pres "Send" and a file will be created in your home directory, attach it to a bug report at the tracker or to a mail to erlide-bugs@REDACTED best regards, Vlad and Jakob From francesco@REDACTED Tue Apr 28 17:55:46 2009 From: francesco@REDACTED (Francesco Cesarini (Erlang Training and Consulting)) Date: Tue, 28 Apr 2009 16:55:46 +0100 Subject: [erlang-questions] Erlang Talk Proposals Wanted: Commercial Users of Functional Programming Workshop Message-ID: <49F72702.1030207@erlang-consulting.com> A reminder that we are looking for Erlang talk proposals for the Commercial Users of Functional Programming Workshop (CUFP) 2009 workshop. The theme of the workshop is Functional Programming As a Means, Not an End. It will be Co-located with ICFP 2009 in Edinburgh,Scotland, 4 September 2009. With so many interesting Erlang projects out there, we are looking for talk proposals on your experiences of using Erlang and Functional Programming languages in commercial environments, and best of all, there is no need for a formal paper to be written. The deadline for talk submissions is May 15th. You can read more about the workshop, including the Call For Presentations at http://cufp.galois.com/ If you have any questions, please let me know. Kind regards, Francesco -- http://www.erlang-consulting.com From amit.murthy@REDACTED Tue Apr 28 19:32:06 2009 From: amit.murthy@REDACTED (Amit Murthy) Date: Tue, 28 Apr 2009 23:02:06 +0530 Subject: [erlang-questions] what is "parallel send"? Message-ID: <4f5fdb630904281032r2cd0e698kc8b5e3c9ec5042af@mail.gmail.com> Hi, Can someone explain what is meant by "parallel send" in the following line from the R13A release notes? "Message passing has been further optimized for parallel execution. Serial message passing is slightly more expensive than before, but parallel send to a common receiver is much cheaper." Regards, Amit -------------- next part -------------- An HTML attachment was scrubbed... URL: From egil@REDACTED Tue Apr 28 20:16:15 2009 From: egil@REDACTED (=?ISO-8859-1?Q?Bj=F6rn-Egil_Dahlberg?=) Date: Tue, 28 Apr 2009 20:16:15 +0200 Subject: [erlang-questions] what is "parallel send"? In-Reply-To: <4f5fdb630904281032r2cd0e698kc8b5e3c9ec5042af@mail.gmail.com> References: <4f5fdb630904281032r2cd0e698kc8b5e3c9ec5042af@mail.gmail.com> Message-ID: <49F747EF.5030509@erix.ericsson.se> The case which is referred is a many-to-one interprocess communication case, where multiple processes sends to a single process receiver. This case has improved performance. // Bj?rn-Egil Erlang/OTP Amit Murthy wrote: > Hi, > > Can someone explain what is meant by "parallel send" in the following > line from the R13A release notes? > > "Message passing has been further optimized for parallel execution. > Serial message passing is slightly more expensive than before, but > parallel send to a common receiver is much cheaper." > > Regards, > Amit > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ferenc.holzhauser@REDACTED Tue Apr 28 21:20:07 2009 From: ferenc.holzhauser@REDACTED (Ferenc Holzhauser) Date: Tue, 28 Apr 2009 21:20:07 +0200 Subject: [erlang-questions] Erlang Reading/Writing /dev/modem? In-Reply-To: <111690.64767.qm@web65513.mail.ac4.yahoo.com> References: <8aff81590904271509n4c330776id02799145a8b5495@mail.gmail.com> <111690.64767.qm@web65513.mail.ac4.yahoo.com> Message-ID: Indeed, Richard is right. Reading/writing the serial device is usually not enough. After looking into different options to talk to my modem from Erlang,I ended up using pyserial. It is a cross platform and simple to use python module. The Erlang communication could be a port or a socket. Regards, Ferenc -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark@REDACTED Tue Apr 28 21:41:02 2009 From: mark@REDACTED (Mark Selby) Date: Tue, 28 Apr 2009 20:41:02 +0100 Subject: [erlang-questions] Sending email Message-ID: <49F75BCE.2070602@tdbcomputing.com> I'm rebuilding a Rails app in Webmachine and need to send email via Gmail, all correctly configured for the domain in question. Is erlmail the only way to go with this, or are there better options? Cheers, Mark. From mark@REDACTED Tue Apr 28 21:42:01 2009 From: mark@REDACTED (Mark Selby) Date: Tue, 28 Apr 2009 20:42:01 +0100 Subject: [erlang-questions] Sending email Message-ID: <49F75C09.1020303@writebox.co.uk> I'm rebuilding a Rails app in Webmachine and need to send email via Gmail, all correctly configured for the domain in question. Is erlmail the only way to go with this, or are there better options? Cheers, Mark. From wolfmanjm@REDACTED Tue Apr 28 21:50:11 2009 From: wolfmanjm@REDACTED (wolfmanjm) Date: Tue, 28 Apr 2009 12:50:11 -0700 (PDT) Subject: [erlang-questions] connect Erlang with Postgre_? In-Reply-To: <5c493e530904280243w6ccabd58l4ee7f8139b64de81@mail.gmail.com> References: <49F3753C.1020904@erlang-consulting.com> <5c493e530904280243w6ccabd58l4ee7f8139b64de81@mail.gmail.com> Message-ID: <8c481d9d-5a29-44ed-bdd2-74ebbe97aaec@s38g2000prg.googlegroups.com> I use an alternative method, as IMHO Erlang is not well suited to talk to DBs, and DB traffic is slower and needs not scale as much I wrote a Java service using JInterface, that looks like an Erlang node and gets all the database requests from my Erlang nodes. This way you get to use all the power of Java database access (like SpringJDBC or Hibernate etc). I wrote an article on getting upto speed on JInterface... http://blog.wolfman.com/articles/2009/4/12/using-erlang-with-jinterface On Apr 28, 2:43?am, Ngoc Dao wrote: > See:http://www.erlangatwork.com/2009/01/erlang-and-postgresql.html > > If you want a ORM-style mapping library, try ErlyDB. It works with Postgres. > > Ngoc. > > On Tue, Apr 28, 2009 at 10:45 AM, Michael Ossareh wrote: > > Or as written by my co-worker: > > >http://erlang.org/pipermail/erlang-questions/2009-March/042712.html > > > Written to deal with the short comings of the current erlang > > postgresql drivers. > > > On Sat, Apr 25, 2009 at 1:40 PM, Francesco Cesarini (Erlang Training > > and Consulting) wrote: > > > You can use our PostgreSQL driver available at > > >http://www.erlang-consulting.com/erlang/opensource.html > > > > Regards, > > > Francesco > > > -- > > >http://www.erlang-consulting.com > > > > Rene Villalta Soto wrote: > > > >> Hi, how I can to connect Erlang with Postgre? I have the Postgre's > > Server in other PC > > > >> Erlang girls are too hot!!! I love this language... > > > >> ------------------------------------------------------------------------ > > > >> _______________________________________________ > > >> erlang-questions mailing list > > >> erlang-questi...@REDACTED > > >>http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questi...@REDACTED > > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > -- > > god loves atheists, Fact: > >http://www.mrwiggleslovesyou.com/comics/rehab477.jpg > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From wolfmanjm@REDACTED Tue Apr 28 22:04:00 2009 From: wolfmanjm@REDACTED (wolfmanjm) Date: Tue, 28 Apr 2009 13:04:00 -0700 (PDT) Subject: [erlang-questions] erlix : Ruby Interface of Erlang In-Reply-To: References: <6050fd5a-473c-4794-99e6-d01418edabc7@n7g2000prc.googlegroups.com> <5c493e530904280239i42733f8er96c17a47652004c9@mail.gmail.com> Message-ID: <920afc1f-4cfb-4647-9451-4c922bec1edf@k19g2000prh.googlegroups.com> This is quite nice, thank you. Currently I am using JInterface in JRuby to talk to my Erlang nodes. How would I do an RPC call using erlix? The equivalent of the Jinterface OtpConnection:sendRPC? IE I want to send an MFA call to a specific Erlang node. Thanks On Apr 28, 5:32?am, KDr2 wrote: > Good Idea, I will move it tohttp://github.com/KDr2/erlix/thanks! > > > > On Tue, Apr 28, 2009 at 5:39 PM, Ngoc Dao wrote: > > Hi KDr2, > > > Why not move your project to GitHub? It will be easier for others to watch, > > write wiki, cooperate etc. > > > Ngoc. > > > On Tue, Apr 28, 2009 at 4:10 PM, KDr2 wrote: > > >> The tutorial is just out : > >>http://code.google.com/p/erlix/wiki/ErlixTutorial > >> Enjoy it! > > >> On Tue, Apr 28, 2009 at 2:06 PM, KDr2 wrote: > > >>> It's Chinese, I will write some english docs an tutorial as soon as i can > >>> :) > > >>> On Tue, Apr 28, 2009 at 1:53 PM, wolfmanjm wrote: > > >>>> I've been looking for something like this, how about some > >>>> documentation in English? The samples and docs seem to be in Kanji or > >>>> something. > > >>>> Thanks > > >>>> On Apr 27, 6:50 pm, KDr2 wrote: > >>>> > I start ?a project called erlix to wrap the erl_interface into > >>>> ruby-api, and > >>>> > erlix-0.2 just out, seehttp://code.google.com/p/erlix/ > >>>> > It's linux-only now. > > >>>> > -- > >>>> > Best Regards, > >>>> > ? ?-- KDr2, at x-macro.com. > > >>>> > _______________________________________________ > >>>> > erlang-questions mailing list > >>>> > erlang-questi...@REDACTED:// > >>>>www.erlang.org/mailman/listinfo/erlang-questions > >>>> _______________________________________________ > >>>> erlang-questions mailing list > >>>> erlang-questi...@REDACTED > >>>>http://www.erlang.org/mailman/listinfo/erlang-questions > > >>> -- > >>> Best Regards, > >>> ? ?-- KDr2, at x-macro.com. > > >> -- > >> Best Regards, > >> ? ?-- KDr2, at x-macro.com. > > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questi...@REDACTED > >>http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Best Regards, > ? ?-- KDr2, at x-macro.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From tuscland@REDACTED Tue Apr 28 23:12:38 2009 From: tuscland@REDACTED (Camille Troillard) Date: Tue, 28 Apr 2009 23:12:38 +0200 Subject: [erlang-questions] gen_event handler question Message-ID: Hello, I would like to know if it is possible to write an event handler that would receive only certain notifications based on a simple criteria. For example, say I have a server process that searches for USB devices, and sends notifications whenever new devices are attached or detached. I would like to write a event handler that would register to only certain kind of devices (based on an atom describing the device for example) or another event handler that would match all devices. I have tried to use different function clauses like : * in a module : handle_event({attach, device_type_A}, State) -> ... handle_event({detach, device_type_A}, State) -> ... * and, in another module : handle_event({attach, device_type_B}, State) -> ... handle_event({detach, device_type_B}, State) -> ... And register those two event handlers with the same manager. Unfortunately it fails with a bad_function_clause error. I was expecting that, but I'm running out of ideas. Am I overlooking something? Best Regards, Camille -------------- next part -------------- An HTML attachment was scrubbed... URL: From q2h46uw02@REDACTED Wed Apr 29 00:56:22 2009 From: q2h46uw02@REDACTED (Kevin) Date: Tue, 28 Apr 2009 18:56:22 -0400 Subject: [erlang-questions] String pattern matching Message-ID: <28615-01975@sneakemail.com> Does this behavior make sense to somebody or is this sugar tasting sour? 25> "a"++B = "ab". "ab" 26> A++"b" = "ab". * 1: illegal pattern I was just looking for an erlangy way to chomp the end of strings, like NewLine ++ "\r\n" = Line From erlangy@REDACTED Wed Apr 29 01:16:40 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Tue, 28 Apr 2009 16:16:40 -0700 Subject: [erlang-questions] Sending email In-Reply-To: <49F75C09.1020303@writebox.co.uk> References: <49F75C09.1020303@writebox.co.uk> Message-ID: <20090428231640.GM10039@delora.autosys.us> I prefer smtp_fsm.erl from http://www.trapexit.org/Special:UserContributions which sends mail via SMTP to whatever server you configure it for. Not certain what you mean by "all correctly configured for the domain in question" so do not know if it is completely appropriate for your use pattern. If the receiving mail server demands proper reverse DNS lookup of the sending server, that is outside of the scope of the individual mail utilities anyway and needs to be configured via your nameserver. smtp_fsm does not require any email system installed on your server (which is also true of some of the other email facilities). See more choices at the above link. ~Michael On Tue, Apr 28, 2009 at 08:42:01PM +0100, Mark Selby wrote: > I'm rebuilding a Rails app in Webmachine and need to send email via > Gmail, all correctly configured for the domain in question. > > Is erlmail the only way to go with this, or are there better options? > > Cheers, > > Mark. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Michael McDaniel Portland, Oregon, USA http://trip.autosys.us http://autosys.us http://mmcdaniel.com/erlview From rvirding@REDACTED Wed Apr 29 01:18:02 2009 From: rvirding@REDACTED (Robert Virding) Date: Wed, 29 Apr 2009 01:18:02 +0200 Subject: [erlang-questions] String pattern matching In-Reply-To: <28615-01975@sneakemail.com> References: <28615-01975@sneakemail.com> Message-ID: <3dbc6d1c0904281618m5bd8d4cbhe4c509cedb2ff00b@mail.gmail.com> A string is just a list and unfortunately you can only match against the front of the list so there is no pattern with which you can test for/remove \r\n from the end of a string. This also means that the results of using the patterns you gave is perfectly logical: - "a"++B is a list/string where the beginning is "a" and the rest of the list is B. It is really syntactic sugar for [$a|B]. - A++"b" tries to match "b" against the end of a string which is impossible. Robert 2009/4/29 Kevin > > Does this behavior make sense to somebody or is this sugar tasting sour? > > > 25> "a"++B = "ab". > "ab" > 26> A++"b" = "ab". > * 1: illegal pattern > > > I was just looking for an erlangy way to chomp the end of strings, like > > NewLine ++ "\r\n" = Line > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Wed Apr 29 01:42:48 2009 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 29 Apr 2009 11:42:48 +1200 Subject: [erlang-questions] String pattern matching In-Reply-To: <28615-01975@sneakemail.com> References: <28615-01975@sneakemail.com> Message-ID: On 29 Apr 2009, at 10:56 am, Kevin wrote: > > Does this behavior make sense to somebody or is this sugar tasting > sour? > > > 25> "a"++B = "ab". > "ab" > 26> A++"b" = "ab". > * 1: illegal pattern 100% sensible. Fundamental rule: pattern matching only takes stuff apart; it NEVER builds new lists or tuples. To put it another way, patterns aren't regular expressions. > I was just looking for an erlangy way to chomp the end of strings, > like > > NewLine ++ "\r\n" = Line Well the *BEST* way to do that is to restructure the program so that the \r\n never gets into the line in the first place. The second best thing to do is to arrange that the rest of the program doesn't _care_ whether the \r\n is there or not. For example, if you are about to remove trailing spaces, use instead something that removes trailing white space of all kinds. You can of course do "\n\r" ++ R = lists:reverse(Line), NewLine = lists:reverse(R) which is easy to think of. From nem@REDACTED Wed Apr 29 02:35:28 2009 From: nem@REDACTED (Geoff Cant) Date: Wed, 29 Apr 2009 02:35:28 +0200 Subject: [erlang-questions] Sending email In-Reply-To: <49F75BCE.2070602@tdbcomputing.com> (Mark Selby's message of "Tue, 28 Apr 2009 20:41:02 +0100") References: <49F75BCE.2070602@tdbcomputing.com> Message-ID: Mark Selby writes: > I'm rebuilding a Rails app in Webmachine and need to send email via > Gmail, all correctly configured for the domain in question. > > Is erlmail the only way to go with this, or are there better options? I got tired of not having an answer to the email sending problem and developed esmtp (http://github.com/archaelus/esmtp) as a result. In my use of esmtp I assume a local smarthost, so I haven't used it with gmail before. I've checked the code and it does support auth, but not ssl yet. Adding ssl is probably not too tricky... (2 hours pass)... so I've just done it: application:load(esmtp), application:set_env(esmtp, smarthost, {"smtp.gmail.com",465}), application:set_env(esmtp, login, {"youraddress@REDACTED","YourPassword"}), application:start(esmtp). (The above is to set the config parameters without a config file). esmtp:send(esmtp_mime:msg("","","Some Subject", "Some Body")). I'll probably need to check to see I haven't broken regular smtp in this update. And make the error reporting better. And document this properly. I couldn't get TLS work properly in R13B, but I'll track that down some other time. Cheers, -- Geoff Cant From kdr2@REDACTED Wed Apr 29 05:04:03 2009 From: kdr2@REDACTED (KDr2) Date: Wed, 29 Apr 2009 11:04:03 +0800 Subject: [erlang-questions] erlix : Ruby Interface of Erlang In-Reply-To: <920afc1f-4cfb-4647-9451-4c922bec1edf@k19g2000prh.googlegroups.com> References: <6050fd5a-473c-4794-99e6-d01418edabc7@n7g2000prc.googlegroups.com> <5c493e530904280239i42733f8er96c17a47652004c9@mail.gmail.com> <920afc1f-4cfb-4647-9451-4c922bec1edf@k19g2000prh.googlegroups.com> Message-ID: I release erlix-v0.3 today: bugfix: IO block bug in ErlixConnection?#erecv feature: 1. ErlixList? #new("string") 2. ErlixConnection?#close 3. ErlixConnection?#closed? 4. ErlixConnection? #rpc("module","function",ErlixTermList?) 5. ErlixConnection?#peer see the section Erlix RPC on http://code.google.com/p/erlix/wiki/ErlixTutorial On Wed, Apr 29, 2009 at 4:04 AM, wolfmanjm wrote: > This is quite nice, thank you. > > Currently I am using JInterface in JRuby to talk to my Erlang nodes. > > How would I do an RPC call using erlix? > > The equivalent of the Jinterface OtpConnection:sendRPC? > > IE I want to send an MFA call to a specific Erlang node. > > > Thanks > > On Apr 28, 5:32 am, KDr2 wrote: > > Good Idea, I will move it tohttp://github.com/KDr2/erlix/thanks! > > > > > > > > On Tue, Apr 28, 2009 at 5:39 PM, Ngoc Dao > wrote: > > > Hi KDr2, > > > > > Why not move your project to GitHub? It will be easier for others to > watch, > > > write wiki, cooperate etc. > > > > > Ngoc. > > > > > On Tue, Apr 28, 2009 at 4:10 PM, KDr2 wrote: > > > > >> The tutorial is just out : > > >>http://code.google.com/p/erlix/wiki/ErlixTutorial > > >> Enjoy it! > > > > >> On Tue, Apr 28, 2009 at 2:06 PM, KDr2 wrote: > > > > >>> It's Chinese, I will write some english docs an tutorial as soon as i > can > > >>> :) > > > > >>> On Tue, Apr 28, 2009 at 1:53 PM, wolfmanjm > wrote: > > > > >>>> I've been looking for something like this, how about some > > >>>> documentation in English? The samples and docs seem to be in Kanji > or > > >>>> something. > > > > >>>> Thanks > > > > >>>> On Apr 27, 6:50 pm, KDr2 wrote: > > >>>> > I start a project called erlix to wrap the erl_interface into > > >>>> ruby-api, and > > >>>> > erlix-0.2 just out, seehttp://code.google.com/p/erlix/ > > >>>> > It's linux-only now. > > > > >>>> > -- > > >>>> > Best Regards, > > >>>> > -- KDr2, at x-macro.com. > > > > >>>> > _______________________________________________ > > >>>> > erlang-questions mailing list > > >>>> > erlang-questi...@REDACTED:// > > >>>>www.erlang.org/mailman/listinfo/erlang-questions > > >>>> _______________________________________________ > > >>>> erlang-questions mailing list > > >>>> erlang-questi...@REDACTED > > >>>>http://www.erlang.org/mailman/listinfo/erlang-questions > > > > >>> -- > > >>> Best Regards, > > >>> -- KDr2, at x-macro.com. > > > > >> -- > > >> Best Regards, > > >> -- KDr2, at x-macro.com. > > > > >> _______________________________________________ > > >> erlang-questions mailing list > > >> erlang-questi...@REDACTED > > >>http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -- > > Best Regards, > > -- KDr2, at x-macro.com. > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED:// > www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, -- KDr2, at x-macro.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From silvester.roessner@REDACTED Wed Apr 29 08:02:59 2009 From: silvester.roessner@REDACTED (Roessner, Silvester) Date: Wed, 29 Apr 2009 08:02:59 +0200 Subject: [erlang-questions] Otp.NET: It would be nice to have seamless string support In-Reply-To: <20090428055434.GA2561@contorpis.lisalinda.com> References: <5259C246-10F0-4B23-BE9B-2DC41892E23E@hi5.com> <20090428055434.GA2561@contorpis.lisalinda.com> Message-ID: <2CEB6DA5040AED4F946351C85FAC87B5031017E0@DEJENSAPP01V1.vision.zeiss.org> Hi, I run into a problem while I tried to send Otp.Erlang.String with length > 64k from a OTP.Net node to a native Erlang node. The Erlang node only received a cut string, not the full one. The cause of this trouble is the strong adherence of OTP.Net to the external term format. The Erlang node sends a list in an external term "STRING_EXT" when the list length < 64k and all list entries are integers in the range 0..255 But it sends a list as an external term "LIST_EXT" otherwise. OTP.Net has implemented Otp.Erlang.String but this is not a real Erlang type only an external term. When I use OTP.Net to receive from or send strings to another node I have to manually distinguish between these two cases. Receiver: .... try { Otp.Erlang.String S = (Otp.Erlang.String)Tuple.elementAt(1); Payload = S.stringValue(); } catch (InvalidCastException) { Otp.Erlang.List List = (Otp.Erlang.List)Tuple.elementAt(1); Payload = stringValue(List); } .... private string stringValue(Otp.Erlang.List L) { System.Text.StringBuilder s = new System.Text.StringBuilder(); int _arity = L.Length; Otp.Erlang.Long E_Char; for (int i = 0; i < _arity; i++) { E_Char = (Otp.Erlang.Long)L.elementAt(i); s.Append(E_Char.charValue()); } return s.ToString(); } Sender: .... Otp.Erlang.Object[] Message = new Otp.Erlang.Object[2]; Message[0] = new Otp.Erlang.Int(L); if (L < 65000) { Message[1] = new Otp.Erlang.String(Payload); } else { Otp.Erlang.String Test = new Otp.Erlang.String(Payload); int LL = Test.stringValue().Length; new Otp.Erlang.List( Message[1] = toList(Payload); } Box.send(Other, new Tuple(Message)); .... This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted. From mtalyans@REDACTED Wed Apr 29 07:06:10 2009 From: mtalyans@REDACTED (Michael Talyansky) Date: Tue, 28 Apr 2009 22:06:10 -0700 Subject: [erlang-questions] Inets and IPv6 (noob) Message-ID: Hi All, I have recently moved my simple web server application from FreeBSD to Ubuntu Linux, and here is what happens: I start inets thus: {ok, Pid} = inets:start(httpd, [{port, 55555}, {server_name,"httpd_test"}, {server_root,"/tmp"}, {document_root,"/tmp"}, {bind_address, "localhost"}, {modules, [mod_get, push]}]), On BSD, server was binding to (and listening on) IPv4 address. On Linux, it binds to IPv6 only (verified with netstat), unless I explicitly specify IPv4 interface address in the bind_address tuple. What should I set and where in order for the server to bind to both IPv4 and IPv6 addresses? I am using R13B, on BSD it was R13A. Could this be a factor? Thanks much in advance! From silvester.roessner@REDACTED Wed Apr 29 08:11:57 2009 From: silvester.roessner@REDACTED (Roessner, Silvester) Date: Wed, 29 Apr 2009 08:11:57 +0200 Subject: [erlang-questions] Otp.NET: It would be nice to have seamless string support References: <5259C246-10F0-4B23-BE9B-2DC41892E23E@hi5.com> <20090428055434.GA2561@contorpis.lisalinda.com> Message-ID: <2CEB6DA5040AED4F946351C85FAC87B5031017E7@DEJENSAPP01V1.vision.zeiss.org> Hi, (sorry for the former incomplete e-mail - I hit enter by accident) I think it would be usefull to have a real Otp.Erlang.List object that combines Otp.Erlang.List and Otp.Erlang.String. This object should have a constructor String(string S) and a methode stringValue(). The reason why I think this is sensible: I run into a problem while I tried to send Otp.Erlang.String with length > 64k from a OTP.Net node to a native Erlang node. The Erlang node only received a cut string, not the full one. The cause of this trouble is the strong adherence of OTP.Net to the external term format. The Erlang node sends a list in an external term "STRING_EXT" when the list length < 64k and all list entries are integers in the range 0..255 But it sends a list as an external term "LIST_EXT" otherwise. OTP.Net has implemented Otp.Erlang.String but this is not a real Erlang type only an external term. When I use OTP.Net to receive from or send strings to another node I have to manually distinguish between these two cases. Receiver: .... try { Otp.Erlang.String S = (Otp.Erlang.String)Tuple.elementAt(1); Payload = S.stringValue(); } catch (InvalidCastException) { Otp.Erlang.List List = (Otp.Erlang.List)Tuple.elementAt(1); Payload = stringValue(List); } .... private string stringValue(Otp.Erlang.List L) { System.Text.StringBuilder s = new System.Text.StringBuilder(); int _arity = L.Length; Otp.Erlang.Long E_Char; for (int i = 0; i < _arity; i++) { E_Char = (Otp.Erlang.Long)L.elementAt(i); s.Append(E_Char.charValue()); } return s.ToString(); } Sender: .... Otp.Erlang.Object[] Message = new Otp.Erlang.Object[2]; Message[0] = new Otp.Erlang.Int(L); if (L < 65000) { Message[1] = new Otp.Erlang.String(Payload); } else { Otp.Erlang.String Test = new Otp.Erlang.String(Payload); int LL = Test.stringValue().Length; new Otp.Erlang.List( Message[1] = toList(Payload); } Box.send(Other, new Tuple(Message)); .... private Otp.Erlang.List toList(string S) { int _arity = S.Length; Otp.Erlang.Object[] Longs = new Otp.Erlang.Object[_arity]; for (int i = 0; i < _arity; i++) { Longs[i] = new Otp.Erlang.Long(S[i]); } return new Otp.Erlang.List(Longs); } This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted. From erlang@REDACTED Wed Apr 29 09:28:02 2009 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 29 Apr 2009 09:28:02 +0200 Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs Message-ID: <9b08084c0904290028u4bdca0eax8c9c9518c6678960@mail.gmail.com> Hi, I recent got mail from Steve Kirsch (Hello Steve) - asking a number of questions about representation of bit vectors for writing Bloom filters. Having read my book he thought I could answer all questions about Erlang little did he know that the collective intelligence of the people reading this list far exceeds what I could contribute :-) So he sent me a program, which crashes his machine (out of memory) which he thought should work - to my eye it looks ok - It will not be blindingly fast, but it looks properly tail-recursive so the garbage collector should not have any problems. I've appended at the end of this mail - so you can see for yourself. It is a GC bug or a user error? The next question is "what is a suitable data structure for representing a large bit vector" (we want to flip specific bits) - the "pure" answer I guess is a tuple of tuples of binaries (say 32x32xB) where B is a 128 byte binary for 2^20 bits. The "tuple of tuple of tuple ..." representation is commonly used to implement array and dicts Possibly we could just use array.erl creating an array of 32x32 elements containing 128 byte binaries. If this is not efficient enough we would turn to C. A linked-in driver seems overkill here - we can't send a large binary back and forth over an I/O interface - so this needs a BIF. What I'd like is a "linked in BIF" - it seems to me to be a bit of a pain in the whatnot to have to mess around with the Erlang internals every time you want to write a new BIF. Much nicer to have a linked-in BIF - on demand loading of C code is pretty easy so this should not be a problem. One could also impose a measure of stack discipline for linked-in BIFs (as in the JVM) - this would make it pretty easy to write extensions. Nuff said ... /Joe Now the origonal post that sparked this thread .. ------ cut --- below this line is from Steve's post----- ... i tested the erlang bloom filter I found in google code which i've included below. Doing 10,000 inserts per my test routine (which allocates a 1M key bitmap to start to make it "tough" for erlang) took 423 cpu seconds, which is only 23 inserts/sec!?!?! That is ludicrous as I'm sure you'd agree And if you tried only 100,000 inserts into my 1.8MB table, erlang crashes: %% binary_alloc: Cannot allocate 3594429 bytes of memory (of type "binary"). The book is pretty much silent on how you'd implement this important class of functions. Nor does it talk about why this code fails, though I'd imagine it is copying and gc'ing large binaries like crazy every time you change 1 bit. I think the book should talk about is there a way to write this code with binaries and work? Or do you have to use arrays or some other means? %% @doc Implementation of the Bloom filter data structure. %% @reference [http://en.wikipedia.org/wiki/Bloom_filter] -module(bitmap). -export([test/1, new/1, new/2, is_bloom/1, is_element/2, add_element/2]). -import(math, [log/1, pow/2]). -import(erlang, [phash2/2]). % B0 = bloom:new(2000, 0.001). % bloom:is_bloom(B0). % B1 = bloom:add_element(Key, B0). % bloom:is_element(Key, B1). -record(bloom, { m = 0, % The size of the bitmap in bits. bitmap = <<>>, % The bitmap. k = 0, % The number of hashes. n = 0, % The maximum number of keys. keys = 0 % The current number of keys. }). %% @spec new(capacity) -> bloom() %% @equiv new(capacity, 0.001) new(N) -> new(N, 0.001). %% @spec new(integer(), float()) -> bloom() %% @doc Creates a new Bloom filter, given a maximum number of keys and a %% false-positive error rate. new(N, E) when N > 0, is_float(E), E > 0, E =< 1 -> {M, K} = calc_least_bits(N, E), #bloom{m=M, bitmap = <<0:((M+7) div 8 * 8)>>, k=K, n=N}. %% @spec is_bloom(bloom()) -> bool() %% @doc Determines if the given argument is a bloom record. is_bloom(#bloom{}) -> true; is_bloom(_) -> false. %% @spec is_element(string(), bloom()) -> bool() %% @doc Determines if the key is (probably) an element of the filter. is_element(Key, B) -> is_element(Key, B, calc_idxs(Key, B)). is_element(_, _, []) -> true; is_element(Key, B, [Idx | T]) -> ByteIdx = Idx div 8, <<_:ByteIdx/binary, Byte:8, _/binary>> = B#bloom.bitmap, Mask = 1 bsl (Idx rem 8), case 0 =/= Byte band Mask of true -> is_element(Key, B, T); false -> false end. %% @spec add_element(string(), bloom()) -> bloom() %% @doc Adds the key to the filter. add_element(Key, #bloom{keys=Keys, n=N, bitmap=Bitmap} = B) when Keys < N -> Idxs = calc_idxs(Key, B), Bitmap0 = set_bits(Bitmap, Idxs), case Bitmap0 == Bitmap of true -> B; % Don't increment key count for duplicates. false -> B#bloom{bitmap=Bitmap0, keys=Keys+1} end. set_bits(Bin, []) -> Bin; set_bits(Bin, [Idx | Idxs]) -> ByteIdx = Idx div 8, <> = Bin, Mask = 1 bsl (Idx rem 8), Byte0 = Byte bor Mask, set_bits(<
>, Idxs).

% Find the optimal bitmap size and number of hashes.
calc_least_bits(N, E) -> calc_least_bits(N, E, 1, 0, 0).
calc_least_bits(N, E, K, MinM, BestK) ->
   M = -1 * K * N / log(1 - pow(E, 1/K)),
   {CurM, CurK} = if M < MinM -> {M, K}; true -> {MinM, BestK} end,
   case K of
         1 -> calc_least_bits(N, E, K+1, M, K);
       100 -> {trunc(CurM)+1, CurK};
         _ -> calc_least_bits(N, E, K+1, CurM, CurK)
   end.

% This uses the "enhanced double hashing" algorithm.
% Todo: handle case of m > 2^32.
calc_idxs(Key, #bloom{m=M, k=K}) ->
   X = phash2(Key, M),
   Y = phash2({"salt", Key}, M),
   calc_idxs(M, K - 1, X, Y, [X]).
calc_idxs(_, 0, _, _, Acc) -> Acc;
calc_idxs(M, I, X, Y, Acc) ->
   Xi = (X+Y) rem M,
   Yi = (Y+I) rem M,
   calc_idxs(M, I-1, Xi, Yi, [Xi | Acc]).

test(N)->
   B0 = new(1000000, 0.001),
   F=fun(Key, Bloom)-> add_element(Key, Bloom) end,
   lists:foldl(F, B0, lists:seq(1,N)).

%% to test: B1=bitmap:test(1000000).
%% which crashes erlang even if only 100,000 entries


%% Crash dump was written to: erl_crash.dump
%% binary_alloc: Cannot allocate 3594429 bytes of memory (of type
"binary").

%% This application has requested the Runtime to terminate it in an
unusual way.
%% Please contact the application's support team for more information.

%% Process inferior-erlang exited abnormally with code 3


From rtrlists@REDACTED  Wed Apr 29 10:17:30 2009
From: rtrlists@REDACTED (Robert Raschke)
Date: Wed, 29 Apr 2009 09:17:30 +0100
Subject: [erlang-questions] gen_event handler question
In-Reply-To: 
References: 
Message-ID: <6a3ae47e0904290117i702c8d65nafdb2e427f5d0a4c@mail.gmail.com>

On Tue, Apr 28, 2009 at 10:12 PM, Camille Troillard  wrote:
> Hello,
> I would like to know if it is possible to write an event handler that would
> receive only certain notifications based on a simple criteria.
> For example, say I have a server process that searches for USB devices, and
> sends notifications whenever new devices are attached or detached. ?I would
> like to write a event handler that would register to only certain kind of
> devices (based on an atom describing the device for example)?or another
> event handler that would match all devices.
> I have tried to use different function clauses like :
> * in a module :
> handle_event({attach, device_type_A}, State) -> ?...
> handle_event({detach, device_type_A}, State) -> ?...
> * and, in another module :
> handle_event({attach, device_type_B}, State) -> ?...
> handle_event({detach, device_type_B}, State) -> ?...
> And register those two event handlers with the same manager. ?Unfortunately
> it fails with a bad_function_clause error. ?I was expecting that, but I'm
> running out of ideas.
> Am?I?overlooking something?
>
> Best Regards,
> Camille
>

You could use a catch all like handle_event(_, State)-> at the end of
your handlers? Not sure if that's the recommended way though.

Robby


From tuscland@REDACTED  Wed Apr 29 10:33:02 2009
From: tuscland@REDACTED (Camille Troillard)
Date: Wed, 29 Apr 2009 10:33:02 +0200
Subject: [erlang-questions] gen_event handler question
In-Reply-To: <6a3ae47e0904290117i702c8d65nafdb2e427f5d0a4c@mail.gmail.com>
References: 
	<6a3ae47e0904290117i702c8d65nafdb2e427f5d0a4c@mail.gmail.com>
Message-ID: 

On Wed, Apr 29, 2009 at 10:17 AM, Robert Raschke wrote:

>
> > I would like to know if it is possible to write an event handler that
> would
> > receive only certain notifications based on a simple criteria.
>
> You could use a catch all like handle_event(_, State)-> at the end of
> your handlers? Not sure if that's the recommended way though.


Yes, I thought about this, hehe.
But then all the handlers would receive notifications and should decide
themselves wether or not they should process the message, which is not good.
 It looks like a design issue on my side, oh well ?  maybe this is not the
"erlang" way to do it ?

Cam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From freza@REDACTED  Wed Apr 29 10:57:04 2009
From: freza@REDACTED (Jachym Holecek)
Date: Wed, 29 Apr 2009 10:57:04 +0200
Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs
In-Reply-To: <9b08084c0904290028u4bdca0eax8c9c9518c6678960@mail.gmail.com>
References: <9b08084c0904290028u4bdca0eax8c9c9518c6678960@mail.gmail.com>
Message-ID: <20090429085703.GA2601@hanele>

Hello,

# Joe Armstrong 2009-04-29:
> So he sent me a program, which crashes his machine (out of memory)
> which he thought should work - to my eye it looks ok - It will not
> be blindingly fast, but it looks properly tail-recursive so the
> garbage collector should not have any problems.
> 
> I've appended at the end of this mail - so you can see for yourself.
> It is a GC bug or a user error?

UNIX heap size limit is certainly one of the factors. During the
test (doesn't crash on my system -- my user is allowed to consume
up to 2GB RAM) 'erl' consumes anywhere between 20MB to 1GB of RAM.

> What I'd like is a "linked in BIF" - it seems to me to be a bit of a
> pain in the whatnot to have to mess around with the Erlang internals
> every time you want to write a new BIF.

Doesn't the FFI EEP solve this?

> ------ cut --- below this line is from Steve's post-----
> [...]
> Nor does it talk about why this code fails, though I'd imagine it is
> copying and gc'ing large binaries like crazy every time you change 1
> bit.

It seems more like it's building new binaries with references to the
old binaries, the structure seems to be flattened on GC. Indeed,
adding a call to erlang:garbage_collect/0 into bitmap:set_bits/2
makes the test run in pretty much constant 30MB of RAM.

Mostly guessing here (based on bitmap.beam disassembly), but I'm
sure someone will correct me if I'm wrong ;-).

Regards,
	-- Jachym


From mikpe@REDACTED  Wed Apr 29 11:25:54 2009
From: mikpe@REDACTED (Mikael Pettersson)
Date: Wed, 29 Apr 2009 11:25:54 +0200
Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs
In-Reply-To: <9b08084c0904290028u4bdca0eax8c9c9518c6678960@mail.gmail.com>
References: <9b08084c0904290028u4bdca0eax8c9c9518c6678960@mail.gmail.com>
Message-ID: <18936.7458.10234.422674@pilspetsen.it.uu.se>

Joe Armstrong writes:
 > Hi,
 > 
 > I recent got mail from Steve Kirsch (Hello Steve) - asking a number
 > of questions about representation of bit vectors for writing Bloom filters.
...
 > So he sent me a program, which crashes his machine (out of memory)
...
 > new(N, E) when N > 0, is_float(E), E > 0, E =< 1 ->
 >    {M, K} = calc_least_bits(N, E),
 >    #bloom{m=M, bitmap = <<0:((M+7) div 8 * 8)>>, k=K, n=N}.

Large bitmaps are problematic in Erlang.

You can do chunked representations, which will work but will incur
high overheads on both reads and writes.

Using large binaries as the code above does is fragile and inefficient.
Large binaries are allocated outside of the GCd heaps in a global shared
area and are accessed via small heap-allocated and GCd handles. Frequent
updates will require frequent new allocations and copies in the shared
area. Old versions of these binaries are only deallocated in response to
local (per-process) GCs when their handles die.

So creating a series of large binaries in rapid succession without
intervening GCs is a fairly reliable way of running out of memory.

HiPE needs large bitmaps for its register allocator, so we added our
own bitarray BIFs since all alternatives suck. As much as _I_ like them,
I cannot recommend them for application developers:
- they're only present in HiPE-enabled systems
- they're not documented or official in any way, and may change at any time
- the effect of sending a bitarray to another process is unspecified
  (the processes may or may not share the object)
- Erlang is _supposed_ to protect application programmers from the perils
  of mutable data :-/


From masse@REDACTED  Wed Apr 29 12:45:04 2009
From: masse@REDACTED (mats cronqvist)
Date: Wed, 29 Apr 2009 12:45:04 +0200
Subject: [erlang-questions] String pattern matching
In-Reply-To: <28615-01975@sneakemail.com> (Kevin's message of "Tue\,
	28 Apr 2009 18\:56\:22 -0400")
References: <28615-01975@sneakemail.com>
Message-ID: <873abrd9hr.fsf@sterlett.hq.kred>

"Kevin"  writes:

> Does this behavior make sense to somebody or is this sugar tasting sour?
>
>
> 25> "a"++B = "ab". 
> "ab"
> 26> A++"b" = "ab".
> * 1: illegal pattern
>
>
> I was just looking for an erlangy way to chomp the end of strings, like
>
> NewLine ++ "\r\n" = Line

 I use something like;
string:tokens("blafoo\r\n","\r\n").

  mats


From carlmcdade@REDACTED  Wed Apr 29 12:49:16 2009
From: carlmcdade@REDACTED (Carl McDade)
Date: Wed, 29 Apr 2009 12:49:16 +0200
Subject: [erlang-questions] Did Windows SMP support ever get added?
Message-ID: 

Hi,

I am asking this because it is not clear in the docs. I recently went from
Windows 2003 server over to Windows XP Pro on a Dual processor PC. Windows
XP did not pick up both processors so I had to force it a bit. But now
Windows sees both processors but Erlang does not. Is it because

a. I need to reinstall Erlang
b. change a configuration file somewhere
c. forget about it. Erlang does not support SMP in Windows yet.

Thanks for any advice

-- 
Carl McDade
www.hiveminds.co.uk
________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From kenneth.lundin@REDACTED  Wed Apr 29 12:59:33 2009
From: kenneth.lundin@REDACTED (Kenneth Lundin)
Date: Wed, 29 Apr 2009 12:59:33 +0200
Subject: [erlang-questions] Did Windows SMP support ever get added?
In-Reply-To: 
References: 
Message-ID: 

Hi,

The SMP support on Windows was introduced in Erlang/OTP R12B which has
been available for more than a year now.


On Wed, Apr 29, 2009 at 12:49 PM, Carl McDade  wrote:
> Hi,
>
> I am asking this because it is not clear in the docs. I recently went from
> Windows 2003 server over to Windows XP Pro on a Dual processor PC. Windows
> XP did not pick up both processors so I had to force it a bit. But now
> Windows sees both processors but Erlang does not. Is it because
>
> a. I need to reinstall Erlang
No
> b. change a configuration file somewhere
No, at least not any Erlang specific file
> c. forget about it. Erlang does not support SMP in Windows yet.
SMP support for Windows since R12B

I am not aware of any specific problems on Windows XP.

/Kenneth , Erlang/OTP , Ericsson
>
> Thanks for any advice
>
> --
> Carl McDade
> www.hiveminds.co.uk
> ________________________
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From bbmaj7@REDACTED  Wed Apr 29 13:01:22 2009
From: bbmaj7@REDACTED (Richard Andrews)
Date: Wed, 29 Apr 2009 04:01:22 -0700 (PDT)
Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs
In-Reply-To: <18936.7458.10234.422674@pilspetsen.it.uu.se>
References: <9b08084c0904290028u4bdca0eax8c9c9518c6678960@mail.gmail.com>
	<18936.7458.10234.422674@pilspetsen.it.uu.se>
Message-ID: <570656.41336.qm@web65516.mail.ac4.yahoo.com>




> From: Mikael Pettersson 
...
> So creating a series of large binaries in rapid succession without
> intervening GCs is a fairly reliable way of running out of memory.

+1

I haven't tested the program but have recently seen similar pathological cases.

You might mitigate the OoM problem with {fullsweep_after,0} in spawn_opt(). As you said Joe, this won't be fast and using the above fullsweep option will slow it down further.


      Enjoy a better web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now.


From ljw1001@REDACTED  Wed Apr 29 13:08:18 2009
From: ljw1001@REDACTED (Larry White)
Date: Wed, 29 Apr 2009 07:08:18 -0400
Subject: [erlang-questions] Sending email
In-Reply-To: 
References: <49F75BCE.2070602@tdbcomputing.com> 
Message-ID: 

There seem toe be quite a few smtp client implementations around. Is there a
process for picking one for addition to the erlang standard libraries?  It
would be incredibly useful to have one that you knew you could count on,
that supported supported the complete standard, etc.

just a thought.

On Tue, Apr 28, 2009 at 8:35 PM, Geoff Cant  wrote:

> Mark Selby  writes:
>
> > I'm rebuilding a Rails app in Webmachine and need to send email via
> > Gmail, all correctly configured for the domain in question.
> >
> > Is erlmail the only way to go with this, or are there better options?
>
> I got tired of not having an answer to the email sending problem and
> developed esmtp (http://github.com/archaelus/esmtp) as a result.
>
> In my use of esmtp I assume a local smarthost, so I haven't used it with
> gmail before. I've checked the code and it does support auth, but not
> ssl yet. Adding ssl is probably not too tricky... (2 hours pass)... so
> I've just done it:
>
> application:load(esmtp),
> application:set_env(esmtp, smarthost, {"smtp.gmail.com",465}),
> application:set_env(esmtp, login,
> {"youraddress@REDACTED","YourPassword"}),
> application:start(esmtp).
>
> (The above is to set the config parameters without a config file).
>
> esmtp:send(esmtp_mime:msg(""," >","Some
> Subject", "Some Body")).
>
> I'll probably need to check to see I haven't broken regular smtp in this
> update. And make the error reporting better. And document this properly.
>
> I couldn't get TLS work properly in R13B, but I'll track that down some
> other time.
>
> Cheers,
> --
> Geoff Cant
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From carlmcdade@REDACTED  Wed Apr 29 13:09:07 2009
From: carlmcdade@REDACTED (Carl McDade)
Date: Wed, 29 Apr 2009 13:09:07 +0200
Subject: [erlang-questions] Did Windows SMP support ever get added?
In-Reply-To: 
References: 
	
Message-ID: 

I guess what I am looking for is a simple  way to confirm that Erlang is
seeing the other processor. Since since Erlang does not show this info at
start up the way it does on Linux.

On Wed, Apr 29, 2009 at 12:59 PM, Kenneth Lundin
wrote:

> Hi,
>
> The SMP support on Windows was introduced in Erlang/OTP R12B which has
> been available for more than a year now.
>
>
> On Wed, Apr 29, 2009 at 12:49 PM, Carl McDade 
> wrote:
> > Hi,
> >
> > I am asking this because it is not clear in the docs. I recently went
> from
> > Windows 2003 server over to Windows XP Pro on a Dual processor PC.
> Windows
> > XP did not pick up both processors so I had to force it a bit. But now
> > Windows sees both processors but Erlang does not. Is it because
> >
> > a. I need to reinstall Erlang
> No
> > b. change a configuration file somewhere
> No, at least not any Erlang specific file
> > c. forget about it. Erlang does not support SMP in Windows yet.
> SMP support for Windows since R12B
>
> I am not aware of any specific problems on Windows XP.
>
> /Kenneth , Erlang/OTP , Ericsson
> >
> > Thanks for any advice
> >
> > --
> > Carl McDade
> > www.hiveminds.co.uk
> > ________________________
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
>



-- 
Carl McDade
www.hiveminds.co.uk
________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From tuscland@REDACTED  Wed Apr 29 13:10:47 2009
From: tuscland@REDACTED (Camille Troillard)
Date: Wed, 29 Apr 2009 13:10:47 +0200
Subject: [erlang-questions] Did Windows SMP support ever get added?
In-Reply-To: 
References: 
	
Message-ID: 

Hello Carl,
I am running Windows XP SP3 on a small laptop, and SMP is working fine.


Best,
Cam

On Wed, Apr 29, 2009 at 12:59 PM, Kenneth Lundin
wrote:

> Hi,
>
> The SMP support on Windows was introduced in Erlang/OTP R12B which has
> been available for more than a year now.
>
>
> On Wed, Apr 29, 2009 at 12:49 PM, Carl McDade 
> wrote:
> > Hi,
> >
> > I am asking this because it is not clear in the docs. I recently went
> from
> > Windows 2003 server over to Windows XP Pro on a Dual processor PC.
> Windows
> > XP did not pick up both processors so I had to force it a bit. But now
> > Windows sees both processors but Erlang does not. Is it because
> >
> > a. I need to reinstall Erlang
> No
> > b. change a configuration file somewhere
> No, at least not any Erlang specific file
> > c. forget about it. Erlang does not support SMP in Windows yet.
> SMP support for Windows since R12B
>
> I am not aware of any specific problems on Windows XP.
>
> /Kenneth , Erlang/OTP , Ericsson
> >
> > Thanks for any advice
> >
> > --
> > Carl McDade
> > www.hiveminds.co.uk
> > ________________________
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From carlmcdade@REDACTED  Wed Apr 29 13:23:34 2009
From: carlmcdade@REDACTED (Carl McDade)
Date: Wed, 29 Apr 2009 13:23:34 +0200
Subject: [erlang-questions] Did Windows SMP support ever get added?
In-Reply-To: 
References: 
	
	
Message-ID: 

This is what I am getting:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

E:\Documents and Settings\carl>erl -smp enable
Eshell V5.7.1  (abort with ^G)
1>

Is this correct? Or should there be more information forthcoming?

Thanks,

On Wed, Apr 29, 2009 at 1:10 PM, Camille Troillard wrote:

> Hello Carl,
> I am running Windows XP SP3 on a small laptop, and SMP is working fine.
>
>
> Best,
> Cam
>
> On Wed, Apr 29, 2009 at 12:59 PM, Kenneth Lundin  > wrote:
>
>> Hi,
>>
>> The SMP support on Windows was introduced in Erlang/OTP R12B which has
>> been available for more than a year now.
>>
>>
>> On Wed, Apr 29, 2009 at 12:49 PM, Carl McDade 
>> wrote:
>> > Hi,
>> >
>> > I am asking this because it is not clear in the docs. I recently went
>> from
>> > Windows 2003 server over to Windows XP Pro on a Dual processor PC.
>> Windows
>> > XP did not pick up both processors so I had to force it a bit. But now
>> > Windows sees both processors but Erlang does not. Is it because
>> >
>> > a. I need to reinstall Erlang
>> No
>> > b. change a configuration file somewhere
>> No, at least not any Erlang specific file
>> > c. forget about it. Erlang does not support SMP in Windows yet.
>> SMP support for Windows since R12B
>>
>> I am not aware of any specific problems on Windows XP.
>>
>> /Kenneth , Erlang/OTP , Ericsson
>> >
>> > Thanks for any advice
>> >
>> > --
>> > Carl McDade
>> > www.hiveminds.co.uk
>> > ________________________
>> >
>> > _______________________________________________
>> > erlang-questions mailing list
>> > erlang-questions@REDACTED
>> > http://www.erlang.org/mailman/listinfo/erlang-questions
>> >
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
Carl McDade
Content Management Systems Consultant
www.hiveminds.co.uk
________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From carlmcdade@REDACTED  Wed Apr 29 13:28:29 2009
From: carlmcdade@REDACTED (Carl McDade)
Date: Wed, 29 Apr 2009 13:28:29 +0200
Subject: [erlang-questions] Did Windows SMP support ever get added?
In-Reply-To: 
References: 
	
	
	
Message-ID: 

Okay I got it. It does not show when using erl which I have gotten in the
habit of doing. Everything shows on using werl.

Thanks again.

On Wed, Apr 29, 2009 at 1:23 PM, Carl McDade  wrote:

> This is what I am getting:
>
> Microsoft Windows XP [Version 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
>
> E:\Documents and Settings\carl>erl -smp enable
> Eshell V5.7.1  (abort with ^G)
> 1>
>
> Is this correct? Or should there be more information forthcoming?
>
> Thanks,
>
>
> On Wed, Apr 29, 2009 at 1:10 PM, Camille Troillard wrote:
>
>> Hello Carl,
>> I am running Windows XP SP3 on a small laptop, and SMP is working fine.
>>
>>
>> Best,
>> Cam
>>
>> On Wed, Apr 29, 2009 at 12:59 PM, Kenneth Lundin <
>> kenneth.lundin@REDACTED> wrote:
>>
>>> Hi,
>>>
>>> The SMP support on Windows was introduced in Erlang/OTP R12B which has
>>> been available for more than a year now.
>>>
>>>
>>> On Wed, Apr 29, 2009 at 12:49 PM, Carl McDade 
>>> wrote:
>>> > Hi,
>>> >
>>> > I am asking this because it is not clear in the docs. I recently went
>>> from
>>> > Windows 2003 server over to Windows XP Pro on a Dual processor PC.
>>> Windows
>>> > XP did not pick up both processors so I had to force it a bit. But now
>>> > Windows sees both processors but Erlang does not. Is it because
>>> >
>>> > a. I need to reinstall Erlang
>>> No
>>> > b. change a configuration file somewhere
>>> No, at least not any Erlang specific file
>>> > c. forget about it. Erlang does not support SMP in Windows yet.
>>> SMP support for Windows since R12B
>>>
>>> I am not aware of any specific problems on Windows XP.
>>>
>>> /Kenneth , Erlang/OTP , Ericsson
>>> >
>>> > Thanks for any advice
>>> >
>>> > --
>>> > Carl McDade
>>> > www.hiveminds.co.uk
>>> > ________________________
>>> >
>>> > _______________________________________________
>>> > erlang-questions mailing list
>>> > erlang-questions@REDACTED
>>> > http://www.erlang.org/mailman/listinfo/erlang-questions
>>> >
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>
>
>
> --
> Carl McDade
> Content Management Systems Consultant
> www.hiveminds.co.uk
> ________________________
>



-- 
Carl McDade
Content Management Systems Consultant
www.hiveminds.co.uk
________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From psa@REDACTED  Wed Apr 29 12:43:07 2009
From: psa@REDACTED (=?ISO-8859-1?Q?Paulo_S=E9rgio_Almeida?=)
Date: Wed, 29 Apr 2009 11:43:07 +0100
Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs
In-Reply-To: <9b08084c0904290028u4bdca0eax8c9c9518c6678960@mail.gmail.com>
References: <9b08084c0904290028u4bdca0eax8c9c9518c6678960@mail.gmail.com>
Message-ID: <49F82F3B.6080509@di.uminho.pt>

Hi all,

Joe Armstrong wrote:

> So he sent me a program, which crashes his machine (out of memory)
> which he thought
> should work - to my eye it looks ok - It will not be blindingly fast,
> but it looks properly
> tail-recursive so the garbage collector should not have any problems.
> 
> I've appended at the end of this mail - so you can see for yourself.
> It is a GC bug
> or a user error?

I have looked at the program. It basically uses a single large binary, 
which means that in each insertion K (for K hashes) new large binaries 
are generated. Each one will be fully copied (right? this would be an 
interesting case for aggressive optimizations in binary handling).

One easy improvement would be to use a variant of bloom filters that 
uses K bitvectors instead of one single vector. But it would not be 
enough. As Joe says:

> (we want to flip specific bits) - the "pure" answer I guess is a tuple
> of tuples of binaries
> (say 32x32xB) where B is a 128 byte binary for 2^20 bits.
> 
> The "tuple of tuple of tuple ..." representation is commonly used to
> implement array and dicts

something like the above. But I would add one more twist. Use an array 
not of binaries but of integers. I have once implemented a data type for 
representing sets with bitmaps. (There I used ets instead of array, but 
that is orthogonal.) First I used binaries but later I switched to 
integers, exploiting the fact that erlang gives us arbitrary size 
integers. It has some advantages:

- the space overhead is smaller than for binaries (specially for 
smallish entries).
- for structures that may contain many zeroes, like in this case, a 
single word for each 0 would be used. This means we could overdimension 
the filter with less impact if it was very little used (again I am 
thinking about small entries in the array, much less that the 128 bytes 
example).

If I have time I will see If I can write a new version. Better, there is 
a nice variant "Scalable Bloom Filters" [1] (shameless self promotion 
:)) that can scale arbitrarily without forcing us dimension the filter. 
It can be trivially implemented on top of a standard one (the 
bidimensional variant).

Regards,
Paulo

1.
Scalable Bloom Filters
Information Processing Letters
Volume 101, Issue 6, 31 March 2007, Pages 255-261


From mryufeng@REDACTED  Wed Apr 29 14:20:11 2009
From: mryufeng@REDACTED (Feng Yu)
Date: Wed, 29 Apr 2009 20:20:11 +0800
Subject: [erlang-questions] BEAM details
In-Reply-To: <37f5c42d0904260808p44bea5c4x397ba741b4562b1a@mail.gmail.com>
References: <37f5c42d0904260808p44bea5c4x397ba741b4562b1a@mail.gmail.com>
Message-ID: <549b206a0904290520j2b43aa4ft867b902949dd49d3@mail.gmail.com>

erts/preloaded/src/*.erl
->erts/preloaded/ebin/*.beam->preload.c:pre_loaded->erlang:pre_loaded().
?? ??? ?? ?????????erlang?
http://blog.yufeng.info



On Sun, Apr 26, 2009 at 11:08 PM, jynlix Sr.Wang  wrote:

> Hi all,
> How BEAM preloads its modules?
> When I read the BEAM code, I am confused with the global "pre_loaded"
> because I can not find where it is
> initalised.
>
> Can anyone show me more instructions about BEAM?
>
> Thanks first.
>
> --
> Yours
> jynlix Sr.Wang
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ljw1001@REDACTED  Wed Apr 29 15:30:31 2009
From: ljw1001@REDACTED (Larry White)
Date: Wed, 29 Apr 2009 09:30:31 -0400
Subject: [erlang-questions] newbie question on deploying third party tools
Message-ID: 

I'm trying to learn erlang by reading the books and building an account
management application that would let me exercise some important
functionality (cryptography, persistence, sending emails, etc.
Based on recent posts to this list, I'm interested in trying the smtp-fsm
and epgsql libraries.  My general question is: How do you deploy these
things?

More specifically, I have my own app with its own src subfolder, etc. Where
do third party libraries get installed relative to something like this?

Also, what if anything, do I then need to do to use the applications?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From erlangy@REDACTED  Wed Apr 29 16:30:06 2009
From: erlangy@REDACTED (Michael McDaniel)
Date: Wed, 29 Apr 2009 07:30:06 -0700
Subject: [erlang-questions] newbie question on deploying third
	party	tools
In-Reply-To: 
References: 
Message-ID: <20090429143005.GQ10039@delora.autosys.us>

On Wed, Apr 29, 2009 at 09:30:31AM -0400, Larry White wrote:
>    I'm trying to learn erlang by reading the books and building an account
>    management application that would let me exercise some important
>    functionality (cryptography, persistence, sending emails, etc.
> 
>    Based on recent posts to this list, I'm interested in trying the
>    smtp-fsm and epgsql libraries.  My general question is: How do you
>    deploy these things?
> 
>    More specifically, I have my own app with its own src subfolder, etc.
>    Where do third party libraries get installed relative to something like
>    this?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 I place smtp_fsm.erl into my application src directory and have
 it compile to ebin (which is in my local '-pa /path/to/ebin' when
 I invoke erl [i.e. my application]).

 If I used a more complex multi-module solution I would probably
 have it in its own subdirectory and include a different ebin.

 I use smpt_fsm.erl thusly from one of my modules ...


send( From, To, Subj, Msg ) ->
  
    try smtp_fsm:start("mx.some_domain.some_tld")
        of {ok, Pid} -> smtp_fsm:ehlo(Pid) ,
                        smtp_fsm:sendemail(Pid, 
                                           From, 
                                           To, 
                                           "Subject: "++Subj++"\n"++Msg) ,
                        catch smtp_fsm:close(Pid) ;

        _Other       -> no_mail_today
    catch _:_        -> no_mail_today
    end
.


 There are other ways of doing it.  Some libraries I keep in completely
 separate (OTP) directory structures and then include their ebin path


   erl -pa /path/to/some/library/ebin  -pa /path/to/another/ebin ...


 or, if I have a bunch of libraries I want to include

  erl -pa /home/libraries/mm/*/ebin


  /home/libraries/mm
                -----
                 /lib_one    /lib_two   ...   /lib_n
                  /ebin       /ebin    ...     /ebin


  lib_one ... lib_n have the regular /src, /include, etc. OTP subdirectories



 With regard to the above smtp_fsm:start/1, occasionally I will import
 a module, e.g.

  -import([smtp_fsm]).

 and then just make the fun call start/1  (though not in a case like this
 where 'start' is so common across modules !).  Also, I say 'occassionally'
 I will import becuase 'usually' I want to use explicit module names.


~Michael



> 
>    Also, what if anything, do I then need to do to use the applications?
> 
>    Thanks.

> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 
Michael McDaniel
Portland, Oregon, USA
http://trip.autosys.us
http://autosys.us
http://mmcdaniel.com/erlview



From wglozer@REDACTED  Wed Apr 29 19:46:25 2009
From: wglozer@REDACTED (Will)
Date: Wed, 29 Apr 2009 10:46:25 -0700
Subject: [erlang-questions] newbie question on deploying third party
	tools
In-Reply-To: 
References: 
Message-ID: 

On Wed, Apr 29, 2009 at 6:30 AM, Larry White  wrote:
>
> Based on recent posts to this list, I'm interested in trying the smtp-fsm and epgsql libraries. ?My general question is: How do you deploy these things?
> More specifically, I have my own app with its own src subfolder, etc. Where do third party libraries get installed relative to something like this?

On a development system it's easiest to set the ERL_LIBS environment
variable to a PATH-like list of directories containing your libraries.
For example I've set ERL_LIBS to ~/erlang/lib/ which contains
directories named yaws-1.81, epgsql-1.1, etc. Another option is to put
libraries in the lib/erlang/lib/ directory under your Erlang
installation.

For more details check out the documentation for the code module,
http://erlang.org/doc/man/code.html.

> Also, what if anything, do I then need to do to use the applications?

When you're running erlang in interactive mode (the default), there's
nothing else to do. The code server will automatically load modules
from the code path as needed. There's also an embedded mode and boot
scripts for production systems, which loads all modules during
startup.

-Will


From steve.kirsch@REDACTED  Wed Apr 29 20:09:06 2009
From: steve.kirsch@REDACTED (Steve Kirsch)
Date: Wed, 29 Apr 2009 11:09:06 -0700
Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs
In-Reply-To: <18936.7458.10234.422674@pilspetsen.it.uu.se>
Message-ID: <76BB7F270C366D47AA79851BB0B39D810299C7A6@exchg02.propel.com>

Great, that explains the crash.

All your caveats are duly noted. We promise to be careful.

So now can you tell us how to use these functions that are already
there? 

Our system is very RAM intensive and I'd love to be able to stay inside
erlang to do this.

thanks!

-----Original Message-----
From: Mikael Pettersson [mailto:mikpe@REDACTED] 
Sent: Wednesday, April 29, 2009 2:26 AM
To: Joe Armstrong
Cc: Erlang
Subject: Re: [erlang-questions] A bug? - bloom filters - and loadable
BIFs

Joe Armstrong writes:
 > Hi,
 >
 > I recent got mail from Steve Kirsch (Hello Steve) - asking a number
> of questions about representation of bit vectors for writing Bloom
filters.
...
 > So he sent me a program, which crashes his machine (out of memory)
...
 > new(N, E) when N > 0, is_float(E), E > 0, E =< 1 ->
 >    {M, K} = calc_least_bits(N, E),
 >    #bloom{m=M, bitmap = <<0:((M+7) div 8 * 8)>>, k=K, n=N}.

Large bitmaps are problematic in Erlang.

You can do chunked representations, which will work but will incur high
overheads on both reads and writes.

Using large binaries as the code above does is fragile and inefficient.
Large binaries are allocated outside of the GCd heaps in a global shared
area and are accessed via small heap-allocated and GCd handles. Frequent
updates will require frequent new allocations and copies in the shared
area. Old versions of these binaries are only deallocated in response to
local (per-process) GCs when their handles die.

So creating a series of large binaries in rapid succession without
intervening GCs is a fairly reliable way of running out of memory.

HiPE needs large bitmaps for its register allocator, so we added our own
bitarray BIFs since all alternatives suck. As much as _I_ like them, I
cannot recommend them for application developers:
- they're only present in HiPE-enabled systems
- they're not documented or official in any way, and may change at any
time
- the effect of sending a bitarray to another process is unspecified
  (the processes may or may not share the object)
- Erlang is _supposed_ to protect application programmers from the
perils
  of mutable data :-/
_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://www.erlang.org/mailman/listinfo/erlang-questions


From nem@REDACTED  Wed Apr 29 23:25:41 2009
From: nem@REDACTED (Geoff Cant)
Date: Wed, 29 Apr 2009 23:25:41 +0200
Subject: [erlang-questions] newbie question on deploying third party
	tools
In-Reply-To: 
	(Will's message of "Wed, 29 Apr 2009 10:46:25 -0700")
References: 
	
Message-ID: 

Will  writes:

> On Wed, Apr 29, 2009 at 6:30 AM, Larry White  wrote:
>>
>> Based on recent posts to this list, I'm interested in trying the smtp-fsm and epgsql libraries. ?My general question is: How do you deploy these things?
>> More specifically, I have my own app with its own src subfolder, etc. Where do third party libraries get installed relative to something like this?
>
> On a development system it's easiest to set the ERL_LIBS environment
> variable to a PATH-like list of directories containing your libraries.
> For example I've set ERL_LIBS to ~/erlang/lib/ which contains
> directories named yaws-1.81, epgsql-1.1, etc. Another option is to put
> libraries in the lib/erlang/lib/ directory under your Erlang
> installation.
>
> For more details check out the documentation for the code module,
> http://erlang.org/doc/man/code.html.
>
>> Also, what if anything, do I then need to do to use the applications?
>
> When you're running erlang in interactive mode (the default), there's
> nothing else to do. The code server will automatically load modules
> from the code path as needed. There's also an embedded mode and boot
> scripts for production systems, which loads all modules during
> startup.

For my part I tend to use git for project source control (but anything
with externals works) and use git submodules to incorporate other
libraries into a project.

/root
     /Emakefile, Makefile -- use erl -make to build invoked from make
     /{src,ebin,include,docs,priv} -- normal project files
     /lib -- incorporated libraries
         /somelib -- git submodule

While developing, run "erl -pa ebin lib/*/ebin -s your_app" to start
your system.

The nice aspects of this approach are:
 * Most erlang libraries aren't mature - you can't often incorporate
   them directly into a build you'd deploy in production, they need
   tweaking. Whether it's adding convenience functions to the API,
   updating deprecated functions or ensuring the library works as an OTP
   app, libraries usually need tweaking.

   DVCSs are incredibly helpful here as you can maintain your small
   fixes as well as incorporate upstream changes
 * You get a reliable checkout - you can checkout the repository on
   someone elses machine, pull down the submodules/externals and build
   the entire thing, with known versions of all the source. This avoids
   having to manually find and fetch the source to all the libraries you
   incorporate and stops different developers from having different
   versions they develop with.
 * If you update a library used by one project, it won't affect some
   other project you're working on that uses the same library. Better
   yet, if you update a submodule/external, that change will be tracked
   as a commit within your source control system and will propagate to
   the other developers working on the code.

If I was confident that my github code built cleanly from a checkout I'd
give you an example of this project style here, but fate isn't usually
that kind to me. ;)

Cheers,
-- 
Geoff Cant



From fritchie@REDACTED  Wed Apr 29 23:21:15 2009
From: fritchie@REDACTED (Scott Lystig Fritchie)
Date: Wed, 29 Apr 2009 16:21:15 -0500
Subject: [erlang-questions] server state output in gen_server error
	logging
In-Reply-To: Message of "Thu, 23 Apr 2009 14:54:53 +0200."
	<20090423125453.GA5102@contorpis.lisalinda.com> 
Message-ID: <88417.1241040075@snookles.snookles.com>

Sorry about joining the thread so late...

Matthias Lang  wrote:

ml> I don't understand how _any_ production systems can work with the
ml> default error logging setup*. On the other hand, you're only the
ml> third person I've come across who agrees it's a problem, so maybe
ml> there's a simple solution I'm unaware of.

I'm the fourth, at least.  Unless I'm included in the previous three
already?  :-)

ml> * i.e. in a crash, arbitrary terms get printed and they can be huge.
ml> The problems with 'huge' are [...]
ml> (b) creating those huge logs can eat huge amounts of RAM, so much
ml> that on memory-limited systems the VM can terminate with
ml> out-of-memory [...]

The worst case I've seen (and it's happened in a production environment)
is a few tens of megabytes in a gen_server process's state term.  The
proc crashes, and the OTP standard error handler formats it.  However,
it gets much worse:

   * The binary includes non-printable bytes, so it gets expanded from a
     more compact <<"foo...">> to <<102,111,111,255,...>>.  I.e. every
     byte in the original is expanded to 3-4 bytes on average, don't
     forget the commas :-).

   * The formatted result is a one-char-per-element list.

   * The platform in question is 64-bit, so each cons cell uses 2
     words.  Multiply the bloated formatted string's size by 16.

It only takes a few of those messages to consume *gigabytes* of RAM.  My
production boxes had 16GB of RAM, but that wasn't nearly enough.

Matt was also correct in that it takes a lot of CPU time to do the
formatting.  Too bad it doesn't always slow down the producers enough.
:-(

We haven't used his solution for truncating messages.  Instead, our
custom event handler checks the size of the term via erts_debug:size/1
and, if it's too big, formats the term with io_lib:format/2 using a
format string "~P" plus a depth limit of 20, instead of whatever the
specified formatting string was.

-Scott


From torben.lehoff@REDACTED  Thu Apr 30 00:25:57 2009
From: torben.lehoff@REDACTED (Torben Hoffmann)
Date: Thu, 30 Apr 2009 00:25:57 +0200
Subject: [erlang-questions] Problem with wx on R13B & Mac OS X 10.4
Message-ID: 

I am running Mac OS X 10.4 and I have installed wxWidgets and
wxWidgets-devel using macports, but I get this error when doing the
./configure to prepare my Erlang R13B install:

wx             : Can not link the wx driver, wx will NOT be useable

Any clues?

Thanks in advance,
Torben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From q2h46uw02@REDACTED  Thu Apr 30 01:12:08 2009
From: q2h46uw02@REDACTED (Kevin)
Date: Wed, 29 Apr 2009 19:12:08 -0400
Subject: [erlang-questions] open_port confusing (concerning qmail-inject)
Message-ID: <29471-18117@sneakemail.com>


Hello, qmail-inject is just a command line program that takes a message 
from stdin and dumps it into the mail queue

example to deliver a very short message to kevin@REDACTED:

prompt> echo "subject:it worked" | qmail-inject kevin@REDACTED


If successful it exits with a code of 0, all other numbers are errors.


I'm writing an erlang function that will eventually, **line-by-line**, 
feed a message to qmail-inject.

Here is my attempt:

start() ->

    From = "somebody@REDACTED",
    To = "kevin@REDACTED",
    Command = "/var/qmail/bin/qmail-inject -a -f " ++ From ++ " " ++ To,
    Port = open_port({spawn, Command}, [stream, exit_status]),

    Port ! {self(), {command, "Subject:It worked!\n"}},
    Port ! {self(), {command, "From:from@REDACTED\n"}},
    Port ! {self(), {command, "To:to@REDACTED\n"}},
    Port ! {self(), close},

    receive
        {Port, {exit_status, 0}} -> %% exited without a result
            {ok, worked};
        {Port, {exit_status, R}} -> %% dig program missing?
            {error, inject_error, R};
        Unknown -> Unknown
    end.


I was confused by the docs for port_command and port_close so I just 
stuck with the standard erlang message passing.

It works fine, but because I'm a little obsessive and I tried hiding the 
qmail-inject program by renaming it and breaking the whole thing.

By playing around I figured out the behavior of a broken command:

14> open_port({spawn, "/asdf"}, [stream, exit_status]).             
#Port<0.444>
15> flush().                                          
Shell got {#Port<0.444>,{exit_status,126}}

Ok, so I now see I can received the message of a broken command.

And here is a successful command:

16> open_port({spawn, "/usr/local/bin/date"}, [stream, exit_status]).
#Port<0.445>
17> flush().                                                        
Shell got {#Port<0.445>,{data,"Wed Apr 29 18:56:27 EDT 2009\n"}}
Shell got {#Port<0.445>,{exit_status,0}}
ok


But with a command like qmail-inject, there is nothing to flush until 
the message is finished, and I'm assuming it will
be sent when send it a close signal.  And with all this flushing, is 
there a chance of a race condition?

17> open_port({spawn, "/usr/local/bin/date"}, [stream, exit_status]).
#Port<0.1830>
18> flush().
ok
19>

So how do I tell if the port successfully opened to a waiting 
qmail-inject without blocking on a message that will only
come until after I fed it the message and closed the port?  And then be 
certain that the qmail-inject program returned
a success code of 0?  And avoid race conditions?

I would take my grandma 5 minutes to figure out how to open a pipe to a 
command line program in a scripting language like perl or ruby, but here 
I don't even know if I'm going in the right direction.

Thanks for any help,
Kevin







From q2h46uw02@REDACTED  Thu Apr 30 04:48:50 2009
From: q2h46uw02@REDACTED (Kevin)
Date: Wed, 29 Apr 2009 22:48:50 -0400
Subject: [erlang-questions] open_port confusing (concerning
 qmail-inject) UPDATE
In-Reply-To: <29471-18117@sneakemail.com>
References: <29471-18117@sneakemail.com>
Message-ID: <15581-38909@sneakemail.com>



Kevin q2h46uw02-at-sneakemail.com |erlang| wrote:
> Hello, qmail-inject is just a command line program that takes a message 
> from stdin and dumps it into the mail queue
>
> example to deliver a very short message to kevin@REDACTED:
>
> prompt> echo "subject:it worked" | qmail-inject kevin@REDACTED
>
>
> If successful it exits with a code of 0, all other numbers are errors.
>
>
> I'm writing an erlang function that will eventually, **line-by-line**, 
> feed a message to qmail-inject.
>
> Here is my attempt:
>
> start() ->
>
>     From = "somebody@REDACTED",
>     To = "kevin@REDACTED",
>     Command = "/var/qmail/bin/qmail-inject -a -f " ++ From ++ " " ++ To,
>     Port = open_port({spawn, Command}, [stream, exit_status]),
>
>     Port ! {self(), {command, "Subject:It worked!\n"}},
>     Port ! {self(), {command, "From:from@REDACTED\n"}},
>     Port ! {self(), {command, "To:to@REDACTED\n"}},
>     Port ! {self(), close},
>
>     receive
>         {Port, {exit_status, 0}} -> %% exited without a result
>             {ok, worked};
>         {Port, {exit_status, R}} -> %% dig program missing?
>             {error, inject_error, R};
>         Unknown -> Unknown
>     end.
>
>
> I was confused by the docs for port_command and port_close so I just 
> stuck with the standard erlang message passing.
>
> It works fine, but because I'm a little obsessive and I tried hiding the 
> qmail-inject program by renaming it and breaking the whole thing.
>
> By playing around I figured out the behavior of a broken command:
>
> 14> open_port({spawn, "/asdf"}, [stream, exit_status]).             
> #Port<0.444>
> 15> flush().                                          
> Shell got {#Port<0.444>,{exit_status,126}}
>
> Ok, so I now see I can received the message of a broken command.
>
> And here is a successful command:
>
> 16> open_port({spawn, "/usr/local/bin/date"}, [stream, exit_status]).
> #Port<0.445>
> 17> flush().                                                        
> Shell got {#Port<0.445>,{data,"Wed Apr 29 18:56:27 EDT 2009\n"}}
> Shell got {#Port<0.445>,{exit_status,0}}
> ok
>
>
> But with a command like qmail-inject, there is nothing to flush until 
> the message is finished, and I'm assuming it will
> be sent when send it a close signal.  And with all this flushing, is 
> there a chance of a race condition?
>
> 17> open_port({spawn, "/usr/local/bin/date"}, [stream, exit_status]).
> #Port<0.1830>
> 18> flush().
> ok
> 19>
>
> So how do I tell if the port successfully opened to a waiting 
> qmail-inject without blocking on a message that will only
> come until after I fed it the message and closed the port?  And then be 
> certain that the qmail-inject program returned
> a success code of 0?  And avoid race conditions?
>
> I would take my grandma 5 minutes to figure out how to open a pipe to a 
> command line program in a scripting language like perl or ruby, but here 
> I don't even know if I'm going in the right direction.
>
> Thanks for any help,
> Kevin
>
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>   

I'm beginning to thing there is no solution to this other than writing a 
wrapper for qmail-inject.  The main problem
is that, according to my research, there is no way to tell qmail-inject 
that it has reached the "end of file" without
port_close(Port), which, when called, will prevent any exit codes from 
being sent, so I'll never know if qmail-inject
succeeded.

-ks









From bgustavsson@REDACTED  Thu Apr 30 09:13:49 2009
From: bgustavsson@REDACTED (Bjorn Gustavsson)
Date: Thu, 30 Apr 2009 09:13:49 +0200
Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs
In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810299C7A6@exchg02.propel.com>
References: <18936.7458.10234.422674@pilspetsen.it.uu.se>
	<76BB7F270C366D47AA79851BB0B39D810299C7A6@exchg02.propel.com>
Message-ID: <6672d0160904300013l42056f4dibc02a02f98082832@mail.gmail.com>

On Wed, Apr 29, 2009 at 8:09 PM, Steve Kirsch  wrote:
> Great, that explains the crash.
>
> All your caveats are duly noted. We promise to be careful.
>
> So now can you tell us how to use these functions that are already
> there?
>

Maybe you should first try the suggestion by Paulo Almeida above? That is,
use an array (as provided by the 'array' module) to store big integers in.
For instance, each entry in the array could could store an integer that can
hold 256 bits. That would most definitely be an improvement over using
binaries and might work good enough to work in your application.

/Bjorn
-- 
Bj?rn Gustavsson, Erlang/OTP, Ericsson AB


From steve.kirsch@REDACTED  Thu Apr 30 09:17:57 2009
From: steve.kirsch@REDACTED (Steve Kirsch)
Date: Thu, 30 Apr 2009 00:17:57 -0700
Subject: [erlang-questions] how can I access test_server_loc in the process
	dict of another	process?
In-Reply-To: <18936.7458.10234.422674@pilspetsen.it.uu.se>
Message-ID: <76BB7F270C366D47AA79851BB0B39D810299C7E7@exchg02.propel.com>

I wrote a simple statistical profiler that basically snapshots a spawned
MFA every 10 msec for 100 samples using process_info(Pid,
current_function)

that's pretty cool.

But way cooler is to include:

-compile({parse_transform,ct_line}). 

in the module I want to statistically profile.

This essentially pushes your M, F, line number in the process dictionary
(under key test_server_loc) each time you execute a line of code
(replacing it if in the same function so you get a call stack more or
less to a max depth of 10).

That's way cool.

So I'd like to access that key (test_server_loc) from my statistical
profiler which is running in another process.

How can I access that key? there isn't a get(test_server_loc, Pid) BIF.



=====================================
P.S. Here's my statistical profiler and test function... this all works
fine. 

% statistical profiler. Spawns the MFA and then takes 100 samples, 10
msec apart.
sprof(M, F, A)->
    Pid=spawn_link(M,F,A),
    Time=10,
    L=lists:seq(1,100),
    GetCurrentMFA=fun()->
			  timer:sleep(Time),
			  case process_info(Pid, current_function) of
			      {_, MFA}->MFA;
			      undefined -> x
			  end
			  end,
    OutList=[GetCurrentMFA()||_X<-L],
    io:format("~p~n", [OutList]).

t1()->
    ok.
t2()->
    bye.
t3()->
    fooey.

sprof_test(0)->
    ok;	
sprof_test(N)->
    t1(),
    t2(),
    t3(),
    sprof_test(N-1).
sprof_test()->    
    sprof(?MODULE, sprof_test, [100000000]).


From steve.kirsch@REDACTED  Thu Apr 30 10:26:01 2009
From: steve.kirsch@REDACTED (Steve Kirsch)
Date: Thu, 30 Apr 2009 01:26:01 -0700
Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs
In-Reply-To: <6672d0160904300013l42056f4dibc02a02f98082832@mail.gmail.com>
Message-ID: <76BB7F270C366D47AA79851BB0B39D810299C7EE@exchg02.propel.com>

I've tried that and you still get about 100% storage overhead.

So what is the undocumented BIF? 

-----Original Message-----
From: Bjorn Gustavsson [mailto:bgustavsson@REDACTED] 
Sent: Thursday, April 30, 2009 12:14 AM
To: Steve Kirsch
Cc: Mikael Pettersson; Joe Armstrong; Erlang
Subject: Re: [erlang-questions] A bug? - bloom filters - and loadable BIFs

On Wed, Apr 29, 2009 at 8:09 PM, Steve Kirsch  wrote:
> Great, that explains the crash.
>
> All your caveats are duly noted. We promise to be careful.
>
> So now can you tell us how to use these functions that are already 
> there?
>

Maybe you should first try the suggestion by Paulo Almeida above? That is, use an array (as provided by the 'array' module) to store big integers in.
For instance, each entry in the array could could store an integer that can hold 256 bits. That would most definitely be an improvement over using binaries and might work good enough to work in your application.

/Bjorn
--
Bj?rn Gustavsson, Erlang/OTP, Ericsson AB


From torben.lehoff@REDACTED  Thu Apr 30 10:59:01 2009
From: torben.lehoff@REDACTED (Torben Hoffmann)
Date: Thu, 30 Apr 2009 10:59:01 +0200
Subject: [erlang-questions] Getting support for X.692 in the asn1
	application OR "If not ASN.1, then what?"
Message-ID: 

Hi,

I am looking into finding efficient ways of dealing with legacy protocols
and during that I found the X.692 standard:
http://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.692-200203-S!PDF-E&type=items
http://www.itu.int/ITU-T/asn1/database/itu-t/x/x692/2002/index.html

The ASN.1 compiler barfs on the ELM and EDM modules since X.692 is not
supported by the asn1 application.

What are the chances of X.692 being supported by the asn1 application?

A aside: no matter how fun it really is to code Erlang nothing beats getting
a pair of encode-decode functions for free.

BTW: the key need I am trying to address is the ability to specify the PDUs
of an arbitrarily weird protocol (mostly telecom ones) and then get a codec
for it. ASN.1 is not a holy grail for me and other good technologies will be
looked at if you suggest it.

Thanks in advance,
Torben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From masse@REDACTED  Thu Apr 30 11:44:00 2009
From: masse@REDACTED (mats cronqvist)
Date: Thu, 30 Apr 2009 11:44:00 +0200
Subject: [erlang-questions] how can I access test_server_loc in the
	process dict of another	process?
In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810299C7E7@exchg02.propel.com>
	(Steve Kirsch's message of "Thu\, 30 Apr 2009 00\:17\:57 -0700")
References: <18936.7458.10234.422674@pilspetsen.it.uu.se>
	<76BB7F270C366D47AA79851BB0B39D810299C7E7@exchg02.propel.com>
Message-ID: <87ab5yxyqn.fsf@sterlett.hq.kred>

"Steve Kirsch"  writes:

> I wrote a simple statistical profiler that basically snapshots a spawned
> MFA every 10 msec for 100 samples using process_info(Pid,
> current_function)
>
> that's pretty cool.
>
> But way cooler is to include:
>
> -compile({parse_transform,ct_line}). 
>
> in the module I want to statistically profile.
>
> This essentially pushes your M, F, line number in the process dictionary
> (under key test_server_loc) each time you execute a line of code
> (replacing it if in the same function so you get a call stack more or
> less to a max depth of 10).
>
> That's way cool.
>
> So I'd like to access that key (test_server_loc) from my statistical
> profiler which is running in another process.

  process_info(Pid,dictionary).

  allow me to point out that what you're trying to accomplish can be
  done (without recompiling/parse transforms) through tracing.

  mats


From magnus@REDACTED  Thu Apr 30 12:09:55 2009
From: magnus@REDACTED (Magnus Henoch)
Date: Thu, 30 Apr 2009 11:09:55 +0100
Subject: [erlang-questions] Problem with wx on R13B & Mac OS X 10.4
References: 
Message-ID: <84iqkma1vw.fsf@linux-b2a3.site>

Torben Hoffmann  writes:

> I am running Mac OS X 10.4 and I have installed wxWidgets and wxWidgets-devel
> using macports, but I get this error when doing the ./configure to prepare my
> Erlang R13B install:
>
> wx???????????? : Can not link the wx driver, wx will NOT be useable
>
> Any clues?

What does config.log say about wx?

-- 
Magnus Henoch, magnus@REDACTED
Erlang Training and Consulting
http://www.erlang-consulting.com/



From mikpe@REDACTED  Thu Apr 30 12:26:11 2009
From: mikpe@REDACTED (Mikael Pettersson)
Date: Thu, 30 Apr 2009 12:26:11 +0200
Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs
In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810299C7EE@exchg02.propel.com>
References: <6672d0160904300013l42056f4dibc02a02f98082832@mail.gmail.com>
	<76BB7F270C366D47AA79851BB0B39D810299C7EE@exchg02.propel.com>
Message-ID: <18937.31939.35066.596902@pilspetsen.it.uu.se>

Steve Kirsch writes:
 > I've tried that and you still get about 100% storage overhead.
 > 
 > So what is the undocumented BIF? 
 > 
 > -----Original Message-----
 > From: Bjorn Gustavsson [mailto:bgustavsson@REDACTED] 
 > Sent: Thursday, April 30, 2009 12:14 AM
 > To: Steve Kirsch
 > Cc: Mikael Pettersson; Joe Armstrong; Erlang
 > Subject: Re: [erlang-questions] A bug? - bloom filters - and loadable BIFs
 > 
 > On Wed, Apr 29, 2009 at 8:09 PM, Steve Kirsch  wrote:
 > > Great, that explains the crash.
 > >
 > > All your caveats are duly noted. We promise to be careful.
 > >
 > > So now can you tell us how to use these functions that are already 
 > > there?
 > >
 > 
 > Maybe you should first try the suggestion by Paulo Almeida above? That is, use an array (as provided by the 'array' module) to store big integers in.
 > For instance, each entry in the array could could store an integer that can hold 256 bits. That would most definitely be an improvement over using binaries and might work good enough to work in your application.

hipe_bifs:bitarray(NrArrayBits, InitialBitValue) -> BitArray
hipe_bifs:bitarray_sub(BitArray, BitNr) -> BitValue
hipe_bifs:bitarray_update(BitArray, BitNr, BitValue) -> BitArray

Bit values are the booleans true and false.
Array indexing is 0-based (1-based indexing is just sooo wrong).
The update operation returns the updated array.

The number of elements in a bit array is limited to what can be
described by non-negative fixnums (immediate "small" integers),
which is something like 2^27 - 1 on 32-bit machines. Larger bitarrays
than that must be emulated using a chunked representation.
See lib/hipe/regalloc/hipe_ig.erl for an example (look for
the USE_NEW_BITARRAY_BIFS define and the adjset code following it).

/Mikael


From tuscland@REDACTED  Thu Apr 30 12:50:09 2009
From: tuscland@REDACTED (Camille Troillard)
Date: Thu, 30 Apr 2009 12:50:09 +0200
Subject: [erlang-questions] open_port and port_close semantics
Message-ID: 

Hello,
I am trying to understand the semantics of open_port and port_close.
I was expecting port_close to send a quit signal to the child process, but
it merely close the file handlers from what I've read in the doc and
trapexit forums.

What is the reason behind this?
How do you make sure there are no leftover processes when the application
shuts down?


Thanks!
Cam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From carlmcdade@REDACTED  Thu Apr 30 14:22:07 2009
From: carlmcdade@REDACTED (Carl McDade)
Date: Thu, 30 Apr 2009 14:22:07 +0200
Subject: [erlang-questions] Edoc syntax
Message-ID: 

I am having a not so nice time trying to get Edoc to work on Mochiweb files
or any files for that matter. I am using Windows XP Pro and r13b.

8> edoc:files("c:/erlang_stuff/mochi/src/mochihex.erl","c:/erlang/doc").
** exception error: no function clause matching
                    filename:do_flatten(99,[])
     in function  filename:basename/1
     in call from edoc:expand_files/1
     in call from edoc:run/3

I have Joe's book which has nothing about Edoc in it that I can find. The
documentation concerning Edoc does not show exact examples of the syntax
needed.

Anyone an expert on documentation and can give help and/or advice?

Thanks,

-- 
Carl McDade
Content Management Systems Consultant
www.hiveminds.co.uk
________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From quangd@REDACTED  Thu Apr 30 13:48:20 2009
From: quangd@REDACTED (Hoat Do)
Date: Thu, 30 Apr 2009 13:48:20 +0200
Subject: [erlang-questions] Email Interview On Inserting Faults into Erlang
	Programs At Run Time
Message-ID: <49F99004.8050406@ituniv.se>

Dear Erlang programmer,

We are two BSc thesis students, studying Software Engineering and 
Management at the IT University of Gothenburg Sweden. We are currently 
conducting a research study on the use of fault injection technique 
(http://en.wikipedia.org/wiki/Fault_injection) for evaluating Erlang 
software testing tools. This approach works by inserting faults into 
Erlang programs, and evaluating testing tools by checking if they can 
detect the fault or not.

This study will involve finding out what typical faults exist in Erlang 
programs, and how they can be injected into such programs. We have been 
going through Erlang/OTP releases (R10B-0 
 - R13 
A) and other Erlang 
sources to find out what faults have been detected over the years. We 
need your help in finding out how these faults can be injected into 
Erlang programs at run time. Any idea on how this can be done will be 
highly appreciated.

Below are some Erlang faults^1 :

*API mismatches*
Calling the wrong function/using the wrong arguments
 
*Race conditions*
Two parallel processes trying to do something incompatible, e.g. one 
deleting and the other reading a table object
 
*Wrong context (process)*
Executing in the wrong context, e.g. trying to read from a table that 
only exists on another Process
 
We hope to receive your reply on or before May 8^th . You can send your 
response or any enquiry to Taiwo on ajakaiye@REDACTED 
 or Hoat on quangd@REDACTED 
. The result of the study will be published on 
Gothenburg University library, and will be available to the public.
 
Thanks in advance for your response,

Ajakaiye Taiwo Dayo and Quang Hoat Do

/IT University of G?teborg/
/Software Engineering and Management/
/Gothenburg, Sweden/
/ /
/ /
^1 Mats Cronqvist, 2004, Troubleshooting a Large Erlang System, 
Erlang'04, ACM New York, NY, USA.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From dgud@REDACTED  Thu Apr 30 11:17:38 2009
From: dgud@REDACTED (Dan Gudmundsson)
Date: Thu, 30 Apr 2009 11:17:38 +0200
Subject: [erlang-questions] Problem with wx on R13B & Mac OS X 10.4]
Message-ID: <49F96CB2.5080406@erix.ericsson.se>


Forgot the list.
/Dan

-------- Original Message --------
Subject: Re: [erlang-questions] Problem with wx on R13B & Mac OS X 10.4
Date: Thu, 30 Apr 2009 11:16:04 +0200
From: Dan Gudmundsson 
Reply-To: dgud@REDACTED
To: Torben Hoffmann 
References: 


I haven't used macports, so I don't what version and how wxwidgets is compiled in that
version.

But this should work.

Download wxwidgets and compile with:

         mkdir MYBUILD; cd MYBUILD
         ../configure --with-opengl --enable-unicode \
                 --disable-shared
         make && make install
         cd contrib/src/stc/
         make && make install

If you don't want the result in /usr/local/ add a --prefix=/WXPATH/

Add the /WXPATH/bin dir to your path so that wx-config shell script can be run
from shell, than remove CONF_INFO file from ERL_PATH/lib/wx and re-run erlang
configure, make, make install

/Dan

Torben Hoffmann wrote:
> I am running Mac OS X 10.4 and I have installed wxWidgets and 
> wxWidgets-devel using macports, but I get this error when doing the 
> ./configure to prepare my Erlang R13B install:
> 
> wx             : Can not link the wx driver, wx will NOT be useable
> 
> Any clues?
> 
> Thanks in advance,
> Torben
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From quangd@REDACTED  Thu Apr 30 14:55:16 2009
From: quangd@REDACTED (Hoat Do)
Date: Thu, 30 Apr 2009 14:55:16 +0200
Subject: [erlang-questions] Email Interview On Inserting Faults into Erlang
	Programs At Run Time
Message-ID: <49F99FB4.4030909@ituniv.se>

Dear Erlang programmer,

We are two BSc thesis students, studying Software Engineering and 
Management at the IT University of Gothenburg Sweden. We are currently 
conducting a research study on the use of fault injection technique 
(http://en.wikipedia.org/wiki/Fault_injection) for evaluating Erlang 
software testing tools. This approach works by inserting faults into 
Erlang programs, and evaluating testing tools by checking if they can 
detect the fault or not.

This study will involve finding out what typical faults exist in Erlang 
programs, and how they can be injected into such programs. We have been 
going through Erlang/OTP releases (R10B-0 
 - R13 
A) and other Erlang 
sources to find out what faults have been detected over the years. We 
need your help in finding out how these faults can be injected into 
Erlang programs at run time. Any idea on how this can be done will be 
highly appreciated.

Below are some Erlang faults^1 :

*API mismatches*
Calling the wrong function/using the wrong arguments
 
*Race conditions*
Two parallel processes trying to do something incompatible, e.g. one 
deleting and the other reading a table object
 
*Wrong context (process)*
Executing in the wrong context, e.g. trying to read from a table that 
only exists on another Process
 
We hope to receive your reply on or before May 8^th . You can send your 
response or any enquiry to Taiwo on ajakaiye@REDACTED 
 or Hoat on quangd@REDACTED 
. The result of the study will be published on 
Gothenburg University library, and will be available to the public.
 
Thanks in advance for your response,

Ajakaiye Taiwo Dayo and Quang Hoat Do

/IT University of G?teborg/
/Software Engineering and Management/
/Gothenburg, Sweden/
/ /
/ /
^1 Mats Cronqvist, 2004, Troubleshooting a Large Erlang System, 
Erlang'04, ACM New York, NY, USA.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From per.melin@REDACTED  Thu Apr 30 14:55:17 2009
From: per.melin@REDACTED (Per Melin)
Date: Thu, 30 Apr 2009 14:55:17 +0200
Subject: [erlang-questions] Edoc syntax
In-Reply-To: 
References: 
Message-ID: 

Carl McDade:
> I am having a not so nice time trying to get Edoc to work on Mochiweb files
> or any files for that matter. I am using Windows XP Pro and r13b.
>
> 8> edoc:files("c:/erlang_stuff/mochi/src/mochihex.erl","c:/erlang/doc").
> ** exception error: no function clause matching
>                     filename:do_flatten(99,[])
>      in function  filename:basename/1
>      in call from edoc:expand_files/1
>      in call from edoc:run/3
>

I've never used edoc:files(), but looking at the doc I think this is
want you want:

edoc:files(["c:/erlang_stuff/mochi/src/mochihex.erl"], [{dir,
"c:/erlang/doc"}]).

I prefer edoc:application/3 myself.


From bbmaj7@REDACTED  Thu Apr 30 14:00:34 2009
From: bbmaj7@REDACTED (Richard Andrews)
Date: Thu, 30 Apr 2009 05:00:34 -0700 (PDT)
Subject: [erlang-questions] open_port and port_close semantics
In-Reply-To: 
References: 
Message-ID: <845533.98192.qm@web65512.mail.ac4.yahoo.com>

On close a port program may need to perform additional steps to close down gracefully, turn off hardware, log out of facilities, remove files, log events, etc.

A heartbeat system is effective if the pipe closure event is not reliably delivered; ie. exit if no event from the erlang node for N seconds.

If erlang is exiting gracefully then send a shutdown command to the port program and wait for the port to be closed.

--
  Rich




________________________________
From: Camille Troillard 
To: erlang-questions@REDACTED
Sent: Thursday, 30 April, 2009 8:50:09 PM
Subject: [erlang-questions] open_port and port_close semantics

Hello,

I am trying to understand the semantics of open_port and port_close.
I was expecting port_close to send a quit signal to the child process, but it merely close the file handlers from what I've read in the doc and trapexit forums.

What is the reason behind this?
How do you make sure there are no leftover processes when the application shuts down?



      Yahoo!7 recommends that you update your browser to the new Internet Explorer 8.Get it now.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From attila.r.nohl@REDACTED  Thu Apr 30 15:25:25 2009
From: attila.r.nohl@REDACTED (Attila Rajmund Nohl)
Date: Thu, 30 Apr 2009 15:25:25 +0200
Subject: [erlang-questions] =?iso-8859-1?q?V=E1=3A__Email_Interview_On_Ins?=
	=?iso-8859-1?q?erting_Faults_into_Erlang_Programs_At_Run_Time?=
In-Reply-To: <49F99004.8050406@ituniv.se>
References: <49F99004.8050406@ituniv.se>
Message-ID: <401d3ba30904300625q31cdce0au53d301019a370a68@mail.gmail.com>

2009/4/30, Hoat Do :
> Dear Erlang programmer,
>
> We are two BSc thesis students, studying Software Engineering and
> Management at the IT University of Gothenburg Sweden. We are currently
> conducting a research study on the use of fault injection technique
> (http://en.wikipedia.org/wiki/Fault_injection) for evaluating Erlang
> software testing tools. This approach works by inserting faults into
> Erlang programs, and evaluating testing tools by checking if they can
> detect the fault or not.
>
> This study will involve finding out what typical faults exist in Erlang
> programs, and how they can be injected into such programs. We have been
> going through Erlang/OTP releases (R10B-0
>  - R13
> A) and other Erlang
> sources to find out what faults have been detected over the years. We
> need your help in finding out how these faults can be injected into
> Erlang programs at run time. Any idea on how this can be done will be
> highly appreciated.
>
> Below are some Erlang faults^1 :
>
> *API mismatches*
> Calling the wrong function/using the wrong arguments
>
> *Race conditions*
> Two parallel processes trying to do something incompatible, e.g. one
> deleting and the other reading a table object
>
> *Wrong context (process)*
> Executing in the wrong context, e.g. trying to read from a table that
> only exists on another Process

My "favourite" kind of faults:
if (Bcchno == no_value) ->
     update(Cell)
end,

similar with case. The other favourite is to implement objects as
gen_servers and have circular dependency between them, leading to
deadlocks. For API mismatches don't forget the wrong return value
type.


From bgustavsson@REDACTED  Thu Apr 30 15:44:15 2009
From: bgustavsson@REDACTED (Bjorn Gustavsson)
Date: Thu, 30 Apr 2009 15:44:15 +0200
Subject: [erlang-questions] eunit-2.1.1 is available
Message-ID: <6672d0160904300644s5e5296b0nce38069c93265143@mail.gmail.com>

eunit-2.1.1 replaces the broken eunit-2.1 included in R13B.
It can be found here:

http://www.erlang.org/download/patches/eunit-2.1.1.tar.gz

(It is only the eunit application itself, which you will need to to install in
the "lib" directory of the Erlang/OTP installation.)

We have taken steps for preventing this kind of problem in future releases
(i.e. make sure that we run eunit's test suite in our daily builds and test
runs).

/Bjorn
-- 
Bj?rn Gustavsson, Erlang/OTP, Ericsson AB


From daveb@REDACTED  Thu Apr 30 15:53:22 2009
From: daveb@REDACTED (Dave Bryson)
Date: Thu, 30 Apr 2009 08:53:22 -0500
Subject: [erlang-questions] open_port and port_close semantics
In-Reply-To: 
References: 
Message-ID: 


I'm pretty sure 'port_close' sends an exit signal to the child process  
(have not confirmed from src) .  At least in my application it kills  
the child process.  However in most cases I'll send my own stop  
message to the child process and have it call exit on itself so it can  
do any clean-up necessary.

Dave

On Apr 30, 2009, at 5:50 AM, Camille Troillard wrote:

> Hello,
>
> I am trying to understand the semantics of open_port and port_close.
> I was expecting port_close to send a quit signal to the child  
> process, but it merely close the file handlers from what I've read  
> in the doc and trapexit forums.
>
> What is the reason behind this?
> How do you make sure there are no leftover processes when the  
> application shuts down?
>
>
> Thanks!
> Cam
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From carlmcdade@REDACTED  Thu Apr 30 16:37:48 2009
From: carlmcdade@REDACTED (Carl McDade)
Date: Thu, 30 Apr 2009 16:37:48 +0200
Subject: [erlang-questions] Edoc syntax
In-Reply-To: 
References: 
	
	
	
Message-ID: 

Wow!,

Thanks Per. Hopefully by documenting your help. I can make this easier for
the next newcomers to the language.

On Thu, Apr 30, 2009 at 4:15 PM, Per Melin  wrote:

> Carl McDade:
> > What would be the syntax for using application?
>
> In your case, if you use absolute paths:
> edoc:application(mochiweb, "c:/erlang_stuff/mochi",
> [{dir,"c:/erlang/doc"}]).
>
> Or if you're in the mochi directory and want to use the standard
> directory for docs (mochi/doc):
> edoc:application(mochiweb, ".", []).
>



-- 
Carl McDade
Content Management Systems Consultant
www.hiveminds.co.uk
________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From pan+eq@REDACTED  Thu Apr 30 11:54:53 2009
From: pan+eq@REDACTED (pan+eq@REDACTED)
Date: Thu, 30 Apr 2009 11:54:53 +0200 (CEST)
Subject: [erlang-questions] Did Windows SMP support ever get added?
In-Reply-To: 
References: 
	
	
Message-ID: 

Hi,

If you run "erl.exe" on windows, you get the "oldshell", which does not 
inform about processors and stuff. The same behaviour as erl -oldshell on 
linux. If you however run werl.exe, you should see a slogan saying 
something like:
Erlang R13B (erts-5.7.1) [64-bit] [smp:2:2] [rq:4] [async-threads:0]

Where smp:2:2 means two logical processors and two schedulers.

In the oldshell, you can do a erlang:system_info(schedulers). or 
erlang:system_info(logical_processors).

/Patrik, OTP


On Wed, 29 Apr 2009, Carl McDade wrote:

> I guess what I am looking for is a simple  way to confirm that Erlang is
> seeing the other processor. Since since Erlang does not show this info at
> start up the way it does on Linux.
>
> On Wed, Apr 29, 2009 at 12:59 PM, Kenneth Lundin
> wrote:
>
>> Hi,
>>
>> The SMP support on Windows was introduced in Erlang/OTP R12B which has
>> been available for more than a year now.
>>
>>
>> On Wed, Apr 29, 2009 at 12:49 PM, Carl McDade 
>> wrote:
>>> Hi,
>>>
>>> I am asking this because it is not clear in the docs. I recently went
>> from
>>> Windows 2003 server over to Windows XP Pro on a Dual processor PC.
>> Windows
>>> XP did not pick up both processors so I had to force it a bit. But now
>>> Windows sees both processors but Erlang does not. Is it because
>>>
>>> a. I need to reinstall Erlang
>> No
>>> b. change a configuration file somewhere
>> No, at least not any Erlang specific file
>>> c. forget about it. Erlang does not support SMP in Windows yet.
>> SMP support for Windows since R12B
>>
>> I am not aware of any specific problems on Windows XP.
>>
>> /Kenneth , Erlang/OTP , Ericsson
>>>
>>> Thanks for any advice
>>>
>>> --
>>> Carl McDade
>>> www.hiveminds.co.uk
>>> ________________________
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>
>>
>
>
>
> -- 
> Carl McDade
> www.hiveminds.co.uk
> ________________________
>


From pan+eq@REDACTED  Thu Apr 30 11:38:42 2009
From: pan+eq@REDACTED (pan+eq@REDACTED)
Date: Thu, 30 Apr 2009 11:38:42 +0200 (CEST)
Subject: [erlang-questions] A specification or a bug of io:get_line ?
In-Reply-To: 
References: <8033176c0904232331i38a84640w9cbe9d6d019b634a@mail.gmail.com>
	
Message-ID: 

Hi!

It seems the last patch was not enough... There were several errors in the 
handling of files with unicode encodings.

Attached is a new patch for the same source file which passes more 
thorough testing. Backout the previous patch before applying this from the 
source code top.

Big thanks to Chiharu for helping in tracking down the problems!

Cheers,
/Patrik

On Fri, 24 Apr 2009, pan+eq@REDACTED wrote:

> Hi!
>
> First, a small reflection about your program: I'm not sure what your 
> io:format in print/3 is supposed to do, it will output UTF-8 "as is" which 
> will work for an UTF-8 terminal in oldshell (and default latin1) mode, but 
> will output strange things on other combinations (like in werl). Better to 
> set the standard output in unicode mode and print with 
> io:format("~ts~n",[Data]) instead, which will work as long as you have an 
> unicode aware terminal (like werl on windows and most modern terminals on 
> Linux).
>
> However, the real problem is that I've let through a bug in the 
> file_io_server in kernel, causing the error...
>
> I've attached a patch for the source tree, hope you can apply that and 
> rebuild kernel. We will of course fix it in the next service release.
>
> Cheers,
> /Patrik, OTP
>
> On Fri, 24 Apr 2009, Kawatake Chiharu wrote:
>
>> Hi,
>> 
>> I have just started learning Erlang by myself and came across this. I
>> searched for this in the past questions, but I was not able to find 
>> anything
>> that might be related this. So please let me ask about this. I am using 
>> R13B
>> on Windows. But this also occurred on Linux.
>> 
>> I wrote fragments of code that read a file and print its content like the
>> following.
>> 
>> ----------
>> 
>> -module(rw).
>> 
>> -export([for_each_line/4, print/3, main/1]).
>> 
>> for_each_line(Filename, [_, {encoding, Encoding}]=Mode, F, Args) ->
>>    case file:open(Filename, Mode) of
>>        {ok, Device} ->
>>            F(Device, Encoding, Args);
>>        {error, Reason} ->
>>            erlang:error(Reason)
>>    end.
>> 
>> print(Device, Encoding, Args) ->
>>    case io:get_line(Device, "") of
>>        {error, Reason} ->
>>            erlang:error(Reason),
>>            file:close(Device);
>>        eof ->
>>            file:close(Device);
>>        Data ->
>>            io:format("~s~n", [unicode:characters_to_binary(Data,
>> Encoding)]),
>>            print(Device, Encoding, Args)
>>    end.
>> 
>> main(Args) ->
>>    [Filename] = Args,
>>    for_each_line(Filename, [read, {encoding, utf8}], fun rw:print/3, []).
>> 
>> ------------
>> 
>> I made files encoded in utf-8 and tried to print its content. This worked
>> fine to some extent.
>> However, when I tried to read files that contained Japanese characters, I
>> got an error saying that
>> 
>> ------------
>> 
>> $ erl -noshell -s rw main test.txt
>> {"init terminating in
>> do_boot",{collect_line,[{rw,print,3},{init,start_it,1},{init,start_em,1}]}}
>> 
>> Crash dump was written to: erl_crash.dump
>> init terminating in do_boot ()
>> 
>> ------------
>> 
>> After I looked into this for a while, I found that it seemed that if a line
>> started with three consecutive ASCII characters following some Japanese
>> characters, this error could occur.
>> For example,
>> 
>> ..????????,????????,????????,????????,????????,,,????????,,????????,????????,????????,????????,????????,,,
>> 
>> which starts with two dots following Japanese characters, was ok. But
>> 
>> ...????????,????????,????????,????????,????????,,,????????,,????????,????????,????????,????????,????????,,,
>> 
>> where a dot "." was added at the head of the line, got the error.
>> 
>> If my code has some problem, which might be so more likely, please advise
>> me.
>> Please let me know if there is someone who has come across something 
>> similar
>> to this.
>> 
>> I will post the dump file later if necessary.
>> 
>> Best regards.
>> 
>> Chiharu
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unicode_get_line3.diff
Type: text/x-patch
Size: 4578 bytes
Desc: New version of patch for OTP-7974
URL: 

From erlangy@REDACTED  Thu Apr 30 17:08:18 2009
From: erlangy@REDACTED (Michael McDaniel)
Date: Thu, 30 Apr 2009 08:08:18 -0700
Subject: [erlang-questions] open_port and port_close semantics
In-Reply-To: 
References: 
	
Message-ID: <20090430150818.GS10039@delora.autosys.us>


 a couple old threads on the subject


http://www.erlang.org/pipermail/erlang-questions/2001-July/003429.html
http://erlang.org/pipermail/erlang-questions/2007-August/028743.html


~M


On Thu, Apr 30, 2009 at 08:53:22AM -0500, Dave Bryson wrote:
> 
> I'm pretty sure 'port_close' sends an exit signal to the child process  
> (have not confirmed from src) .  At least in my application it kills  
> the child process.  However in most cases I'll send my own stop  
> message to the child process and have it call exit on itself so it can  
> do any clean-up necessary.
> 
> Dave
> 
> On Apr 30, 2009, at 5:50 AM, Camille Troillard wrote:
> 
> > Hello,
> >
> > I am trying to understand the semantics of open_port and port_close.
> > I was expecting port_close to send a quit signal to the child  
> > process, but it merely close the file handlers from what I've read  
> > in the doc and trapexit forums.
> >
> > What is the reason behind this?
> > How do you make sure there are no leftover processes when the  
> > application shuts down?
> >
> >
> > Thanks!
> > Cam
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> 


From steve.kirsch@REDACTED  Thu Apr 30 17:11:58 2009
From: steve.kirsch@REDACTED (Steve Kirsch)
Date: Thu, 30 Apr 2009 08:11:58 -0700
Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs
In-Reply-To: <18937.31939.35066.596902@pilspetsen.it.uu.se>
Message-ID: <76BB7F270C366D47AA79851BB0B39D810299C7F7@exchg02.propel.com>

Wow. That is very cool. And if the bitarray is large enough, it is
passed by reference in a message. Awesome.

So is there a way to set a byte or word at a time??

-----Original Message-----

hipe_bifs:bitarray(NrArrayBits, InitialBitValue) -> BitArray
hipe_bifs:bitarray_sub(BitArray, BitNr) -> BitValue
hipe_bifs:bitarray_update(BitArray, BitNr, BitValue) -> BitArray

Bit values are the booleans true and false.
Array indexing is 0-based (1-based indexing is just sooo wrong).
The update operation returns the updated array.

The number of elements in a bit array is limited to what can be
described by non-negative fixnums (immediate "small" integers), which is
something like 2^27 - 1 on 32-bit machines. Larger bitarrays than that
must be emulated using a chunked representation.
See lib/hipe/regalloc/hipe_ig.erl for an example (look for the
USE_NEW_BITARRAY_BIFS define and the adjset code following it).

/Mikael


From gordon@REDACTED  Thu Apr 30 18:12:28 2009
From: gordon@REDACTED (Gordon Guthrie)
Date: Thu, 30 Apr 2009 17:12:28 +0100
Subject: [erlang-questions] Reading An Mnesia Index (Not The Records It
	Points To)
Message-ID: 

I have an index on a table that represents a user taxonomy - how the
user has chosen to organise their world in the application.

It is a fairly dense index, that is for each indice there will be
between 30 and several hundred actual records.

At the moment to expose the taxonomy to the user I have to build a
query that returns the value of the index from every record, and then
de-duplicate that back down to get the index - which has been slow on
occasions...

As far as I can tell there is no way through the published API to
simply 'read the index' but I am sure I could plow into the code and
'work it out' but I am wary of the old 'undocumented API' beartrap.

Any suggestions?

Gordon


From steve.kirsch@REDACTED  Thu Apr 30 18:25:28 2009
From: steve.kirsch@REDACTED (Steve Kirsch)
Date: Thu, 30 Apr 2009 09:25:28 -0700
Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs
In-Reply-To: 
Message-ID: <76BB7F270C366D47AA79851BB0B39D810299C7FB@exchg02.propel.com>

is there a way to do a destructive setelement?

This is in the VM, but the compiler rarely generates it.

Is there a way to force this?

-----Original Message-----
From: Steve Kirsch 

Wow. That is very cool. And if the bitarray is large enough, it is
passed by reference in a message. Awesome.

So is there a way to set a byte or word at a time??

-----Original Message-----

hipe_bifs:bitarray(NrArrayBits, InitialBitValue) -> BitArray
hipe_bifs:bitarray_sub(BitArray, BitNr) -> BitValue
hipe_bifs:bitarray_update(BitArray, BitNr, BitValue) -> BitArray

Bit values are the booleans true and false.
Array indexing is 0-based (1-based indexing is just sooo wrong).
The update operation returns the updated array.

The number of elements in a bit array is limited to what can be
described by non-negative fixnums (immediate "small" integers), which is
something like 2^27 - 1 on 32-bit machines. Larger bitarrays than that
must be emulated using a chunked representation.
See lib/hipe/regalloc/hipe_ig.erl for an example (look for the
USE_NEW_BITARRAY_BIFS define and the adjset code following it).

/Mikael


From steve.kirsch@REDACTED  Thu Apr 30 18:41:46 2009
From: steve.kirsch@REDACTED (Steve Kirsch)
Date: Thu, 30 Apr 2009 09:41:46 -0700
Subject: [erlang-questions] how can I access test_server_loc in the
	process dict	ofanother	process?
In-Reply-To: <87ab5yxyqn.fsf@sterlett.hq.kred>
Message-ID: <76BB7F270C366D47AA79851BB0B39D810299C7FD@exchg02.propel.com>

Thanks, I had missed that.

trace can do lots of things, but it won't tell you line numbers unless
I'm mistaken (assuming you've inserted them).

but i do agree that line numbers might be useless for profiling in many
cases, but it can be very very useful.

-----Original Message-----
From: mats cronqvist [mailto:masse@REDACTED] 
Sent: Thursday, April 30, 2009 2:44 AM
To: Steve Kirsch
Cc: Erlang
Subject: Re: how can I access test_server_loc in the process dict
ofanother process?

"Steve Kirsch"  writes:

> I wrote a simple statistical profiler that basically snapshots a 
> spawned MFA every 10 msec for 100 samples using process_info(Pid,
> current_function)
>
> that's pretty cool.
>
> But way cooler is to include:
>
> -compile({parse_transform,ct_line}). 
>
> in the module I want to statistically profile.
>
> This essentially pushes your M, F, line number in the process 
> dictionary (under key test_server_loc) each time you execute a line of

> code (replacing it if in the same function so you get a call stack 
> more or less to a max depth of 10).
>
> That's way cool.
>
> So I'd like to access that key (test_server_loc) from my statistical 
> profiler which is running in another process.

  process_info(Pid,dictionary).

  allow me to point out that what you're trying to accomplish can be
  done (without recompiling/parse transforms) through tracing.

  mats


From raould@REDACTED  Thu Apr 30 19:02:52 2009
From: raould@REDACTED (Raoul Duke)
Date: Thu, 30 Apr 2009 10:02:52 -0700
Subject: [erlang-questions]
	=?iso-8859-1?q?V=E1=3A_Email_Interview_On_Inse?=
	=?iso-8859-1?q?rting_Faults_into_Erlang_Programs_At_Run_Time?=
In-Reply-To: <401d3ba30904300625q31cdce0au53d301019a370a68@mail.gmail.com>
References: <49F99004.8050406@ituniv.se>
	<401d3ba30904300625q31cdce0au53d301019a370a68@mail.gmail.com>
Message-ID: <91a2ba3e0904301002t301eb29ckc1699f65b33c429a@mail.gmail.com>

hi,

> For API mismatches don't forget the wrong return value
> type.

does dyalizer not help with such things?

-Mr. Perpetual Newbie.


From carlmcdade@REDACTED  Thu Apr 30 19:18:53 2009
From: carlmcdade@REDACTED (Carl McDade)
Date: Thu, 30 Apr 2009 19:18:53 +0200
Subject: [erlang-questions] Edoc syntax
In-Reply-To: 
References: 
	
	
	
	
Message-ID: 

Another question,

Is there any function for showing the source code that is being refered to
along with its comments?

On Thu, Apr 30, 2009 at 4:37 PM, Carl McDade  wrote:

> Wow!,
>
> Thanks Per. Hopefully by documenting your help. I can make this easier for
> the next newcomers to the language.
>
>
> On Thu, Apr 30, 2009 at 4:15 PM, Per Melin  wrote:
>
>> Carl McDade:
>> > What would be the syntax for using application?
>>
>> In your case, if you use absolute paths:
>> edoc:application(mochiweb, "c:/erlang_stuff/mochi",
>> [{dir,"c:/erlang/doc"}]).
>>
>> Or if you're in the mochi directory and want to use the standard
>> directory for docs (mochi/doc):
>> edoc:application(mochiweb, ".", []).
>>
>
>
>
> --
> Carl McDade
> Content Management Systems Consultant
> www.hiveminds.co.uk
> ________________________
>



-- 
Carl McDade
Content Management Systems Consultant
www.hiveminds.co.uk
________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From tom.mcnulty@REDACTED  Thu Apr 30 20:48:18 2009
From: tom.mcnulty@REDACTED (Tom McNulty)
Date: Thu, 30 Apr 2009 12:48:18 -0600
Subject: [erlang-questions] erl_tidy: Preserve spec attribute.
Message-ID: 

Hello,

I've been using erl_tidy over all my code lately and have been very  
happy with the output it produces.

Ran into this problem though:

-spec add2(number()) -> number().
add2(Val) -> Val + 2.

turns into

-'spec'({{add2, 1},
	 [{type, 6, 'fun',
	   [{type, 6, product, [{type, 6, number, []}]},
	    {type, 6, number, []}]}]}).

add2(Val) -> Val + 2.


Ugh!. Is there any work around for this?

I'm using R13B.


Thanks,

- Tom



From francesco@REDACTED  Thu Apr 30 21:39:02 2009
From: francesco@REDACTED (Francesco Cesarini (Erlang Training and Consulting))
Date: Thu, 30 Apr 2009 20:39:02 +0100
Subject: [erlang-questions] ErlLounge Bay Area / BoFs tonight (30/4)
Message-ID: <49F9FE56.8090407@erlang-consulting.com>

Hi All,

For those who could not make it to the Erlang Factory in Palo Alto this 
week, but are based in the are;You are welcome to join us for the Birds 
of a Feather Session, open for everyone. Conference finishes at 17.30, 
Bof starts at 18.00. BoF sessions which  have been registered so far include
* CouchDB and Erlang related databases
* AMQP and XMPP, using Erlang in your messaging backbone

We have room for one more. Location is the Palo Alto Sheraton: 
http://www.erlang-factory.com/conference/SFBayAreaErlangFactory2009/venue

For those who prefer to join us for a drink and some finger food, we 
will be moving on to Gordon Biersch on 640 Emerson Street in downtown 
Palo Alto (5 minutes walk from the CalTrain) at 19.30.  
http://www.gordonbiersch.com/restaurants/index.php?pg=location&sub=loc&location_id=15

Welcome!

Francesco

PS. For those not here, but want excellent live coverage, follow 
#erlangfactory on twitter.
--
http://www.erlang-consulting.com


From thomasl_erlang@REDACTED  Thu Apr 30 22:37:13 2009
From: thomasl_erlang@REDACTED (Thomas Lindgren)
Date: Thu, 30 Apr 2009 13:37:13 -0700 (PDT)
Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs
In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810299C7FB@exchg02.propel.com>
References: <76BB7F270C366D47AA79851BB0B39D810299C7FB@exchg02.propel.com>
Message-ID: <417958.68244.qm@web111408.mail.gq1.yahoo.com>






----- Original Message ----
> From: Steve Kirsch 
> To: Mikael Pettersson 
> Cc: Erlang 
> Sent: Thursday, April 30, 2009 6:25:28 PM
> Subject: Re: [erlang-questions] A bug? - bloom filters - and loadable BIFs
> 
> is there a way to do a destructive setelement?
> 
> This is in the VM, but the compiler rarely generates it.
> 
> Is there a way to force this?
> 

Practically speaking, for this to work in general, the VM needs a generational collector that tracks and handles pointers from the old generation to the new, which the current one does not. Philosophically speaking, just throwing destructive updates into the language is the quick road out of functional programming and into the grottier parts of Lisp. A general user mechanism for Erlang has to be cleaner than that.

(NB: I say this as the original proponent of and user of destructive updates in Hipe :-)

Best,
Thomas