From: teodor Date: Thu, 26 Oct 2006 15:39:25 +0000 (+0000) Subject: Add close() call X-Git-Url: http://sigaev.ru/git/gitweb.cgi?a=commitdiff_plain;h=f49cd0e73b63f89a2ace96e341aea51135cbae4b;p=ftsbench.git Add close() call --- diff --git a/ftsbench.c b/ftsbench.c index f577336..da6a4b0 100644 --- a/ftsbench.c +++ b/ftsbench.c @@ -280,6 +280,7 @@ main(int argn, char *argv[]) { fflush(stdout); db->finishCreateScheme(db); printf("done\n"); + db->Close(db); } else { ftsDB **dbs = initConnections(rdbms, nclients, dbname); pthread_t *tid = (pthread_t*)malloc( sizeof(pthread_t) * nclients); @@ -345,8 +346,10 @@ main(int argn, char *argv[]) { elapsed = elapsedtime(&begin); pthread_mutex_unlock( &mutexFinish ); - for(i=0;iClose(dbs[i]); + } printf("\r%d(%.02f%%) queries proceed\n", total, (100.0*(float)total)/(nclients * n)); printf("Total time: %.02f sec, Queries per second: %.02f\n", elapsed, total/elapsed); diff --git a/ftsbench.h b/ftsbench.h index 5c2ba2e..9037333 100644 --- a/ftsbench.h +++ b/ftsbench.h @@ -55,6 +55,7 @@ typedef struct ftsDB { void (*startCreateScheme)(struct ftsDB*, int); void (*finishCreateScheme)(struct ftsDB*); void (*InsertRow)(struct ftsDB*, int, char*); + void (*Close)(struct ftsDB*); /* stats */ pthread_mutex_t nqueryMutex; diff --git a/mysqldriver.c b/mysqldriver.c index be64aa4..034a37a 100644 --- a/mysqldriver.c +++ b/mysqldriver.c @@ -215,6 +215,13 @@ InsertRow(ftsDB *adb, int id, char *txt) { } } +static void +Close(ftsDB* adb) { + ftsMY *db = (ftsMY*)adb; + + mysql_close(db->conn); +} + ftsDB* MYInit(char * connstr) { ftsMY *db = (ftsMY*)malloc(sizeof(ftsMY)); @@ -232,6 +239,7 @@ MYInit(char * connstr) { db->db.startCreateScheme = startCreateScheme; db->db.finishCreateScheme = finishCreateScheme; db->db.InsertRow = InsertRow; + db->db.Close = Close; return (ftsDB*)db; } diff --git a/pgdriver.c b/pgdriver.c index 1ee408a..0a373b6 100644 --- a/pgdriver.c +++ b/pgdriver.c @@ -415,6 +415,13 @@ InsertRow(ftsDB* adb, int id, char *txt) { db->db.nquery++; } +static void +Close(ftsDB* adb) { + ftsPG *db = (ftsPG*)adb; + + PQfinish(db->conn); +} + ftsDB* PGInit(char * connstr) { ftsPG *db = (ftsPG*)malloc(sizeof(ftsPG)); @@ -436,6 +443,7 @@ PGInit(char * connstr) { db->db.startCreateScheme = startCreateScheme; db->db.finishCreateScheme = finishCreateScheme; db->db.InsertRow = InsertRow; + db->db.Close = Close; db->socket = PQsocket(db->conn); if ( db->socket < 0 ) { fprintf(stderr,"Socket error\n");