]> git.ipfire.org Git - thirdparty/squid.git/blame - src/helper/Request.h
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / helper / Request.h
CommitLineData
24438ec5 1/*
77b1029d 2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
24438ec5
AJ
3 *
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.
7 */
8
9#ifndef _SQUID_SRC_HELPER_REQUEST_H
10#define _SQUID_SRC_HELPER_REQUEST_H
11
12#include "helper/forward.h"
32fd6d8a 13#include "SquidTime.h"
24438ec5
AJ
14
15namespace Helper
16{
17
18class Request
19{
741c2986
AJ
20 MEMPROXY_CLASS(Helper::Request);
21
24438ec5
AJ
22public:
23 Request(HLPCB *c, void *d, const char *b) :
f53969cc
SM
24 buf(b ? xstrdup(b) : NULL),
25 callback(c),
26 data(cbdataReference(d)),
27 placeholder(b == NULL),
28 Id(0),
29 retries(0)
4579a6d0
AJ
30 {
31 memset(&dispatch_time, 0, sizeof(dispatch_time));
32 }
33
24438ec5
AJ
34 ~Request() {
35 cbdataReferenceDone(data);
36 xfree(buf);
37 }
38
24438ec5
AJ
39 char *buf;
40 HLPCB *callback;
41 void *data;
42
43 int placeholder; /* if 1, this is a dummy request waiting for a stateful helper to become available */
44 struct timeval dispatch_time;
32fd6d8a
CT
45 uint64_t Id;
46 /**
47 * A helper may configured to retry timed out requests or on BH replies.
48 * We attempt to recover by trying the lookup again, but limit the
49 * number of retries to prevent lag and lockups.
50 * This tracks the number of previous failures for the request.
51 */
52 int retries;
53 bool timedOut(time_t timeout) {return (squid_curtime - dispatch_time.tv_sec) > timeout;}
24438ec5
AJ
54};
55
56} // namespace Helper
57
24438ec5 58#endif /* _SQUID_SRC_HELPER_REQUEST_H */
f53969cc 59