abyss_conn.h

Go to the documentation of this file.
00001 #ifndef CONN_H_INCLUDED
00002 #define CONN_H_INCLUDED
00003 
00004 #include <xmlrpc-c/abyss.h>
00005 #include "abyss_socket.h"
00006 #include "abyss_file.h"
00007 
00008 #define BUFFER_SIZE 4096 
00009 
00010 struct _TConn {
00011     struct _TConn * nextOutstandingP;
00012         /* Link to the next connection in the list of outstanding
00013            connections
00014         */
00015     TServer * server;
00016     uint32_t buffersize;
00017         /* Index into the connection buffer (buffer[], below) where
00018            the next byte read on the connection will go.
00019         */
00020     uint32_t bufferpos;
00021         /* Index into the connection buffer (buffer[], below) where
00022            the next byte to be delivered to the user is.
00023         */
00024     uint32_t inbytes,outbytes;  
00025     TSocket * socketP;
00026     TIPAddr peerip;
00027     abyss_bool hasOwnThread;
00028     TThread * threadP;
00029     abyss_bool finished;
00030         /* We have done all the processing there is to do on this
00031            connection, other than possibly notifying someone that we're
00032            done.  One thing this signifies is that any thread or process
00033            that the connection spawned is dead or will be dead soon, so
00034            one could reasonably wait for it to be dead, e.g. with
00035            pthread_join().  Note that one can scan a bunch of processes
00036            for 'finished' status, but sometimes can't scan a bunch of
00037            threads for liveness.
00038         */
00039     const char * trace;
00040     TThreadProc * job;
00041     TThreadDoneFn * done;
00042     char buffer[BUFFER_SIZE];
00043 };
00044 
00045 typedef struct _TConn TConn;
00046 
00047 TConn * ConnAlloc(void);
00048 
00049 void ConnFree(TConn * const connectionP);
00050 
00051 void
00052 ConnCreate(TConn **            const connectionPP,
00053            TServer *           const serverP,
00054            TSocket *           const connectedSocketP,
00055            TThreadProc *       const job,
00056            TThreadDoneFn *     const done,
00057            enum abyss_foreback const foregroundBackground,
00058            abyss_bool          const useSigchld,
00059            const char **       const errorP);
00060 
00061 abyss_bool
00062 ConnProcess(TConn * const connectionP);
00063 
00064 abyss_bool
00065 ConnKill(TConn * const connectionP);
00066 
00067 void
00068 ConnWaitAndRelease(TConn * const connectionP);
00069 
00070 abyss_bool
00071 ConnWrite(TConn *      const connectionP,
00072           const void * const buffer,
00073           uint32_t     const size);
00074 
00075 abyss_bool
00076 ConnRead(TConn *  const c,
00077          uint32_t const timems);
00078 
00079 void
00080 ConnReadInit(TConn * const connectionP);
00081 
00082 abyss_bool
00083 ConnReadHeader(TConn * const connectionP,
00084                char ** const headerP);
00085 
00086 abyss_bool
00087 ConnWriteFromFile(TConn *  const connectionP,
00088                   TFile *  const file,
00089                   uint64_t const start,
00090                   uint64_t const end,
00091                   void *   const buffer,
00092                   uint32_t const buffersize,
00093                   uint32_t const rate);
00094 
00095 TServer *
00096 ConnServer(TConn * const connectionP);
00097 
00098 #endif

Generated on Thu May 17 10:00:23 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6