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 #if !defined (P_VConnection_h)
00026 #define P_VConnection_h
00027 #include "I_EventSystem.h"
00028 
00029 TS_INLINE const char *
00030 get_vc_event_name(int event)
00031 {
00032   switch (event) {
00033   default:
00034     return "unknown event";
00035   case VC_EVENT_NONE:
00036     return "VC_EVENT_NONE";
00037   case VC_EVENT_IMMEDIATE:
00038     return "VC_EVENT_IMMEDIATE";
00039   case VC_EVENT_READ_READY:
00040     return "VC_EVENT_READ_READY";
00041   case VC_EVENT_WRITE_READY:
00042     return "VC_EVENT_WRITE_READY";
00043   case VC_EVENT_READ_COMPLETE:
00044     return "VC_EVENT_READ_COMPLETE";
00045   case VC_EVENT_WRITE_COMPLETE:
00046     return "VC_EVENT_WRITE_COMPLETE";
00047   case VC_EVENT_EOS:
00048     return "VC_EVENT_EOS";
00049   case VC_EVENT_ERROR:
00050     return "VC_EVENT_ERROR";
00051   case VC_EVENT_INACTIVITY_TIMEOUT:
00052     return "VC_EVENT_INACTIVITY_TIMEOUT";
00053   case VC_EVENT_ACTIVE_TIMEOUT:
00054     return "VC_EVENT_ACTIVE_TIMEOUT";
00055   }
00056 }
00057 
00058 
00059 TS_INLINE
00060 VConnection::VConnection(ProxyMutex * aMutex)
00061   :
00062 Continuation(aMutex),
00063 lerrno(0)
00064 {
00065   SET_HANDLER(0);
00066 }
00067 
00068 TS_INLINE
00069 VConnection::~
00070 VConnection()
00071 {
00072 }
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 TS_INLINE VIO *
00087 vc_do_io_write(VConnection * vc, Continuation * cont, int64_t nbytes, MIOBuffer * buf, int64_t offset)
00088 {
00089   IOBufferReader *reader = buf->alloc_reader();
00090 
00091   if (offset > 0)
00092     reader->consume(offset);
00093 
00094   return vc->do_io_write(cont, nbytes, reader, true);
00095 }
00096 
00097 TS_INLINE VIO *
00098 VConnection::do_io(int op, Continuation * c, int64_t nbytes, MIOBuffer * cb, int data)
00099 {
00100   switch (op) {
00101   case VIO::READ:
00102     return do_io_read(c, nbytes, cb);
00103   case VIO::WRITE:
00104     return vc_do_io_write(this, c, nbytes, cb, data);
00105   case VIO::CLOSE:
00106     do_io_close();
00107     return NULL;
00108   case VIO::ABORT:
00109     do_io_close(data);
00110     return NULL;
00111   case VIO::SHUTDOWN_READ:
00112     do_io_shutdown(IO_SHUTDOWN_READ);
00113     return NULL;
00114   case VIO::SHUTDOWN_WRITE:
00115     do_io_shutdown(IO_SHUTDOWN_WRITE);
00116     return NULL;
00117   case VIO::SHUTDOWN_READWRITE:
00118     do_io_shutdown(IO_SHUTDOWN_READWRITE);
00119     return NULL;
00120   }
00121   ink_assert(!"cannot use default implementation for do_io operation");
00122   return NULL;
00123 }
00124 
00125 TS_INLINE void
00126 VConnection::set_continuation(VIO *, Continuation *)
00127 {
00128 }
00129 TS_INLINE void
00130 VConnection::reenable(VIO *)
00131 {
00132 }
00133 TS_INLINE void
00134 VConnection::reenable_re(VIO * vio)
00135 {
00136   reenable(vio);
00137 }
00138 #endif