Re: odbc resources
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Nov 16, 2005
- 530 views
Craig Welch wrote: > > Matt Lewis wrote: > > >OK, I think I know what's happening. I'm not reusing the bookkeeping > >sequence handle_children properly. > > > ><snip> > >...and the for-loop in the middle of freeHandleODBC(): > >}}} <eucode> > > for i = 1 to length( handle_children[id] ) do > > freeHandleODBC( handle_children[id][i] ) > > > > -- mark this as ready for reuse > > handle_children[id][i] = -1 > > end for > ></eucode> {{{ > > > Thanks Matt, but that didn't do it. > Whoops. The code I posted clears out a handle's children, but doesn't clear a child from the parent. Here's a corrected version of freeHandleODBC():
global procedure freeHandleODBC( integer id ) atom handle integer ix, parent if id < 0 then id = - id end if if not id then id = current_handle end if handle = getHandleODBC( id ) if not handle then return end if for i = 1 to length( handle_children[id] ) do freeHandleODBC( handle_children[id][i] ) -- mark this as ready for reuse handle_children[id][i] = -1 end for -- free it up in its parent's handle_children sequence parent = handle_parent[id] if parent then ix = find( id, handle_children[parent] ) if ix then handle_children[parent][ix] = -1 end if end if if handle_type[id] = SQL_HANDLE_STMT then freeStmt( id, SQL_RESET_PARAMS ) freeStmt( id, SQL_UNBIND ) end if VOID = c_func( SQLFreeHandle, { handle_type[id], handle_odbc[id] } ) handle_odbc[id] = -1 if id = current_handle then current_handle = 0 end if end procedure
Matt Lewis