fd.c File Reference

#include "nsd.h"

Data Structures

struct  Tmp

Defines

#define DEVNULL   "/dev/null"

Functions

void NsInitFd (void)
int Ns_CloseOnExec (int fd)
int ns_closeonexec (int fd)
int Ns_NoCloseOnExec (int fd)
int ns_duphigh (int *fdPtr)
int Ns_DupHigh (int *fdPtr)
int Ns_GetTemp (void)
void Ns_ReleaseTemp (int fd)
int Ns_DevNull (void)
int ns_pipe (int *fds)
int ns_sockpair (SOCKET *socks)
void * NsMap (int fd, off_t start, size_t len, int writable, void **argPtr)
void NsUnMap (void *addr, void *arg)

Define Documentation

#define DEVNULL   "/dev/null"


Function Documentation

int ns_closeonexec ( int  fd  ) 

---------------------------------------------------------------------- Ns_NoCloseOnExec --

Clear the close-on-exec flag for a file descriptor

Results: Return NS_OK on success or NS_ERROR on failure

Side effects: None.

----------------------------------------------------------------------

int Ns_CloseOnExec ( int  fd  ) 

---------------------------------------------------------------------- Ns_CloseOnExec --

Set the close-on-exec flag for a file descriptor

Results: Return NS_OK on success or NS_ERROR on failure

Side effects: None.

----------------------------------------------------------------------

int Ns_DevNull ( void   ) 

----------------------------------------------------------------------

Ns_DevNull --

Return an open fd to /dev/null. This is a read-only, shared fd which can not be closed.

Results: Open file descriptor.

Side effects: None.

----------------------------------------------------------------------

int Ns_DupHigh ( int *  fdPtr  ) 

int ns_duphigh ( int *  fdPtr  ) 

---------------------------------------------------------------------- Ns_DupHigh --

Dup a file descriptor to be 256 or higher

Results: Returns new file discriptor.

Side effects: Original file descriptor is closed.

----------------------------------------------------------------------

int Ns_GetTemp ( void   ) 

----------------------------------------------------------------------

Ns_GetTemp --

Pop or allocate a temp file. Temp files are immediately removed on Unix and marked non-shared and delete on close on NT to avoid snooping of data being sent to the CGI.

Results: Open file descriptor.

Side effects: File may be opened.

----------------------------------------------------------------------

int Ns_NoCloseOnExec ( int  fd  ) 

int ns_pipe ( int *  fds  ) 

---------------------------------------------------------------------- ns_sockpair, ns_pipe --

Create a pipe/socketpair with fd's set close on exec.

Results: 0 if ok, -1 otherwise.

Side effects: Updates given fd array.

----------------------------------------------------------------------

void Ns_ReleaseTemp ( int  fd  ) 

----------------------------------------------------------------------

Ns_ReleaseTemp --

Return a temp file to the pool.

Results: None.

Side effects: File may be closed on error.

----------------------------------------------------------------------

int ns_sockpair ( SOCKET *  socks  ) 

void NsInitFd ( void   ) 

----------------------------------------------------------------------

NsInitFd --

Initialize the fd API's.

Results: None.

Side effects: Will open a shared fd to /dev/null and ensure stdin, stdout, and stderr are open on something.

----------------------------------------------------------------------

Ensure fd 0, 1, and 2 are open on at least /dev/null.

AOLserver now uses poll() but Tcl and other components may still use select() which will likely break when fd's exceed FD_SETSIZE. We now allow setting the fd limit above FD_SETSIZE, but do so at your own risk.

Open a fd on /dev/null which can be later re-used.

void* NsMap ( int  fd,
off_t  start,
size_t  len,
int  writable,
void **  argPtr 
)

----------------------------------------------------------------------

NsMap --

Memory map a region of a file.

Results: Pointer to mapped region or NULL if mapping failed.

Side effects: None.

----------------------------------------------------------------------

void NsUnMap ( void *  addr,
void *  arg 
)

----------------------------------------------------------------------

NsUnMap --

Unmap a previosly mmapped region.

Results: None.

Side effects: Failure is considered fatal.

----------------------------------------------------------------------


Generated on Tue Sep 4 19:58:56 2007 by  doxygen 1.5.1