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 #ifndef __INK_API_PRIVATE_IOCORE_H__
00025 #define __INK_API_PRIVATE_IOCORE_H__
00026 #include "ts.h"
00027 #if !defined(__GNUC__)
00028 #include "I_EventSystem.h"
00029 #include "I_Cache.h"
00030 #include "I_Net.h"
00031 #else
00032 #include "P_EventSystem.h"
00033 #include "P_Cache.h"
00034 #include "P_Net.h"
00035 #endif
00036
00037 enum INKContInternalMagic_t
00038 {
00039 INKCONT_INTERN_MAGIC_ALIVE = 0x00009631,
00040 INKCONT_INTERN_MAGIC_DEAD = 0xDEAD9631
00041 };
00042
00043 class INKContInternal:public DummyVConnection
00044 {
00045 public:
00046 INKContInternal();
00047 INKContInternal(TSEventFunc funcp, TSMutex mutexp);
00048
00049 void init(TSEventFunc funcp, TSMutex mutexp);
00050 virtual void destroy();
00051
00052 void handle_event_count(int event);
00053 int handle_event(int event, void *edata);
00054
00055 public:
00056 void *mdata;
00057 TSEventFunc m_event_func;
00058 volatile int m_event_count;
00059 volatile int m_closed;
00060 int m_deletable;
00061 int m_deleted;
00062
00063 INKContInternalMagic_t m_free_magic;
00064 };
00065
00066 class INKVConnInternal:public INKContInternal
00067 {
00068 public:
00069 INKVConnInternal();
00070 INKVConnInternal(TSEventFunc funcp, TSMutex mutexp);
00071
00072 void init(TSEventFunc funcp, TSMutex mutexp);
00073 virtual void destroy();
00074
00075 int handle_event(int event, void *edata);
00076
00077 VIO *do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *buf);
00078
00079 VIO *do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *buf, bool owner = false);
00080
00081 void do_io_transform(VConnection *vc);
00082
00083 void do_io_close(int lerrno = -1);
00084
00085 void do_io_shutdown(ShutdownHowTo_t howto);
00086
00087 void reenable(VIO *vio);
00088
00089 void retry(unsigned int delay);
00090
00091 bool get_data(int id, void *data);
00092 bool set_data(int id, void *data);
00093
00094 public:
00095 VIO m_read_vio;
00096 VIO m_write_vio;
00097 VConnection *m_output_vc;
00098 };
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 #define UNSAFE_FORCE_MUTEX
00121
00122 #ifdef UNSAFE_FORCE_MUTEX
00123 #define LOCK_MONGO_MUTEX
00124 #define UNLOCK_MONGO_MUTEX
00125 #define MUX_WARNING(p) \
00126 TSDebug ("sdk","(SDK) null mutex detected in critical region (mutex created)"); \
00127 TSDebug ("sdk","(SDK) please create continuation [%p] with mutex", (p));
00128 #else
00129 static ink_mutex big_mux;
00130
00131 #define MUX_WARNING(p) 1
00132 #define LOCK_MONGO_MUTEX ink_mutex_acquire (&big_mux)
00133 #define UNLOCK_MONGO_MUTEX ink_mutex_release (&big_mux)
00134 #endif
00135
00136 #define FORCE_PLUGIN_MUTEX(_c) \
00137 MutexLock ml; \
00138 LOCK_MONGO_MUTEX; \
00139 if (( (INKContInternal*)_c)->mutex == NULL) { \
00140 ( (INKContInternal*)_c)->mutex = new_ProxyMutex(); \
00141 UNLOCK_MONGO_MUTEX; \
00142 MUX_WARNING(_c); \
00143 MUTEX_SET_AND_TAKE_LOCK(ml, ((INKContInternal*)_c)->mutex, this_ethread()); \
00144 } else { \
00145 UNLOCK_MONGO_MUTEX; \
00146 MUTEX_SET_AND_TAKE_LOCK(ml, ((INKContInternal*)_c)->mutex, this_ethread()); \
00147 }
00148
00149 #ifdef __cplusplus
00150 extern "C"
00151 {
00152 #endif
00153
00154 TSReturnCode sdk_sanity_check_mutex(TSMutex);
00155 TSReturnCode sdk_sanity_check_hostlookup_structure(TSHostLookupResult);
00156 TSReturnCode sdk_sanity_check_iocore_structure(void *);
00157
00158
00159
00160
00161
00162
00163
00164 tsapi TSMutex TSMutexCreateInternal(void);
00165 tsapi int TSMutexCheck(TSMutex mutex);
00166
00167
00168
00169 tsapi void TSIOBufferReaderCopy(TSIOBufferReader readerp, const void *buf, int64_t length);
00170 tsapi int64_t TSIOBufferBlockDataSizeGet(TSIOBufferBlock blockp);
00171 tsapi void TSIOBufferBlockDestroy(TSIOBufferBlock blockp);
00172 typedef void *INKUDPPacket;
00173 typedef void *INKUDPacketQueue;
00174 typedef void *INKUDPConn;
00175
00176
00177
00178
00179 tsapi TSAction INKUDPBind(TSCont contp, unsigned int ip, int port);
00180
00181
00182
00183
00184 tsapi TSAction INKUDPSendTo(TSCont contp, INKUDPConn udp, unsigned int ip, int port, char *buf, int len);
00185
00186
00187
00188
00189 tsapi TSAction INKUDPRecvFrom(TSCont contp, INKUDPConn udp);
00190
00191
00192
00193
00194
00195 tsapi int INKUDPConnFdGet(INKUDPConn udp);
00196
00197
00198
00199
00200
00201 tsapi INKUDPPacket INKUDPPacketCreate();
00202
00203
00204
00205
00206 tsapi TSIOBufferBlock INKUDPPacketBufferBlockGet(INKUDPPacket packet);
00207
00208
00209
00210
00211 tsapi unsigned int INKUDPPacketFromAddressGet(INKUDPPacket packet);
00212
00213
00214
00215
00216 tsapi int INKUDPPacketFromPortGet(INKUDPPacket packet);
00217
00218
00219
00220
00221 tsapi INKUDPConn INKUDPPacketConnGet(INKUDPPacket packet);
00222
00223
00224
00225
00226 tsapi void INKUDPPacketDestroy(INKUDPPacket packet);
00227
00228
00229
00230
00231
00232 tsapi INKUDPPacket INKUDPPacketGet(INKUDPacketQueue queuep);
00233
00234 #ifdef __cplusplus
00235 }
00236 #endif
00237
00238 #endif