I wrote: > Got it. > > We just need to have SegReader wrap all of its calls to Architecture's factory > methods in "try" blocks. Then, it can catch an exception, free itself, and > rethrow for the benefit of higher level open call. It'll mean a bunch more > silly private methods like SegReader_Try_Open_Lex_Reader() for the binding to > implement, but that's the way it goes.
I've gotten this working in KS. The retry logic doesn't leak any more when a needed index file isn't found. If there's a fatal error due to a corrupt file or something like that we still leak, but that doesn't matter. Turns out that SegReader itself didn't get significantly messier, and I was actually able to reduce and simplify the host-specific code. The big change was that Folder_Open_InStream, Json_slurp_json, Seg_Read_File, and CFReader_new all had to start returning NULL upon failure rather than throwing exceptions -- which meant the return values had to be checked for each of those calls. Marvin Humphrey
