abyss_server.h

00001 #ifndef SERVER_H_INCLUDED
00002 #define SERVER_H_INCLUDED
00003 
00004 #include <sys/types.h>
00005 
00006 #include <xmlrpc-c/abyss.h>
00007 
00008 #include "abyss_file.h"
00009 #include "abyss_data.h"
00010 
00011 typedef struct _Tsocket Tsocket;
00012 
00013 struct _TServer {
00014     abyss_bool terminationRequested;
00015         /* User wants this server to terminate as soon as possible,
00016            in particular before accepting any more connections and without
00017            waiting for any.
00018         */
00019     abyss_bool socketBound;
00020         /* The listening socket exists and is bound to a local address
00021            (may already be listening as well)
00022         */
00023     TSocket * listenSocketP;
00024         /* Meaningful only when 'socketBound' is true: file descriptor of
00025            the listening socket ("listening socket" means socket for listening,
00026            not a socket that is listening right now).
00027         */
00028     abyss_bool weCreatedListenSocket;
00029         /* We created the listen socket (whose fd is 'listensock'), as
00030            opposed to 1) User supplied it; or 2) there isn't one.
00031         */
00032     const char * logfilename;
00033     abyss_bool logfileisopen;
00034     TFile logfile;
00035     TMutex logmutex;
00036     const char * name;
00037     const char * filespath;
00038     abyss_bool serverAcceptsConnections;
00039         /* We listen for and accept TCP connections for HTTP transactions.
00040            (The alternative is the user supplies a TCP-connected socket
00041            for each transaction)
00042         */
00043     uint16_t port;
00044         /* Meaningful only when 'socketBound' is false: port number to which
00045            we should bind the listening socket
00046         */
00047     uint32_t keepalivetimeout;
00048     uint32_t keepalivemaxconn;
00049     uint32_t timeout;
00050         /* Maximum time in seconds the server will wait to read a header
00051            or a data chunk from the socket.
00052         */
00053     TList handlers;
00054     TList defaultfilenames;
00055     void * defaulthandler;
00056     abyss_bool advertise;
00057     MIMEType * mimeTypeP;
00058         /* NULL means to use the global MIMEType object */
00059     abyss_bool useSigchld;
00060         /* Meaningless if not using forking for threads.
00061            TRUE means user will call ServerHandleSigchld to indicate that
00062            a SIGCHLD signal was received, and server shall use that as its
00063            indication that a child has died.  FALSE means server will not
00064            be aware of SIGCHLD and will instead poll for existence of PIDs
00065            to determine if a child has died.
00066         */
00067 #ifndef WIN32
00068     uid_t uid;
00069     gid_t gid;
00070     TFile pidfile;
00071 #endif
00072 };
00073 
00074 
00075 void
00076 ServerBackgroundProcessComplete(pid_t const pid);
00077 
00078 #endif