CAChain.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __CA_CHAIN__
00033 #define __CA_CHAIN__
00034 #include "../doxygen.h"
00035 #ifndef ONLY_LOCAL_PROXY
00036 #include "CALastMixBChannelList.hpp"
00037 #include "../CASocket.hpp"
00038 #include "../CAQueue.hpp"
00039 #ifdef HAVE_EPOLL
00040 #include "../CASocketGroupEpoll.hpp"
00041 #else
00042 #include "../CASocketGroup.hpp"
00043 #endif
00044 #ifdef DELAY_CHANNELS
00045 #include "../CAMutex.hpp"
00046 #endif
00047
00048
00049 struct t_channelEntry {
00050 struct t_lastMixBChannelListEntry* channel;
00051 t_channelEntry* nextChannel;
00052 };
00053
00054 struct t_socketGroupEntry {
00055 #ifdef HAVE_EPOLL
00056 CASocketGroupEpoll* socketGroup;
00057 #else
00058 CASocketGroup* socketGroup;
00059 #endif
00060 t_socketGroupEntry* nextSocketGroup;
00061 };
00062
00063
00064 class CAChain {
00065 public:
00066 #ifndef DELAY_CHANNELS
00067 CAChain(UINT8* a_chainId);
00068 #else
00069 CAChain(UINT8* a_chainId, CAMutex* a_delayBucketMutex, SINT32* a_delayBucket);
00070 #endif
00071 ~CAChain(void);
00072 UINT8* getChainId();
00073 #ifdef LOG_CHAIN_STATISTICS
00074 void setSocket(CASocket* a_socket, UINT32 a_alreadyProcessedPackets, UINT32 a_alreadyProcessedBytes);
00075 #else
00076 void setSocket(CASocket* a_socket);
00077 #endif
00078 void addChannel(t_lastMixBChannelListEntry* a_channel, bool a_fastResponse);
00079 void addDataToUpstreamQueue(UINT8* a_buffer, UINT32 a_size);
00080 void signalConnectionError();
00081 void signalUnknownChain();
00082 void closeUpstream();
00083 void closeDownstream();
00084 UINT8* getPrintableChainId();
00085 #ifdef HAVE_EPOLL
00086 void addToSocketGroup(CASocketGroupEpoll* a_socketGroup);
00087 void removeFromSocketGroup(CASocketGroupEpoll* a_socketGroup);
00088 bool isSignaledInSocketGroup(CASocketGroupEpoll* a_socketGroup);
00089 UINT32 sendUpstreamData(UINT32 a_maxLength, CASocketGroupEpoll* a_removedSocketGroup);
00090 SINT32 processDownstream(CASocketGroupEpoll* a_signalingGroup, MIXPACKET* a_downstreamPacket, UINT32* a_processedBytes);
00091 #else
00092 void addToSocketGroup(CASocketGroup* a_socketGroup);
00093 void removeFromSocketGroup(CASocketGroup* a_socketGroup);
00094 bool isSignaledInSocketGroup(CASocketGroup* a_socketGroup);
00095 UINT32 sendUpstreamData(UINT32 a_maxLength, CASocketGroup* a_removedSocketGroup);
00096 SINT32 processDownstream(CASocketGroup* a_signalingGroup, MIXPACKET* a_downstreamPacket, UINT32* a_processedBytes);
00097 #endif
00098
00099 private:
00100 UINT8* m_chainId;
00101 SINT32 m_lastAccessTime;
00102 CASocket* m_socket;
00103 CAQueue* m_upstreamSendQueue;
00104 t_channelEntry* m_firstChannel;
00105 t_socketGroupEntry* m_firstSocketGroup;
00106 bool m_connectionError;
00107 bool m_downstreamClosed;
00108 bool m_upstreamClosed;
00109 bool m_firstDownstreamPacket;
00110 bool m_unknownChainId;
00111
00112 #ifdef LOG_CHAIN_STATISTICS
00113
00114 UINT32 m_packetsFromUser;
00115 UINT32 m_bytesFromUser;
00116 UINT32 m_packetsToUser;
00117 UINT32 m_bytesToUser;
00118 UINT64 m_creationTime;
00119 #endif
00120
00121 #ifdef DELAY_CHANNELS
00122 CAMutex* m_pDelayBucketMutex;
00123 SINT32* m_pDelayBucket;
00124
00125 SINT32 getDelayBucketInternal();
00126 void removeFromDelayBucketInternal(SINT32 a_bytesToRemove);
00127 #endif
00128
00129 void closeChainInternal();
00130 void forceImmediateResponsesInternal();
00131 void removeFromAllSocketGroupsInternal();
00132 UINT32 sendUpstreamDataInternal(UINT32 a_maxLength);
00133 };
00134 #endif //__CA_CHAIN__
00135 #endif //ONLY_LOCAL_PROXY