Alter table engine in migration script only when needed.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 11 Jun 2009 17:10:35 +0000 (17:10 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 11 Jun 2009 17:10:35 +0000 (17:10 +0000)
Small startup memory leaks.

org.glite.lb.server/config/glite-lb-migrate_db2version20
org.glite.lb.server/src/bkserverd.c
org.glite.lb.server/src/openserver.c

index c5d9a0c..f59d647 100644 (file)
@@ -59,20 +59,13 @@ if [ "$SERVER" -a "$PROXY" ]; then
 fi
 
 
-# convert for transactions (if very old DB)
-cat <<EOF | mysql -u lbserver $DB_NAME
-ALTER TABLE jobs ENGINE=innodb;
-ALTER TABLE users ENGINE=innodb;
-ALTER TABLE events ENGINE=innodb;
-ALTER TABLE short_fields ENGINE=innodb;
-ALTER TABLE long_fields ENGINE=innodb;
-ALTER TABLE states ENGINE=innodb;
-ALTER TABLE status_tags ENGINE=innodb;
-ALTER TABLE server_state ENGINE=innodb;
-ALTER TABLE acls ENGINE=innodb;
-ALTER TABLE notif_registrations ENGINE=innodb;
-ALTER TABLE notif_jobs ENGINE=innodb;
-EOF
+# convert for transactions (if needed and very old DB)
+for table in jobs users events short_fields long_fields states status_tags server_state acls notif_registrations notif_jobs; do
+       echo "SHOW CREATE TABLE $table;" | mysql -u lbserver $DB_NAME | grep -i ENGINE | grep -i InnoDB >/dev/null
+       if [ $? != 0 ]; then
+               echo "ALTER TABLE $table ENGINE=InnoDB" | mysql -u lbserver $DB_NAME
+       fi
+done
 
 
 # add new columns
index 0138b56..8f8e62a 100644 (file)
@@ -636,6 +636,10 @@ int main(int argc, char *argv[])
 #endif /* GLITE_LB_SERVER_WITH_WS */
 
        }
+#ifdef GLITE_LB_SERVER_WITH_WS
+       free(ws_port);
+       ws_port = NULL;
+#endif
        if (mode & SERVICE_PROXY) {     /* proxy stuff */
                struct sockaddr_un      a;
 
@@ -695,6 +699,7 @@ int main(int argc, char *argv[])
        /* Just check the database and let it be. The slaves do the job. */
        edg_wll_InitContext(&ctx);
        if (wait_for_open(ctx, dbstring)) {
+               edg_wll_Close(ctx);
                edg_wll_FreeContext(ctx);
                return 1;
        }
@@ -1520,6 +1525,8 @@ static int wait_for_open(edg_wll_Context ctx, const char *dbstring)
                if (dbfail_string1) free(dbfail_string1);
                edg_wll_Error(ctx,&errt,&errd);
                asprintf(&dbfail_string1,"%s (%s)\n",errt,errd);
+               free(errt);
+               free(errd);
                if (dbfail_string1 != NULL) {
                        if (dbfail_string2 == NULL || strcmp(dbfail_string1,dbfail_string2)) {
                                if (dbfail_string2) free(dbfail_string2);
@@ -1542,6 +1549,8 @@ static int wait_for_open(edg_wll_Context ctx, const char *dbstring)
        if (err) {
                edg_wll_Error(ctx,&errt,&errd);
                asprintf(&dbfail_string1,"%s (%s)\n",errt,errd);
+               free(errt);
+               free(errd);
                dprintf(("[%d]: %s\n", getpid(), dbfail_string1));
                if (!debug) syslog(LOG_ERR,dbfail_string1);
                free(dbfail_string1);
index 40e2e08..8580ff5 100644 (file)
@@ -15,7 +15,7 @@ edg_wll_ErrorCode edg_wll_Open(edg_wll_Context ctx, char *cs)
        char *cols[20];
        glite_lbu_Statement stmt;
 
-       if (glite_lbu_InitDBContext((glite_lbu_DBContext*) &ctx->dbctx) != 0) {
+       if (!ctx->dbctx && glite_lbu_InitDBContext((glite_lbu_DBContext*) &ctx->dbctx) != 0) {
                char *ed;
 
                glite_lbu_DBError(ctx->dbctx, NULL, &ed);