Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
fredix
ncs
Commits
cf5323ed
Commit
cf5323ed
authored
Apr 16, 2013
by
fred
Browse files
added scoped_ptr on getScopedDbConnection to close connection
parent
fc7b5299
Changes
1
Hide whitespace changes
Inline
Side-by-side
mongodb.cpp
View file @
cf5323ed
...
...
@@ -667,14 +667,18 @@ BSONObj Mongodb::GetGfsid(const string filename)
QBool
Mongodb
::
ExtractByChunck
(
const
be
&
gfs_id
,
int
chunk_index
,
QByteArray
&
chunk_data
,
int
&
chunk_length
)
{
QMutexLocker
locker
(
m_mutex
);
ScopedDbConnection
*
replicaset
;
//
ScopedDbConnection *replicaset;
std
::
cout
<<
"Mongodb::ExtractByChunck : "
<<
gfs_id
<<
std
::
endl
;
try
{
replicaset
=
ScopedDbConnection
::
getScopedDbConnection
(
m_server
.
toStdString
()
);
if
(
replicaset
->
ok
())
//replicaset = ScopedDbConnection::getScopedDbConnection( m_server.toStdString() );
scoped_ptr
<
ScopedDbConnection
>
connPtr
(
ScopedDbConnection
::
getScopedDbConnection
(
m_server
.
toStdString
()
));
ScopedDbConnection
&
replicaset
=
*
connPtr
;
if
(
replicaset
.
ok
())
{
GridFS
gfs
(
replicaset
->
conn
(),
m_database
.
toAscii
().
data
());
GridFS
gfs
(
replicaset
.
conn
(),
m_database
.
toAscii
().
data
());
for
(
int
i
=
0
;
i
<
5
;
i
++
)
...
...
@@ -711,7 +715,7 @@ QBool Mongodb::ExtractByChunck(const be &gfs_id, int chunk_index, QByteArray &ch
std
::
cout
<<
"Mongodb::ExtractByChunck CHUNCK SIZE : "
<<
chunk_data
.
size
()
<<
std
::
endl
;
delete
(
m_grid_file
);
replicaset
->
done
();
replicaset
.
done
();
return
QBool
(
true
);
}
else
...
...
@@ -719,18 +723,19 @@ QBool Mongodb::ExtractByChunck(const be &gfs_id, int chunk_index, QByteArray &ch
//*chunk_data = NULL;
chunk_data
.
clear
();
delete
(
m_grid_file
);
replicaset
->
done
();
replicaset
.
done
();
return
QBool
(
false
);
}
}
}
replicaset
.
done
();
return
QBool
(
false
);
}
}
catch
(
mongo
::
DBException
&
e
)
{
std
::
cout
<<
"caught on get file : "
<<
e
.
what
()
<<
std
::
endl
;
qDebug
()
<<
"Mongodb::ExtractByChunck ERROR ON GRIDFS"
;
qDebug
()
<<
"Mongodb::ExtractByChunck ERROR ON GRIDFS"
;
return
QBool
(
false
);
}
return
QBool
(
false
);
...
...
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