Multiple threds accessing single TZquery object
Posted: 25.01.2010, 07:10
Hello,
recently I've been developing application witch is listening for some port ( TIdTCPServer indy component), getting XML and updating DB according to the XML. For that I created 1 query object that I would pass SQL to. Also I'm using timer to check if there are changes in DB from time to time (using the same TZQuery component). The program seemed to work, but after 12 hour or so I get access violations at ntdll.dll .
Now what I changed - as indy creates thread for reading from socket buffer I create separate TZQuery object to be used only in this thread and then free it. This did the trick and now for 3 days the program is running without errors.
The question would be - is it safe to use single query with multiple threads (I guess not), why, and what could be done not to raise access violations in such cases?
ZeosLib 6.6.6, Delphi 2006, Postgresql 8.4, WinXP
recently I've been developing application witch is listening for some port ( TIdTCPServer indy component), getting XML and updating DB according to the XML. For that I created 1 query object that I would pass SQL to. Also I'm using timer to check if there are changes in DB from time to time (using the same TZQuery component). The program seemed to work, but after 12 hour or so I get access violations at ntdll.dll .
Now what I changed - as indy creates thread for reading from socket buffer I create separate TZQuery object to be used only in this thread and then free it. This did the trick and now for 3 days the program is running without errors.
The question would be - is it safe to use single query with multiple threads (I guess not), why, and what could be done not to raise access violations in such cases?
ZeosLib 6.6.6, Delphi 2006, Postgresql 8.4, WinXP