From matthew@REDACTED Sun Apr 6 06:12:22 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Sat, 5 Apr 2008 21:12:22 -0700 Subject: [erlang-patches] odbc and ssl applications use error_logger:error_report/2 instead of error_logger:error_msg/2 Message-ID: While looking for idiomatic uses of error_logger:error_report in the OTP distribution, I noticed that the odbc and ssl applications call error_logger:error_report/2 with arguments that look intended for error_logger:error_msg/2. The patch below corrects this. --- odbc/src/odbc.erl.orig 2008-04-05 21:00:25.000000000 -0700 +++ odbc/src/odbc.erl 2008-04-05 21:01:03.000000000 -0700 @@ -678,8 +678,8 @@ ok -> ok; {error, Reason} -> - error_logger:error_report("ODBC could not end connection " - "gracefully due to ~p~n", [Reason]) + error_logger:error_msg("ODBC could not end connection " + "gracefully due to ~p~n", [Reason]) end, {stop, normal, State#state{reply_to = undefined}}; @@ -754,8 +754,7 @@ %% so we do not want to crash, but we make a log entry as it is an %% unwanted behaviour.) handle_info(Info, State) -> - error_logger:error_report("ODBC: received unexpected info: ~p~n", - [Info]), + error_logger:error_msg("ODBC: received unexpected info: ~p~n", [Info]), {noreply, State}. %%-------------------------------------------------------------------------- --- ssl/src/ssl_handshake.erl.orig 2008-04-05 21:05:12.000000000 -0700 +++ ssl/src/ssl_handshake.erl 2008-04-05 21:05:52.000000000 -0700 @@ -274,8 +274,8 @@ Result catch exit:Reason -> - error_logger:error_report("Key calculation failed due to ~p", - [Reason]), + error_logger:error_msg("Key calculation failed due to ~p~n", + [Reason]), #alert{level = ?FATAL, description = ?HANDSHAKE_FAILURE} end; @@ -294,8 +294,8 @@ catch exit:Reason -> - error_logger:error_report("Master secret calculation failed" - " due to ~p", [Reason]), + error_logger:error_msg("Master secret calculation failed" + " due to ~p~n", [Reason]), #alert{level = ?FATAL, description = ?HANDSHAKE_FAILURE} end. From ingela@REDACTED Mon Apr 7 08:43:47 2008 From: ingela@REDACTED (Ingela Anderton Andin) Date: Mon, 07 Apr 2008 08:43:47 +0200 Subject: [erlang-patches] odbc and ssl applications use error_logger:error_report/2 instead of error_logger:error_msg/2 In-Reply-To: References: Message-ID: <47F9C2A3.3020604@erix.ericsson.se> Hi! Thank you for reporting this. Indeed there needs to be a change in the code. I have created a ticket for this. Regards Ingela - OTP team Matthew Dempsky wrote: > While looking for idiomatic uses of error_logger:error_report in the > OTP distribution, I noticed that the odbc and ssl applications call > error_logger:error_report/2 with arguments that look intended for > error_logger:error_msg/2. The patch below corrects this. > > --- odbc/src/odbc.erl.orig 2008-04-05 21:00:25.000000000 -0700 > +++ odbc/src/odbc.erl 2008-04-05 21:01:03.000000000 -0700 > @@ -678,8 +678,8 @@ > ok -> > ok; > {error, Reason} -> > - error_logger:error_report("ODBC could not end connection " > - "gracefully due to ~p~n", [Reason]) > + error_logger:error_msg("ODBC could not end connection " > + "gracefully due to ~p~n", [Reason]) > end, > > {stop, normal, State#state{reply_to = undefined}}; > @@ -754,8 +754,7 @@ > %% so we do not want to crash, but we make a log entry as it is an > %% unwanted behaviour.) > handle_info(Info, State) -> > - error_logger:error_report("ODBC: received unexpected info: ~p~n", > - [Info]), > + error_logger:error_msg("ODBC: received unexpected info: ~p~n", [Info]), > {noreply, State}. > > %%-------------------------------------------------------------------------- > --- ssl/src/ssl_handshake.erl.orig 2008-04-05 21:05:12.000000000 -0700 > +++ ssl/src/ssl_handshake.erl 2008-04-05 21:05:52.000000000 -0700 > @@ -274,8 +274,8 @@ > Result > catch > exit:Reason -> > - error_logger:error_report("Key calculation failed due to ~p", > - [Reason]), > + error_logger:error_msg("Key calculation failed due to ~p~n", > + [Reason]), > #alert{level = ?FATAL, description = ?HANDSHAKE_FAILURE} > end; > > @@ -294,8 +294,8 @@ > > catch > exit:Reason -> > - error_logger:error_report("Master secret calculation failed" > - " due to ~p", [Reason]), > + error_logger:error_msg("Master secret calculation failed" > + " due to ~p~n", [Reason]), > #alert{level = ?FATAL, description = ?HANDSHAKE_FAILURE} > end. > _______________________________________________ > erlang-patches mailing list > erlang-patches@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-patches > > From matthew@REDACTED Fri Apr 18 05:48:36 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Thu, 17 Apr 2008 20:48:36 -0700 Subject: [erlang-patches] Patrick Mahoney's SIGWINCH patch In-Reply-To: References: Message-ID: This patch was not included in R12B-2 either, and I've still received no feedback from the developers regarding this patch. Are there any concerns barring its consideration? Upon further review, I did notice that cols_needs_update was not properly marked as volatile in the original diff, so I've changed corrected that and included the updated diff below. I'd really like to see this included upstream. :-) On Thu, Feb 7, 2008 at 12:00 AM, Matthew Dempsky wrote: > I noticed that Patrick Mahoney's SIGWINCH patch[1] was not included in > R12B-1. Is it possible for it to be included in R12B-2? Are there > any issues that need to be resolved for it to be acceptable for > inclusion? > > [1] http://www.erlang.org/pipermail/erlang-patches/2007-December/000205.html --- erts/emulator/drivers/unix/ttsl_drv.c.orig 2007-12-18 04:57:58.000000000 -0700 +++ erts/emulator/drivers/unix/ttsl_drv.c 2007-12-31 12:13:30.000000000 -0700 @@ -58,6 +58,7 @@ static char *capbuf; static char *up, *down, *left, *right; static int cols, xn; +static volatile int cols_needs_update = FALSE; /* The various opcodes. */ #define OP_PUTC 0 @@ -114,6 +115,7 @@ static int move_right(int); static int move_up(int); static int move_down(int); +static void update_cols(void); /* Terminal setting functions. */ static int tty_init(int,int,int,int); @@ -122,6 +124,7 @@ static int ttysl_control(ErlDrvData, unsigned int, char *, int, char **, int); static RETSIGTYPE suspend(int); static RETSIGTYPE cont(int); +static RETSIGTYPE winch(int); /* Define the driver table entry. */ struct erl_drv_entry ttsl_driver_entry = { @@ -200,6 +203,7 @@ setlocale(LC_CTYPE, ""); /* Set international environment */ sys_sigset(SIGCONT, cont); + sys_sigset(SIGWINCH, winch); driver_select(port, (ErlDrvEvent)(Uint)ttysl_fd, DO_READ, 1); ttysl_port = port; @@ -262,6 +266,7 @@ close(ttysl_fd); driver_select(ttysl_port, (ErlDrvEvent)(Uint)ttysl_fd, DO_READ, 0); sys_sigset(SIGCONT, SIG_DFL); + sys_sigset(SIGWINCH, SIG_DFL); } ttysl_port = (ErlDrvPort)-1; ttysl_fd = -1; @@ -432,6 +437,8 @@ int i, l, r; byte *c; + update_cols(); + /* Step forward or backwards over n logical characters. */ c = step_over_chars(n); @@ -553,6 +560,8 @@ */ static int write_buf(byte *s, int n) { + update_cols(); + while (n > 0) { if (isprint(*s)) { outc(*s); @@ -598,6 +607,8 @@ { int dc, dl; + update_cols(); + dc = COL(to) - COL(from); dl = LINE(to) - LINE(from); if (dl > 0) @@ -704,6 +715,27 @@ tputs(down, 1, outc); return TRUE; } + +/* + * Updates cols if terminal has resized (SIGWINCH). Should be called + * at the start of any function that uses the COL or LINE macros. If + * the terminal is resized after calling this function but before use + * of the macros, then we may write to the wrong screen location. + * + * We cannot call this from the SIGWINCH handler because it uses + * ioctl() which is not a safe function as listed in the signal(7) + * man page. + */ +static void update_cols(void) +{ + Uint32 width, height; + + if (cols_needs_update) { + cols_needs_update = FALSE; + ttysl_get_window_size(&width, &height); + cols = width; + } +} /* @@ -830,3 +862,7 @@ } } +static RETSIGTYPE winch(int sig) +{ + cols_needs_update = TRUE; +} From bjorn@REDACTED Wed Apr 23 16:15:59 2008 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 23 Apr 2008 16:15:59 +0200 Subject: [erlang-patches] [erlang-bugs] Patrick Mahoney's SIGWINCH patch In-Reply-To: References: Message-ID: "Matthew Dempsky" writes: > I'd really like to see this included upstream. :-) Thanks for the patch. We will test it and consider it for inclusion in R12B-3. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From magnus@REDACTED Thu Apr 24 10:18:36 2008 From: magnus@REDACTED (Magnus Froberg) Date: Thu, 24 Apr 2008 10:18:36 +0200 Subject: [erlang-patches] init:stop/1 Message-ID: Hi, a patch that makes it possible to terminate an erlang system using init:stop with a specified Status code (ala erlang:halt/1). Handy if one need to terminate the system cleanly but want an exit code that can be checked. The patch is for R11B-2. lake:R11B-2> svn diff lib/kernel/src/init.erl Index: lib/kernel/src/init.erl =================================================================== --- lib/kernel/src/init.erl (revision 26) +++ lib/kernel/src/init.erl (working copy) @@ -44,7 +44,7 @@ %% -module(init). --export([restart/0,reboot/0,stop/0, +-export([restart/0,reboot/0,stop/0,stop/1, get_status/0,boot/1,get_arguments/0,get_plain_arguments/0, get_argument/1,script_id/0]). @@ -129,9 +129,10 @@ Rep end. -restart() -> init ! {stop,restart},ok. -reboot() -> init ! {stop,reboot},ok. -stop() -> init ! {stop,stop},ok. +restart() -> init ! {stop,restart},ok. +reboot() -> init ! {stop,reboot},ok. +stop() -> init ! {stop,stop},ok. +stop(Status) -> init ! {stop,{stop,Status}},ok. boot(BootArgs) -> register(init, self()), @@ -468,7 +469,10 @@ halt(); do_stop(stop,State) -> stop_heart(State), - halt(). + halt(); +do_stop({stop,Status},State) -> + stop_heart(State), + halt(Status). /Magnus From magnus@REDACTED Fri Apr 25 09:46:59 2008 From: magnus@REDACTED (=?UTF-8?B?TWFnbnVzIEZyb8KaYmVyZw==?=) Date: Fri, 25 Apr 2008 09:46:59 +0200 Subject: [erlang-patches] Added connect_timeout option to http.erl (R11B-2) Message-ID: Hi, I needed support to use a connect timeout that is used in the gen_tcp:connect (and ssl:connect) call done from http_transport.erl. Thus, the connect_timeout option is added to the http options. The patch is for R11B-2. Now, I noticed that a similar fix was applied to R12B-2 to get a connect timeout. However, that fix reuses the timeout http option as connect timeout as well but I think it is better to be able to specify two different timeout values (as the connect timeout normally should be smaller than the session timeout). Thus, a fix for R12B-2 could be that if connect_timeout is not specified it will fallback to the timeout option instead of default infinity as I did it for R11B-2. Another thing (not included in the patch) noted is that at several places in the inets application error_logger:info_report/2 and error_report/2 is used. This reports are not printed unless an own error event handler has been added. This calls should be replaced with error_logger:info_msg/2 resp. error_msg/2. /Magnus -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: http_patch.txt URL: From ingela@REDACTED Fri Apr 25 11:25:26 2008 From: ingela@REDACTED (Ingela Anderton Andin) Date: Fri, 25 Apr 2008 11:25:26 +0200 Subject: [erlang-patches] Added connect_timeout option to http.erl (R11B-2) In-Reply-To: References: Message-ID: <4811A386.6020201@erix.ericsson.se> Hi Magnus Fro?berg wrote: > Hi, > > I needed support to use a connect timeout that > is used in the gen_tcp:connect (and ssl:connect) > call done from http_transport.erl. > > Thus, the connect_timeout option is added to the http options. > > The patch is for R11B-2. > > Now, I noticed that a similar fix was applied to R12B-2 > to get a connect timeout. However, that fix reuses the > timeout http option as connect timeout as well but I > think it is better to be able to specify two different > timeout values (as the connect timeout normally should > be smaller than the session timeout). > Thus, a fix for R12B-2 could be that if connect_timeout > is not specified it will fallback to the timeout option > instead of default infinity as I did it for R11B-2. > I am just in the middel of doing a major change in another application but as soon as I finshed that I will consider what will be the best solution for inets. I will get back to you on that. > Another thing (not included in the patch) noted is that > at several places in the inets application > error_logger:info_report/2 and error_report/2 is used. > This reports are not printed unless an own error event > handler has been added. This calls should be replaced > with error_logger:info_msg/2 resp. error_msg/2. Thank you for pointing this out. Actually it will be replaced by io_lib:format and error_logger:error_report/1 and error_logger:info_report/1 to work as intended. Regards Ingela -OTP team