Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
liblinphone
Commits
10049e07
Commit
10049e07
authored
Feb 28, 2018
by
Ronan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(Abstract): in reconnect case, disable foreign key before init call
parent
7d491f86
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
10 deletions
+14
-10
src/db/abstract/abstract-db-p.h
src/db/abstract/abstract-db-p.h
+2
-0
src/db/abstract/abstract-db.cpp
src/db/abstract/abstract-db.cpp
+12
-10
No files found.
src/db/abstract/abstract-db-p.h
View file @
10049e07
...
...
@@ -35,6 +35,8 @@ public:
DbSession
dbSession
;
private:
void
safeInit
();
AbstractDb
::
Backend
backend
;
L_DECLARE_PUBLIC
(
AbstractDb
);
...
...
src/db/abstract/abstract-db.cpp
View file @
10049e07
...
...
@@ -43,6 +43,15 @@ LINPHONE_BEGIN_NAMESPACE
}
#endif // if defined(SOCI_ENABLED) && (TARGET_OS_IPHONE || defined(__ANDROID__))
void
AbstractDbPrivate
::
safeInit
()
{
#ifdef SOCI_ENABLED
L_Q
();
dbSession
.
enableForeignKeys
(
false
);
q
->
init
();
dbSession
.
enableForeignKeys
(
true
);
#endif // ifdef SOCI_ENABLED
}
AbstractDb
::
AbstractDb
(
AbstractDbPrivate
&
p
)
:
Object
(
p
)
{}
bool
AbstractDb
::
connect
(
Backend
backend
,
const
string
&
parameters
)
{
...
...
@@ -66,11 +75,7 @@ bool AbstractDb::connect (Backend backend, const string ¶meters) {
if
(
d
->
dbSession
)
{
try
{
#ifdef SOCI_ENABLED
d
->
dbSession
.
enableForeignKeys
(
false
);
init
();
d
->
dbSession
.
enableForeignKeys
(
true
);
#endif // ifdef SOCI_ENABLED
d
->
safeInit
();
}
catch
(
const
exception
&
e
)
{
lWarning
()
<<
"Unable to init database: "
<<
e
.
what
();
...
...
@@ -99,14 +104,11 @@ bool AbstractDb::forceReconnect () {
lInfo
()
<<
"Trying sql backend reconnect..."
;
try
{
soci
::
session
*
session
=
d
->
dbSession
.
getBackendSession
();
session
->
close
();
for
(
int
i
=
0
;
i
<
retryCount
;
++
i
)
{
try
{
lInfo
()
<<
"Reconnect... Try: "
<<
i
;
s
ession
->
reconnect
();
i
nit
();
d
->
dbSession
.
getBackendS
ession
()
->
reconnect
();
// Equivalent to close and connect.
d
->
safeI
nit
();
lInfo
()
<<
"Database reconnection successful!"
;
return
true
;
}
catch
(
const
soci
::
soci_error
&
e
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment