I should, of course, mention that this also does not fix any threading
problems.

Some things to look for:

1. Are there any static or global variables used?  These will be a problem
in a multi-threaded environment.

2. Memory allocation: I'm no expert at this, by any means.  But I do know
that aolserver has a special "zippy" allocator that gets used when aolserver
is loaded with the -z option.  Because of this, aolserver modules should use
stuff like ns_alloc instead of Tcl_Alloc, etc.  Any module made for tcl is
going to use Tcl_Alloc, Tcl_Calloc, Tcl_Free, etc, or even worse, watch out
for plain mallocs.  I've had some success with making a macro for each one,
like

#ifdef __AOLSERVER __
#include "ns.h"
#define ALLOC(x)    ns_malloc(x)
#define FREE(x)     ns_free(x)
#else
#include "tcl.h"
#define ALLOC(x)    Tcl_Alloc(x)
#define FREE(x)     Tcl_Free(x)
#endif

This way I can use a module with both plain tcl and aolserver.  You've got
to be scrupulously careful with always using the right procedure.  If you
use Tcl_Alloc, and then turn around and use free(), god only knows what
could happen.

Another thing to think about, memory-wise, is that many tcl modules play
pretty loose with memory, and don't need to worry about leakage, because at
the end of the program, the memory all gets turned back to the OS, even if
the programmer didn't free() it.  Not the case with AOLServer, which may run
for a long period without restarting.  I'm currently half struggling with
such a problem trying to convert the minizip sample application (that comes
with zlib) into a .so module.

Just some stuff to think about.

Rusty

Reply via email to