add debug messages about effective requested operations

This commit is contained in:
Oswald Buddenhagen 2022-02-10 21:07:40 +01:00
parent 3091e2fe5a
commit 950ebe833d
4 changed files with 20 additions and 0 deletions

View File

@ -217,6 +217,13 @@ void fmt_bits( uint bits, uint num_bits, const char *bit_str, const int *bit_off
BIT_FORMATTER_RET(name, pfx) \ BIT_FORMATTER_RET(name, pfx) \
BIT_FORMATTER_IMPL(name, pfx, static) BIT_FORMATTER_IMPL(name, pfx, static)
#define DECL_BIT_FORMATTER_FUNCTION(name, pfx) \
BIT_FORMATTER_RET(name, pfx) \
BIT_FORMATTER_PROTO(name, pfx, );
#define DEF_BIT_FORMATTER_FUNCTION(name, pfx) \
BIT_FORMATTER_IMPL(name, pfx, )
void *nfmalloc( size_t sz ); void *nfmalloc( size_t sz );
void *nfzalloc( size_t sz ); void *nfzalloc( size_t sz );
void *nfrealloc( void *mem, size_t sz ); void *nfrealloc( void *mem, size_t sz );

View File

@ -5,6 +5,8 @@
* mbsync - mailbox synchronizer * mbsync - mailbox synchronizer
*/ */
#define DEBUG_FLAG DEBUG_MAIN
#include "config.h" #include "config.h"
#include "sync.h" #include "sync.h"
@ -20,6 +22,8 @@ char FieldDelimiter = ';';
char FieldDelimiter = ':'; char FieldDelimiter = ':';
#endif #endif
DEF_BIT_FORMATTER_FUNCTION(ops, OP)
char * char *
expand_strdup( const char *s, const conffile_t *cfile ) expand_strdup( const char *s, const conffile_t *cfile )
{ {
@ -310,6 +314,10 @@ merge_ops( int cops, int ops[], const char *chan_name )
int aops, op; int aops, op;
uint i; uint i;
if (!cops && !ops[F] && !ops[N]) // Only to denoise the debug output
return 0;
debug( "merge ops (%s):\n common: %s\n far: %s\n near: %s\n",
channel_str( chan_name ), fmt_ops( cops ).str, fmt_ops( ops[F] ).str, fmt_ops( ops[N] ).str );
aops = ops[F] | ops[N]; aops = ops[F] | ops[N];
if (ops[F] & XOP_HAVE_TYPE) { if (ops[F] & XOP_HAVE_TYPE) {
if (aops & OP_MASK_TYPE) { // PullNew, etc. if (aops & OP_MASK_TYPE) { // PullNew, etc.
@ -377,6 +385,7 @@ merge_ops( int cops, int ops[], const char *chan_name )
ops[N] |= cops & op; ops[N] |= cops & op;
} }
} }
debug( " => far: %s\n => near: %s\n", fmt_ops( ops[F] ).str, fmt_ops( ops[N] ).str );
return 0; return 0;
} }

View File

@ -186,6 +186,8 @@ add_channel( chan_ent_t ***chanapp, channel_conf_t *chan, int ops[] )
merge_actions( chan, ops, XOP_HAVE_CREATE, OP_CREATE, 0 ); merge_actions( chan, ops, XOP_HAVE_CREATE, OP_CREATE, 0 );
merge_actions( chan, ops, XOP_HAVE_REMOVE, OP_REMOVE, 0 ); merge_actions( chan, ops, XOP_HAVE_REMOVE, OP_REMOVE, 0 );
merge_actions( chan, ops, XOP_HAVE_EXPUNGE, OP_EXPUNGE, 0 ); merge_actions( chan, ops, XOP_HAVE_EXPUNGE, OP_EXPUNGE, 0 );
debug( "channel ops (%s):\n far: %s\n near: %s\n",
chan->name, fmt_ops( ops[F] ).str, fmt_ops( ops[N] ).str );
for (int t = 0; t < 2; t++) { for (int t = 0; t < 2; t++) {
if (chan->ops[t] & OP_MASK_TYPE) if (chan->ops[t] & OP_MASK_TYPE)

View File

@ -41,6 +41,8 @@ BIT_ENUM(
#define OP_MASK_TYPE (OP_NEW | OP_RENEW | OP_DELETE | OP_FLAGS) // Asserted in the target side ops #define OP_MASK_TYPE (OP_NEW | OP_RENEW | OP_DELETE | OP_FLAGS) // Asserted in the target side ops
#define XOP_MASK_DIR (XOP_PUSH | XOP_PULL) #define XOP_MASK_DIR (XOP_PUSH | XOP_PULL)
DECL_BIT_FORMATTER_FUNCTION(ops, OP)
typedef struct channel_conf { typedef struct channel_conf {
struct channel_conf *next; struct channel_conf *next;
const char *name; const char *name;