示例#1
0
QStore::~QStore()
{
    if (need_url_seen_db) {
        memcached_free(url_seen_memc);
    }

    if (need_html_db) {
        memcached_free(html_memc);
    }

    if (need_record_db) {
        if(!tcrdbclose(record_db)){
            int ecode = tcrdbecode(record_db);
            fprintf(stderr, "close record db error: %s\n", tcrdberrmsg(ecode));
        }
        tcrdbdel(record_db);
    }


    if (need_media_db) {
        if(!tcrdbclose(media_db)){
            int ecode = tcrdbecode(media_db);
            fprintf(stderr, "close media db error: %s\n", tcrdberrmsg(ecode));
        }
        tcrdbdel(media_db);
    }
}
示例#2
0
static int tt_shutdown(void) {
  sfree(config_host);
  sfree(config_port);

  if (rdb != NULL) {
    if (!tcrdbclose(rdb)) {
      printerr();
      tcrdbdel(rdb);
      return 1;
    }
    tcrdbdel(rdb);
    rdb = NULL;
  }

  return 0;
}
示例#3
0
static void tt_open_db (void)
{
    char* host = NULL;
    int   port = DEFAULT_PORT;

    if (rdb != NULL)
        return;

    host = ((config_host != NULL) ? config_host : DEFAULT_HOST);

    if (config_port != NULL)
    {
        port = parse_service_name (config_port);
        if (port <= 0)
            return;
    }

    rdb = tcrdbnew ();
    if (rdb == NULL)
        return;
    else if (!tcrdbopen(rdb, host, port))
    {
        printerr ();
        tcrdbdel (rdb);
        rdb = NULL;
    }
} /* void tt_open_db */
示例#4
0
int tt_put(char * key,char * zv,int nv,value_t vt)
{
	int ecode;
	int rt = 0;
	int nk = strlen(key);
	TCRDB * rdb = tcrdbnew();
	int db_port = get_db_port(vt);
	printf("db_port -- %d\n",db_port);
	if(!tcrdbopen(rdb,LOCALHOST,db_port))
	{
		ecode = tcrdbecode(rdb);
		fprintf(stderr,"tt_put:open %s error -- %s\n",db_port,tcrdberrmsg(ecode));
		rt = 1;
	}
	else
	{
		printf("db open success!\n");
    	if(!tcrdbput(rdb,key,nk,zv,nv))
    	{
    		ecode = tcrdbecode(rdb);
    		fprintf(stderr,"(key=%s) tt_put error:%s\n",key,tcrdberrmsg(ecode));
    		rt = 2;
    	}
    	else
    	{
			printf("(key=%s) tt_put success!\n",key);
    	}
	}
	tcrdbdel(rdb);
	return rt;
}
示例#5
0
char *iod_get(char *key,int *nv)
{
	int ecode;
	int nk = strlen(key);
	char *value;
	TCRDB * rdb = tcrdbnew();
	int db_port = get_db_port(IO_DATA);
	printf("db_port -- %d\n",db_port);
	if(!tcrdbopen(rdb,LOCALHOST,db_port))
	{
		ecode = tcrdbecode(rdb);
		fprintf(stderr,"iod_get:open %s error -- %s\n",db_port,tcrdberrmsg(ecode));
		return NULL;
	}else{
		printf("db open success!\n");
	    if((value = tcrdbget(rdb,key,nk,nv)) == NULL)
    	{
	    	ecode = tcrdbecode(rdb);
	    	fprintf(stderr,"(key=%s) tt_get error:%s\n",key,tcrdberrmsg(ecode));
			return NULL;
		}else{
	    	printf("(key=%s) tt_get success!\n",key);
			printf("%d bytes read\n",*nv);
    	}
	}
	tcrdbdel(rdb);
	return value;
}
示例#6
0
int open_db(char *addr, int port, TCRDB **rdb)
{
    int ecode=0;

    if (*rdb != NULL) {
        if(!tcrdbclose(*rdb)){
          ecode = tcrdbecode(*rdb);
          fprintf(stderr, "close error: %s\n", tcrdberrmsg(ecode));
        }
        tcrdbdel(*rdb);
        *rdb = NULL;
    }
    *rdb = tcrdbnew();
    if(!tcrdbopen(*rdb, addr, port)){
        ecode = tcrdbecode(*rdb);
        fprintf(stderr, "open error(%s:%d): %s\n", addr, port, tcrdberrmsg(ecode));
        *rdb = NULL;
    } else {
        char *status = tcrdbstat(*rdb);
        printf("adding indices\n---------------------\n");
        tcrdbtblsetindex(*rdb, "x", RDBITDECIMAL);
        tcrdbtblsetindex(*rdb, "y", RDBITDECIMAL);
        printf("%s---------------------\n", status);
        if (status) free(status);
    }
    return ecode;
}
示例#7
0
文件: tcfiler.c 项目: wix/tcfiler
void close_db(){
    if(use_cabinet_lib){ 
        tchdbclose(hdb);
        tchdbdel(hdb);
    } else{ 
        tcrdbclose(tdb);
        tcrdbdel(tdb);
    }
}
示例#8
0
文件: ltyrant.c 项目: MengJie/solid
static int
rdb_close(lua_State *L){
	RDBDATA *data = luaL_checkudata(L, 1, MT_NAME);
	if(data->is_open){
		if(!tcrdbclose(data->rdb)) return rdb_error(L, data->rdb);
		data->is_open = false;
		tcrdbdel(data->rdb);
	}
	lua_pushboolean(L, 1);
	return 1;
}
示例#9
0
int
main(int argc, char **argv)
{
    int i, errCode;
    double magic, rlat, s, c;
    int lat;
    
    g_progname = argv[0];
    for (i=1; i < argc; i++) {
        if(!strcmp(argv[i], "-tchost")) {
            if(++i >= argc) usage();
            db_host = argv[i];
        } else if(!strcmp(argv[i], "-tcport")) {
            if(++i >= argc) usage();
            db_port = tcatoi(argv[i]);
        } else if (!strcmp(argv[i], "-help")) {
            usage();
        }
    }
    
    pi = atan(1.0)*4;
    magic = cos(pi/180.0);
    for (lat = 0; lat < 181; ++lat) {
        rlat = lat*pi/180;
        s = sin(rlat);
        c = cos(rlat);
        longDistance[lat] = radius*acos((s*s)+(magic*c*c));
    }
    
    memset(&db_status, -1, sizeof(db_status));
    simplehttp_init();
    db_reconnect(0, 0, NULL);
    simplehttp_set_cb("/search*", search_cb, NULL);
    simplehttp_set_cb("/put*", put_cb, NULL);
    simplehttp_set_cb("/get*", get_cb, NULL);
    simplehttp_set_cb("/del*", del_cb, NULL);
    simplehttp_set_cb("/distance*", distance_cb, NULL);
    simplehttp_set_cb("/box*", box_cb, NULL);
    simplehttp_main(argc, argv);
    
    if (!tcrdbclose(rdb)) {
        errCode = tcrdbecode(rdb);
        fprintf(stderr, "close error: %s\n", tcrdberrmsg(errCode));
    }
    tcrdbdel(rdb);

    return 0;
}
示例#10
0
int tt_get(char * key,char * zv,value_t vt)
{
	int ecode;
	int nv;
	int rt = 0;
	int nk = strlen(key);
	char * value;
	TCRDB * rdb = tcrdbnew();
	int db_port = get_db_port(vt);
	printf("db_port -- %d\n",db_port);
	if(!tcrdbopen(rdb,LOCALHOST,db_port))
	{
		ecode = tcrdbecode(rdb);
		fprintf(stderr,"tt_get:open %s error -- %s\n",db_port,tcrdberrmsg(ecode));
		rt = 1;
	}
	else
	{
		printf("db open success!\n");
	    if((value = tcrdbget(rdb,key,nk,&nv)) == NULL)
    	{
	    	ecode = tcrdbecode(rdb);
	    	fprintf(stderr,"(key=%s) tt_get error:%s\n",key,tcrdberrmsg(ecode));
	    	rt = 2;
    	}
    	else
    	{
	    	printf("(key=%s) tt_get success!\n",key);
			printf("%d bytes read\n",nv);
			memcpy(zv,value,nv);
			free(value);
    	}
	}
	tcrdbdel(rdb);
	return rt;
}
示例#11
0
void 
xtcrdb_del(void* rdb)
{
        tcrdbdel(rdb);
}
示例#12
0
	void TTClient::close(){
	    if(tcrdbPtr_)
		tcrdbdel(tcrdbPtr_);
	}
static void mTokyoMessenger_free(TCRDB *db){
  tcrdbdel(db);
}
示例#14
0
文件: db_obj.cpp 项目: Quix0r/seeks
  db_obj_remote::~db_obj_remote()
  {
#if defined(TT)
    tcrdbdel(_hdb);
#endif
  }
示例#15
0
/* destruct */
JNIEXPORT void JNICALL
Java_tokyotyrant_TCRDB_destruct(JNIEnv *env, jobject self){
  TCRDB *tcrdb = (TCRDB *)(intptr_t)(*env)->GetLongField(env, self, tcrdb_fid_ptr);
  tcrdbdel(tcrdb);
}