Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
07bcaf52
Commit
07bcaf52
authored
9 years ago
by
Matt Jordan
Committed by
Gerrit Code Review
9 years ago
Browse files
Options
Downloads
Plain Diff
Merge "res_odbc: Use negative connection cache for all connections"
parents
0aab8cdc
ebe37135
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
res/res_odbc.c
+10
-6
10 additions, 6 deletions
res/res_odbc.c
with
10 additions
and
6 deletions
res/res_odbc.c
+
10
−
6
View file @
07bcaf52
...
...
@@ -1253,8 +1253,7 @@ struct odbc_obj *_ast_odbc_request_obj2(const char *name, struct ast_flags flags
if
(
obj
)
{
ast_assert
(
ao2_ref
(
obj
,
0
)
>
1
);
}
if
(
!
obj
&&
(
ast_atomic_fetchadd_int
(
&
class
->
count
,
+
1
)
<
class
->
limit
)
&&
(
time
(
NULL
)
>
class
->
last_negative_connect
.
tv_sec
+
class
->
negative_connection_cache
.
tv_sec
))
{
if
(
!
obj
&&
(
ast_atomic_fetchadd_int
(
&
class
->
count
,
+
1
)
<
class
->
limit
))
{
obj
=
ao2_alloc
(
sizeof
(
*
obj
),
odbc_obj_destructor
);
if
(
!
obj
)
{
class
->
count
--
;
...
...
@@ -1412,10 +1411,7 @@ struct odbc_obj *_ast_odbc_request_obj2(const char *name, struct ast_flags flags
}
if
(
ast_test_flag
(
&
flags
,
RES_ODBC_CONNECTED
)
&&
!
obj
->
up
)
{
/* Check if this connection qualifies for reconnection, with negative connection cache time */
if
(
time
(
NULL
)
>
obj
->
parent
->
last_negative_connect
.
tv_sec
+
obj
->
parent
->
negative_connection_cache
.
tv_sec
)
{
odbc_obj_connect
(
obj
);
}
odbc_obj_connect
(
obj
);
}
else
if
(
ast_test_flag
(
&
flags
,
RES_ODBC_SANITY_CHECK
))
{
ast_odbc_sanity_check
(
obj
);
}
else
if
(
obj
->
parent
->
idlecheck
>
0
&&
ast_tvdiff_sec
(
ast_tvnow
(),
obj
->
last_used
)
>
obj
->
parent
->
idlecheck
)
{
...
...
@@ -1522,6 +1518,7 @@ static odbc_status odbc_obj_connect(struct odbc_obj *obj)
char
*
tracefile
=
"/tmp/odbc.trace"
;
#endif
SQLHDBC
con
;
long
int
negative_cache_expiration
;
if
(
obj
->
up
)
{
odbc_obj_disconnect
(
obj
);
...
...
@@ -1531,6 +1528,13 @@ static odbc_status odbc_obj_connect(struct odbc_obj *obj)
ast_log
(
LOG_NOTICE
,
"Connecting %s
\n
"
,
obj
->
parent
->
name
);
}
/* Dont connect while server is marked as unreachable via negative_connection_cache */
negative_cache_expiration
=
obj
->
parent
->
last_negative_connect
.
tv_sec
+
obj
->
parent
->
negative_connection_cache
.
tv_sec
;
if
(
time
(
NULL
)
<
negative_cache_expiration
)
{
ast_log
(
LOG_WARNING
,
"Not connecting to %s. Negative connection cache for %ld seconds
\n
"
,
obj
->
parent
->
name
,
negative_cache_expiration
-
time
(
NULL
));
return
ODBC_FAIL
;
}
res
=
SQLAllocHandle
(
SQL_HANDLE_DBC
,
obj
->
parent
->
env
,
&
con
);
if
((
res
!=
SQL_SUCCESS
)
&&
(
res
!=
SQL_SUCCESS_WITH_INFO
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment