@@ -1144,10 +1144,100 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted
11441144
11451145 UCharArrayAutoPtr port_buffer;
11461146
1147+
1148+ enum io_direction_t {
1149+ NONE,
1150+ SEND,
1151+ RECEIVE
1152+ };
1153+
1154+ private:
1155+ // packets over physical connection
11471156 FB_UINT64 port_snd_packets;
11481157 FB_UINT64 port_rcv_packets;
1158+ // protocol packets
1159+ FB_UINT64 port_out_packets;
1160+ FB_UINT64 port_in_packets;
1161+ // bytes over physical connection
11491162 FB_UINT64 port_snd_bytes;
11501163 FB_UINT64 port_rcv_bytes;
1164+ // bytes before/after compression
1165+ FB_UINT64 port_out_bytes;
1166+ FB_UINT64 port_in_bytes;
1167+ FB_UINT64 port_roundtrips; // number of changes of IO direction from SEND to RECEIVE
1168+ io_direction_t port_io_direction; // last direction of IO
1169+
1170+ public:
1171+ void bumpPhysStats (io_direction_t direction, ULONG count)
1172+ {
1173+ fb_assert (direction != NONE);
1174+
1175+ if (direction == SEND)
1176+ {
1177+ port_snd_packets++;
1178+ port_snd_bytes += count;
1179+ }
1180+ else
1181+ {
1182+ port_rcv_packets++;
1183+ port_rcv_bytes += count;
1184+ }
1185+
1186+ if (direction != port_io_direction)
1187+ {
1188+ if (port_io_direction != NONE && direction == RECEIVE)
1189+ port_roundtrips++;
1190+ port_io_direction = direction;
1191+ }
1192+ }
1193+
1194+ void bumpLogBytes (io_direction_t direction, ULONG count)
1195+ {
1196+ fb_assert (direction != NONE);
1197+
1198+ if (direction == SEND)
1199+ port_out_bytes += count;
1200+ else
1201+ port_in_bytes += count;
1202+ }
1203+
1204+ void bumpLogPackets (io_direction_t direction)
1205+ {
1206+ fb_assert (direction != NONE);
1207+
1208+ if (direction == SEND)
1209+ port_out_packets++;
1210+ else
1211+ port_in_packets++;
1212+ }
1213+
1214+ FB_UINT64 getStatItem (UCHAR infoItem) const
1215+ {
1216+ switch (infoItem)
1217+ {
1218+ case fb_info_wire_snd_packets:
1219+ return port_snd_packets;
1220+ case fb_info_wire_rcv_packets:
1221+ return port_rcv_packets;
1222+ case fb_info_wire_out_packets:
1223+ return port_out_packets;
1224+ case fb_info_wire_in_packets:
1225+ return port_in_packets;
1226+ case fb_info_wire_snd_bytes:
1227+ return port_snd_bytes;
1228+ case fb_info_wire_rcv_bytes:
1229+ return port_rcv_bytes;
1230+ case fb_info_wire_out_bytes:
1231+ return port_out_bytes;
1232+ case fb_info_wire_in_bytes:
1233+ return port_in_bytes;
1234+ case fb_info_wire_roundtrips:
1235+ return port_roundtrips;
1236+ default :
1237+ return 0 ;
1238+ }
1239+ }
1240+
11511241
11521242#ifdef WIRE_COMPRESS_SUPPORT
11531243 z_stream port_send_stream, port_recv_stream;
@@ -1187,7 +1277,9 @@ struct rem_port : public Firebird::GlobalStorage, public Firebird::RefCounted
11871277 port_known_server_keys(getPool()), port_crypt_plugin(NULL ),
11881278 port_client_crypt_callback(NULL ), port_server_crypt_callback(NULL ), port_crypt_name(getPool()),
11891279 port_replicator(NULL ), port_buffer(FB_NEW_POOL(getPool()) UCHAR[rpt]),
1190- port_snd_packets(0 ), port_rcv_packets(0 ), port_snd_bytes(0 ), port_rcv_bytes(0 )
1280+ port_snd_packets(0 ), port_rcv_packets(0 ), port_out_packets(0 ), port_in_packets(0 ),
1281+ port_snd_bytes(0 ), port_rcv_bytes(0 ), port_out_bytes(0 ), port_in_bytes(0 ),
1282+ port_roundtrips(0 ), port_io_direction(NONE)
11911283 {
11921284 addRef ();
11931285 memset (&port_linger, 0 , sizeof port_linger);
0 commit comments