summaryrefslogtreecommitdiff
path: root/logger.h
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2016-06-11 21:15:45 -0700
committerdormando <dormando@rydia.net>2016-06-16 17:14:34 -0700
commitd5f7f89ad53b749ae22e896dc76d16ff980c7528 (patch)
tree35d9b60d28c890833e53b144bcbf13f85ec09ad6 /logger.h
parent6a4e8e1f209f5fac250ea74b3040cf07664c97e1 (diff)
downloadmemcached-d5f7f89ad53b749ae22e896dc76d16ff980c7528.tar.gz
remove "logger chunks", add individualized streams
Stop doing a multi-reader circular buffer structure on top of a circular buffer. Also adds individualized streams based off of the central buffer. Sadly this requires managing iovecs and dealing with partial writes into said iovecs. That makes things very complicated. Since it's not clear to me how to simplify it too much (as of this writing), one of the next commits should remove iovecs and instead give each watcher its own circular buffer. The parser thread will copy watched events into each buffer. The above would only be slower for the case of many watchers watching the same event streams. Given all of the extra loops required for managing the iovecs, and the more complicated syscall handling, it might even be the same speed to manage multiple buffers anyway. I completed this intermediary change since it simplifies the surrounding code and was educational to fiddle with iovecs again.
Diffstat (limited to 'logger.h')
-rw-r--r--logger.h17
1 files changed, 6 insertions, 11 deletions
diff --git a/logger.h b/logger.h
index 31a246d..6cad6ca 100644
--- a/logger.h
+++ b/logger.h
@@ -28,17 +28,20 @@ enum logger_ret_type {
enum logger_parse_entry_ret {
LOGGER_PARSE_ENTRY_OK = 0,
- LOGGER_PARSE_ENTRY_FULLBUF
+ LOGGER_PARSE_ENTRY_FULLBUF,
+ LOGGER_PARSE_ENTRY_FAILED
};
typedef const struct {
enum log_entry_subtype subtype;
int reqlen;
+ uint16_t watcher_flag;
char *format;
} entry_details;
typedef struct _logentry {
enum log_entry_subtype event;
+ uint16_t watcher_flag;
uint64_t gid;
struct timeval tv; /* not monotonic! */
int size;
@@ -56,6 +59,7 @@ typedef struct _logentry {
#define LOG_EVICTIONS (1<<6) /* defailts of evicted items */
#define LOG_STRICT (1<<7) /* block worker instead of drop */
#define LOG_TIME (1<<8) /* log the entry time */
+#define LOG_RAWCMDS (1<<9) /* raw ascii commands */
typedef struct _logger {
struct _logger *prev;
@@ -71,15 +75,6 @@ typedef struct _logger {
const entry_details *entry_map;
} logger;
-typedef struct _logger_chunk {
- struct _logger_chunk *next;
- int size; /* max potential size */
- int written; /* amount written into the buffer (actual size) */
- int refcount; /* number of attached watchers */
- unsigned int filled :1; /* reached storage max */
- char data[];
-} logger_chunk;
-
enum logger_watcher_type {
LOGGER_WATCHER_STDERR = 0,
LOGGER_WATCHER_CLIENT = 1
@@ -87,10 +82,10 @@ enum logger_watcher_type {
typedef struct {
void *c; /* original connection structure. still with source thread attached */
- logger_chunk *lc;
int chunks; /* count of chunks stored up */
int sfd; /* client fd */
int flushed; /* backlog data flushed so far from active chunk */
+ int min_flushed; /* it's safe to flush the central buffer up to here */
int id; /* id number for watcher list */
enum logger_watcher_type t; /* stderr, client, syslog, etc */
uint16_t eflags; /* flags we are interested in */