+/*
+ * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
/*
* DiskThreads.h
*
#ifndef __DISKTHREADS_H__
#define __DISKTHREADS_H__
-#ifdef AUFS_IO_THREADS
+#include "dlink.h"
+#include "mem/forward.h"
+
+/* this non-standard-conformant include is needed in order to have stat(2) and struct stat
+ properly defined on some systems (e.g. OpenBSD 5.4) */
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#if AUFS_IO_THREADS
#define NUMTHREADS AUFS_IO_THREADS
#else
#define NUMTHREADS (Config.cacheSwap.n_configured*16)
_AIO_OP_WRITE,
_AIO_OP_CLOSE,
_AIO_OP_UNLINK,
- _AIO_OP_TRUNCATE,
_AIO_OP_OPENDIR,
_AIO_OP_STAT
};
typedef void AIOCB(int fd, void *cbdata, const char *buf, int aio_return, int aio_errno);
-struct squidaio_result_t
+class squidaio_result_t
{
- int aio_return;
- int aio_errno;
- enum _squidaio_request_type result_type;
- void *_data; /* Internal housekeeping */
- void *data; /* Available to the caller */
+public:
+ int aio_return = 0;
+ int aio_errno = 0;
+ enum _squidaio_request_type result_type = _AIO_OP_NONE;
+ void *_data = nullptr; /* Internal housekeeping */
+ void *data = nullptr; /* Available to the caller */
};
-struct squidaio_ctrl_t
+class squidaio_ctrl_t
{
+ MEMPROXY_CLASS(squidaio_ctrl_t);
+public:
+ squidaio_ctrl_t() : done_handler(NULL), free_func(NULL) {}
- struct squidaio_ctrl_t *next;
- int fd;
- int operation;
+ squidaio_ctrl_t *next = nullptr;
+ int fd = 0;
+ int operation = 0;
AIOCB *done_handler;
- void *done_handler_data;
+ void *done_handler_data = nullptr;
squidaio_result_t result;
- int len;
- char *bufp;
+ int len = 0;
+ char *bufp = nullptr;
FREE *free_func;
dlink_node node;
};
void squidaio_shutdown(void);
int squidaio_cancel(squidaio_result_t *);
int squidaio_open(const char *, int, mode_t, squidaio_result_t *);
-int squidaio_read(int, char *, int, off_t, int, squidaio_result_t *);
-int squidaio_write(int, char *, int, off_t, int, squidaio_result_t *);
+int squidaio_read(int, char *, size_t, off_t, int, squidaio_result_t *);
+int squidaio_write(int, char *, size_t, off_t, int, squidaio_result_t *);
int squidaio_close(int, squidaio_result_t *);
int squidaio_stat(const char *, struct stat *, squidaio_result_t *);
int squidaio_unlink(const char *, squidaio_result_t *);
-int squidaio_truncate(const char *, off_t length, squidaio_result_t *);
int squidaio_opendir(const char *, squidaio_result_t *);
squidaio_result_t *squidaio_poll_done(void);
int squidaio_operations_pending(void);
int squidaio_get_queue_len(void);
void *squidaio_xmalloc(int size);
void squidaio_xfree(void *p, int size);
+void squidaio_stats(StoreEntry *);
void aioInit(void);
void aioDone(void);
void aioCancel(int);
void aioOpen(const char *, int, mode_t, AIOCB *, void *);
void aioClose(int);
-void aioWrite(int, int offset, char *, int size, AIOCB *, void *, FREE *);
-void aioRead(int, int offset, int size, AIOCB *, void *);
+void aioWrite(int, off_t offset, char *, size_t size, AIOCB *, void *, FREE *);
+void aioRead(int, off_t offset, size_t size, AIOCB *, void *);
void aioStat(char *, struct stat *, AIOCB *, void *);
void aioUnlink(const char *, AIOCB *, void *);
-void aioTruncate(const char *, off_t length, AIOCB *, void *);
int aioQueueSize(void);
#include "DiskIO/DiskFile.h"
class DiskThreadsIOStrategy;
-struct AIOCounts
+class AIOCounts
{
- int open_start;
- int open_finish;
- int close_start;
- int close_finish;
- int cancel;
- int write_start;
- int write_finish;
- int read_start;
- int read_finish;
- int stat_start;
- int stat_finish;
- int unlink_start;
- int unlink_finish;
- int check_callback;
+public:
+ uint64_t open_start = 0;
+ uint64_t open_finish = 0;
+ uint64_t close_start = 0;
+ uint64_t close_finish = 0;
+ uint64_t cancel = 0;
+ uint64_t write_start = 0;
+ uint64_t write_finish = 0;
+ uint64_t read_start = 0;
+ uint64_t read_finish = 0;
+ uint64_t stat_start = 0;
+ uint64_t stat_finish = 0;
+ uint64_t unlink_start = 0;
+ uint64_t unlink_finish = 0;
+ uint64_t check_callback = 0;
};
extern AIOCounts squidaio_counts;
extern dlink_list used_list;
-
#endif
+