'target_defaults': {
'configurations': {
'Debug': {
+ 'defines': [ '_DEBUG' ],
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'RuntimeLibrary':'MultiThreadedDebugDLL'
+ }
+ },
},
'Release':{
'defines': [ 'NDEBUG' ],
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'RuntimeLibrary':'MultiThreadedDLL'
+ }
+ }
}
},
'conditions': [
['OS == "win"', {
-
+ 'variables': {
+ 'EJDB_HOME%': 'C:/EJDB'
+ },
+ 'defines': [
+ '_UNICODE',
+ ],
+ 'libraries': [
+ '-l<(EJDB_HOME)/lib/tcejdbdll.lib'
+ ],
}, {
'defines': [
'_LARGEFILE_SOURCE',
'-lz -lpthread -lm -lc'
]
}],
- [ 'OS=="mac"', {
- 'defines': ['_DARWIN_USE_64_BIT_INODE=1'],
- 'cflags_cc!' : [ '-fno-exceptions' ],
- 'xcode_settings': {
- 'GCC_ENABLE_CPP_EXCEPTIONS':'YES',
- 'OTHER_CFLAGS': [
- '-fsigned-char', '-pthread', '-Wno-variadic-macros', '-fexceptions'
- ],
- 'OTHER_LDFLAGS': [
- '-Wl,-search_paths_first',
- '-L./tcejdb/static',
- '-lstcejdb -lz -lpthread -lm -lc'
- ]
- }
- }]
- ],
+ [ 'OS=="mac"', {
+ 'defines': ['_DARWIN_USE_64_BIT_INODE=1'],
+ 'cflags_cc!' : [ '-fno-exceptions' ],
+ 'xcode_settings': {
+ 'GCC_ENABLE_CPP_EXCEPTIONS':'YES',
+ 'OTHER_CFLAGS': [
+ '-fsigned-char', '-pthread', '-Wno-variadic-macros', '-fexceptions'
+ ],
+ 'OTHER_LDFLAGS': [
+ '-Wl,-search_paths_first',
+ '-L./tcejdb/static',
+ '-lstcejdb -lz -lpthread -lm -lc'
+ ]
+ }
+ }]
+ ],
'include_dirs' : ['tcejdb'],
},
return luaL_error(L, emsg);
}
-static bool ejcollockmethod(EJCOLL *coll, bool wr) {
- assert(coll && coll->jb);
- if (!coll->mmtx) return false;
- if (wr ? pthread_rwlock_wrlock((pthread_rwlock_t*) coll->mmtx) != 0 : pthread_rwlock_rdlock((pthread_rwlock_t*) coll->mmtx) != 0) {
- return false;
- }
- return (coll->tdb && coll->tdb->open);
-}
-
-static bool ejcollunlockmethod(EJCOLL *coll) {
- assert(coll && coll->jb);
- if (!coll->mmtx) return false;
- if (pthread_rwlock_unlock((pthread_rwlock_t*) coll->mmtx) != 0) {
- return false;
- }
- return true;
-}
-
static EJDB *check_ejdb(lua_State *L, EJDB *jb) {
if (jb == NULL) {
luaL_error(L, "Closed EJDB database");
#include <vector>
#include <sstream>
#include <locale.h>
-#include <ext/hash_set>
#include <stdint.h>
+#ifdef _WIN32
+#include <hash_set>
+#else
+#include <ext/hash_set>
+#endif
+
using namespace node;
using namespace v8;
namespace ejdb {
- static bool ejcollockmethod(EJCOLL *coll, bool wr) {
- assert(coll && coll->jb);
- if (!coll->mmtx) return false;
- if (wr ? pthread_rwlock_wrlock((pthread_rwlock_t*) coll->mmtx) != 0 : pthread_rwlock_rdlock((pthread_rwlock_t*) coll->mmtx) != 0) {
- return false;
- }
- return (coll->tdb && coll->tdb->open);
- }
-
- static bool ejcollunlockmethod(EJCOLL *coll) {
- assert(coll && coll->jb);
- if (!coll->mmtx) return false;
- if (pthread_rwlock_unlock((pthread_rwlock_t*) coll->mmtx) != 0) {
- return false;
- }
- return true;
- }
-
-
///////////////////////////////////////////////////////////////////////////
// Some symbols //
///////////////////////////////////////////////////////////////////////////
raise SystemExit(err_msg.format(ext.name, ext.min_ver, ext.url))
return lib
-ejdb_ext = EJDBPythonExt(True, "tcejdb", "EJDB", "1.0.65",
+ejdb_ext = EJDBPythonExt(True, "tcejdb", "EJDB", "1.1.3",
"tcversion", "http://ejdb.org",
"_pyejdb", ["src/pyejdb.c"],
libraries=["tcejdb", "z", "pthread", "m", "c"],
setup(
name="pyejdb",
- version="1.0.4",
+ version="1.0.5",
url="http://ejdb.org",
keywords=["ejdb", "tokyocabinet", "nosql", "database", "storage", "embedded", "mongodb", "json"],
description="Python3 binding for EJDB database engine.",
"License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)",
"Operating System :: POSIX",
"Programming Language :: Python :: 3.2",
+ "Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries"
],
data_files = [("doc", ["README.md"])]
Py_BEGIN_ALLOW_THREADS
doc = ejdbloadbson(coll, &oid);
Py_END_ALLOW_THREADS
- if (!doc) {
+ if (!doc) {
int ecode = ejdbecode(self->ejdb);
if (ecode != TCESUCCESS && ecode != TCENOREC) {
return set_ejdb_error(self->ejdb);
goto fail;
}
for (int i = 0; i < TCLISTNUM(cols); ++i) {
-
+ bool locked = false;
PyObject *pycoll = NULL;
PyObject *pyindexes = NULL;
PyObject *pyopts = NULL;
if (!pycoll) {
goto ffail;
}
+ if (!ejcollockmethod(coll, false)) {
+ goto ffail;
+ }
+ locked = true;
val = PyUnicode_FromStringAndSize(coll->cname, coll->cnamesz);
PyDict_SetItemString(pycoll, "name", val);
Py_XDECREF(val);
Py_XDECREF(pyindexes);
PyList_Append(carr, pycoll);
+ if (locked) {
+ ejcollunlockmethod(coll);
+ locked = false;
+ }
continue;
ffail:
+ if (locked) {
+ ejcollunlockmethod(coll);
+ }
Py_XDECREF(pycoll);
Py_XDECREF(pyindexes);
Py_XDECREF(pyopts);
test -n "$LDFLAGS" && MYLDFLAGS="$LDFLAGS $MYLDFLAGS"
# Package name
-AC_INIT(tcejdb, 1.1.2)
+AC_INIT(tcejdb, 1.1.3)
AC_CANONICAL_HOST
# Package information
/* private function prototypes */
static void _ejdbsetecode(EJDB *jb, int ecode, const char *filename, int line, const char *func);
static bool _ejdbsetmutex(EJDB *ejdb);
-static bool _ejdblockmethod(EJDB *ejdb, bool wr);
-static bool _ejdbunlockmethod(EJDB *ejdb);
-static bool _ejdbcolsetmutex(EJCOLL *coll);
-static bool _ejcollockmethod(EJCOLL *coll, bool wr);
-static bool _ejcollunlockmethod(EJCOLL *coll);
+EJDB_INLINE bool _ejdblockmethod(EJDB *ejdb, bool wr);
+EJDB_INLINE bool _ejdbunlockmethod(EJDB *ejdb);
+EJDB_INLINE bool _ejdbcolsetmutex(EJCOLL *coll);
+EJDB_INLINE bool _ejcollockmethod(EJCOLL *coll, bool wr);
+EJDB_INLINE bool _ejcollunlockmethod(EJCOLL *coll);
static bson_type _bsonoidkey(bson *bs, bson_oid_t *oid);
static char* _bsonitstrval(EJDB *jb, bson_iterator *it, int *vsz, TCLIST *tokens, txtflags_t flags);
static char* _bsonipathrowldr(TCLIST *tokens, const char *pkbuf, int pksz, const char *rowdata, int rowdatasz,
`tdb' specifies the table database object.
`wr' specifies whether the lock is writer or not.
If successful, the return value is true, else, it is false. */
-static bool _ejdblockmethod(EJDB *ejdb, bool wr) {
+EJDB_INLINE bool _ejdblockmethod(EJDB *ejdb, bool wr) {
assert(ejdb);
if (wr ? pthread_rwlock_wrlock(ejdb->mmtx) != 0 : pthread_rwlock_rdlock(ejdb->mmtx) != 0) {
_ejdbsetecode(ejdb, TCETHREAD, __FILE__, __LINE__, __func__);
/* Unlock a method of the table database object.
`tdb' specifies the table database object.
If successful, the return value is true, else, it is false. */
-static bool _ejdbunlockmethod(EJDB *ejdb) {
+EJDB_INLINE bool _ejdbunlockmethod(EJDB *ejdb) {
assert(ejdb);
if (pthread_rwlock_unlock(ejdb->mmtx) != 0) {
_ejdbsetecode(ejdb, TCETHREAD, __FILE__, __LINE__, __func__);
return true;
}
-static bool _ejdbcolsetmutex(EJCOLL *coll) {
+EJDB_INLINE bool _ejdbcolsetmutex(EJCOLL *coll) {
assert(coll && coll->jb);
if (coll->mmtx) {
_ejdbsetecode(coll->jb, TCEINVALID, __FILE__, __LINE__, __func__);
return true;
}
-static bool _ejcollockmethod(EJCOLL *coll, bool wr) {
+EJDB_INLINE bool _ejcollockmethod(EJCOLL *coll, bool wr) {
assert(coll && coll->jb);
if (wr ? pthread_rwlock_wrlock(coll->mmtx) != 0 : pthread_rwlock_rdlock(coll->mmtx) != 0) {
_ejdbsetecode(coll->jb, TCETHREAD, __FILE__, __LINE__, __func__);
return (coll->tdb && coll->tdb->open);
}
-static bool _ejcollunlockmethod(EJCOLL *coll) {
+EJDB_INLINE bool _ejcollunlockmethod(EJCOLL *coll) {
assert(coll && coll->jb);
if (pthread_rwlock_unlock(coll->mmtx) != 0) {
_ejdbsetecode(coll->jb, TCETHREAD, __FILE__, __LINE__, __func__);
return true;
}
+bool ejcollockmethod(EJCOLL *coll, bool wr) {
+ return _ejcollockmethod(coll, wr);
+}
+
+bool ejcollunlockmethod(EJCOLL *coll) {
+ return _ejcollunlockmethod(coll);
+}
+
static void _qrydel(EJQ *q, bool freequery) {
if (!q) {
return;
#include "tchdb.h"
#include <assert.h>
-#include <pthread.h>
EJDB_EXTERN_C_START
#define JBINOPTMAPTHRESHOLD 16 /**> If number of tokens in `$in` array exeeds it then TCMAP will be used in fullscan matching of tokens */
+
+EJDB_EXPORT bool ejcollockmethod(EJCOLL *coll, bool wr);
+EJDB_EXPORT bool ejcollunlockmethod(EJCOLL *coll);
+
EJDB_EXTERN_C_END
#endif /* EJDB_PRIVATE_H */