*--------------------------------------------------------------------------*
****************************************************************************/
-/* FD_SETSIZE must be redefined before including sys/types.h */
-#if 0
-/* AYJ: would dearly like to use this to enforce include order
- but at present some helpers don't follow the squid include methodology.
- that will need fixing later.
-*/
-#ifdef _SYS_TYPES_H
-#error squid_fdsetsize.h for FDSETSIZE must be included before sys/types.h
-#error Make sure that squid.h is the first file included by your .cc
-#endif
-#endif /* 0 */
/*
* On some systems, FD_SETSIZE is set to something lower than the
* actual number of files which can be opened. IRIX is one case,
/* These functions are provided by the OS */
#if !HAVE_DECL_GETADDRINFO
-/* SG 23/09/2007:
-On Windows the following definitions are already available, may be that
-this could be needed on some other platform */
-#if 0
-struct addrinfo {
- int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
- int ai_family; /* PF_xxx */
- int ai_socktype; /* SOCK_xxx */
- int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
- socklen_t ai_addrlen; /* length of ai_addr */
- char *ai_canonname; /* canonical name for nodename */
- struct sockaddr *ai_addr; /* binary address */
- struct addrinfo *ai_next; /* next structure in linked list */
-};
-
-/* Supposed to be defined in <netdb.h> */
-#define AI_PASSIVE 1 /* Socket address is intended for `bind'. */
-#define AI_CANONNAME 2 /* Request for canonical name. */
-#define AI_NUMERICHOST 4 /* Don't use name resolution. */
-
-/* Supposed to be defined in <netdb.h> */
-#define EAI_ADDRFAMILY 1 /* address family for nodename not supported */
-#define EAI_AGAIN 2 /* temporary failure in name resolution */
-#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
-#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
-#define EAI_FAMILY 5 /* ai_family not supported */
-#define EAI_MEMORY 6 /* memory allocation failure */
-#define EAI_NODATA 7 /* no address associated with nodename */
-#define EAI_NONAME 8 /* nodename nor servname provided, or not known */
-#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
-#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
-#endif
#ifndef EAI_SYSTEM
/* Not defined on mingw32. */
#define EAI_SYSTEM 11 /* System error returned in `errno'. */
hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
#else
hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
-#if 0 // getnameinfo.c:161:9: error: variable 'h_error' set but not used
-#if HAVE_H_ERRNO
- h_error = h_errno;
-#else
- h_error = EINVAL;
-#endif
-#endif /* 0 */
#endif
if (hp) {
-#if 0
- if (flags & NI_NOFQDN) {
- /*
- * According to RFC3493 section 6.2, NI_NOFQDN
- * means "node name portion of the FQDN shall
- * be returned for local hosts." The following
- * code tries to implement it by returning the
- * first label (the part before the first
- * period) of the FQDN. However, it is not
- * clear if this always makes sense, since the
- * given address may be outside of "local
- * hosts." Due to the unclear description, we
- * disable the code in this implementation.
- */
- char *p;
- p = strchr(hp->h_name, '.');
- if (p)
- *p = '\0';
- }
-#endif
if (strlen(hp->h_name) + 1 > hostlen) {
#if USE_GETIPNODEBY
freehostent(hp);
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
-#if ARPA_INET_H
+#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#if HAVE_ARPA_NAMESER_H
#define _XOPEN_SOURCE_EXTENDED 1
#endif
-/* AIX 6.1 does not define recvmsg() flag MSG_DONTWAIT */
-#if !defined(MSG_DONTWAIT)
-#define MSG_DONTWAIT 0
-#endif
-
#endif /* _SQUID_AIX_ */
#endif /* SQUID_OS_AIX_H */
#include <errno.h>
#endif
-#ifndef INT64_MIN
-/* Native 64 bit system without strtoll() */
-#if defined(LONG_MIN) && (SIZEOF_LONG == 8)
-#define INT64_MIN LONG_MIN
-#else
-/* 32 bit system */
-#define INT64_MIN (-9223372036854775807LL-1LL)
-#endif
-#endif
-
-#ifndef INT64_MAX
-/* Native 64 bit system without strtoll() */
-#if defined(LONG_MAX) && (SIZEOF_LONG == 8)
-#define INT64_MAX LONG_MAX
-#else
-/* 32 bit system */
-#define INT64_MAX 9223372036854775807LL
-#endif
-#endif
-
/*
* Convert a string to a int64 integer.
*
return _tmpnam();
}
-#ifdef TEST
-int
-main()
-{
- char *t;
- int n = 0;
- while ((t = tempnam(NULL, NULL))) {
- printf("%s\n", t);
- if (++n == 1000)
- break;
- }
- return 1;
-}
-#endif
-
u_char *asn_parse_null(u_char *, int *, u_char *);
u_char *asn_build_null(u_char *, int *, u_char);
-#if 0
-u_char *asn_parse_bitstring(u_char *, int *, u_char *, u_char *, int *);
-u_char *asn_build_bitstring(u_char *, int *, u_char, u_char *, int);
-
-#endif
u_char *asn_build_exception(u_char *, int *, u_char);
#ifdef __cplusplus
* @(#)radix.h 8.2 (Berkeley) 10/31/94
*/
-#undef RN_DEBUG
/*
* Radix search tree node layout.
*/
struct squid_radix_node *rn_R; /* progeny */
} rn_node;
} rn_u;
-#ifdef RN_DEBUG
-
- int rn_info;
-
- struct squid_radix_node *rn_twin;
-
- struct squid_radix_node *rn_ybro;
-#endif
};
#define rn_key rn_u.rn_leaf.rn_Key
#include <asn1.h> /* Need OID Definition */
#include <snmp_vars.h> /* Need variable_list */
-#if 0
-#include <mib.h> /* Then the function definitions */
-#endif
#endif /* SQUID_SNMP_MIB_H */
*/
int snmp_build(struct snmp_session *, struct snmp_pdu *, u_char *, int *);
-/*
- * struct snmp_session *snmp_open(session)
- * struct snmp_session *session;
- *
- * Sets up the session with the snmp_session information provided
- * by the user. Then opens and binds the necessary UDP port.
- * A handle to the created session is returned (this is different than
- * the pointer passed to snmp_open()). On any error, NULL is returned
- * and snmp_errno is set to the appropriate error code.
- */
-#if 0
-struct snmp_session *snmp_open(struct snmp_session *);
-
-/*
- * int snmp_close(session)
- * struct snmp_session *session;
- *
- * Close the input session. Frees all data allocated for the session,
- * dequeues any pending requests, and closes any sockets allocated for
- * the session. Returns 0 on error, 1 otherwise.
- */
-int snmp_close(struct snmp_session *);
-
-/*
- * int snmp_send(session, pdu)
- * struct snmp_session *session;
- * struct snmp_pdu *pdu;
- *
- * Sends the input pdu on the session after calling snmp_build to create
- * a serialized packet. If necessary, set some of the pdu data from the
- * session defaults. Add a request corresponding to this pdu to the list
- * of outstanding requests on this session, then send the pdu.
- * Returns the request id of the generated packet if applicable, otherwise 1.
- * On any error, 0 is returned.
- * The pdu is freed by snmp_send() unless a failure occurred.
- */
-int snmp_send(struct snmp_session *, struct snmp_pdu *);
-
-/*
- * void snmp_read(fdset)
- * fd_set *fdset;
- *
- * Checks to see if any of the fd's set in the fdset belong to
- * snmp. Each socket with it's fd set has a packet read from it
- * and snmp_parse is called on the packet received. The resulting pdu
- * is passed to the callback routine for that session. If the callback
- * routine returns successfully, the pdu and it's request are deleted.
- */
-void snmp_read(fd_set *);
-
-/*
- * int snmp_select_info(numfds, fdset, timeout, block)
- * int *numfds;
- * fd_set *fdset;
- * struct timeval *timeout;
- * int *block;
- *
- * Returns info about what snmp requires from a select statement.
- * numfds is the number of fds in the list that are significant.
- * All file descriptors opened for SNMP are OR'd into the fdset.
- * If activity occurs on any of these file descriptors, snmp_read
- * should be called with that file descriptor set.
- *
- * The timeout is the latest time that SNMP can wait for a timeout. The
- * select should be done with the minimum time between timeout and any other
- * timeouts necessary. This should be checked upon each invocation of select.
- * If a timeout is received, snmp_timeout should be called to check if the
- * timeout was for SNMP. (snmp_timeout is idempotent)
- *
- * Block is 1 if the select is requested to block indefinitely, rather than time out.
- * If block is input as 1, the timeout value will be treated as undefined, but it must
- * be available for setting in snmp_select_info. On return, if block is true, the value
- * of timeout will be undefined.
- *
- * snmp_select_info returns the number of open sockets. (i.e. The number of sessions open)
- */
-int snmp_select_info(int *, fd_set *, struct timeval *, int *);
-
-/*
- * void snmp_timeout();
- *
- * snmp_timeout should be called whenever the timeout from snmp_select_info expires,
- * but it is idempotent, so snmp_timeout can be polled (probably a cpu expensive
- * proposition). snmp_timeout checks to see if any of the sessions have an
- * outstanding request that has timed out. If it finds one (or more), and that
- * pdu has more retries available, a new packet is formed from the pdu and is
- * resent. If there are no more retries available, the callback for the session
- * is used to alert the user of the timeout.
- */
-void snmp_timeout(void);
-
-/*
- * This routine must be supplied by the application:
- *
- * int callback(operation, session, reqid, pdu, magic)
- * int operation;
- * struct snmp_session *session; The session authenticated under.
- * int reqid; The request id of this pdu (0 for TRAP)
- * struct snmp_pdu *pdu; The pdu information.
- * void *magic A link to the data for this routine.
- *
- * Returns 1 if request was successful, 0 if it should be kept pending.
- * Any data in the pdu must be copied because it will be freed elsewhere.
- * Operations are defined below:
- */
-
-void snmp_api_stats(void *);
-#endif
#ifdef __cplusplus
}
SOFTWARE.
******************************************************************/
-#if 0
-#if (defined vax) || (defined (mips))
-/*
- * This is a fairly bogus thing to do, but there seems to be no better way for
- * compilers that don't understand void pointers.
- */
-#ifndef void
-#define void char
-#endif
-#endif
-#endif
-
#define SID_MAX_LEN 64
#define READ 1
#define SNMP_PDU_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
#define SNMP_PDU_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
#define SNMP_PDU_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
-#ifdef UNUSED_CODE
-#define SNMP_PDU_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
-#define TRP_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /*Obsolete */
-#endif
#define SNMP_PDU_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
-#ifdef UNUSED_CODE
-#define SNMP_PDU_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
-#define SNMP_PDU_V2TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
-#define SNMP_PDU_REPORT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8)
-#endif
#define MAX_BINDINGS 2147483647 /* PDU Defaults */
#define SNMP_DEFAULT_ERRSTAT -1
#define SNMP_DEFAULT_ERRINDEX -1
#define SNMP_DEFAULT_ADDRESS 0
#define SNMP_DEFAULT_REQID 0
-/* RFC 1907: Management Information Base for SNMPv2
- *
- * RFC 1157: A Simple Network Management Protocol (SNMP)
- *
- * Trap Types
- */
-#if UNUSED_CODE
-#define SNMP_TRAP_COLDSTART (0x0)
-#define SNMP_TRAP_WARMSTART (0x1)
-#define SNMP_TRAP_LINKDOWN (0x2)
-#define SNMP_TRAP_LINKUP (0x3)
-#define SNMP_TRAP_AUTHENTICATIONFAILURE (0x4)
-#define SNMP_TRAP_EGPNEIGHBORLOSS (0x5)
-#define SNMP_TRAP_ENTERPRISESPECIFIC (0x6)
-#endif
-
#ifdef __cplusplus
}
#endif
hp->nodes[elm2->id] = elm2;
}
-#ifdef NOTDEF
-/*
- * Copy KEY and DATA fields of SRC to DEST. ID field is NOT copied.
- */
-static void
-_heap_copy_element(heap_node * src, heap_node * dest)
-{
- dest->key = src->key;
- dest->data = src->data;
-}
-
-#endif /* NOTDEF */
-
/*
* True if HP needs to be grown in size.
*/
newSize = hp->size * NormalRate;
hp->nodes = xrealloc(hp->nodes, newSize * sizeof(heap_node *));
-#if COMMENTED_OUT
- for (i = 0; i < hp->size; i++)
- newNodes[i] = hp->nodes[i];
- xfree(hp->nodes);
- hp->nodes = newNodes;
-#endif
hp->size = newSize;
}
return 0;
}
-#ifdef RN_DEBUG
-int rn_nodenum;
-struct squid_radix_node *rn_clist;
-int rn_saveinfo;
-int rn_debug = 1;
-#endif
-
struct squid_radix_node *
squid_rn_newpair(void *v, int b, struct squid_radix_node nodes[2]) {
register struct squid_radix_node *tt = nodes, *t = tt + 1;
tt->rn_key = (caddr_t) v;
tt->rn_p = t;
tt->rn_flags = t->rn_flags = RNF_ACTIVE;
-#ifdef RN_DEBUG
- tt->rn_info = rn_nodenum++;
- t->rn_info = rn_nodenum++;
- tt->rn_twin = t;
- tt->rn_ybro = rn_clist;
- rn_clist = tt;
-#endif
return t;
}
else
x = x->rn_l;
} while (b > (unsigned) x->rn_b); /* x->rn_b < b && x->rn_b >= 0 */
-#ifdef RN_DEBUG
- if (rn_debug)
- fprintf(stderr, "squid_rn_insert: Going In:\n");
- traverse(p);
-#endif
t = squid_rn_newpair(v_arg, b, nodes);
tt = t->rn_l;
if ((cp[p->rn_off] & p->rn_bmask) == 0)
t->rn_r = tt;
t->rn_l = x;
}
-#ifdef RN_DEBUG
- if (rn_debug)
- log(LOG_DEBUG, "squid_rn_insert: Coming Out:\n"), traverse(p);
-#endif
}
return (tt);
}
tt->rn_dupedkey = t->rn_dupedkey;
t->rn_dupedkey = tt;
}
-#ifdef RN_DEBUG
- t = tt + 1;
- tt->rn_info = rn_nodenum++;
- t->rn_info = rn_nodenum++;
- tt->rn_twin = t;
- tt->rn_ybro = rn_clist;
- rn_clist = tt;
-#endif
tt->rn_key = (caddr_t) v;
tt->rn_b = -1;
tt->rn_flags = RNF_ACTIVE;
*/
if (tt->rn_flags & RNF_ROOT)
return (0);
-#ifdef RN_DEBUG
- /* Get us out of the creation list */
- for (t = rn_clist; t && t->rn_ybro != tt; t = t->rn_ybro) {
- }
- if (t)
- t->rn_ybro = tt->rn_ybro;
-#endif
t = tt->rn_p;
if ((dupedkey = saved_tt->rn_dupedkey)) {
if (tt == saved_tt) {
}
t = tt + 1;
if (t->rn_flags & RNF_ACTIVE) {
-#ifndef RN_DEBUG
- *++x = *t;
- p = t->rn_p;
-#else
- b = t->rn_info;
*++x = *t;
- t->rn_info = b;
p = t->rn_p;
-#endif
if (p->rn_l == t)
p->rn_l = x;
else
squid_MKFree(m);
m = mm;
}
-#if RN_DEBUG
- if (m)
- fprintf(stderr, "%s %x at %x\n",
- "squid_rn_delete: Orphaned Mask", (int) m, (int) x);
-#else
assert(m == NULL);
-#endif
}
}
/*
*/
x = tt + 1;
if (t != x) {
-#ifndef RN_DEBUG
- *t = *x;
-#else
- b = t->rn_info;
*t = *x;
- t->rn_info = b;
-#endif
t->rn_l->rn_p = t;
t->rn_r->rn_p = t;
p = x->rn_p;
return buf;
}
-#if 0
-int
-main()
-{
- char *x;
- time_t t, pt;
-
- t = time(NULL);
- x = mkrfc1123(t);
- printf("HTTP Time: %s\n", x);
-
- pt = parse_rfc1123(x);
- printf("Parsed: %d vs. %d\n", pt, t);
-}
-
-#endif
-
int RFCNB_Timeout = 0; /* Timeout in seconds ... */
-static int RFCNB_Discard_Rest(struct RFCNB_Con *con, int len);
-
-#ifdef NOT_USED
-void
-rfcnb_alarm(int sig)
-{
-
- fprintf(stderr, "IO Timed out ...\n");
-
-}
-
-#endif /* NOT_USED */
-
-#ifdef NOT_USED
-/* Set timeout value and setup signal handling */
-int
-RFCNB_Set_Timeout(int seconds)
-{
- /* If we are on a Bezerkeley system, use sigvec, else sigaction */
-
-#if ORIGINAL_SAMBA_CODE
-#ifndef SA_RESTART
- struct sigvec invec, outvec;
-#else
- struct sigaction inact, outact;
-#endif
-
- RFCNB_Timeout = seconds;
-
- if (RFCNB_Timeout > 0) { /* Set up handler to ignore but not restart */
-
-#ifndef SA_RESTART
- invec.sv_handler = (void (*)()) rfcnb_alarm;
- invec.sv_mask = 0;
- invec.sv_flags = SV_INTERRUPT;
-
- if (sigvec(SIGALRM, &invec, &outvec) < 0)
- return (-1);
-#else /* !SA_RESTART */
- inact.sa_handler = (void (*)()) rfcnb_alarm;
-#ifdef Solaris
- /* Solaris seems to have an array of vectors ... */
- inact.sa_mask.__sigbits[0] = 0;
- inact.sa_mask.__sigbits[1] = 0;
- inact.sa_mask.__sigbits[2] = 0;
- inact.sa_mask.__sigbits[3] = 0;
-#else /* !Solaris */
- inact.sa_mask = (sigset_t) 0;
-#endif /* Solaris */
- inact.sa_flags = 0; /* Don't restart */
-
- if (sigaction(SIGALRM, &inact, &outact) < 0)
- return (-1);
-
-#endif /* !SA_RESTART */
-
- }
-#else /* !ORIGINAL_SAMBA_CODE ADAPTED SQUID CODE */
-#if HAVE_SIGACTION
- struct sigaction inact, outact;
-#else
- struct sigvec invec, outvec;
-#endif
-
- RFCNB_Timeout = seconds;
-
- if (RFCNB_Timeout > 0) { /* Set up handler to ignore but not restart */
-
-#if HAVE_SIGACTION
- inact.sa_handler = (void (*)()) rfcnb_alarm;
- sigemptyset(&inact.sa_mask);
- inact.sa_flags = 0; /* Don't restart */
-
- if (sigaction(SIGALRM, &inact, &outact) < 0)
- return (-1);
-#else /* !HAVE_SIGACTION */
- invec.sv_handler = (void (*)()) rfcnb_alarm;
- invec.sv_mask = 0;
- invec.sv_flags = SV_INTERRUPT;
-
- if (sigvec(SIGALRM, &invec, &outvec) < 0)
- return (-1);
-#endif /* !HAVE_SIGACTION */
- }
-#endif /* !ORIGINAL_SAMBA_CODE ADAPTED SQUID CODE */
- return (0);
-}
-#endif /* NOT_USED */
-
/* Discard the rest of an incoming packet as we do not have space for it
* in the buffer we allocated or were passed ... */
+static
int
RFCNB_Discard_Rest(struct RFCNB_Con *con, int len)
{
#define RFCNB_Pkt_Type(p) (CVAL((p), RFCNB_Pkt_Type_Offset))
-#if UNUSED_CODE
-typedef struct RFCNB_Hdr {
- unsigned char type;
- unsigned char flags;
- int16 len;
-} RFCNB_Hdr;
-
-typedef struct RFCNB_Sess_Pkt {
- unsigned char type;
- unsigned char flags;
- int16 length;
- unsigned char n1_len;
- char called_name[33];
- unsigned char n2_len;
- char calling_name[33];
-} RFCNB_Sess_Pkt;
-
-typedef struct RFCNB_Nack_Pkt {
- struct RFCNB_Hdr hdr;
- unsigned char error;
-} RFCNB_Nack_Pkt;
-
-typedef struct RFCNB_Retarget_Pkt {
- struct RFCNB_Hdr hdr;
- int dest_ip;
- unsigned char port;
-} RFCNB_Redir_Pkt;
-#endif /* UNUSED_CODE */
-
/* Static variables */
/* Only declare this if not defined */
strupper(char *s)
{
while (*s) {
-#if UNUSED_CODE
-#if !defined(KANJI_WIN95_COMPATIBILITY)
- if (lp_client_code_page() == KANJI_CODEPAGE) {
-
- if (is_shift_jis(*s)) {
- if (is_sj_lower(s[0], s[1]))
- s[1] = sj_toupper2(s[1]);
- s += 2;
- } else if (is_kana(*s)) {
- s++;
- } else {
- if (islower((int)(unsigned char)*s))
- *s = toupper((int)(unsigned char)*s);
- s++;
- }
- } else
-#endif /* KANJI_WIN95_COMPATIBILITY */
-#endif /* UNUSED_CODE */
- {
- if (islower((int)(unsigned char)*s))
- *s = toupper((int)(unsigned char)*s);
- s++;
- }
+ if (islower((int)(unsigned char)*s))
+ *s = toupper((int)(unsigned char)*s);
+ s++;
}
}
return (asn_build_length(data, datalength, length, truth));
}
-#if 0
-/*
- * asn_build_sequence - builds an ASN header for a sequence with the ID and
- * length specified.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * in this object following the id and length.
- *
- * This only works on data types < 30, i.e. no extension octets.
- * The maximum length is 0xFFFF;
- *
- * Returns a pointer to the first byte of the contents of this object.
- * Returns NULL on any error.
- */
-u_char *
-asn_build_sequence(u_char * data, int *datalength,
- u_char type, int length)
-/* u_char *data; IN - pointer to start of object */
-/* int *datalength; IN/OUT - # of valid bytes left in buffer */
-/* u_char type; IN - ASN type of object */
-/* int length; IN - length of object */
-{
- *datalength -= 4;
- if (*datalength < 0) {
- *datalength += 4; /* fix up before punting */
- snmp_set_api_error(SNMPERR_ASN_ENCODE);
- return (NULL);
- }
- *data++ = type;
- *data++ = (u_char) (0x02 | ASN_LONG_LEN);
- *data++ = (u_char) ((length >> 8) & 0xFF);
- *data++ = (u_char) (length & 0xFF);
- return (data);
-}
-#endif
-
/*
* asn_parse_length - interprets the length of the current object.
* On exit, length contains the value of this length field.
return (data + asnlength);
}
-#if 0
-/*
- * asn_parse_null - Interprets an ASN null type.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the beginning of the next object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns NULL on any error.
- */
-u_char *
-asn_parse_null(u_char * data, int *datalength, u_char * type)
-/* u_char *data; IN - pointer to start of object */
-/* int *datalength; IN/OUT - # of valid bytes left in buf */
-/* u_char *type; OUT - ASN type of object */
-{
- /*
- * ASN.1 null ::= 0x05 0x00
- */
- u_char *bufp = data;
- u_int asn_length;
-
- *type = *bufp++;
- bufp = asn_parse_length(bufp, &asn_length);
- if (bufp == NULL)
- return (NULL);
-
- if (asn_length != 0) {
- snmp_set_api_error(SNMPERR_ASN_DECODE);
- return (NULL);
- }
- *datalength -= (bufp - data);
- return (bufp + asn_length);
-}
-#endif
-
/*
* asn_build_null - Builds an ASN null object.
* On entry, datalength is input as the number of valid bytes following
return (asn_build_header_with_truth(data, datalength, type, 0, 1));
}
-#if 0
-
-/*
- * asn_parse_bitstring - pulls a bitstring out of an ASN bitstring type.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the beginning of the next object.
- *
- * "string" is filled with the bit string.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns NULL on any error.
- */
-u_char *
-asn_parse_bitstring(u_char * data, int *datalength,
- u_char * type, u_char * string, int *strlength)
-/* u_char *data; IN - pointer to start of object */
-/* int *datalength; IN/OUT - # of valid bytes left in buf */
-/* u_char *type; OUT - asn type of object */
-/* u_char *string; IN/OUT - pointer to start of output buf */
-/* int *strlength; IN/OUT - size of output buffer */
-{
- /*
- * bitstring ::= 0x03 asnlength unused {byte}*
- */
- u_char *bufp = data;
- u_int asn_length;
-
- *type = *bufp++;
- bufp = asn_parse_length(bufp, &asn_length);
- if (bufp == NULL)
- return (NULL);
-
- if (asn_length + (bufp - data) > *datalength) {
- snmp_set_api_error(SNMPERR_ASN_DECODE);
- return (NULL);
- }
- if (asn_length > *strlength) {
- snmp_set_api_error(SNMPERR_ASN_DECODE);
- return (NULL);
- }
- if (asn_length < 1) {
- snmp_set_api_error(SNMPERR_ASN_DECODE);
- return (NULL);
- }
- if ((int) (*(char *) bufp) < 0 || (int) (*bufp) > 7) {
- snmp_set_api_error(SNMPERR_ASN_DECODE);
- return (NULL);
- }
- memcpy((char *) string, (char *) bufp, (int) asn_length);
- *strlength = (int) asn_length;
- *datalength -= (int) asn_length + (bufp - data);
- return (bufp + asn_length);
-}
-
-/*
- * asn_build_bitstring - Builds an ASN bit string object containing the
- * input string.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the beginning of the next object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns NULL on any error.
- */
-u_char *
-asn_build_bitstring(u_char * data, int *datalength,
- u_char type, u_char * string, int strlength)
-/* u_char *data; IN - pointer to start of object */
-/* int *datalength; IN/OUT - # of valid bytes left in buf */
-/* u_char type; IN - ASN type of string */
-/* u_char *string; IN - pointer to start of input buffer */
-/* int strlength; IN - size of input buffer */
-{
- /*
- * ASN.1 bit string ::= 0x03 asnlength unused {byte}*
- */
- if ((strlength < 1) || ((*(char *) string) < 0) || ((*string) > 7)) {
- snmp_set_api_error(SNMPERR_ASN_ENCODE);
- return (NULL);
- }
- data = asn_build_header_with_truth(data, datalength, type, strlength, 1);
- if (data == NULL)
- return (NULL);
-
- if (*datalength < strlength) {
- snmp_set_api_error(SNMPERR_ASN_ENCODE);
- return (NULL);
- }
- memcpy((char *) data, (char *) string, strlength);
- *datalength -= strlength;
- return (data + strlength);
-}
-
-#endif
-
/*
* To do: Write an asn_parse_exception function to go with the new
* asn_build_exception function below so that the exceptional values can
snmplib_debug(0, "%s: On or around line %d\n", string, Line);
}
-#if TEST
-print_subtree(tree, count)
-struct snmp_mib_tree *tree;
-int count;
-{
- struct snmp_mib_tree *tp;
- int i;
-
- for (i = 0; i < count; i++)
- printf(" ");
- printf("Children of %s:\n", tree->label);
- count++;
- for (tp = tree->child_list; tp; tp = tp->next_peer) {
- for (i = 0; i < count; i++)
- printf(" ");
- printf("%s\n", tp->label);
- }
- for (tp = tree->child_list; tp; tp = tp->next_peer) {
- print_subtree(tp, count);
- }
-}
-#endif /* TEST */
-
int translation_table[40];
static void
xfree(oldnp);
}
-#if !TEST
static
-#endif
struct snmp_mib_tree *
build_tree(struct node *nodes) {
struct node *np;
init_node_hash(nodes);
/* XXX nodes isn't needed in do_subtree() ??? */
do_subtree(tp, &nodes);
-#if TEST
- print_subtree(tp, 0);
-#endif /* TEST */
/* If any nodes are left, the tree is probably inconsistent */
for (bucket = 0; bucket < NHASHSIZE; bucket++) {
if (nbuckets[bucket]) {
* Parses a mib file and returns a linked list of nodes found in the file.
* Returns NULL on error.
*/
-#if !TEST
static
-#endif
struct node *
parse(FILE *fp) {
char token[64];
return NULL;
}
}
-#if TEST
- {
- struct enum_list *ep;
-
- for (np = root; np; np = np->next) {
- printf("%s ::= { %s %d } (%d)\n", np->label, np->parent, np->subid,
- np->type);
- if (np->enums) {
- printf("Enums: \n");
- for (ep = np->enums; ep; ep = ep->next) {
- printf("%s(%d)\n", ep->label, ep->value);
- }
- }
- }
- }
-#endif /* TEST */
return root;
}
u_char *bufp;
u_char PDUType;
u_char ASNType;
-#if UNUSED_CODE
- int four;
- oid objid[MAX_NAME_LEN];
-#endif
bufp = asn_parse_header(Packet, Length, &PDUType);
if (bufp == NULL)
#include "asn1.h"
#include "snmp.h"
-#include "snmp_vars.h"
-#if 0
-#include "mibii.h"
-#endif
#include "snmp_api_error.h"
#include "snmp_msg.h"
#include "snmp_pdu.h"
+#include "snmp_vars.h"
#include "util.h"
/* hash */
cacheDigestHashKey(this, key);
/* turn on corresponding bits */
-#if CD_FAST_ADD
+ int on_xition_cnt = 0;
- CBIT_SET(mask, hashed_keys[0]);
- CBIT_SET(mask, hashed_keys[1]);
- CBIT_SET(mask, hashed_keys[2]);
- CBIT_SET(mask, hashed_keys[3]);
-#else
-
- {
- int on_xition_cnt = 0;
-
- if (!CBIT_TEST(mask, hashed_keys[0])) {
- CBIT_SET(mask, hashed_keys[0]);
- ++on_xition_cnt;
- }
-
- if (!CBIT_TEST(mask, hashed_keys[1])) {
- CBIT_SET(mask, hashed_keys[1]);
- ++on_xition_cnt;
- }
+ if (!CBIT_TEST(mask, hashed_keys[0])) {
+ CBIT_SET(mask, hashed_keys[0]);
+ ++on_xition_cnt;
+ }
- if (!CBIT_TEST(mask, hashed_keys[2])) {
- CBIT_SET(mask, hashed_keys[2]);
- ++on_xition_cnt;
- }
+ if (!CBIT_TEST(mask, hashed_keys[1])) {
+ CBIT_SET(mask, hashed_keys[1]);
+ ++on_xition_cnt;
+ }
- if (!CBIT_TEST(mask, hashed_keys[3])) {
- CBIT_SET(mask, hashed_keys[3]);
- ++on_xition_cnt;
- }
+ if (!CBIT_TEST(mask, hashed_keys[2])) {
+ CBIT_SET(mask, hashed_keys[2]);
+ ++on_xition_cnt;
+ }
- statCounter.cd.on_xition_count.count(on_xition_cnt);
+ if (!CBIT_TEST(mask, hashed_keys[3])) {
+ CBIT_SET(mask, hashed_keys[3]);
+ ++on_xition_cnt;
}
-#endif
+
+ statCounter.cd.on_xition_count.count(on_xition_cnt);
++count;
}
*d = *s;
break;
}
-#if 0
- } else if (*s == '$' && quoteChar == '"') {
- errorStr = "Unsupported cfg macro";
- errorPos = s;
-#endif
-#if 0
- } else if (*s == '%' && quoteChar == '"' && (!AllowMacros_ )) {
- errorStr = "Macros are not supported here";
- errorPos = s;
-#endif
} else
*d = *s;
++s;
*/
assert(!initialised);
memset(&diskd_stats, '\0', sizeof(diskd_stats));
-#if 0
- /*
- * DPW 2007-04-12
- * No debugging here please because this method is called before
- * the debug log is configured and we'll get the message on
- * stderr when doing things like 'squid -k reconfigure'
- */
- debugs(47, DBG_IMPORTANT, "diskd started");
-#endif
+
initialised = true;
registerWithCacheManager();
}
while (1) {
-#ifdef ALWAYS_ZERO_BUFFERS
- memset(&M, '\0', sizeof(M));
-#endif
-
x = msgrcv(rmsgid, &M, diomsg::msg_snd_rcv_sz, 0, IPC_NOWAIT);
if (x < 0)
data_hdr.freeContent();
-#if 0
- /*
- * There is no way to abort FD-less clients, so they might
- * still have mem->clients set.
- */
- assert(clients.head == NULL);
-
-#endif
-
ctx_exit(ctx); /* must exit before we free mem->url */
}
MemObject::dump() const
{
data_hdr.dump();
-#if 0
- /* do we want this one? */
- debugs(20, DBG_IMPORTANT, "MemObject->data.origin_offset: " << (data_hdr.head ? data_hdr.head->nodeBuffer.offset : 0));
-#endif
debugs(20, DBG_IMPORTANT, "MemObject->start_ping: " << start_ping);
debugs(20, DBG_IMPORTANT, "MemObject->inmem_hi: " << data_hdr.endOffset());
for (dlink_node *node = clients.head; node; node = node->next) {
store_client *sc = (store_client *) node->data;
-#if 0
- /* This test is invalid because the client may be writing data
- * and thus will want data immediately.
- * If we include the test, there is a race condition when too much
- * data is read - if all sc's are writing when a read is scheduled.
- * XXX: fixme.
- */
-
- if (!sc->callbackPending())
- /* not waiting for more data */
- continue;
-
-#endif
j = sc->delayId.bytesWanted(0, sc->copyInto.length);
edui_conf.persist_timeout = -1;
edui_conf.mode = 0;
edui_conf.mode |= EDUI_MODE_INIT;
-
- /* Set defaults from compile-time-options, if provided, but depriciated. */
-#ifdef EDUI_BASE_DN
- xstrncpy(edui_conf.basedn, EDUI_BASE_DN, sizeof(edui_conf.basedn));
-#endif
-#ifdef EDUI_DEFAULT_HOST
- xstrncpy(edui_conf.host, EDUI_DEFAULT_HOST, sizeof(edui_conf.host));
-#endif
-#ifdef EDUI_BIND_DN
- xstrncpy(edui_conf.dn, EDUI_BIND_DN, sizeof(edui_conf.dn));
-#endif
-#ifdef EDUI_BIND_PASS
- xstrncpy(edui_conf.passwd, EDUI_BIND_PASS, sizeof(edui_conf.passwd));
-#endif
-#ifdef EDUI_USER_ATTRIB
- xstrncpy(edui_conf.attrib, EDUI_USER_ATTRIB, sizeof(edui_conf.attrib));
-#endif
-#ifdef EDUI_SEARCH_FILTER
- xstrncpy(edui_conf.search_filter, EDUI_SEARCH_FILTER, sizeof(edui_conf.search_filter));
-#endif
-#ifdef EDUI_SEARCH_SCOPE
- if (!strcmp(EDUI_SEARCH_SCOPE, "base"))
- edui_conf.scope = 0;
- else if (!strcmp(EDUI_SEARCH_SCOPE, "one"))
- edui_conf.scope = 1;
- else if (!strcmp(EDUI_SEARCH_SCOPE, "sub"))
- edui_conf.scope = 2;
- else
- edui_conf.scope = 1;
-#endif
-#ifdef EDUI_LDAP_VERSION
- edui_conf.ver = EDUI_LDAP_VERSION;
-#endif
-#ifdef EDUI_DEFAULT_PORT
- edui_conf.port = EDUI_DEFAULT_PORT;
-#endif
-#ifdef EDUI_FORCE_IPV4
- edui_conf.mode |= EDUI_MODE_IPV4;
-#endif
-#ifdef EDUI_FORCE_IPV6
- edui_conf.mode |= EDUI_MODE_IPV6;
-#endif
-#ifdef EDUI_USE_TLS
- edui_conf.mode |= EDUI_MODE_TLS;
-#endif
-#ifdef EDUI_USE_PERSIST
- edui_conf.mode |= EDUI_MODE_PERSIST;
-#endif
-#ifdef EDUI_PERSIST_TIMEOUT
- edui_conf.persist_timeout = EDUI_PERSIST_TIMEOUT;
-#endif
-#ifdef EDUI_GROUP_REQUIRED
- edui_conf.mode |= EDUI_MODE_GROUP;
-#endif
-#ifdef EDUI_DEBUG
- edui_conf.mode |= EDUI_MODE_DEBUG;
-#endif
}
/* Displays running configuration */
startGettingOptions();
}
-#if 0
-static
-void Adaptation::Icap::ServiceRep_noteTimeToNotify(void *data)
-{
- Adaptation::Icap::ServiceRep *service = static_cast<Adaptation::Icap::ServiceRep*>(data);
- Must(service);
- service->noteTimeToNotify();
-}
-#endif
-
void Adaptation::Icap::ServiceRep::noteTimeToNotify()
{
Must(!notifying);
AsyncJob::Start(cs.get());
}
-/*
- * This event handler is necessary to work around the no-rentry policy
- * of Adaptation::Icap::Xaction::callStart()
- */
-#if 0
-void
-Adaptation::Icap::Xaction::reusedConnection(void *data)
-{
- debugs(93, 5, HERE << "reused connection");
- Adaptation::Icap::Xaction *x = (Adaptation::Icap::Xaction*)data;
- x->noteCommConnected(Comm::OK);
-}
-#endif
-
void Adaptation::Icap::Xaction::closeConnection()
{
if (haveConnection()) {
return false;
}
-#if HARDCODE_DENY_PORTS
- /* These ports are filtered in the default squid.conf, but
- * maybe someone wants them hardcoded... */
- if (foundPort == 7 || foundPort == 9 || foundPort == 19) {
- debugs(23, DBG_CRITICAL, MYNAME << "Deny access to port " << foundPort);
- return false;
- }
-#endif
-
if (stringHasWhitespace(urlpath)) {
debugs(23, 2, "URI has whitespace: {" << rawUrl << "}");
{
if (nonce) {
assert(nonce->references == 0);
-#if UNREACHABLECODE
-
- if (nonce->flags.incache)
- hash_remove_link(digest_nonce_cache, nonce);
-
-#endif
-
assert(!nonce->flags.incache);
safe_free(nonce->key);
}
}
-#if DEBUGSHUTDOWN
- if (digest_nonce_pool) {
- delete digest_nonce_pool;
- digest_nonce_pool = NULL;
- }
-
-#endif
debugs(29, 2, "Nonce cache shutdown");
}
rc = nmasldap_get_password(ld, object_dn, pwd_len, (unsigned char *)pwd);
if (rc == LDAP_SUCCESS) {
-#ifdef DEBUG_PASSWORD
- DEBUG(100,("nmasldap_get_password returned %s for %s\n", pwd, object_dn));
-#endif
DEBUG(5, ("NDS Universal Password retrieved for %s\n", object_dn));
} else {
DEBUG(3, ("NDS Universal Password NOT retrieved for %s\n", object_dn));
if (rc != LDAP_SUCCESS) {
rc = nmasldap_get_simple_pwd(ld, object_dn, *pwd_len, pwd);
if (rc == LDAP_SUCCESS) {
-#ifdef DEBUG_PASSWORD
- DEBUG(100,("nmasldap_get_simple_pwd returned %s for %s\n", pwd, object_dn));
-#endif
DEBUG(5, ("NDS Simple Password retrieved for %s\n", object_dn));
} else {
/* We couldn't get the password */
*var = std::chrono::nanoseconds::zero();
}
-#if UNUSED_CODE
-static void
-dump_size_t(StoreEntry * entry, const char *name, size_t var)
-{
- storeAppendPrintf(entry, "%s %d\n", name, (int) var);
-}
-#endif
-
static void
dump_b_size_t(StoreEntry * entry, const char *name, size_t var)
{
storeAppendPrintf(entry, "%s %d %s\n", name, (int) var, B_BYTES_STR);
}
-#if UNUSED_CODE
-static void
-dump_kb_size_t(StoreEntry * entry, const char *name, size_t var)
-{
- storeAppendPrintf(entry, "%s %d %s\n", name, (int) var, B_KBYTES_STR);
-}
-#endif
-
static void
dump_b_int64_t(StoreEntry * entry, const char *name, int64_t var)
{
storeAppendPrintf(entry, "%s %" PRId64 " %s\n", name, var, B_KBYTES_STR);
}
-#if UNUSED_CODE
-static void
-parse_size_t(size_t * var)
-{
- int i;
- i = GetInteger();
- *var = (size_t) i;
-}
-#endif
-
static void
parse_b_size_t(size_t * var)
{
parseBytesLineSigned(var, B_BYTES_STR);
}
-#if UNUSED_CODE
-static void
-parse_kb_size_t(size_t * var)
-{
- parseBytesLine(var, B_KBYTES_STR);
-}
-#endif
-
static void
parse_b_int64_t(int64_t * var)
{
wordlistAdd(list, token);
}
-#if 0 /* now unused */
-static int
-check_null_wordlist(wordlist * w)
-{
- return w == NULL;
-}
-#endif
-
static int
check_null_acl_access(acl_access * a)
{
#include "CacheManager.h"
#include "comm/Connection.h"
#include "Debug.h"
-#include "errorpage.h"
#include "error/ExceptionErrorDetail.h"
+#include "errorpage.h"
#include "fde.h"
#include "HttpReply.h"
#include "HttpRequest.h"
}
return instance;
}
+
entries.back().cfgLines.push_back(buff);
}
break;
-#if 0
case sEXIT:
assert(0); /* should never get here */
break;
-#endif
}
}
#include <systemd/sd-daemon.h>
#endif
-#if LINGERING_CLOSE
-#define comm_close comm_lingering_close
-#endif
-
/// dials clientListenerConnectionOpened call
class ListeningStartedDialer: public CallDialer, public Ipc::StartListeningCb
{
}
}
-/* A write has completed, what is the next status based on the
- * canonical request data?
- * 1 something is wrong
- * 0 nothing is wrong.
- *
- */
-int
-clientHttpRequestStatus(int fd, ClientHttpRequest const *http)
-{
-#if SIZEOF_INT64_T == 4
- if (http->out.size > 0x7FFF0000) {
- debugs(88, DBG_IMPORTANT, "WARNING: closing FD " << fd << " to prevent out.size counter overflow");
- if (http->getConn())
- debugs(88, DBG_IMPORTANT, "\tclient " << http->getConn()->peer);
- debugs(88, DBG_IMPORTANT, "\treceived " << http->out.size << " bytes");
- debugs(88, DBG_IMPORTANT, "\tURI " << http->log_uri);
- return 1;
- }
-
- if (http->out.offset > 0x7FFF0000) {
- debugs(88, DBG_IMPORTANT, "WARNING: closing FD " << fd < " to prevent out.offset counter overflow");
- if (http->getConn())
- debugs(88, DBG_IMPORTANT, "\tclient " << http->getConn()->peer);
- debugs(88, DBG_IMPORTANT, "\treceived " << http->out.size << " bytes, offset " << http->out.offset);
- debugs(88, DBG_IMPORTANT, "\tURI " << http->log_uri);
- return 1;
- }
-
-#endif
- return 0;
-}
-
/* Preconditions:
* *http is a valid structure.
* fd is either -1, or an open fd.
HttpHeader *hdr = &reply->header;
const bool is_hit = http->logType.isTcpHit();
HttpRequest *request = http->request;
-#if DONT_FILTER_THESE
- /* but you might want to if you run Squid as an HTTP accelerator */
- /* hdr->delById(HDR_ACCEPT_RANGES); */
- hdr->delById(HDR_ETAG);
-#endif
if (is_hit || collapsedRevalidation == crSlave)
hdr->delById(Http::HdrType::SET_COOKIE);
#include "ssl/support.h"
#endif
-#if LINGERING_CLOSE
-#define comm_close comm_lingering_close
-#endif
-
static const char *const crlf = "\r\n";
#if FOLLOW_X_FORWARDED_FOR
ACLFilledChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http);
void clientAclChecklistFill(ACLFilledChecklist &, ClientHttpRequest *);
-int clientHttpRequestStatus(int fd, ClientHttpRequest const *http);
void clientAccessCheck(ClientHttpRequest *);
/* ones that should be elsewhere */
static FTPSM ftpReadMdtm;
static FTPSM ftpSendSize;
static FTPSM ftpReadSize;
-#if 0
-static FTPSM ftpSendEPRT;
-#endif
static FTPSM ftpReadEPRT;
static FTPSM ftpSendPORT;
static FTPSM ftpReadPORT;
ftpRestOrList(ftpState);
}
-#if 0
-static void
-ftpSendEPRT(Ftp::Gateway * ftpState)
-{
- /* check the server control channel is still available */
- if (!ftpState || !ftpState->haveControlChannel("ftpSendEPRT"))
- return;
-
- if (Config.Ftp.epsv_all && ftpState->flags.epsv_all_sent) {
- debugs(9, DBG_IMPORTANT, "FTP does not allow EPRT method after 'EPSV ALL' has been sent.");
- return;
- }
-
- if (!Config.Ftp.eprt) {
- /* Disabled. Switch immediately to attempting old PORT command. */
- debugs(9, 3, "EPRT disabled by local administrator");
- ftpSendPORT(ftpState);
- return;
- }
-
- debugs(9, 3, HERE);
- ftpState->flags.pasv_supported = 0;
-
- ftpOpenListenSocket(ftpState, 0);
- debugs(9, 3, "Listening for FTP data connection with FD " << ftpState->data.conn);
- if (!Comm::IsConnOpen(ftpState->data.conn)) {
- /* XXX Need to set error message */
- ftpFail(ftpState);
- return;
- }
-
- char buf[MAX_IPSTRLEN];
-
- /* RFC 2428 defines EPRT as IPv6 equivalent to IPv4 PORT command. */
- /* Which can be used by EITHER protocol. */
- snprintf(cbuf, CTRL_BUFLEN, "EPRT |%d|%s|%d|\r\n",
- ( ftpState->data.listenConn->local.isIPv6() ? 2 : 1 ),
- ftpState->data.listenConn->local.toStr(buf,MAX_IPSTRLEN),
- ftpState->data.listenConn->local.port() );
-
- ftpState->writeCommand(cbuf);
- ftpState->state = Ftp::Client::SENT_EPRT;
-}
-#endif
-
static void
ftpReadEPRT(Ftp::Gateway * ftpState)
{
}
}
-// XXX: This code has been broken, unused, and untested since 933dd09. Remove.
-#if LINGERING_CLOSE
-static void
-commLingerClose(int fd, void *unused)
-{
- LOCAL_ARRAY(char, buf, 1024);
- int n = FD_READ_METHOD(fd, buf, 1024);
- if (n < 0) {
- int xerrno = errno;
- debugs(5, 3, "FD " << fd << " read: " << xstrerr(xerrno));
- }
- comm_close(fd);
-}
-
-static void
-commLingerTimeout(const FdeCbParams ¶ms)
-{
- debugs(5, 3, "commLingerTimeout: FD " << params.fd);
- comm_close(params.fd);
-}
-
-/*
- * Inspired by apache
- */
-void
-comm_lingering_close(int fd)
-{
- Security::SessionSendGoodbye(fd_table[fd].ssl);
-
- if (shutdown(fd, 1) < 0) {
- comm_close(fd);
- return;
- }
-
- fd_note(fd, "lingering close");
- AsyncCall::Pointer call = commCbCall(5,4, "commLingerTimeout", FdeCbPtrFun(commLingerTimeout, NULL));
-
- debugs(5, 3, HERE << "FD " << fd << " timeout " << timeout);
- assert(fd_table[fd].flags.open);
- if (callback != NULL) {
- typedef FdeCbParams Params;
- Params ¶ms = GetCommParams<Params>(callback);
- params.fd = fd;
- fd_table[fd].timeoutHandler = callback;
- fd_table[fd].timeout = squid_curtime + static_cast<time_t>(10);
- }
-
- Comm::SetSelect(fd, COMM_SELECT_READ, commLingerClose, NULL, 0);
-}
-
-#endif
-
/**
* enable linger with time of 0 so that when the socket is
* closed, TCP generates a RESET
#define comm_close(x) (_comm_close((x), __FILE__, __LINE__))
void old_comm_reset_close(int fd);
void comm_reset_close(const Comm::ConnectionPointer &conn);
-#if LINGERING_CLOSE
-void comm_lingering_close(int fd);
-#endif
int comm_connect_addr(int sock, const Ip::Address &addr);
void comm_init(void);
statCounter.comm_tcp_incoming.count(nevents);
}
-#define DEBUG_FDBITS 0
/* Select on all sockets; call handlers for those that are ready. */
Comm::Flag
Comm::DoSelect(int msec)
int maxindex;
unsigned int k;
int j;
-#if DEBUG_FDBITS
-
- int i;
-#endif
-
fd_mask *fdsp;
fd_mask *pfdsp;
fd_mask tmask;
}
}
-#if DEBUG_FDBITS
- for (i = 0; i < maxfd; ++i) {
- /* Check each open socket for a handler. */
-
- if (fd_table[i].read_handler) {
- assert(FD_ISSET(i, &readfds));
- }
-
- if (fd_table[i].write_handler) {
- assert(FD_ISSET(i, &writefds));
- }
- }
-
-#endif
if (nreadfds + nwritefds == 0) {
assert(shutting_down);
return Comm::SHUTDOWN;
EBIT_CLR(tmask, k); /* this will be done */
-#if DEBUG_FDBITS
-
- debugs(5, 9, "FD " << fd << " bit set for reading");
-
- assert(FD_ISSET(fd, &readfds));
-
-#endif
-
if (fdIsUdpListener(fd)) {
calludp = 1;
continue;
EBIT_CLR(tmask, k); /* this will be done */
-#if DEBUG_FDBITS
-
- debugs(5, 9, "FD " << fd << " bit set for writing");
-
- assert(FD_ISSET(fd, &writefds));
-
-#endif
-
if (fdIsUdpListener(fd)) {
calludp = 1;
continue;
statCounter.comm_tcp_incoming.count(nevents);
}
-#define DEBUG_FDBITS 0
/* Select on all sockets; call handlers for those that are ready. */
Comm::Flag
Comm::DoSelect(int msec)
int pending;
int calldns = 0, calludp = 0, calltcp = 0;
int j;
-#if DEBUG_FDBITS
-
- int i;
-#endif
struct timeval poll_time;
double timeout = current_dtime + (msec / 1000.0);
fde *F;
}
}
-#if DEBUG_FDBITS
- for (i = 0; i < maxfd; ++i) {
- /* Check each open socket for a handler. */
-
- if (fd_table[i].read_handler) {
- assert(FD_ISSET(i, readfds));
- }
-
- if (fd_table[i].write_handler) {
- assert(FD_ISSET(i, writefds));
- }
- }
-
-#endif
if (nreadfds + nwritefds == 0) {
assert(shutting_down);
return Comm::SHUTDOWN;
if (no_bits)
continue;
-#if DEBUG_FDBITS
-
- debugs(5, 9, "FD " << fd << " bit set for reading");
-
- assert(FD_ISSET(fd, readfds));
-
-#endif
-
if (fdIsUdpListener(fd)) {
calludp = 1;
continue;
if (no_bits)
continue;
-#if DEBUG_FDBITS
-
- debugs(5, 9, "FD " << fd << " bit set for writing");
-
- assert(FD_ISSET(fd, writefds));
-
-#endif
-
if (fdIsUdpListener(fd)) {
calludp = 1;
continue;
#endif
}
-#if 0
- // Untested code.
- // Set TOS if needed.
- // To correctly implement TOS values on listening sockets, probably requires
- // more work to inherit TOS values to created connection objects.
- if (conn->tos)
- Ip::Qos::setSockTos(conn, conn->tos)
-#if SO_MARK
- if (conn->nfmark)
- Ip::Qos::setSockNfmark(conn, conn->nfmark);
-#endif
-#endif
-
typedef CommCbMemFunT<Comm::TcpAcceptor, CommCloseCbParams> Dialer;
closer_ = JobCallback(5, 4, Dialer, this, Comm::TcpAcceptor::handleClosure);
comm_add_close_handler(conn->fd, closer_);
}
RR->rdlength = rdlength;
switch (RR->type) {
-#if DNS_CNAME
- case RFC1035_TYPE_CNAME:
-#endif
case RFC1035_TYPE_PTR:
RR->rdata = (char*)xmalloc(RFC1035_MAXHOSTNAMESZ);
rdata_off = *off;
memcpy(buf, &s, sizeof(s));
}
-#if DRIVER
-#include <sys/socket.h>
-int
-main(int argc, char *argv[])
-{
- char input[SQUID_DNS_BUFSZ];
- char buf[SQUID_DNS_BUFSZ];
- char rbuf[SQUID_DNS_BUFSZ];
- size_t sz = SQUID_DNS_BUFSZ;
- unsigned short sid;
- int s;
- int rl;
- struct sockaddr_in S;
- if (3 != argc) {
- fprintf(stderr, "usage: %s ip port\n", argv[0]);
- exit(EXIT_FAILURE);
- }
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
- s = socket(PF_INET, SOCK_DGRAM, 0);
- if (s < 0) {
- perror("socket");
- exit(EXIT_FAILURE);
- }
- memset(&S, '\0', sizeof(S));
- S.sin_family = AF_INET;
- S.sin_port = htons(atoi(argv[2]));
- S.sin_addr.s_addr = inet_addr(argv[1]);
- while (fgets(input, RFC1035_DEFAULT_PACKET_SZ, stdin)) {
- struct in_addr junk;
- strtok(input, "\r\n");
- memset(buf, '\0', RFC1035_DEFAULT_PACKET_SZ);
- sz = RFC1035_DEFAULT_PACKET_SZ;
- if (inet_pton(AF_INET, input, &junk)) {
- sid = rfc1035BuildPTRQuery(junk, buf, &sz);
- } else {
- sid = rfc1035BuildAQuery(input, buf, &sz);
- }
- sendto(s, buf, sz, 0, (struct sockaddr *) &S, sizeof(S));
- do {
- fd_set R;
- struct timeval to;
- FD_ZERO(&R);
- FD_SET(s, &R);
- to.tv_sec = 10;
- to.tv_usec = 0;
- rl = select(s + 1, &R, NULL, NULL, &to);
- } while (0);
- if (rl < 1) {
- printf("TIMEOUT\n");
- continue;
- }
- memset(rbuf, '\0', RFC1035_DEFAULT_PACKET_SZ);
- rl = recv(s, rbuf, RFC1035_DEFAULT_PACKET_SZ, 0);
- {
- unsigned short rid = 0;
- int i;
- int n;
- rfc1035_rr *answers = NULL;
- n = rfc1035AnswersUnpack(rbuf,
- rl,
- &answers,
- &rid);
- if (n < 0) {
- printf("ERROR %d\n", -n);
- } else if (rid != sid) {
- printf("ERROR, ID mismatch (%#hx, %#hx)\n", sid, rid);
- } else {
- printf("%d answers\n", n);
- for (i = 0; i < n; i++) {
- if (answers[i].type == RFC1035_TYPE_A) {
- struct in_addr a;
- char ipa_str[sizeof(a)];
- memcpy(&a, answers[i].rdata, 4);
- printf("A\t%d\t%s\n", answers[i].ttl, inet_ntop(AF_INET,&a,tmp,sizeof(a)));
- } else if (answers[i].type == RFC1035_TYPE_PTR) {
- char ptr[128];
- strncpy(ptr, answers[i].rdata, answers[i].rdlength);
- printf("PTR\t%d\t%s\n", answers[i].ttl, ptr);
- } else {
- fprintf(stderr, "can't print answer type %d\n",
- (int) answers[i].type);
- }
- }
- }
- }
- }
- return EXIT_SUCCESS;
-}
-#endif
-
return rfc3596BuildHostQuery(rev, buf, sz, qid, query, RFC1035_TYPE_PTR, edns_sz);
}
-#if DRIVER
-
-/* driver needs the rfc1035 code _without_ the main() */
-# define main(a,b) rfc1035_main(a,b)
-# include "rfc1035.c"
-# undef main(a,b)
-
-#include <sys/socket.h>
-
-int
-main(int argc, char *argv[])
-{
-#define PACKET_BUFSZ 1024
- char input[PACKET_BUFSZ];
- char buf[PACKET_BUFSZ];
- char rbuf[PACKET_BUFSZ];
- size_t sz = PACKET_BUFSZ;
- unsigned short sid, sidb;
- int s;
- int rl;
- ssize_t edns_max = -1;
-
- struct sockaddr* S;
- int var = 1;
-
- if ( argc < 3 || argc > 4) {
- fprintf(stderr, "usage: %s [-6|-4] ip port\n", argv[0]);
- exit(EXIT_FAILURE);
- }
-
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
-
- if (argv[var][0] == '-') {
- if (argv[var][1] == '4')
- prefer = AF_INET;
- else if (argv[var][1] == '6')
- prefer = AF_INET6;
- else if (argv[var][1] == 'E')
- edns_max = atoi(argv[var++]);
- else {
- fprintf(stderr, "usage: %s [-6|-4] [-E packet-size] ip port\n", argv[0]);
- fprintf(stderr, " EDNS packets my be up to %d\n", PACKET_BUFSZ);
- exit(EXIT_FAILURE);
- }
-
- var++;
- }
-
- s = socket(PF_INET, SOCK_DGRAM, 0);
-
- if (s < 0) {
- perror("socket");
- exit(EXIT_FAILURE);
- }
-
- memset(&S, '\0', sizeof(S));
-
- if (prefer == 6) {
- S = (struct sockaddr *) new sockaddr_in6;
- memset(S,0,sizeof(struct sockaddr_in6));
-
- ((struct sockaddr_in6 *)S)->sin6_family = AF_INET6;
- ((struct sockaddr_in6 *)S)->sin6_port = htons(atoi(argv[var+1]));
-
- if ( ! inet_pton(AF_INET6, argv[var], &((struct sockaddr_in6 *)S)->sin6_addr.s_addr) ) {
- perror("listen address");
- exit(EXIT_FAILURE);
- }
-
- s = socket(PF_INET6, SOCK_DGRAM, 0);
- } else {
- S = (struct sockaddr *) new sockaddr_in;
- memset(S,0,sizeof(struct sockaddr_in));
-
- ((struct sockaddr_in *)S)->sin_family = AF_INET;
- ((struct sockaddr_in *)S)->sin_port = htons(atoi(argv[var+1]));
-
- if ( ! inet_pton(AF_INET, argv[var], &((struct sockaddr_in *)S)->sin_addr.s_addr) ) {
- perror("listen address");
- exit(EXIT_FAILURE);
- }
- }
-
- while (fgets(input, PACKET_BUFSZ, stdin))
- {
-
- struct in6_addr junk6;
-
- struct in_addr junk4;
- strtok(input, "\r\n");
- memset(buf, '\0', PACKET_BUFSZ);
- sz = PACKET_BUFSZ;
-
- if (inet_pton(AF_INET6, input, &junk6)) {
- sid = rfc1035BuildPTRQuery6(junk6, buf, &sz, edns_max);
- sidb=0;
- } else if (inet_pton(AF_INET, input, &junk4)) {
- sid = rfc1035BuildPTRQuery4(junk4, buf, &sz, edns_max);
- sidb=0;
- } else {
- sid = rfc1035BuildAAAAQuery(input, buf, &sz, edns_max);
- sidb = rfc1035BuildAQuery(input, buf, &sz, edns_max);
- }
-
- sendto(s, buf, sz, 0, S, sizeof(*S));
-
- do {
- fd_set R;
-
- struct timeval to;
- FD_ZERO(&R);
- FD_SET(s, &R);
- to.tv_sec = 10;
- to.tv_usec = 0;
- rl = select(s + 1, &R, NULL, NULL, &to);
- } while (0);
-
- if (rl < 1) {
- printf("TIMEOUT\n");
- continue;
- }
-
- memset(rbuf, '\0', PACKET_BUFSZ);
- rl = recv(s, rbuf, PACKET_BUFSZ, 0);
- {
- unsigned short rid = 0;
- int i;
- int n;
- rfc1035_rr *answers = NULL;
- n = rfc1035AnswersUnpack(rbuf,
- rl,
- &answers,
- &rid);
-
- if (n < 0) {
- printf("ERROR %d\n", -n);
- } else if (rid != sid && rid != sidb) {
- printf("ERROR, ID mismatch (%#hx, %#hx)\n", sid, rid);
- printf("ERROR, ID mismatch (%#hx, %#hx)\n", sidb, rid);
- } else {
- printf("%d answers\n", n);
-
- for (i = 0; i < n; i++) {
- if (answers[i].type == RFC1035_TYPE_A) {
-
- struct in_addr a;
- char tmp[16];
- memcpy(&a, answers[i].rdata, 4);
- printf("A\t%d\t%s\n", answers[i].ttl, inet_ntop(AF_INET,&a,tmp,16));
- } else if (answers[i].type == RFC1035_TYPE_AAAA) {
-
- struct in6_addr a;
- char tmp[INET6_ADDRSTRLEN];
- memcpy(&a, answers[i].rdata, 16);
- printf("AAAA\t%d\t%s\n", answers[i].ttl, inet_ntop(AF_INET6,&a,tmp,sizeof(tmp)));
- } else if (answers[i].type == RFC1035_TYPE_PTR) {
- char ptr[RFC1035_MAXHOSTNAMESZ];
- strncpy(ptr, answers[i].rdata, answers[i].rdlength);
- printf("PTR\t%d\t%s\n", answers[i].ttl, ptr);
- } else if (answers[i].type == RFC1035_TYPE_CNAME) {
- char ptr[RFC1035_MAXHOSTNAMESZ];
- strncpy(ptr, answers[i].rdata, answers[i].rdlength);
- printf("CNAME\t%d\t%s\n", answers[i].ttl, ptr);
- } else {
- fprintf(stderr, "can't print answer type %d\n",
- (int) answers[i].type);
- }
- }
- }
- }
- }
-
- return EXIT_SUCCESS;
-}
-
-#endif
-
} else
flags.oktosend = 1;
-#if 0
-
- if (!flags.oktosend) {
-
- fatal("ESIContext::send: Not OK to send.\n");
- return 0;
- }
-
-#endif
-
if (!(rep || (outbound.getRaw() &&
outbound->len && (outbound_offset <= outbound->len)))) {
debugs(86, 5, "ESIContext::send: Nothing to send.");
return;
}
- /* after the write to the user occurs, (ie here, or in a callback)
- * we call */
- if (clientHttpRequestStatus(-1, http)) {
- /* TODO: Does thisNode if block leak htto ? */
- /* XXX when reviewing ESI this is the first place to look */
- node->data = NULL;
- esiStream->finished = 1;
- esiStream->include->includeFail (esiStream);
- return;
- };
-
switch (clientStreamStatus (node, http)) {
case STREAM_UNPLANNED_COMPLETE: /* fallthru ok */
"index corruption. Forcing a full cache index rebuild. " <<
"See Squid bug #3441.");
return NULL;
-
-#if UNUSED_CODE
- // baseline
- // 32-bit sfileno
- // native time_t (hopefully 64-bit)
- // 64-bit file size
- if (header.record_size == sizeof(StoreSwapLogData)) {
- debugs(47, DBG_IMPORTANT, "Version 1 of swap file with LFS support detected... ");
- return new UFSSwapLogParser_v1(fp);
- }
-
- // which means we have a 3-way grid of permutations to import (yuck!)
- // 1) sfileno 32-bit / 64-bit (64-bit was broken)
- // 2) time_t 32-bit / 64-bit
- // 3) size_t 32-bit / 64-bit (32-bit was pre-LFS)
-
- // 32-bit systems...
- // only LFS (size_t) differs from baseline
- if (header.record_size == sizeof(struct UFSSwapLogParser_v1_32bs::StoreSwapLogDataOld)) {
- debugs(47, DBG_IMPORTANT, "Version 1 (32-bit) swap file without LFS support detected... ");
- return new UFSSwapLogParser_v1_32bs(fp);
- }
- // LFS (size_t) and timestamps (time_t) differs from baseline
- if (header.record_size == sizeof(struct UFSSwapLogParser_v1_32bst::StoreSwapLogDataOld)) {
- debugs(47, DBG_IMPORTANT, "Version 1 (32-bit) swap file with short timestamps and without LFS support detected... ");
- return new UFSSwapLogParser_v1_32bst(fp);
- }
- // No downgrade for 64-bit timestamps to 32-bit.
-
- // 64-bit systems
- // sfileno was 64-bit for a some builds
- if (header.record_size == sizeof(struct UFSSwapLogParser_v1_64bfn::StoreSwapLogDataOld)) {
- debugs(47, DBG_IMPORTANT, "Version 1 (64-bit) swap file with broken sfileno detected... ");
- return new UFSSwapLogParser_v1_64bfn(fp);
- }
- // NP: 64-bit system with 32-bit size_t/time_t are not handled.
-
- debugs(47, DBG_IMPORTANT, "WARNING: The swap file has wrong format!... ");
- debugs(47, DBG_IMPORTANT, "NOTE: Cannot safely downgrade caches to short (32-bit) timestamps.");
- return NULL;
-#endif
}
if (header.version >= 2) {
*/
assert(F->write_handler == NULL);
-#if CALL_FSYNC_BEFORE_CLOSE
-
- fsync(fd);
-
-#endif
-
close(fd);
debugs(6, F->flags.close_request ? 2 : 5, "file_close: FD " << fd << " really closing");
#endif
default:
-#if QUESTIONABLE
- /*
- * Any 2xx response should eject previously cached entities...
- */
-
- if (status >= 200 && status < 300)
- remove = 1;
-
-#endif
-
break;
}
if (!cc)
cc = new HttpHdrCc();
-#if 0 /* see bug 2330 */
- /* Set no-cache if determined needed but not found */
- if (request->flags.nocache)
- EBIT_SET(cc->mask, HttpHdrCcType::CC_NO_CACHE);
-#endif
-
/* Add max-age only without no-cache */
if (!cc->hasMaxAge() && !cc->hasNoCache()) {
// XXX: performance regression. c_str() reallocates
};
const class HeaderTableRecord *
-HttpHeaderHashTable::lookup (const char *str, size_t len)
+ HttpHeaderHashTable::lookup (const char *str, size_t len)
{
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
http->out.size += size;
- if (clientHttpRequestStatus(clientConnection->fd, http)) {
- initiateClose("failure or true request status");
- /* Do we leak here ? */
- return;
- }
-
switch (socketState()) {
case STREAM_NONE:
s = write(ll->fd, (char const *) buf, len);
fd_bytes(ll->fd, s, FD_WRITE);
#if 0
+ // TODO: Enable after polishing to properly log these errors.
if (s < 0) {
int xerrno = errno;
debugs(1, DBG_IMPORTANT, "logfile (udp): got errno (" << errno << "):" << xstrerr(xerrno));
new_pool_limit = -1;
}
-#if 0
- /** \par
- * DPW 2007-04-12
- * No debugging here please because this method is called before
- * the debug log is configured and we'll get the message on
- * stderr when doing things like 'squid -k reconfigure'
- */
- if (MemPools::GetInstance().idleLimit() > new_pool_limit)
- debugs(13, DBG_IMPORTANT, "Shrinking idle mem pools to "<< std::setprecision(3) << toMB(new_pool_limit) << " MB");
-#endif
-
MemPools::GetInstance().setIdleLimit(new_pool_limit);
}
if (pb > pa)
return 1;
-#if 0
- // use this to sort on In Use high(hrs)
- //
- if (A->meter->inuse.peakTime() > B->meter->inuse.peakTime())
- return -1;
-
- if (B->meter->inuse.peakTime() > A->meter->inuse.peakTime())
- return 1;
-
-#endif
-
return 0;
}
peerDigestSetCheck(pd, 0); /* check asap */
}
-/* currently we do not have a reason to disable without destroying */
-#if FUTURE_CODE
-/* disables peer for good */
-static void
-peerDigestDisable(PeerDigest * pd)
-{
- debugs(72, 2, "peerDigestDisable: peer " << pd->host.buf() << " disabled for good");
- pd->times.disabled = squid_curtime;
- pd->times.next_check = -1; /* never */
- pd->flags.usable = 0;
-
- delete pd->cd
- pd->cd = nullptr;
-
- /* we do not destroy the pd itself to preserve its "history" and stats */
-}
-
-#endif
-
/* increment retry delay [after an unsuccessful attempt] */
static time_t
peerDigestIncDelay(const PeerDigest * pd)
if (!reason) {
if (!(pd = fetch->pd))
reason = "peer digest disappeared?!";
-
-#if DONT /* WHY NOT? /HNO */
-
- else if (!cbdataReferenceValid(pd))
- reason = "invalidated peer digest?!";
-
-#endif
-
else
host = pd->host;
}
void
SBuf::clear()
{
-#if 0
- //enabling this code path, the store will be freed and reinitialized
- store_ = GetStorePrototype(); //uncomment to actually free storage upon clear()
-#else
- //enabling this code path, we try to release the store without deallocating it.
- // will be lazily reallocated if needed.
if (store_->LockCount() == 1)
store_->clear();
-#endif
len_ = 0;
off_ = 0;
++stats.clear;
auto session = fd_table[fd].ssl.get();
debugs(83, 3, "started for session=" << (void*)session);
-#if DONT_DO_THIS && USE_OPENSSL
- if (!SSL_is_init_finished(session)) {
- errno = ENOTCONN;
- return -1;
- }
-#endif
-
#if USE_OPENSSL
int i = SSL_read(session, buf, len);
#elif USE_GNUTLS
#include "comm.h"
#include "StoreSearch.h"
-#define DEBUG_OPENFD 1
-
typedef int STOBJFLT(const StoreEntry *);
class StatObjectsState
static double statCPUUsage(int minutes);
static OBJH stat_objects_get;
static OBJH stat_vmobjects_get;
-#if DEBUG_OPENFD
static OBJH statOpenfdObj;
-#endif
static EVH statObjects;
static OBJH statCountersDump;
static OBJH statPeerSelect;
statObjectsStart(sentry, statObjectsVmFilter);
}
-#if DEBUG_OPENFD
static int
statObjectsOpenfdFilter(const StoreEntry * e)
{
statObjectsStart(sentry, statObjectsOpenfdFilter);
}
-#endif
-
#if XMALLOC_STATISTICS
static void
info_get_mallstat(int size, int number, int oldnum, void *data)
"Active Cached Usernames",
Auth::User::CredentialsCacheStats, 0, 1);
#endif
-#if DEBUG_OPENFD
Mgr::RegisterAction("openfd_objects", "Objects with Swapout files open",
statOpenfdObj, 0, 0);
-#endif
#if STAT_GRAPHS
Mgr::RegisterAction("graph_variables", "Display cache metrics graphically",
statGraphDump, 0, 1);
*
* If RELEASE_REQUEST is set, setPublicKey() should not be called.
*/
-#if MORE_DEBUG_OUTPUT
-
- if (EBIT_TEST(flags, RELEASE_REQUEST))
- debugs(20, DBG_IMPORTANT, "assertion failed: RELEASE key " << key << ", url " << mem_obj->url);
-
-#endif
assert(!EBIT_TEST(flags, RELEASE_REQUEST));
struct _store_check_cachable_hist {
struct {
- int non_get;
int not_entry_cachable;
int wrong_content_length;
int too_big;
return 0; // avoid rerequesting release below
}
-#if CACHE_ALL_METHODS
-
- if (mem_obj->method != Http::METHOD_GET) {
- debugs(20, 2, "StoreEntry::checkCachable: NO: non-GET method");
- ++store_check_cachable_hist.no.non_get;
- } else
-#endif
- if (store_status == STORE_OK && EBIT_TEST(flags, ENTRY_BAD_LENGTH)) {
- debugs(20, 2, "StoreEntry::checkCachable: NO: wrong content-length");
- ++store_check_cachable_hist.no.wrong_content_length;
- } else if (!mem_obj) {
- // XXX: In bug 4131, we forgetHit() without mem_obj, so we need
- // this segfault protection, but how can we get such a HIT?
- debugs(20, 2, "StoreEntry::checkCachable: NO: missing parts: " << *this);
- ++store_check_cachable_hist.no.missing_parts;
- } else if (checkTooBig()) {
- debugs(20, 2, "StoreEntry::checkCachable: NO: too big");
- ++store_check_cachable_hist.no.too_big;
- } else if (checkTooSmall()) {
- debugs(20, 2, "StoreEntry::checkCachable: NO: too small");
- ++store_check_cachable_hist.no.too_small;
- } else if (EBIT_TEST(flags, KEY_PRIVATE)) {
- debugs(20, 3, "StoreEntry::checkCachable: NO: private key");
- ++store_check_cachable_hist.no.private_key;
- } else if (hasDisk()) {
- /*
- * the remaining cases are only relevant if we haven't
- * started swapping out the object yet.
- */
- return 1;
- } else if (storeTooManyDiskFilesOpen()) {
- debugs(20, 2, "StoreEntry::checkCachable: NO: too many disk files open");
- ++store_check_cachable_hist.no.too_many_open_files;
- } else if (fdNFree() < RESERVED_FD) {
- debugs(20, 2, "StoreEntry::checkCachable: NO: too many FD's open");
- ++store_check_cachable_hist.no.too_many_open_fds;
- } else {
- ++store_check_cachable_hist.yes.Default;
- return 1;
- }
+ if (store_status == STORE_OK && EBIT_TEST(flags, ENTRY_BAD_LENGTH)) {
+ debugs(20, 2, "StoreEntry::checkCachable: NO: wrong content-length");
+ ++store_check_cachable_hist.no.wrong_content_length;
+ } else if (!mem_obj) {
+ // XXX: In bug 4131, we forgetHit() without mem_obj, so we need
+ // this segfault protection, but how can we get such a HIT?
+ debugs(20, 2, "StoreEntry::checkCachable: NO: missing parts: " << *this);
+ ++store_check_cachable_hist.no.missing_parts;
+ } else if (checkTooBig()) {
+ debugs(20, 2, "StoreEntry::checkCachable: NO: too big");
+ ++store_check_cachable_hist.no.too_big;
+ } else if (checkTooSmall()) {
+ debugs(20, 2, "StoreEntry::checkCachable: NO: too small");
+ ++store_check_cachable_hist.no.too_small;
+ } else if (EBIT_TEST(flags, KEY_PRIVATE)) {
+ debugs(20, 3, "StoreEntry::checkCachable: NO: private key");
+ ++store_check_cachable_hist.no.private_key;
+ } else if (hasDisk()) {
+ /*
+ * the remaining cases are only relevant if we haven't
+ * started swapping out the object yet.
+ */
+ return 1;
+ } else if (storeTooManyDiskFilesOpen()) {
+ debugs(20, 2, "StoreEntry::checkCachable: NO: too many disk files open");
+ ++store_check_cachable_hist.no.too_many_open_files;
+ } else if (fdNFree() < RESERVED_FD) {
+ debugs(20, 2, "StoreEntry::checkCachable: NO: too many FD's open");
+ ++store_check_cachable_hist.no.too_many_open_fds;
+ } else {
+ ++store_check_cachable_hist.yes.Default;
+ return 1;
+ }
releaseRequest();
return 0;
storeCheckCachableStats(StoreEntry *sentry)
{
storeAppendPrintf(sentry, "Category\t Count\n");
-
-#if CACHE_ALL_METHODS
-
- storeAppendPrintf(sentry, "no.non_get\t%d\n",
- store_check_cachable_hist.no.non_get);
-#endif
-
storeAppendPrintf(sentry, "no.not_entry_cachable\t%d\n",
store_check_cachable_hist.no.not_entry_cachable);
storeAppendPrintf(sentry, "no.wrong_content_length\t%d\n",
return NULL; /* NOTREACHED */
}
-#if 0
-void
-storeSwapFileNumberSet(StoreEntry * e, sfileno filn)
-{
- if (e->swap_file_number == filn)
- return;
-
- if (filn < 0) {
- assert(-1 == filn);
- storeDirMapBitReset(e->swap_file_number);
- storeDirLRUDelete(e);
- e->swap_file_number = -1;
- } else {
- assert(-1 == e->swap_file_number);
- storeDirMapBitSet(e->swap_file_number = filn);
- storeDirLRUAdd(e);
- }
-}
-
-#endif
-
void
StoreEntry::storeErrorResponse(HttpReply *reply)
{
#if STORE_CLIENT_LIST_DEBUG
assert(sc == storeClientListSearch(e->mem_obj, data));
#endif
-#ifndef SILLY_CODE
assert(sc);
-#endif
-
assert(sc->entry == e);
-#if SILLY_CODE
-
- if (sc == NULL)
- return 0;
-
-#endif
if (!sc->_callback.pending())
return 0;
return sbuf.str();
}
-#if 0
-/// helper function to convert SBuf position to a human-friendly string
-inline std::string
-PosToString(const SBuf::size_type pos)
-{
- return pos == SBuf::npos ? std::string("npos") : AnyToString(pos);
-}
-#endif
-
/// helper function to convert std::string position to a human-friendly string
inline std::string
PosToString(const std::string::size_type pos)
void _comm_close(int fd, char const *file, int line) STUB
void old_comm_reset_close(int fd) STUB
void comm_reset_close(const Comm::ConnectionPointer &conn) STUB
-#if LINGERING_CLOSE
-void comm_lingering_close(int fd) STUB
-#endif
int comm_connect_addr(int sock, const Ip::Address &addr) STUB_RETVAL(-1)
void comm_init(void) STUB
void comm_exit(void) STUB
input.clear();
}
-#if 0
- // too-long method (over 16 bytes)
- {
- input.append("HELLOSTRANGEWORLD / HTTP/1.1\r\n", 31);
- struct resultSet expect = {
- .parsed = false,
- .needsMore = false,
- .parserState = Http1::HTTP_PARSE_DONE,
- .status = Http::scNotImplemented,
- .suffixSz = input.length(),
- .method = HttpRequestMethod(),
- .uri = NULL,
- .version = AnyP::ProtocolVersion()
- };
- output.clear();
- testResults(__LINE__, input, output, expect);
- input.clear();
- }
-#endif
-
// method-only
{
input.append("A\n", 2);
anIP.getAddrInfo(ipval);
-#if 0
- /* display a byte-by-byte hex comparison of the addr cores */
- unsigned int *p;
- p = (unsigned int*)expect;
- printf("\nSYS-ADDRINFO: %2x %2x %2x %2x %2x %2x",
- p[0],p[1],p[2],p[3],p[4],p[5]);
-
- p = (unsigned int*)ipval;
- printf("\nSQD-ADDRINFO: %2x %2x %2x %2x %2x %2x",
- p[0],p[1],p[2],p[3],p[4],p[5] );
- printf("\n");
-#endif /*0*/
-
// check the addrinfo object core. (BUT not the two ptrs at the tail)
// details
CPPUNIT_ASSERT_EQUAL( expect->ai_flags, ipval->ai_flags );
// check the sockaddr it points to.
CPPUNIT_ASSERT_EQUAL( expect->ai_addrlen, ipval->ai_addrlen );
-#if 0
- printf("sizeof IN(%d), IN6(%d), STORAGE(%d), \n",
- sizeof(struct sockaddr_in), sizeof(struct sockaddr_in6), sizeof(struct sockaddr_storage));
-
- p = (unsigned int*)(expect->ai_addr);
- printf("\nSYS-ADDR: (%d) {%d} %x %x %x %x %x %x %x %x ...",
- expect->ai_addrlen, sizeof(*p),
- p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7] );
-
- p = (unsigned int*)(ipval->ai_addr);
- printf("\nSQD-ADDR: (%d) {%d} %x %x %x %x %x %x %x %x ...",
- ipval->ai_addrlen, sizeof(*p),
- p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7] );
- printf("\n");
-#if HAVE_SS_LEN_IN_SS
- printf("\nSYS SS_LEN=%d\nSQD SS_LEN=%d\n",((struct sockaddr_storage*)expect->ai_addr)->ss_len,
- ((struct sockaddr_storage*)ipval->ai_addr)->ss_len );
-#endif
-#endif /*0*/
-
#if HAVE_SS_LEN_IN_SS
CPPUNIT_ASSERT_EQUAL( ((struct sockaddr_storage*)expect->ai_addr)->ss_len,
((struct sockaddr_storage*)ipval->ai_addr)->ss_len );
CPPUNIT_ASSERT_EQUAL(false, search->error());
CPPUNIT_ASSERT_EQUAL(false, search->isDone());
CPPUNIT_ASSERT_EQUAL(static_cast<StoreEntry *>(NULL), search->currentItem());
-#if 0
-
- CPPUNIT_ASSERT_EQUAL(false, search->next());
-#endif
/* trigger a callback */
cbcalled = false;
CPPUNIT_ASSERT_EQUAL(false, search->error());
CPPUNIT_ASSERT_EQUAL(false, search->isDone());
CPPUNIT_ASSERT_EQUAL(static_cast<StoreEntry *>(NULL), search->currentItem());
-#if 0
-
- CPPUNIT_ASSERT_EQUAL(false, search->next());
-#endif
/* trigger a callback */
cbcalled = false;
*/
StoreSearchPointer search = Store::Root().search(); /* search for everything in the store */
- /* nothing should be immediately available */
-#if 0
-
- CPPUNIT_ASSERT_EQUAL(false, search->next());
-#endif
-
CPPUNIT_ASSERT_EQUAL(false, search->error());
CPPUNIT_ASSERT_EQUAL(false, search->isDone());
CPPUNIT_ASSERT_EQUAL(static_cast<StoreEntry *>(NULL), search->currentItem());
CPPUNIT_TEST_SUITE_REGISTRATION( testUriScheme );
-#if 0
-/*
- * We should be able to make an HttpRequestMethod straight from a string.
- */
-void
-testHttpRequestMethod::testConstructCharStart()
-{
- /* parse an empty string -> METHOD_NONE */
- CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL));
- /* parsing a literal should work */
- CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL));
-}
-
-/*
- * We can also parse precise ranges of characters
- */
-void
-testHttpRequestMethod::testConstructCharStartEnd()
-{
- char const * buffer;
- /* parse an empty string -> METHOD_NONE */
- CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL, NULL));
- /* parsing a literal should work */
- CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL));
- /* parsing with an explicit end should work */
- buffer = "POSTPLUS";
- CPPUNIT_ASSERT(METHOD_POST == HttpRequestMethod(buffer, buffer + 4));
-}
-
-#endif
-
/*
* we should be able to assign a protocol_t to a AnyP::UriScheme for ease
* of code conversion
CPPUNIT_TEST( testAssignFromprotocol_t );
CPPUNIT_TEST( testCastToprotocol_t );
CPPUNIT_TEST( testConstructprotocol_t );
-#if 0
-
- CPPUNIT_TEST( testConstructCharStart );
- CPPUNIT_TEST( testConstructCharStartEnd );
-#endif
-
CPPUNIT_TEST( testDefaultConstructor );
CPPUNIT_TEST( testEqualprotocol_t );
CPPUNIT_TEST( testNotEqualprotocol_t );
void testAssignFromprotocol_t();
void testCastToprotocol_t();
void testConstructprotocol_t();
-#if 0
-
- void testConstructCharStart();
- void testConstructCharStartEnd();
-#endif
-
void testC_str();
void testDefaultConstructor();
void testEqualprotocol_t();
while (strlen (expressions[i])) {
int result = ESIExpression::Evaluate (expressions[i]);
-#if VERBOSEDEBUG
-
- printf("Expr '%s' = '%s' (expected %s)\n", expressions[i],
- result ? "true" : "false",
- results[i] ? "true" : "false");
-#endif
if (result != results[i])
return 1;
void
request_done(struct _r *r)
{
-#if 0
- fprintf(stderr, "DONE: %s, (%d+%d)\n",
- r->url,
- r->hdr_length,
- r->content_length);
-#endif
if (r->content_length != r->bytes_read)
fprintf(stderr, "ERROR! Short reply, expected %d bytes got %d\n",
r->content_length, r->bytes_read);
}
/* Process headers */
if (r->hdr_length == 0 && (end = mime_headers_end(r->reply_hdrs)) != NULL) {
-#if 0
- fprintf(stderr, "FOUND EOH FOR %s\n", r->url);
- */
-#endif
r->hdr_length = end - r->reply_hdrs;
-#if 0
- fprintf(stderr, "HDR_LENGTH = %d\n", r->hdr_length);
-#endif
/* "unread" any body contents received */
blen = r->hdr_offset - r->hdr_length;
assert(blen >= 0);
*t = '\0';
port = (unsigned short) atoi(t + 1);
}
-#if 0
- if ((int) port != 80)
- return 0;
-#endif
t = strchr(url + 7, '/');
strncpy(path, (t ? t : "/"), URL_BUF_SZ);
memset(&S, '\0', sizeof(S));
char **args = argv;
while (argc > 1 && args[1][0] == '-') {
-// const char *value = "";
char option = args[1][1];
switch (option) {
case 'd':
debug_enabled = 1;
break;
default:
-#if 0 // unused for now.
- if (strlen(args[1]) > 2) {
- value = args[1] + 2;
- } else if (argc > 2) {
- value = args[2];
- ++args;
- --argc;
- } else
- value = "";
-#endif
break;
}
++args;
if (fp == NULL) {
#ifdef CACHEMGR_HOSTNAME_DEFINED
-
+ // TODO: simplify and maybe get rid of CACHEMGR_HOSTNAME altogether
if (strcmp(hostname, CACHEMGR_HOSTNAME) == 0 && port == CACHE_HTTP_PORT)
return 1;
unsigned long result = strtoul( arg, &errstr, 0 );
if ( result < 65536 && errstr != arg ) return htons(result);
-#if 0
- // one last try, test for a symbolical service name
- struct servent* service = getservbyname( arg, "tcp" );
- return service ? service->s_port : -1;
-#else
return -1;
-#endif
}
void
(SigFunc*) old.sa_handler;
}
-SIGRETTYPE
+void
sigChild( int signo )
// purpose: supply ad hoc child handler with output on stderr
// paramtr: signo (IN): == SIGCHLD
}
}
errno = saveerr;
-
-#if SIGRETTYPE != void
- return 0;
-#endif
}
// File: signal.hh
// Date: Sat Feb 28 1998
// Compiler: gcc 2.7.2.x series
-//
+//
// Books: W. Richard Steven, "Advanced Programming in the UNIX Environment",
// Addison-Wesley, 1992.
-//
+//
// (c) 1998 Lehrgebiet Rechnernetze und Verteilte Systeme
// Universit?t Hannover, Germany
//
#endif
#endif /* __cplusplus */
-#if 1 // so far, all systems I know use void
-# define SIGRETTYPE void
-#else
-# define SIGRETTYPE int
-#endif
-
#if defined(SUNOS) && defined(SUN)
# define SIGPARAM void
#else // SOLARIS, LINUX, IRIX, AIX, SINIXY
#endif
extern "C" {
- typedef SIGRETTYPE SigFunc( SIGPARAM );
+ typedef void SigFunc( SIGPARAM );
}
SigFunc*
// doInterrupt (IN): interrupted system calls wanted!
// returns: the old signal handler, or SIG_ERR in case of error.
-SIGRETTYPE
+void
sigChild( int signo );
// purpose: supply ad hoc child handler with output on stderr
// paramtr: signo (IN): == SIGCHLD