Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
1c4a19d4
Commit
1c4a19d4
authored
Sep 05, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(LogDB): добавил флаг для безопасного многопоточного доступа к БД.
parent
8faecd39
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
3 deletions
+7
-3
SQLiteInterface.cc
extensions/DBServer-SQLite/SQLiteInterface.cc
+4
-1
SQLiteInterface.h
extensions/DBServer-SQLite/SQLiteInterface.h
+1
-1
LogDB.cc
extensions/LogDB/LogDB.cc
+1
-1
LogDB.h
extensions/LogDB/LogDB.h
+1
-0
No files found.
extensions/DBServer-SQLite/SQLiteInterface.cc
View file @
1c4a19d4
...
...
@@ -73,7 +73,7 @@ bool SQLiteInterface::connect( const std::string& param )
return
connect
(
dbfile
,
false
);
}
// -----------------------------------------------------------------------------------------
bool
SQLiteInterface
::
connect
(
const
string
&
dbfile
,
bool
create
)
bool
SQLiteInterface
::
connect
(
const
string
&
dbfile
,
bool
create
,
int
extra_sqlite_flags
)
{
// т.к. sqlite3 по умолчанию, создаёт файл при открытии, то проверим "сами"
// if( !create && !uniset::file_exist(dbfile) )
...
...
@@ -81,6 +81,9 @@ bool SQLiteInterface::connect( const string& dbfile, bool create )
int
flags
=
create
?
0
:
SQLITE_OPEN_READWRITE
;
if
(
extra_sqlite_flags
)
flags
|=
extra_sqlite_flags
;
int
rc
=
sqlite3_open_v2
(
dbfile
.
c_str
(),
&
db
,
flags
,
NULL
);
if
(
rc
!=
SQLITE_OK
)
...
...
extensions/DBServer-SQLite/SQLiteInterface.h
View file @
1c4a19d4
...
...
@@ -91,7 +91,7 @@ namespace uniset
~
SQLiteInterface
();
virtual
bool
connect
(
const
std
::
string
&
param
)
override
;
bool
connect
(
const
std
::
string
&
dbfile
,
bool
create
);
bool
connect
(
const
std
::
string
&
dbfile
,
bool
create
,
int
extra_sqlite_flags
=
0
);
virtual
bool
close
()
override
;
virtual
bool
isConnection
()
const
override
;
virtual
bool
ping
()
const
override
;
...
...
extensions/LogDB/LogDB.cc
View file @
1c4a19d4
...
...
@@ -141,7 +141,7 @@ LogDB::LogDB( const string& name , const string& prefix ):
db
=
unisetstd
::
make_unique
<
SQLiteInterface
>
();
if
(
!
db
->
connect
(
dbfile
,
false
)
)
if
(
!
db
->
connect
(
dbfile
,
false
,
SQLITE_OPEN_FULLMUTEX
)
)
{
ostringstream
err
;
err
<<
myname
...
...
extensions/LogDB/LogDB.h
View file @
1c4a19d4
...
...
@@ -89,6 +89,7 @@ namespace uniset
\todo Добавить ротацию БД
\todo REST API: продумать команды и реализовать
\todo Сделать настройку, для формата даты и времени при выгрузке из БД (при формировании json).
\todo Возможно в /logs стоит в ответе сразу возвращать и общее количество в БД (это один лишний запрос, каждый раз).
\todo Продумать поддержку websocket
\todo Возможно в последствии оптимизировать таблицы (нормализовать) если будет тормозить. Сейчас пока прототип.
*/
...
...
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