Thread: Various ecpg cleanup
Hi, I'd cleaned up some codes in ecpg. * Release all prepared statements on disconnection to avoid memory leaks even if users forget to DEALLOCATE their statements before disconnection. * Remove memset(0) from ECPGalloc() because calloc() has already done it. * Add const to some global variables. * Make pthread_mutex_lock() for Win32 thread-safe. (It might be a paranoia...) * Add more pthread emulation codes for Win32 to reduce #ifdef WIN32. I'll try to fix thread-safe issues in memory management and SQL DESCRIPTOR based on this change. Regards, --- ITAGAKI Takahiro NTT Open Source Software Center
Attachment
Here is a patch to get memory management to thread-safe. The auto_allocs global variable is split into per-thread variables and accessed separately in each thread. This patch is including the previous cleanup patch I sent because I found pthread_once() for Win32 has a bug; it was not thread-safe. I move the initialization of the mutexes and the init-once functions to the loading of libecpg (DllMain). * Fix memory management in multi-thread programs. The regression test for it is put on thread/alloc.pgc . * Release all prepared statements on disconnection to avoid memory leaks even if users forget to DEALLOCATE their statements before disconnection. * Remove memset(0) from ECPGalloc() because calloc() has already done it. * Add const to some global variables. * More thread-safety for Win32. (pthread_mutex_lock and pthread_once) * Add more pthread emulation codes for Win32 to reduce #ifdef WIN32. Regards, --- ITAGAKI Takahiro NTT Open Source Software Center
Attachment
On Fri, Sep 28, 2007 at 03:00:54PM +0900, ITAGAKI Takahiro wrote: > Here is a patch to get memory management to thread-safe. > The auto_allocs global variable is split into per-thread variables > and accessed separately in each thread. Thanks. Committed to CVS HEAD. > * Release all prepared statements on disconnection to avoid memory leaks > even if users forget to DEALLOCATE their statements before disconnection. Oops, should have noticed this. Michael -- Michael Meskes Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!