Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion doc/appendices/command-line/traffic_server.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ environments or where the working set is highly variable.

.. option:: -R LEVEL, --regression LEVEL

.. option:: -r TEST, --regression_rest TEST
.. option:: -r TEST, --regression_test TEST

.. option:: -l, --regression_list

If Traffic Server was built with tests enabled, this option lists
the available tests.

.. option:: -T TAGS, --debug_tags TAGS

Expand Down
40 changes: 20 additions & 20 deletions iocore/eventsystem/I_Lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

*/
#ifdef DEBUG
#define SCOPED_MUTEX_LOCK(_l, _m, _t) MutexLock _l(DiagsMakeLocation(), NULL, _m, _t)
#define SCOPED_MUTEX_LOCK(_l, _m, _t) MutexLock _l(MakeSourceLocation(), NULL, _m, _t)
#else
#define SCOPED_MUTEX_LOCK(_l, _m, _t) MutexLock _l(_m, _t)
#endif // DEBUG
Expand All @@ -69,7 +69,7 @@
@param _t The current EThread executing your code.

*/
#define MUTEX_TRY_LOCK(_l, _m, _t) MutexTryLock _l(DiagsMakeLocation(), (char *)NULL, _m, _t)
#define MUTEX_TRY_LOCK(_l, _m, _t) MutexTryLock _l(MakeSourceLocation(), (char *)NULL, _m, _t)

/**
Attempts to acquire the lock to the ProxyMutex.
Expand All @@ -85,7 +85,7 @@
@param _sc The number of attempts or spin count. It must be a positive value.

*/
#define MUTEX_TRY_LOCK_SPIN(_l, _m, _t, _sc) MutexTryLock _l(DiagsMakeLocation(), (char *)NULL, _m, _t, _sc)
#define MUTEX_TRY_LOCK_SPIN(_l, _m, _t, _sc) MutexTryLock _l(MakeSourceLocation(), (char *)NULL, _m, _t, _sc)

/**
Attempts to acquire the lock to the ProxyMutex.
Expand All @@ -102,7 +102,7 @@

*/

#define MUTEX_TRY_LOCK_FOR(_l, _m, _t, _c) MutexTryLock _l(DiagsMakeLocation(), NULL, _m, _t)
#define MUTEX_TRY_LOCK_FOR(_l, _m, _t, _c) MutexTryLock _l(MakeSourceLocation(), NULL, _m, _t)
#else // DEBUG
#define MUTEX_TRY_LOCK(_l, _m, _t) MutexTryLock _l(_m, _t)
#define MUTEX_TRY_LOCK_SPIN(_l, _m, _t, _sc) MutexTryLock _l(_m, _t, _sc)
Expand All @@ -126,18 +126,18 @@
/////////////////////////////////////
// DEPRECATED DEPRECATED DEPRECATED
#ifdef DEBUG
#define MUTEX_TAKE_TRY_LOCK(_m, _t) Mutex_trylock(DiagsMakeLocation(), (char *)NULL, _m, _t)
#define MUTEX_TAKE_TRY_LOCK_FOR(_m, _t, _c) Mutex_trylock(DiagsMakeLocation(), (char *)NULL, _m, _t)
#define MUTEX_TAKE_TRY_LOCK_FOR_SPIN(_m, _t, _c, _sc) Mutex_trylock_spin(DiagsMakeLocation(), NULL, _m, _t, _sc)
#define MUTEX_TAKE_TRY_LOCK(_m, _t) Mutex_trylock(MakeSourceLocation(), (char *)NULL, _m, _t)
#define MUTEX_TAKE_TRY_LOCK_FOR(_m, _t, _c) Mutex_trylock(MakeSourceLocation(), (char *)NULL, _m, _t)
#define MUTEX_TAKE_TRY_LOCK_FOR_SPIN(_m, _t, _c, _sc) Mutex_trylock_spin(MakeSourceLocation(), NULL, _m, _t, _sc)
#else
#define MUTEX_TAKE_TRY_LOCK(_m, _t) Mutex_trylock(_m, _t)
#define MUTEX_TAKE_TRY_LOCK_FOR(_m, _t, _c) Mutex_trylock(_m, _t)
#define MUTEX_TAKE_TRY_LOCK_FOR_SPIN(_m, _t, _c, _sc) Mutex_trylock_spin(_m, _t, _sc)
#endif

#ifdef DEBUG
#define MUTEX_TAKE_LOCK(_m, _t) Mutex_lock(DiagsMakeLocation(), (char *)NULL, _m, _t)
#define MUTEX_TAKE_LOCK_FOR(_m, _t, _c) Mutex_lock(DiagsMakeLocation(), NULL, _m, _t)
#define MUTEX_TAKE_LOCK(_m, _t) Mutex_lock(MakeSourceLocation(), (char *)NULL, _m, _t)
#define MUTEX_TAKE_LOCK_FOR(_m, _t, _c) Mutex_lock(MakeSourceLocation(), NULL, _m, _t)
#else
#define MUTEX_TAKE_LOCK(_m, _t) Mutex_lock(_m, _t)
#define MUTEX_TAKE_LOCK_FOR(_m, _t, _c) Mutex_lock(_m, _t)
Expand All @@ -152,9 +152,9 @@ typedef EThread *EThreadPtr;
typedef volatile EThreadPtr VolatileEThreadPtr;

#if DEBUG
inkcoreapi extern void lock_waiting(const SrcLoc &, const char *handler);
inkcoreapi extern void lock_holding(const SrcLoc &, const char *handler);
inkcoreapi extern void lock_taken(const SrcLoc &, const char *handler);
inkcoreapi extern void lock_waiting(const SourceLocation &, const char *handler);
inkcoreapi extern void lock_holding(const SourceLocation &, const char *handler);
inkcoreapi extern void lock_taken(const SourceLocation &, const char *handler);
#endif

/**
Expand Down Expand Up @@ -209,7 +209,7 @@ class ProxyMutex : public RefCountObj

#ifdef DEBUG
ink_hrtime hold_time;
SrcLoc srcloc;
SourceLocation srcloc;
const char *handler;

#ifdef MAX_LOCK_TAKEN
Expand Down Expand Up @@ -280,7 +280,7 @@ extern inkcoreapi ClassAllocator<ProxyMutex> mutexAllocator;
inline bool
Mutex_trylock(
#ifdef DEBUG
const SrcLoc &location, const char *ahandler,
const SourceLocation &location, const char *ahandler,
#endif
ProxyMutex *m, EThread *t)
{
Expand Down Expand Up @@ -324,7 +324,7 @@ Mutex_trylock(
inline bool
Mutex_trylock_spin(
#ifdef DEBUG
const SrcLoc &location, const char *ahandler,
const SourceLocation &location, const char *ahandler,
#endif
ProxyMutex *m, EThread *t, int spincnt = 1)
{
Expand Down Expand Up @@ -373,7 +373,7 @@ Mutex_trylock_spin(
inline int
Mutex_lock(
#ifdef DEBUG
const SrcLoc &location, const char *ahandler,
const SourceLocation &location, const char *ahandler,
#endif
ProxyMutex *m, EThread *t)
{
Expand Down Expand Up @@ -416,7 +416,7 @@ Mutex_unlock(ProxyMutex *m, EThread *t)
if (m->taken > MAX_LOCK_TAKEN)
lock_taken(m->srcloc, m->handler);
#endif // MAX_LOCK_TAKEN
m->srcloc = SrcLoc(NULL, NULL, 0);
m->srcloc = SourceLocation(NULL, NULL, 0);
m->handler = NULL;
#endif // DEBUG
ink_assert(m->thread_holding);
Expand All @@ -436,7 +436,7 @@ class MutexLock
public:
MutexLock(
#ifdef DEBUG
const SrcLoc &location, const char *ahandler,
const SourceLocation &location, const char *ahandler,
#endif // DEBUG
ProxyMutex *am, EThread *t)
: m(am)
Expand All @@ -462,7 +462,7 @@ class MutexTryLock
public:
MutexTryLock(
#ifdef DEBUG
const SrcLoc &location, const char *ahandler,
const SourceLocation &location, const char *ahandler,
#endif // DEBUG
ProxyMutex *am, EThread *t)
: m(am)
Expand All @@ -476,7 +476,7 @@ class MutexTryLock

MutexTryLock(
#ifdef DEBUG
const SrcLoc &location, const char *ahandler,
const SourceLocation &location, const char *ahandler,
#endif // DEBUG
ProxyMutex *am, EThread *t, int sp)
: m(am)
Expand Down
6 changes: 3 additions & 3 deletions iocore/eventsystem/Lock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
ClassAllocator<ProxyMutex> mutexAllocator("mutexAllocator");

void
lock_waiting(const SrcLoc &srcloc, const char *handler)
lock_waiting(const SourceLocation &srcloc, const char *handler)
{
if (is_diags_on("locks")) {
char buf[128];
Expand All @@ -43,7 +43,7 @@ lock_waiting(const SrcLoc &srcloc, const char *handler)
}

void
lock_holding(const SrcLoc &srcloc, const char *handler)
lock_holding(const SourceLocation &srcloc, const char *handler)
{
if (is_diags_on("locks")) {
char buf[128];
Expand All @@ -52,7 +52,7 @@ lock_holding(const SrcLoc &srcloc, const char *handler)
}

void
lock_taken(const SrcLoc &srcloc, const char *handler)
lock_taken(const SourceLocation &srcloc, const char *handler)
{
if (is_diags_on("locks")) {
char buf[128];
Expand Down
10 changes: 5 additions & 5 deletions iocore/net/P_SSLUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,19 @@ ssl_error_t SSLAccept(SSL *ssl);
ssl_error_t SSLConnect(SSL *ssl);

// Log an SSL error.
#define SSLError(fmt, ...) SSLDiagnostic(DiagsMakeLocation(), false, NULL, fmt, ##__VA_ARGS__)
#define SSLErrorVC(vc, fmt, ...) SSLDiagnostic(DiagsMakeLocation(), false, (vc), fmt, ##__VA_ARGS__)
#define SSLError(fmt, ...) SSLDiagnostic(MakeSourceLocation(), false, NULL, fmt, ##__VA_ARGS__)
#define SSLErrorVC(vc, fmt, ...) SSLDiagnostic(MakeSourceLocation(), false, (vc), fmt, ##__VA_ARGS__)
// Log a SSL diagnostic using the "ssl" diagnostic tag.
#define SSLDebug(fmt, ...) SSLDiagnostic(DiagsMakeLocation(), true, NULL, fmt, ##__VA_ARGS__)
#define SSLDebugVC(vc, fmt, ...) SSLDiagnostic(DiagsMakeLocation(), true, (vc), fmt, ##__VA_ARGS__)
#define SSLDebug(fmt, ...) SSLDiagnostic(MakeSourceLocation(), true, NULL, fmt, ##__VA_ARGS__)
#define SSLDebugVC(vc, fmt, ...) SSLDiagnostic(MakeSourceLocation(), true, (vc), fmt, ##__VA_ARGS__)

#define SSL_CLR_ERR_INCR_DYN_STAT(vc, x, fmt, ...) \
do { \
SSLDebugVC((vc), fmt, ##__VA_ARGS__); \
RecIncrRawStat(ssl_rsb, NULL, (int)x, 1); \
} while (0)

void SSLDiagnostic(const SrcLoc &loc, bool debug, SSLNetVConnection *vc, const char *fmt, ...) TS_PRINTFLIKE(4, 5);
void SSLDiagnostic(const SourceLocation &loc, bool debug, SSLNetVConnection *vc, const char *fmt, ...) TS_PRINTFLIKE(4, 5);

// Return a static string name for a SSL_ERROR constant.
const char *SSLErrorName(int ssl_error);
Expand Down
2 changes: 1 addition & 1 deletion iocore/net/SSLUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ increment_ssl_server_error(unsigned long err)
}

void
SSLDiagnostic(const SrcLoc &loc, bool debug, SSLNetVConnection *vc, const char *fmt, ...)
SSLDiagnostic(const SourceLocation &loc, bool debug, SSLNetVConnection *vc, const char *fmt, ...)
{
unsigned long l;
char buf[256];
Expand Down
39 changes: 3 additions & 36 deletions lib/ts/Diags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,39 +65,6 @@ vprintline(FILE *fp, char (&buffer)[Size], va_list ap)
}
}

//////////////////////////////////////////////////////////////////////////////
//
// char *SrcLoc::str(char *buf, int buflen)
//
// This method takes a SrcLoc source location data structure and
// converts it to a human-readable representation, in the buffer <buf>
// with length <buflen>. The buffer will always be NUL-terminated, and
// must always have a length of at least 1. The buffer address is
// returned on success. The routine will only fail if the SrcLoc is
// not valid, or the buflen is less than 1.
//
//////////////////////////////////////////////////////////////////////////////

char *
SrcLoc::str(char *buf, int buflen) const
{
const char *shortname;

if (!this->valid() || buflen < 1)
return (NULL);

shortname = strrchr(file, '/');
shortname = shortname ? (shortname + 1) : file;

if (func != NULL) {
snprintf(buf, buflen, "%s:%d (%s)", shortname, line, func);
} else {
snprintf(buf, buflen, "%s:%d", shortname, line);
}
buf[buflen - 1] = NUL;
return (buf);
}

//////////////////////////////////////////////////////////////////////////////
//
// Diags::Diags(char *bdt, char *bat)
Expand Down Expand Up @@ -229,7 +196,7 @@ Diags::~Diags()
//////////////////////////////////////////////////////////////////////////////

void
Diags::print_va(const char *debug_tag, DiagsLevel diags_level, const SrcLoc *loc, const char *format_string, va_list ap) const
Diags::print_va(const char *debug_tag, DiagsLevel diags_level, const SourceLocation *loc, const char *format_string, va_list ap) const
{
struct timeval tp;
const char *s;
Expand Down Expand Up @@ -545,7 +512,7 @@ Diags::log(const char *tag, DiagsLevel level, const char *file, const char *func
va_list ap;
va_start(ap, format_string);
if (show_location) {
SrcLoc lp(file, func, line);
SourceLocation lp(file, func, line);
print_va(tag, level, &lp, format_string, ap);
} else {
print_va(tag, level, NULL, format_string, ap);
Expand All @@ -563,7 +530,7 @@ Diags::error_va(DiagsLevel level, const char *file, const char *func, const int
}

if (show_location) {
SrcLoc lp(file, func, line);
SourceLocation lp(file, func, line);
print_va(NULL, level, &lp, format_string, ap);
} else {
print_va(NULL, level, NULL, format_string, ap);
Expand Down
46 changes: 4 additions & 42 deletions lib/ts/Diags.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "ContFlags.h"
#include "ink_inet.h"
#include "BaseLogFile.h"
#include "SourceLocation.h"

#define DIAGS_MAGIC 0x12345678
#define BYTES_IN_MB 1000000
Expand Down Expand Up @@ -90,45 +91,6 @@ struct DiagsConfigState {
DiagsModeOutput outputs[DiagsLevel_Count]; // where each level prints
};

//////////////////////////////////////////////////////////////////////////////
//
// class SrcLoc
//
// The SrcLoc class wraps up a source code location, including file
// name, function name, and line number, and contains a method to
// format the result into a string buffer.
//
//////////////////////////////////////////////////////////////////////////////

#define DiagsMakeLocation() SrcLoc(__FILE__, __FUNCTION__, __LINE__)

class SrcLoc
{
public:
const char *file;
const char *func;
int line;

bool
valid() const
{
return file && line;
}

SrcLoc(const SrcLoc &rhs) : file(rhs.file), func(rhs.func), line(rhs.line) {}
SrcLoc(const char *_file, const char *_func, int _line) : file(_file), func(_func), line(_line) {}
SrcLoc &
operator=(const SrcLoc &rhs)
{
this->file = rhs.file;
this->func = rhs.func;
this->line = rhs.line;
return *this;
}

char *str(char *buf, int buflen) const;
};

//////////////////////////////////////////////////////////////////////////////
//
// class Diags
Expand Down Expand Up @@ -194,7 +156,7 @@ class Diags

const char *level_name(DiagsLevel dl) const;

inkcoreapi void print_va(const char *tag, DiagsLevel dl, const SrcLoc *loc, const char *format_string, va_list ap) const;
inkcoreapi void print_va(const char *tag, DiagsLevel dl, const SourceLocation *loc, const char *format_string, va_list ap) const;

//////////////////////////////
// user printing interfaces //
Expand All @@ -207,7 +169,7 @@ class Diags
va_list ap;
va_start(ap, format_string);
if (show_location) {
SrcLoc lp(file, func, line);
SourceLocation lp(file, func, line);
print_va(tag, dl, &lp, format_string, ap);
} else {
print_va(tag, dl, NULL, format_string, ap);
Expand All @@ -221,7 +183,7 @@ class Diags
///////////////////////////////////////////////////////////////////////

void
log_va(const char *tag, DiagsLevel dl, const SrcLoc *loc, const char *format_string, va_list ap)
log_va(const char *tag, DiagsLevel dl, const SourceLocation *loc, const char *format_string, va_list ap)
{
if (!on(tag))
return;
Expand Down
2 changes: 2 additions & 0 deletions lib/ts/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ libtsutil_la_SOURCES = \
ContFlags.h \
Diags.cc \
Diags.h \
SourceLocation.h \
SourceLocation.cc \
DynArray.h \
EventNotify.cc \
EventNotify.h \
Expand Down
Loading