Hi,
I'm in the process of securing the PL/Java signal handling routines. Since a multi-threaded JVM is running and a signal can occur at any time in any thread, I need to trap some of them and make sure that they are executed in the main thread. Using Posix signals, this is easy. Here's a sample handler:

static void pljavaStatementCancelHandler(int signum)
{
   if(pthread_self() == mainThread)
      /*
       * Call original handler
       */
       StatementCancelHandler(signum);
   else
      /*
       * Dispatch to main thread.
       */
       pthread_kill(mainThread, signum); /* Send it to main thread */
}

The mainThread was initialized when the handler was first registered.

From looking at the PostgreSQL signal handling routines for Win32, I realize that several threads are involved already. Perhaps all signals are indeed dispatched to the main thread already? I couldn't really figure it out. I need help from someone who knows more about this.

Regards,
Thomas Hallgren


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to