Reference

io_thtrp(3)

set a trap function to cope with io threads table overfrow

NAME

io_thtrp - set a trap function to cope with io threads table overfrow

SYNOPSIS

#include <peks.h>

int io_thtrp (unsigned fd,
              int(*)(void*,unsigned long) trap, void *data,
              int use_pid);

DESCRIPTION

This function installs a trap on the server that is invoked when the client detects an io threads table overflow. This typically happens when a series of server child functions die unexpectedly before destroying the io threads on the receiving client.

On the client, the trap feature is activated while the second function argument is -1 or 1.

The trap function gets a thread id (or a process id) and checks, whether the server part of the io thread is still alive. If so, the trap function returns a non-zero value, otherwise the value 0.

In the latter case, the client is informed to purge the corresponding thread (see IO_PURGE_THREAD in io_ctrl(3).)

If the second argument trap is NULL, the trap is removed. If the argument is 1, or -1, a receiver trap is installed on the receiver but no user defined function will be invoked.

Example (receiver):

int n = io_ctrl (socket, IO_MAX_THREADS, 0, 0) ;
/* set the high water mark on 2/3rd of the total of channels */
io_ctrl (socket, IO_HWMBL_THREADS, (n /= 3, &n), 0); 
io_thtrp (socket, (int(*)(void*,unsigned long))-1, 0, 1); 
...

Example (sender):

int verify_io_process 
  (void      *unused,
   unsigned long pid)
{
/* this function is reliable as super user, only */
return (kill (pid, 0) >= 0 : 1 : 0) ;
}
...

/* install process tracker */
io_thtrp (socket, verify_io_process, 0, 1);

SEE ALSO

iostream(3), io_ctrl(3), io_push(3), io_send(3), fork(2),

AUTHOR

The peks package where these functions belong to was written by Jordan Hrycaj <[email protected]>, originally to support the nessus security scanner.