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 #ifndef __UNIXUDPCONNECTION_H_
00032 #define __UNIXUDPCONNECTION_H_
00033
00034 #include "P_UDPConnection.h"
00035 #include "P_UDPPacket.h"
00036
00037 class UnixUDPConnection:public UDPConnectionInternal
00038 {
00039 public:
00040 void init(int the_fd);
00041 void setEthread(EThread * e);
00042 void errorAndDie(int e);
00043 int callbackHandler(int event, void *data);
00044
00045 LINK(UnixUDPConnection, polling_link);
00046 LINK(UnixUDPConnection, callback_link);
00047 SLINK(UnixUDPConnection, newconn_alink);
00048
00049 InkAtomicList inQueue;
00050 int onCallbackQueue;
00051 Action *callbackAction;
00052 EThread *ethread;
00053 EventIO ep;
00054
00055 UnixUDPConnection(int the_fd);
00056 virtual ~ UnixUDPConnection();
00057 private:
00058 int m_errno;
00059 virtual void UDPConnection_is_abstract() {};
00060 };
00061
00062 TS_INLINE
00063 UnixUDPConnection::UnixUDPConnection(int the_fd)
00064 : onCallbackQueue(0)
00065 , callbackAction(NULL)
00066 , ethread(NULL)
00067 , m_errno(0)
00068 {
00069 fd = the_fd;
00070 UDPPacketInternal p;
00071 ink_atomiclist_init(&inQueue, "Incoming UDP Packet queue", (char *) &p.alink.next - (char *) &p);
00072 SET_HANDLER(&UnixUDPConnection::callbackHandler);
00073 }
00074
00075 TS_INLINE void
00076 UnixUDPConnection::init(int the_fd)
00077 {
00078 fd = the_fd;
00079 onCallbackQueue = 0;
00080 callbackAction = NULL;
00081 ethread = NULL;
00082 m_errno = 0;
00083
00084 UDPPacketInternal p;
00085 ink_atomiclist_init(&inQueue, "Incoming UDP Packet queue", (char *) &p.alink.next - (char *) &p);
00086 SET_HANDLER(&UnixUDPConnection::callbackHandler);
00087 }
00088
00089 TS_INLINE void
00090 UnixUDPConnection::setEthread(EThread * e)
00091 {
00092 ethread = e;
00093 }
00094
00095 TS_INLINE void
00096 UnixUDPConnection::errorAndDie(int e)
00097 {
00098 m_errno = e;
00099 }
00100
00101 TS_INLINE Action *
00102 UDPConnection::recv(Continuation * c)
00103 {
00104 UnixUDPConnection *p = (UnixUDPConnection *) this;
00105
00106 p->continuation = c;
00107 ink_assert(c != NULL);
00108 mutex = c->mutex;
00109 p->recvActive = 1;
00110 return ACTION_RESULT_NONE;
00111 }
00112
00113
00114 TS_INLINE UDPConnection *
00115 new_UDPConnection(int fd)
00116 {
00117 return (fd >= 0) ? new UnixUDPConnection(fd) : 0;
00118 }
00119
00120 #endif //__UNIXUDPCONNECTION_H_