const char *req_result; /**< text status of the last request */
struct {
- unsigned int needed:1; /**< there were requests for this digest */
- unsigned int usable:1; /**< can be used for lookups */
- unsigned int requested:1; /**< in process of receiving [fresh] digest */
+ bool needed; /**< there were requests for this digest */
+ bool usable; /**< can be used for lookups */
+ bool requested; /**< in process of receiving [fresh] digest */
} flags;
struct {
RefreshPattern *next;
struct {
- unsigned int icase:1;
- unsigned int refresh_ims:1;
- unsigned int store_stale:1;
+ bool icase;
+ bool refresh_ims;
+ bool store_stale;
#if USE_HTTP_VIOLATIONS
- unsigned int override_expire:1;
- unsigned int override_lastmod:1;
- unsigned int reload_into_ims:1;
- unsigned int ignore_reload:1;
- unsigned int ignore_no_store:1;
- unsigned int ignore_must_revalidate:1;
- unsigned int ignore_private:1;
- unsigned int ignore_auth:1;
+ bool override_expire;
+ bool override_lastmod;
+ bool reload_into_ims;
+ bool ignore_reload;
+ bool ignore_no_store;
+ bool ignore_must_revalidate;
+ bool ignore_private;
+ bool ignore_auth;
#endif
} flags;
int max_stale;
t->max = max;
if (flags & REG_ICASE)
- t->flags.icase = 1;
+ t->flags.icase = true;
if (refresh_ims)
- t->flags.refresh_ims = 1;
+ t->flags.refresh_ims = true;
if (store_stale)
- t->flags.store_stale = 1;
+ t->flags.store_stale = true;
t->max_stale = max_stale;
#if USE_HTTP_VIOLATIONS
if (override_expire)
- t->flags.override_expire = 1;
+ t->flags.override_expire = true;
if (override_lastmod)
- t->flags.override_lastmod = 1;
+ t->flags.override_lastmod = true;
if (reload_into_ims)
- t->flags.reload_into_ims = 1;
+ t->flags.reload_into_ims = true;
if (ignore_reload)
- t->flags.ignore_reload = 1;
+ t->flags.ignore_reload = true;
if (ignore_no_store)
- t->flags.ignore_no_store = 1;
+ t->flags.ignore_no_store = true;
if (ignore_must_revalidate)
- t->flags.ignore_must_revalidate = 1;
+ t->flags.ignore_must_revalidate = true;
if (ignore_private)
- t->flags.ignore_private = 1;
+ t->flags.ignore_private = true;
if (ignore_auth)
- t->flags.ignore_auth = 1;
+ t->flags.ignore_auth = true;
#endif
char *host;
char ipbuf[MAX_IPSTRLEN];
- http->flags.accel = 1;
+ http->flags.accel = true;
/* BUG: Squid cannot deal with '*' URLs (RFC2616 5.1.2) */
http->uri = xstrdup(internalLocalUri(NULL, url));
// We just re-wrote the URL. Must replace the Host: header.
// But have not parsed there yet!! flag for local-only handling.
- http->flags.internal = 1;
+ http->flags.internal = true;
} else if (csd->port->accel || csd->switchedToHttps()) {
/* accelerator mode */
if (internalCheck(request->urlpath.termedBuf())) {
if (internalHostnameIs(request->GetHost()) &&
request->port == getMyPort()) {
- http->flags.internal = 1;
+ http->flags.internal = true;
} else if (Config.onoff.global_internal_static && internalStaticCheck(request->urlpath.termedBuf())) {
request->SetHost(internalHostname());
request->port = getMyPort();
- http->flags.internal = 1;
+ http->flags.internal = true;
}
}
}
/* It might be half-closed, we can't tell */
- fd_table[io.conn->fd].flags.socket_eof = 1;
+ fd_table[io.conn->fd].flags.socket_eof = true;
commMarkHalfClosed(io.conn->fd);
clientReplyContext::purgeRequestFindObjectToPurge()
{
/* Try to find a base entry */
- http->flags.purging = 1;
+ http->flags.purging = true;
lookingforstore = 1;
// TODO: can we use purgeAllCached() here instead of doing the
if (http->request->method == Http::METHOD_HEAD) {
/* do not forward body for HEAD replies */
body_size = 0;
- http->flags.done_copying = 1;
+ http->flags.done_copying = true;
flags.complete = 1;
}
/* Set flags */
/* internal requests only makes sense in an
* accelerator today. TODO: accept flags ? */
- http->flags.accel = 1;
+ http->flags.accel = true;
/* allow size for url rewriting */
url_sz = strlen(url) + Config.appendDomainLen + 5;
http->uri = (char *)xcalloc(url_sz, 1);
AccessLogEntry::Pointer al; ///< access.log entry
struct {
- unsigned int accel:1;
- unsigned int intercepted:1;
- unsigned int spoof_client_ip:1;
- unsigned int internal:1;
- unsigned int done_copying:1;
- unsigned int purging:1;
+ bool accel;
+ //bool intercepted; //XXX: it's apparently never used.
+ //bool spoof_client_ip; //XXX: it's apparently never used.
+ bool internal;
+ bool done_copying;
+ bool purging;
} flags;
struct {
/* prevent those nasty RST packets */
char buf[SQUID_TCP_SO_RCVBUF];
- if (fd_table[fd].flags.nonblocking == 1) {
+ if (fd_table[fd].flags.nonblocking) {
while (FD_READ_METHOD(fd, buf, SQUID_TCP_SO_RCVBUF) > 0) {};
}
#endif
debugs(50, DBG_IMPORTANT, "comm_open: setsockopt(IP_TRANSPARENT) on FD " << fd << ": " << xstrerror());
} else {
/* mark the socket as having transparent options */
- fd_table[fd].flags.transparent = 1;
+ fd_table[fd].flags.transparent = true;
}
#else
debugs(50, DBG_CRITICAL, "WARNING: comm_open: setsockopt(IP_TRANSPARENT) not supported on this platform");
comm_init_opened(conn, 0, 0, note, AI);
if (!(conn->flags & COMM_NOCLOEXEC))
- fd_table[conn->fd].flags.close_on_exec = 1;
+ fd_table[conn->fd].flags.close_on_exec = true;
if (conn->local.GetPort() > (unsigned short) 0) {
#if _SQUID_WINDOWS_
if (AI->ai_socktype != SOCK_DGRAM)
#endif
- fd_table[conn->fd].flags.nolinger = 1;
+ fd_table[conn->fd].flags.nolinger = true;
}
if ((conn->flags & COMM_TRANSPARENT))
- fd_table[conn->fd].flags.transparent = 1;
+ fd_table[conn->fd].flags.transparent = true;
if (conn->flags & COMM_NONBLOCKING)
- fd_table[conn->fd].flags.nonblocking = 1;
+ fd_table[conn->fd].flags.nonblocking = true;
#ifdef TCP_NODELAY
if (AI->ai_socktype == SOCK_STREAM)
- fd_table[conn->fd].flags.nodelay = 1;
+ fd_table[conn->fd].flags.nodelay = true;
#endif
/* no fd_table[fd].flags. updates needed for these conditions:
errno = 0;
if (!F->flags.called_connect) {
- F->flags.called_connect = 1;
+ F->flags.called_connect = true;
++ statCounter.syscalls.sock.connects;
x = connect(sock, AI->ai_addr, AI->ai_addrlen);
PROF_start(comm_close);
- F->flags.close_request = 1;
+ F->flags.close_request = true;
#if USE_SSL
if (F->ssl) {
if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &L, sizeof(L)) < 0)
debugs(50, 0, "commSetNoLinger: FD " << fd << ": " << xstrerror());
- fd_table[fd].flags.nolinger = 1;
+ fd_table[fd].flags.nolinger = true;
}
static void
#if _SQUID_CYGWIN_
}
#endif
- fd_table[fd].flags.nonblocking = 1;
+ fd_table[fd].flags.nonblocking = true;
return 0;
}
return COMM_ERROR;
}
- fd_table[fd].flags.nonblocking = 0;
+ fd_table[fd].flags.nonblocking = false;
return 0;
}
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0)
debugs(50, 0, "FD " << fd << ": set close-on-exec failed: " << xstrerror());
- fd_table[fd].flags.close_on_exec = 1;
+ fd_table[fd].flags.close_on_exec = true;
#endif
}
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof(on)) < 0)
debugs(50, DBG_IMPORTANT, "commSetTcpNoDelay: FD " << fd << ": " << xstrerror());
- fd_table[fd].flags.nodelay = 1;
+ fd_table[fd].flags.nodelay = true;
}
#endif
* Also, legacy code still depends on comm_local_port() with no access to Comm::Connection
* when those are done comm_local_port can become one of our member functions to do the below.
*/
- fd_table[conn_->fd].flags.open = 1;
+ fd_table[conn_->fd].flags.open = true;
fd_table[conn_->fd].local_addr = conn_->local;
}
if ((hdl = F->read_handler)) {
PROF_start(comm_read_handler);
F->read_handler = NULL;
- F->flags.read_pending = 0;
+ F->flags.read_pending = false;
hdl(fd, F->read_data);
PROF_stop(comm_read_handler);
++ statCounter.select_fds;
while (!diskWriteIsComplete(fd))
diskHandleWrite(fd, NULL);
#else
- F->flags.close_request = 1;
+ F->flags.close_request = true;
debugs(6, 2, "file_close: FD " << fd << ", delaying close");
PROF_stop(file_close);
return;
_fde_disk *fdd = &F->disk;
dwrite_q *q = fdd->write_q;
int status = DISK_OK;
- int do_close;
+ bool do_close;
if (NULL == q)
return;
debugs(6, 3, "diskHandleWrite: FD " << fd);
- F->flags.write_daemon = 0;
+ F->flags.write_daemon = false;
assert(fdd->write_q != NULL);
/* another block is queued */
diskCombineWrites(fdd);
Comm::SetSelect(fd, COMM_SELECT_WRITE, diskHandleWrite, NULL, 0);
- F->flags.write_daemon = 1;
+ F->flags.write_daemon = true;
}
do_close = F->flags.close_request;
fde *F = &fd_table[fd];
assert(fd >= 0);
- assert(F->flags.open == 1);
+ assert(F->flags.open);
if (F->type == FD_FILE) {
assert(F->read_handler == NULL);
debugs(51, 3, "fd_close FD " << fd << " " << F->desc);
Comm::SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
Comm::SetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
- F->flags.open = 0;
+ F->flags.open = false;
fdUpdateBiggest(fd, 0);
--Number_FD;
*F = fde();
assert(!F->flags.open);
debugs(51, 3, "fd_open() FD " << fd << " " << desc);
F->type = type;
- F->flags.open = 1;
+ F->flags.open = true;
F->epoll_state = 0;
#if _SQUID_WINDOWS_
char desc[FD_DESC_SZ];
struct _fde_flags {
- unsigned int open:1;
- unsigned int close_request:1; // file_ or comm_close has been called
- unsigned int write_daemon:1;
- unsigned int socket_eof:1;
- unsigned int nolinger:1;
- unsigned int nonblocking:1;
- unsigned int ipc:1;
- unsigned int called_connect:1;
- unsigned int nodelay:1;
- unsigned int close_on_exec:1;
- unsigned int read_pending:1;
- unsigned int write_pending:1;
- unsigned int transparent:1;
+ bool open;
+ bool close_request; ///< true if file_ or comm_close has been called
+ bool write_daemon;
+ bool socket_eof;
+ bool nolinger;
+ bool nonblocking;
+ bool ipc;
+ bool called_connect;
+ bool nodelay;
+ bool close_on_exec;
+ bool read_pending;
+ //bool write_pending; //XXX seems not to be used
+ bool transparent;
} flags;
int64_t bytes_read;
unsigned short locks;
struct {
- unsigned int negcached:1;
- unsigned int fromhosts:1;
+ bool negcached;
+ bool fromhosts;
} flags;
int age() const; ///< time passed since request_time or -1 if unknown
int ttl = 0;
const char *name = (const char *)f->hash.key;
f->expires = squid_curtime + Config.negativeDnsTtl;
- f->flags.negcached = 1;
+ f->flags.negcached = true;
if (nr < 0) {
debugs(35, 3, "fqdncacheParse: Lookup of '" << name << "' failed (" << error_message << ")");
f->expires = squid_curtime + ttl;
- f->flags.negcached = 0;
+ f->flags.negcached = false;
return f->name_count;
}
fce->name_count = j;
fce->names[j] = NULL; /* it's safe */
- fce->flags.fromhosts = 1;
+ fce->flags.fromhosts = true;
fqdncacheAddEntry(fce);
fqdncacheLockEntry(fce);
}
shutdown(writePipe->fd, SD_BOTH);
#endif
- flags.closing = 1;
+ flags.closing = true;
if (readPipe->fd == writePipe->fd)
readPipe->fd = -1;
else
shutdown(writePipe->fd, (readPipe->fd == writePipe->fd ? SD_BOTH : SD_SEND));
#endif
- flags.closing = 1;
+ flags.closing = true;
if (readPipe->fd == writePipe->fd)
readPipe->fd = -1;
writePipe->close();
helper_stateful_server *srv = cbdataAlloc(helper_stateful_server);
srv->hIpc = hIpc;
srv->pid = pid;
- srv->flags.reserved = 0;
+ srv->flags.reserved = false;
srv->initStats();
srv->index = k;
srv->addr = hlp->addr;
++ srv->stats.releases;
- srv->flags.reserved = 0;
+ srv->flags.reserved = false;
if (srv->parent->OnEmptyQueue != NULL && srv->data)
srv->parent->OnEmptyQueue(srv->data);
assert(hlp->childs.n_active > 0);
-- hlp->childs.n_active;
- srv->flags.shutdown = 1; /* request it to shut itself down */
+ srv->flags.shutdown = true; /* request it to shut itself down */
if (srv->flags.closing) {
debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is CLOSING.");
assert(hlp->childs.n_active > 0);
-- hlp->childs.n_active;
- srv->flags.shutdown = 1; /* request it to shut itself down */
+ srv->flags.shutdown = true; /* request it to shut itself down */
if (srv->flags.busy) {
debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is BUSY.");
if (!srv->flags.shutdown) {
helperKickQueue(hlp);
} else if (!srv->flags.closing && !srv->stats.pending) {
- srv->flags.closing=1;
+ srv->flags.closing=true;
srv->writePipe->close();
}
}
// only skip off the \0's _after_ passing its location in HelperReply above
t += skip;
- srv->flags.busy = 0;
+ srv->flags.busy = false;
/**
* BUG: the below assumes that only one response per read() was received and discards any octets remaining.
* Doing this prohibits concurrency support with multiple replies per read().
srv->writebuf->clean();
delete srv->writebuf;
srv->writebuf = NULL;
- srv->flags.writing = 0;
+ srv->flags.writing = false;
if (flag != COMM_OK) {
/* Helper server has crashed */
if (!srv->wqueue->isNull()) {
srv->writebuf = srv->wqueue;
srv->wqueue = new MemBuf;
- srv->flags.writing = 1;
+ srv->flags.writing = true;
AsyncCall::Pointer call = commCbCall(5,5, "helperDispatchWriteDone",
CommIoCbPtrFun(helperDispatchWriteDone, srv));
Comm::Write(srv->writePipe, srv->writebuf->content(), srv->writebuf->contentSize(), call, NULL);
assert(NULL == srv->writebuf);
srv->writebuf = srv->wqueue;
srv->wqueue = new MemBuf;
- srv->flags.writing = 1;
+ srv->flags.writing = true;
AsyncCall::Pointer call = commCbCall(5,5, "helperDispatchWriteDone",
CommIoCbPtrFun(helperDispatchWriteDone, srv));
Comm::Write(srv->writePipe, srv->writebuf->content(), srv->writebuf->contentSize(), call, NULL);
return;
}
- srv->flags.busy = 1;
- srv->flags.reserved = 1;
+ srv->flags.busy = true;
+ srv->flags.reserved = true;
srv->request = r;
srv->dispatch_time = current_time;
AsyncCall::Pointer call = commCbCall(5,5, "helperStatefulDispatchWriteDone",
dlink_node link;
struct _helper_flags {
- unsigned int busy:1;
- unsigned int writing:1;
- unsigned int closing:1;
- unsigned int shutdown:1;
- unsigned int reserved:1;
+ bool busy;
+ bool writing;
+ bool closing;
+ bool shutdown;
+ bool reserved;
} flags;
struct {
if (wfd)
*wfd = pwfd;
- fd_table[prfd].flags.ipc = 1;
-
- fd_table[pwfd].flags.ipc = 1;
-
- fd_table[crfd].flags.ipc = 1;
-
- fd_table[cwfd].flags.ipc = 1;
+ fd_table[prfd].flags.ipc = true;
+ fd_table[pwfd].flags.ipc = true;
+ fd_table[crfd].flags.ipc = true;
+ fd_table[cwfd].flags.ipc = true;
if (Config.sleep_after_fork) {
/* XXX emulation of usleep() */
dlink_node lru;
unsigned short locks;
struct {
- unsigned int negcached:1;
- unsigned int fromhosts:1;
+ bool negcached;
+ bool fromhosts;
} flags;
int age() const; ///< time passed since request_time or -1 if unknown
int cname_found = 0;
i->expires = squid_curtime + Config.negativeDnsTtl;
- i->flags.negcached = 1;
+ i->flags.negcached = true;
safe_free(i->addrs.in_addrs);
assert(i->addrs.in_addrs == NULL);
safe_free(i->addrs.bad_mask);
i->expires = squid_curtime + ttl;
- i->flags.negcached = 0;
+ i->flags.negcached = false;
return i->addrs.count;
}
i->addrs.bad_mask = (unsigned char *)xcalloc(1, sizeof(unsigned char));
i->addrs.in_addrs[0] = ip;
i->addrs.bad_mask[0] = FALSE;
- i->flags.fromhosts = 1;
+ i->flags.fromhosts = true;
ipcacheAddEntry(i);
ipcacheLockEntry(i);
return 0;
assert(!pd->flags.needed);
assert(!pd->cd);
- pd->flags.needed = 1;
+ pd->flags.needed = true;
pd->times.needed = squid_curtime;
peerDigestSetCheck(pd, 0); /* check asap */
}
StoreIOBuffer tempBuffer;
pd->req_result = NULL;
- pd->flags.requested = 1;
+ pd->flags.requested = true;
/* compute future request components */
/* must go before peerDigestPDFinish */
if (pdcb_valid) {
- fetch->pd->flags.requested = 0;
+ fetch->pd->flags.requested = false;
fetch->pd->req_result = reason;
}
pd->cd = NULL;
}
- pd->flags.usable = 0;
+ pd->flags.usable = false;
if (!pcb_valid)
peerDigestNotePeerGone(pd);
} else {
assert(pcb_valid);
- pd->flags.usable = 1;
+ pd->flags.usable = true;
/* XXX: ugly condition, but how? */
if (i > 0 && SSL_pending(ssl) > 0) {
debugs(83, 2, "SSL FD " << fd << " is pending");
- fd_table[fd].flags.read_pending = 1;
+ fd_table[fd].flags.read_pending = true;
} else
- fd_table[fd].flags.read_pending = 0;
+ fd_table[fd].flags.read_pending = false;
return i;
}