Merge remote-tracking branch 'git.irl/master'
Conflicts:
wscript
diff --git a/include/object-db-file.h b/include/object-db-file.h
index dea8582..1eb1ef8 100644
--- a/include/object-db-file.h
+++ b/include/object-db-file.h
@@ -4,8 +4,6 @@
#include "object-db.h"
#include <stdio.h>
#include <fstream>
-#include <ifstream>
-#include <ofstream>
#include <sstream>
#include <deque>
#include <boost/thread/locks.hpp>
@@ -50,7 +48,7 @@
typedef boost::unique_lock<Mutex> ULock;
ObjectDBFile(const string &filename);
- virtual ~ObjectDBFile(){}
+ virtual ~ObjectDBFile();
// reserve the "address" table for n COs; must reserve before
// write anything (unless reserved quota has not be consumed yet)
@@ -149,4 +147,7 @@
void
readBytes(istream &in, Bytes &bytes);
+char *
+head(const Bytes &bytes);
+
#endif
diff --git a/include/object-db.h b/include/object-db.h
index 7daa37c..207e0b3 100644
--- a/include/object-db.h
+++ b/include/object-db.h
@@ -35,7 +35,7 @@
// size in terms of number of COs
virtual int
- size() = 0 const;
+ size() = 0;
};
diff --git a/src/db-helper.h b/src/db-helper.h
index a0a9442..51970dd 100644
--- a/src/db-helper.h
+++ b/src/db-helper.h
@@ -22,6 +22,7 @@
#ifndef DB_HELPER_H
#define DB_HELPER_H
+#include <stdint.h>
#include <sqlite3.h>
#include <openssl/evp.h>
#include <boost/exception/all.hpp>
diff --git a/src/object-db-file.cpp b/src/object-db-file.cpp
index 526ea4e..26f8fb3 100644
--- a/src/object-db-file.cpp
+++ b/src/object-db-file.cpp
@@ -1,6 +1,12 @@
#include "object-db-file.h"
#include <assert.h>
+char *
+head(const Bytes &bytes)
+{
+ return (char *)&bytes[0];
+}
+
void
writeBytes(ostream &out, const Bytes &bytes)
{
@@ -26,9 +32,9 @@
, m_filename(filename)
// This ensures file with filename exists (assuming having write permission)
// This is needed as file_lock only works with existing file
- , m_ostream(m_filename, ios_base::binary | ios_base::app)
- , m_istream(m_filename, ios_base::binary | ios_base::in)
- , m_filelock(m_filename)
+ , m_ostream(m_filename.c_str(), ios_base::binary | ios_base::app)
+ , m_istream(m_filename.c_str(), ios_base::binary | ios_base::binary)
+ , m_filelock(m_filename.c_str())
{
int magic;
ReadLock(m_filelock);
@@ -51,7 +57,7 @@
void
ObjectDBFile::init(int capacity)
{
- WriteLock(m_filelock);
+ WriteLock(*m_filelock);
if (m_initialized)
{
throwException("Trying to init already initialized ObjectDBFile object" + m_filename);
@@ -66,7 +72,7 @@
writeInt(m_ostream, m_size);
m_initialized = true;
- int count = size;
+ int count = m_cap;
int offset = 0;
while (count-- > 0)
{
@@ -126,7 +132,7 @@
{
SLock(m_cacheLock);
// no need to read file if found in cache
- if (m_dummyCache.find(m_index) != map::end)
+ if (m_dummyCache.find(m_index) != m_dummyCache.end())
{
int index = m_index;
m_index++;
@@ -177,7 +183,7 @@
}
void
-ObjectDBFile::updateSzie()
+ObjectDBFile::updateSize()
{
int pos = m_istream.tellg();
m_istream.seekg(2 * sizeof(int), ios::beg);
@@ -219,7 +225,7 @@
}
void
-rewind()
+ObjectDBFile::rewind()
{
ReadLock(m_filelock);
m_index = 0;
diff --git a/wscript b/wscript
index 7ca0fbd..f221147 100644
--- a/wscript
+++ b/wscript
@@ -53,7 +53,7 @@
conf.load('protoc')
conf.load('ice_cxx')
-
+
conf.write_config_header('src/config.h')
def build (bld):
@@ -65,11 +65,12 @@
'src/ccnx-pco.cpp',
'src/ccnx-closure.cpp',
'src/ccnx-tunnel.cpp',
+ 'src/object-db-file.cpp'
],
use = 'BOOST BOOST_THREAD SSL CCNX',
includes = ['include', ],
)
-
+
# Unit tests
if bld.get_define("_TEST"):
unittests = bld.program (