Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-UDR
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-UDR
Commits
f74a9eb1
Commit
f74a9eb1
authored
Jun 17, 2022
by
yangjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mysql reconnection
parent
e29e19ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
19 deletions
+30
-19
src/impl/AuthenticationStatusDocumentApiImpl.cpp
src/impl/AuthenticationStatusDocumentApiImpl.cpp
+2
-0
src/impl/AuthenticationStatusDocumentApiImpl.h
src/impl/AuthenticationStatusDocumentApiImpl.h
+2
-0
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
+25
-19
src/impl/AuthenticationSubscriptionDocumentApiImpl.h
src/impl/AuthenticationSubscriptionDocumentApiImpl.h
+1
-0
No files found.
src/impl/AuthenticationStatusDocumentApiImpl.cpp
View file @
f74a9eb1
...
...
@@ -38,6 +38,8 @@ AuthenticationStatusDocumentApiImpl::AuthenticationStatusDocumentApiImpl(
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
mysql_WitcommUDRDB
));
return
;
}
reconnect
=
1
;
mysql_options
(
mysql_WitcommUDRDB
,
MYSQL_OPT_RECONNECT
,
&
reconnect
);
}
AuthenticationStatusDocumentApiImpl
::~
AuthenticationStatusDocumentApiImpl
()
...
...
src/impl/AuthenticationStatusDocumentApiImpl.h
View file @
f74a9eb1
...
...
@@ -53,6 +53,8 @@ public:
private:
MYSQL
*
mysql_WitcommUDRDB
;
char
reconnect
;
};
}
...
...
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
View file @
f74a9eb1
...
...
@@ -44,7 +44,9 @@ AuthenticationSubscriptionDocumentApiImpl::
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
mysql_WitcommUDRDB
));
return
;
}
// mysql_WitcommUDRDB = &mysqldb;
reconnect
=
1
;
mysql_options
(
mysql_WitcommUDRDB
,
MYSQL_OPT_RECONNECT
,
&
reconnect
);
Logger
::
udr_server
().
debug
(
"****** AuthenticationSubscription: mysql init pointer(%p) ******"
,
mysql_WitcommUDRDB
);
}
AuthenticationSubscriptionDocumentApiImpl
::
...
...
@@ -78,6 +80,7 @@ void AuthenticationSubscriptionDocumentApiImpl::
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
int
ret
;
const
std
::
string
select_Authenticationsubscription
=
"select * from AuthenticationSubscription WHERE ueid='"
+
ueId
+
"'"
;
...
...
@@ -92,20 +95,20 @@ void AuthenticationSubscriptionDocumentApiImpl::
nlohmann
::
json
::
parse
(
patchItem
[
i
].
getValue
().
c_str
())
.
get_to
(
sequencenumber
);
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
select_Authenticationsubscription
.
c_str
(),
(
unsigned
long
)
select_Authenticationsubscription
.
size
()))
{
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s)"
,
select_Authenticationsubscription
.
c_str
()
);
ret
=
mysql_real_query
(
mysql_WitcommUDRDB
,
select_Authenticationsubscription
.
c_str
(),(
unsigned
long
)
select_Authenticationsubscription
.
size
());
if
(
ret
)
{
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s), mysql_error(%d): %s"
,
select_Authenticationsubscription
.
c_str
(),
ret
,
mysql_error
(
mysql_WitcommUDRDB
));
Logger
::
udr_server
().
error
(
"****** AuthenticationSubscription: mysql_real_query pointer(%p) ******"
,
mysql_WitcommUDRDB
);
// mysql_close(&mysqldb);
return
;
}
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
if
(
res
==
NULL
)
{
Logger
::
udr_server
().
error
(
"mysql_store_result failure!SQL(%s)"
,
select_Authenticationsubscription
.
c_str
());
// mysql_close(&mysqldb
);
Logger
::
udr_server
().
error
(
"mysql_store_result failure!SQL(%s)
, mysql_error: %s
"
,
select_Authenticationsubscription
.
c_str
()
,
mysql_error
(
mysql_WitcommUDRDB
)
);
Logger
::
udr_server
().
error
(
"****** AuthenticationSubscription: mysql_store_result pointer(%p) ******"
,
mysql_WitcommUDRDB
);
return
;
}
if
(
mysql_num_rows
(
res
))
{
...
...
@@ -125,10 +128,11 @@ void AuthenticationSubscriptionDocumentApiImpl::
// Logger::udr_server().debug("modify content:
// %s",query.c_str());
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
Logger
::
udr_server
().
error
(
"update mysql failure!SQL(%s)"
,
query
.
c_str
());
ret
=
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
());
if
(
ret
)
{
Logger
::
udr_server
().
error
(
"update mysql failure!SQL(%s), mysql_error(%d): %s"
,
query
.
c_str
(),
ret
,
mysql_error
(
mysql_WitcommUDRDB
));
// mysql_close(&mysqldb);
return
;
}
...
...
@@ -156,6 +160,7 @@ void AuthenticationSubscriptionDocumentApiImpl::
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
MYSQL_FIELD
*
field
=
nullptr
;
int
ret
;
nlohmann
::
json
j
;
...
...
@@ -176,18 +181,19 @@ void AuthenticationSubscriptionDocumentApiImpl::
const
std
::
string
query
=
"select * from AuthenticationSubscription WHERE ueid='"
+
ueId
+
"'"
;
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s)"
,
query
.
c_str
());
ret
=
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
());
if
(
ret
)
{
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s), mysql_error(%d): %s"
,
query
.
c_str
(),
ret
,
mysql_error
(
mysql_WitcommUDRDB
));
// mysql_close(&mysqldb);
return
;
}
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
if
(
res
==
NULL
)
{
Logger
::
udr_server
().
error
(
"mysql_store_result failure!SQL(%s)"
,
query
.
c_str
());
Logger
::
udr_server
().
error
(
"mysql_store_result failure!SQL(%s)
, mysql_error: %s
"
,
query
.
c_str
()
,
mysql_error
(
mysql_WitcommUDRDB
)
);
// mysql_close(&mysqldb);
return
;
}
...
...
src/impl/AuthenticationSubscriptionDocumentApiImpl.h
View file @
f74a9eb1
...
...
@@ -55,6 +55,7 @@ public:
private:
MYSQL
*
mysql_WitcommUDRDB
;
char
reconnect
;
};
}
...
...
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