]>
Commit | Line | Data |
---|---|---|
528b2c61 | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
528b2c61 | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
528b2c61 | 7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: none FDE */ |
10 | ||
582c2af2 | 11 | #include "squid.h" |
7e66d5e2 | 12 | #include "comm/Read.h" |
ef8acffa | 13 | #include "fd.h" |
528b2c61 | 14 | #include "fde.h" |
582c2af2 | 15 | #include "globals.h" |
985c86bc | 16 | #include "SquidTime.h" |
528b2c61 | 17 | #include "Store.h" |
528b2c61 | 18 | |
3a929bc0 | 19 | fde *fde::Table = NULL; |
f9fb22f5 | 20 | |
528b2c61 | 21 | bool |
22 | fde::readPending(int fdNumber) | |
23 | { | |
24 | if (type == FD_SOCKET) | |
7e66d5e2 | 25 | return Comm::MonitorsRead(fdNumber); |
62e76326 | 26 | |
528b2c61 | 27 | return read_handler ? true : false ; |
28 | } | |
29 | ||
30 | void | |
31 | fde::dumpStats (StoreEntry &dumpEntry, int fdNumber) | |
32 | { | |
33 | if (!flags.open) | |
62e76326 | 34 | return; |
35 | ||
7aa9bb3e | 36 | #if _SQUID_WINDOWS_ |
74cef207 | 37 | |
c91ca3ce | 38 | storeAppendPrintf(&dumpEntry, "%4d 0x%-8lX %-6.6s %4d %7" PRId64 "%c %7" PRId64 "%c %-21s %s\n", |
74cef207 | 39 | fdNumber, |
40 | win32.handle, | |
41 | #else | |
c91ca3ce | 42 | storeAppendPrintf(&dumpEntry, "%4d %-6.6s %4d %7" PRId64 "%c %7" PRId64 "%c %-21s %s\n", |
62e76326 | 43 | fdNumber, |
74cef207 | 44 | #endif |
62e76326 | 45 | fdTypeStr[type], |
2bb66f46 | 46 | timeoutHandler != NULL ? (int) (timeout - squid_curtime) : 0, |
62e76326 | 47 | bytes_read, |
48 | readPending(fdNumber) ? '*' : ' ', | |
49 | bytes_written, | |
50 | write_handler ? '*' : ' ', | |
51 | remoteAddr(), | |
52 | desc); | |
528b2c61 | 53 | } |
54 | ||
55 | void | |
56 | fde::DumpStats (StoreEntry *dumpEntry) | |
57 | { | |
58 | int i; | |
59 | storeAppendPrintf(dumpEntry, "Active file descriptors:\n"); | |
7aa9bb3e | 60 | #if _SQUID_WINDOWS_ |
74cef207 | 61 | |
62 | storeAppendPrintf(dumpEntry, "%-4s %-10s %-6s %-4s %-7s* %-7s* %-21s %s\n", | |
63 | "File", | |
64 | "Handle", | |
65 | #else | |
528b2c61 | 66 | storeAppendPrintf(dumpEntry, "%-4s %-6s %-4s %-7s* %-7s* %-21s %s\n", |
62e76326 | 67 | "File", |
74cef207 | 68 | #endif |
62e76326 | 69 | "Type", |
70 | "Tout", | |
71 | "Nread", | |
72 | "Nwrite", | |
73 | "Remote Address", | |
74 | "Description"); | |
7aa9bb3e | 75 | #if _SQUID_WINDOWS_ |
74cef207 | 76 | storeAppendPrintf(dumpEntry, "---- ---------- ------ ---- -------- -------- --------------------- ------------------------------\n"); |
77 | #else | |
528b2c61 | 78 | storeAppendPrintf(dumpEntry, "---- ------ ---- -------- -------- --------------------- ------------------------------\n"); |
74cef207 | 79 | #endif |
62e76326 | 80 | |
95dc7ff4 | 81 | for (i = 0; i < Squid_MaxFD; ++i) { |
528b2c61 | 82 | fd_table[i].dumpStats(*dumpEntry, i); |
83 | } | |
84 | } | |
85 | ||
86 | char const * | |
87 | fde::remoteAddr() const | |
88 | { | |
7f5f1385 | 89 | LOCAL_ARRAY(char, buf, MAX_IPSTRLEN ); |
62e76326 | 90 | |
528b2c61 | 91 | if (type != FD_SOCKET) |
62e76326 | 92 | return null_string; |
93 | ||
7f5f1385 AJ |
94 | if ( *ipaddr ) |
95 | snprintf( buf, MAX_IPSTRLEN, "%s:%d", ipaddr, (int)remote_port); | |
96 | else | |
4dd643d5 | 97 | local_addr.toUrl(buf,MAX_IPSTRLEN); // toHostStr does not include port. |
62e76326 | 98 | |
528b2c61 | 99 | return buf; |
100 | } | |
101 | ||
781ce8ff | 102 | void |
e8dca475 | 103 | fde::noteUse() |
781ce8ff | 104 | { |
95dc7ff4 | 105 | ++ pconn.uses; |
781ce8ff | 106 | } |
f53969cc | 107 |