304cdd78d3fea00b496197634bbb062f0e149d3a braney Tue Nov 10 08:36:34 2015 -0800 fix problem that Galt found with leaking sql connections (no redmine) diff --git src/hg/hgTracks/chainTrack.c src/hg/hgTracks/chainTrack.c index 78599ce..0a4310a 100644 --- src/hg/hgTracks/chainTrack.c +++ src/hg/hgTracks/chainTrack.c @@ -129,31 +129,30 @@ sqlFreeResult(&sr); dyStringFree(&query); } static void chainDraw(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, MgFont *font, Color color, enum trackVisibility vis) /* Draw chained features. This loads up the simple features from * the chainLink table, calls linkedFeaturesDraw, and then * frees the simple features again. */ { struct linkedFeatures *lf; struct simpleFeature *sf; struct lm *lm; struct hash *hash; /* Hash of chain ids. */ -struct sqlConnection *conn = NULL; double scale = ((double)(winEnd - winStart))/width; char fullName[64]; int start, end, extra; struct simpleFeature *lastSf = NULL; int maxOverLeft = 0, maxOverRight = 0; int overLeft, overRight; if (tg->items == NULL) /*Exit Early if nothing to do */ return; void *closure; struct sqlClosure sqlClosure; struct bbClosure bbClosure; linkRetrieveFunc queryFunc; if (tg->isBigBed) @@ -299,33 +298,37 @@ sf->qStart = lf->components->qStart; sf->qEnd = sf->qStart + (sf->end - sf->start); sf->next = lf->components; lf->components = sf; slSort(&lf->components, linkedFeaturesCmpStart); } } } } linkedFeaturesDraw(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis); /* Cleanup time. */ for (lf = tg->items; lf != NULL; lf = lf->next) lf->components = NULL; +if (tg->isBigBed) + bbiFileClose(&bbClosure.bbi); +else + hFreeConn(&sqlClosure.conn); + lmCleanup(&lm); freeHash(&hash); -hFreeConn(&conn); } void bigChainLoadItems(struct track *tg) /* Load up all of the chains from correct table into tg->items * item list. At this stage to conserve memory for other tracks * we don't load the links into the components list until draw time. */ { struct linkedFeatures *list = NULL, *lf; int qs; char *optionChrStr; struct cartOptions *chainCart; chainCart = (struct cartOptions *) tg->extraUiData; optionChrStr = cartOptionalStringClosestToHome(cart, tg->tdb, FALSE, @@ -373,30 +376,31 @@ lf->components = NULL; slAddHead(&list, lf); } /* Make sure this is sorted if in full mode. Sort by score when * coloring by score and in dense */ if (tg->visibility != tvDense) slSort(&list, linkedFeaturesCmpStart); else if ((tg->visibility == tvDense) && (chainCart->chainColor == chainColorScoreColors)) slSort(&list, chainCmpScore); else slReverse(&list); tg->items = list; +bbiFileClose(&bbi); } void chainLoadItems(struct track *tg) /* Load up all of the chains from correct table into tg->items * item list. At this stage to conserve memory for other tracks * we don't load the links into the components list until draw time. */ { char *table = tg->table; struct chain chain; int rowOffset; char **row; struct sqlConnection *conn = hAllocConn(database); struct sqlResult *sr = NULL; struct linkedFeatures *list = NULL, *lf; int qs;