X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fshmlog.h;h=e755d2f139cdc003e9d5fc655d7aec7c882bd79a;hb=e68a8dd86c34db800a2b5643c94b292ad191a708;hp=c513babf698e3e931ecabb011e024dde2a95cba3;hpb=fd8e1c98c91c86300904ae85dd22657dcb291bf5;p=i3%2Fi3 diff --git a/include/shmlog.h b/include/shmlog.h index c513babf..e755d2f1 100644 --- a/include/shmlog.h +++ b/include/shmlog.h @@ -12,11 +12,33 @@ #define _I3_SHMLOG_H #include +#include +/* + * Header of the shmlog file. Used by i3/src/log.c and i3/i3-dump-log/main.c. + * + */ typedef struct i3_shmlog_header { + /* Byte offset where the next line will be written to. */ uint32_t offset_next_write; + + /* Byte offset where the last wrap occured. */ uint32_t offset_last_wrap; + + /* The size of the logfile in bytes. Since the size is limited to 25 MiB + * an uint32_t is sufficient. */ uint32_t size; + + /* wrap counter. We need it to reliably signal to clients that we just + * wrapped (clients cannot use offset_last_wrap because that might + * coincidentally be exactly the same as previously). Overflows can happen + * and don’t matter — clients use an equality check (==). */ + uint32_t wrap_count; + + /* pthread condvar which will be broadcasted whenever there is a new + * message in the log. i3-dump-log uses this to implement -f (follow, like + * tail -f) in an efficient way. */ + pthread_cond_t condvar; } i3_shmlog_header; #endif