Response.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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/* DEBUG: section 16 Cache Manager API */
10
11#include "squid.h"
12#include "base/TextException.h"
13#include "CacheManager.h"
14#include "ipc/Messages.h"
15#include "ipc/RequestId.h"
16#include "ipc/TypedMsgHdr.h"
17#include "mgr/ActionCreator.h"
18#include "mgr/ActionProfile.h"
19#include "mgr/Response.h"
20
21Mgr::Response::Response(const Ipc::RequestId aRequestId, const Action::Pointer anAction):
22 Ipc::Response(aRequestId), action(anAction)
23{
24 Must(!action || action->name()); // if there is an action, it must be named
25}
26
28{
30 msg.getPod(requestId);
31 Must(requestId != 0);
32
33 if (msg.hasMoreData()) {
34 String actionName;
35 msg.getString(actionName);
37 Must(hasAction());
38 action->unpack(msg);
39 }
40}
41
42void
44{
45 Must(requestId != 0);
47 msg.putPod(requestId);
48 if (hasAction()) {
49 msg.putString(action->name());
50 action->pack(msg);
51 }
52}
53
56{
57 return new Response(*this);
58}
59
60bool
62{
63 return action != nullptr;
64}
65
66const Mgr::Action&
68{
69 Must(hasAction());
70 return *action;
71}
72
#define Must(condition)
Definition: TextException.h:75
static CacheManager * GetInstance()
Mgr::Action::Pointer createNamedAction(const char *actionName)
Response()=default
recipient's constructor
struct msghdr with a known type, fixed-size I/O and control buffers
Definition: TypedMsgHdr.h:35
void putString(const String &s)
store variable-length string
Definition: TypedMsgHdr.cc:143
bool hasMoreData() const
returns true if there is data to extract; handy for optional parts
Definition: TypedMsgHdr.h:66
void getPod(Pod &pod) const
load POD
Definition: TypedMsgHdr.h:118
void getString(String &s) const
load variable-length string
Definition: TypedMsgHdr.cc:125
void checkType(int aType) const
Definition: TypedMsgHdr.cc:94
void putPod(const Pod &pod)
store POD
Definition: TypedMsgHdr.h:126
void setType(int aType)
sets message type; use MessageType enum
Definition: TypedMsgHdr.cc:100
Ipc::Response::Pointer clone() const override
returns a copy of this
Definition: Response.cc:55
void pack(Ipc::TypedMsgHdr &msg) const override
prepare for sendmsg()
Definition: Response.cc:43
bool hasAction() const
whether response contain action object
Definition: Response.cc:61
const Action & getAction() const
returns action object
Definition: Response.cc:67
Action::Pointer action
action relating to response
Definition: Response.h:39
char const * termedBuf() const
Definition: SquidString.h:92
Definition: IpcIoFile.h:24
@ mtCacheMgrResponse
Definition: Messages.h:36
static bool action(int fd, size_t metasize, const char *fn, const char *url, const SquidMetaList &meta)
Definition: purge.cc:315

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors