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(
...
@@ -38,6 +38,8 @@ AuthenticationStatusDocumentApiImpl::AuthenticationStatusDocumentApiImpl(
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
mysql_WitcommUDRDB
));
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
mysql_WitcommUDRDB
));
return
;
return
;
}
}
reconnect
=
1
;
mysql_options
(
mysql_WitcommUDRDB
,
MYSQL_OPT_RECONNECT
,
&
reconnect
);
}
}
AuthenticationStatusDocumentApiImpl
::~
AuthenticationStatusDocumentApiImpl
()
AuthenticationStatusDocumentApiImpl
::~
AuthenticationStatusDocumentApiImpl
()
...
...
src/impl/AuthenticationStatusDocumentApiImpl.h
View file @
f74a9eb1
...
@@ -53,6 +53,8 @@ public:
...
@@ -53,6 +53,8 @@ public:
private:
private:
MYSQL
*
mysql_WitcommUDRDB
;
MYSQL
*
mysql_WitcommUDRDB
;
char
reconnect
;
};
};
}
}
...
...
src/impl/AuthenticationSubscriptionDocumentApiImpl.cpp
View file @
f74a9eb1
...
@@ -44,7 +44,9 @@ AuthenticationSubscriptionDocumentApiImpl::
...
@@ -44,7 +44,9 @@ AuthenticationSubscriptionDocumentApiImpl::
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
mysql_WitcommUDRDB
));
Logger
::
udr_server
().
error
(
"An error occurred while connecting to db: %s"
,
mysql_error
(
mysql_WitcommUDRDB
));
return
;
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
::
AuthenticationSubscriptionDocumentApiImpl
::
...
@@ -78,6 +80,7 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -78,6 +80,7 @@ void AuthenticationSubscriptionDocumentApiImpl::
MYSQL_RES
*
res
=
NULL
;
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
int
ret
;
const
std
::
string
select_Authenticationsubscription
=
const
std
::
string
select_Authenticationsubscription
=
"select * from AuthenticationSubscription WHERE ueid='"
+
ueId
+
"'"
;
"select * from AuthenticationSubscription WHERE ueid='"
+
ueId
+
"'"
;
...
@@ -92,20 +95,20 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -92,20 +95,20 @@ void AuthenticationSubscriptionDocumentApiImpl::
nlohmann
::
json
::
parse
(
patchItem
[
i
].
getValue
().
c_str
())
nlohmann
::
json
::
parse
(
patchItem
[
i
].
getValue
().
c_str
())
.
get_to
(
sequencenumber
);
.
get_to
(
sequencenumber
);
if
(
mysql_real_query
(
ret
=
mysql_real_query
(
mysql_WitcommUDRDB
,
select_Authenticationsubscription
.
c_str
(),(
unsigned
long
)
select_Authenticationsubscription
.
size
());
mysql_WitcommUDRDB
,
select_Authenticationsubscription
.
c_str
(),
if
(
ret
)
{
(
unsigned
long
)
select_Authenticationsubscription
.
size
()))
{
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s), mysql_error(%d): %s"
,
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s)"
,
select_Authenticationsubscription
.
c_str
(),
ret
,
mysql_error
(
mysql_WitcommUDRDB
));
select_Authenticationsubscription
.
c_str
()
);
Logger
::
udr_server
().
error
(
"****** AuthenticationSubscription: mysql_real_query pointer(%p) ******"
,
mysql_WitcommUDRDB
);
// mysql_close(&mysqldb);
// mysql_close(&mysqldb);
return
;
return
;
}
}
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
if
(
res
==
NULL
)
{
if
(
res
==
NULL
)
{
Logger
::
udr_server
().
error
(
"mysql_store_result failure!SQL(%s)"
,
Logger
::
udr_server
().
error
(
"mysql_store_result failure!SQL(%s)
, mysql_error: %s
"
,
select_Authenticationsubscription
.
c_str
());
select_Authenticationsubscription
.
c_str
()
,
mysql_error
(
mysql_WitcommUDRDB
)
);
// mysql_close(&mysqldb
);
Logger
::
udr_server
().
error
(
"****** AuthenticationSubscription: mysql_store_result pointer(%p) ******"
,
mysql_WitcommUDRDB
);
return
;
return
;
}
}
if
(
mysql_num_rows
(
res
))
{
if
(
mysql_num_rows
(
res
))
{
...
@@ -125,10 +128,11 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -125,10 +128,11 @@ void AuthenticationSubscriptionDocumentApiImpl::
// Logger::udr_server().debug("modify content:
// Logger::udr_server().debug("modify content:
// %s",query.c_str());
// %s",query.c_str());
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
ret
=
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
(
unsigned
long
)
query
.
size
());
Logger
::
udr_server
().
error
(
"update mysql failure!SQL(%s)"
,
if
(
ret
)
{
query
.
c_str
());
Logger
::
udr_server
().
error
(
"update mysql failure!SQL(%s), mysql_error(%d): %s"
,
query
.
c_str
(),
ret
,
mysql_error
(
mysql_WitcommUDRDB
));
// mysql_close(&mysqldb);
// mysql_close(&mysqldb);
return
;
return
;
}
}
...
@@ -156,6 +160,7 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -156,6 +160,7 @@ void AuthenticationSubscriptionDocumentApiImpl::
MYSQL_RES
*
res
=
NULL
;
MYSQL_RES
*
res
=
NULL
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
MYSQL_FIELD
*
field
=
nullptr
;
MYSQL_FIELD
*
field
=
nullptr
;
int
ret
;
nlohmann
::
json
j
;
nlohmann
::
json
j
;
...
@@ -176,18 +181,19 @@ void AuthenticationSubscriptionDocumentApiImpl::
...
@@ -176,18 +181,19 @@ void AuthenticationSubscriptionDocumentApiImpl::
const
std
::
string
query
=
const
std
::
string
query
=
"select * from AuthenticationSubscription WHERE ueid='"
+
ueId
+
"'"
;
"select * from AuthenticationSubscription WHERE ueid='"
+
ueId
+
"'"
;
if
(
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
ret
=
mysql_real_query
(
mysql_WitcommUDRDB
,
query
.
c_str
(),
(
unsigned
long
)
query
.
size
()))
{
(
unsigned
long
)
query
.
size
());
Logger
::
udr_server
().
error
(
"mysql_real_query failure!SQL(%s)"
,
if
(
ret
)
{
query
.
c_str
());
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);
// mysql_close(&mysqldb);
return
;
return
;
}
}
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
res
=
mysql_store_result
(
mysql_WitcommUDRDB
);
if
(
res
==
NULL
)
{
if
(
res
==
NULL
)
{
Logger
::
udr_server
().
error
(
"mysql_store_result failure!SQL(%s)"
,
Logger
::
udr_server
().
error
(
"mysql_store_result failure!SQL(%s)
, mysql_error: %s
"
,
query
.
c_str
());
query
.
c_str
()
,
mysql_error
(
mysql_WitcommUDRDB
)
);
// mysql_close(&mysqldb);
// mysql_close(&mysqldb);
return
;
return
;
}
}
...
...
src/impl/AuthenticationSubscriptionDocumentApiImpl.h
View file @
f74a9eb1
...
@@ -55,6 +55,7 @@ public:
...
@@ -55,6 +55,7 @@ public:
private:
private:
MYSQL
*
mysql_WitcommUDRDB
;
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