#include #include #include #include #include // g++ testgdbm.cpp -lgdbm // test if locking works // run one instance, then start another instance // int main() { GDBM_FILE dbf=0; do { dbf=gdbm_open((char*)"/tmp/testdb_gdbm",0,GDBM_WRCREAT|GDBM_SYNC,0666,0); if (dbf == 0) usleep(1000); } while (dbf == 0); std::cout << "geopend ..." << std::endl; //sleep(15); //return 0; int w=10; datum key,content; key.dptr = (char*)&w; key.dsize = sizeof(w); content.dptr = (char*)&w; content.dsize = sizeof(w); for (int i=0; i<3000000; i++) { int rc = gdbm_store(dbf,key,content,GDBM_REPLACE); if (rc !=0) { std::cout << "rc: " << rc << std::endl; goto einde; } } std::cout << "gestored ..." << std::endl; einde: if (dbf != 0) gdbm_close(dbf); return 0; }