aboutsummaryrefslogtreecommitdiffstats
path: root/lib/odbc/src
diff options
context:
space:
mode:
authorStefan Strigler <[email protected]>2015-05-22 11:11:36 +0200
committerStefan Strigler <[email protected]>2015-07-02 16:36:39 +0200
commitc95f0a64e5189ad1240fc547fcd774fe60f414a2 (patch)
treef404baeb7a716a4b903ec0175fc2440d6e3604d5 /lib/odbc/src
parent74a95b3d511177a9b35c2b0272b9ca5511b6f750 (diff)
downloadotp-c95f0a64e5189ad1240fc547fcd774fe60f414a2.tar.gz
otp-c95f0a64e5189ad1240fc547fcd774fe60f414a2.tar.bz2
otp-c95f0a64e5189ad1240fc547fcd774fe60f414a2.zip
introduce odbc port_timeout
This introduces a new application environment variable 'port_timeout' that lets you set a custom timeout for ODBC when connecting to the port drivers upon initialization within odbc:connect/2. Default is still 5000 msec.
Diffstat (limited to 'lib/odbc/src')
-rw-r--r--lib/odbc/src/odbc.erl9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/odbc/src/odbc.erl b/lib/odbc/src/odbc.erl
index 4901821e9c..12560bfb6e 100644
--- a/lib/odbc/src/odbc.erl
+++ b/lib/odbc/src/odbc.erl
@@ -26,6 +26,8 @@
-include("odbc_internal.hrl").
+-define(ODBC_PORT_TIMEOUT, 5000).
+
%% API --------------------------------------------------------------------
-export([start/0, start/1, stop/0,
@@ -523,10 +525,10 @@ handle_msg({connect, ODBCCmd, AutoCommitMode, SrollableCursors},
NewState = State#state{auto_commit_mode = AutoCommitMode,
scrollable_cursors = SrollableCursors},
- case gen_tcp:accept(ListenSocketSup, 5000) of
+ case gen_tcp:accept(ListenSocketSup, port_timeout()) of
{ok, SupSocket} ->
gen_tcp:close(ListenSocketSup),
- case gen_tcp:accept(ListenSocketOdbc, 5000) of
+ case gen_tcp:accept(ListenSocketOdbc, port_timeout()) of
{ok, OdbcSocket} ->
gen_tcp:close(ListenSocketOdbc),
odbc_send(OdbcSocket, ODBCCmd),
@@ -983,3 +985,6 @@ string_terminate_value(Binary) when is_binary(Binary) ->
<<Binary/binary,0:16>>;
string_terminate_value(null) ->
null.
+
+port_timeout() ->
+ application:get_env(?MODULE, port_timeout, ?ODBC_PORT_TIMEOUT).