Improve debug logging

- add debug.trace to help track down segfaults
- warn about alarms without names (which are then hard to track down).
This commit is contained in:
gardners 2013-02-16 06:22:37 +10:30 committed by Jeremy Lakeman
parent 1e76772c3a
commit 80168e3530
6 changed files with 25 additions and 10 deletions

View File

@ -210,6 +210,7 @@ ATOM(char, rhizome_rx, 0, cf_opt_char_boolean,, "")
ATOM(char, rhizome_ads, 0, cf_opt_char_boolean,, "")
ATOM(char, manifests, 0, cf_opt_char_boolean,, "")
ATOM(char, vomp, 0, cf_opt_char_boolean,, "")
ATOM(char, trace, 0, cf_opt_char_boolean,, "")
END_STRUCT
STRUCT(log)

View File

@ -87,7 +87,13 @@ int is_scheduled(const struct sched_ent *alarm)
int _schedule(struct __sourceloc __whence, struct sched_ent *alarm)
{
if (config.debug.io)
DEBUGF("schedule(alarm=%s)", alloca_alarm_name(alarm));
DEBUGF("schedule(alarm=%s) called from %s() %s:%d",
alloca_alarm_name(alarm),
__whence.function,__whence.file,__whence.line);
if (!alarm->stats)
WARNF("schedule() called from %s() %s:%d without supplying an alarm name",
alloca_alarm_name(alarm),
__whence.function,__whence.file,__whence.line);
struct sched_ent *node = next_alarm, *last = NULL;

1
log.h
View File

@ -135,6 +135,7 @@ void set_log_implementation(void (*log_function)(int level, struct strbuf *buf))
#define DEBUGF_perror(F,...) LOGF_perror(LOG_LEVEL_DEBUG, F, ##__VA_ARGS__)
#define DEBUG_perror(X) DEBUGF_perror("%s", (X))
#define D DEBUG("D")
#define T { if (config.debug.trace) DEBUG("T"); }
#define DEBUG_argv(X,ARGC,ARGV) logArgv(LOG_LEVEL_DEBUG, __WHENCE__, (X), (ARGC), (ARGV))
#define dump(X,A,N) logDump(LOG_LEVEL_DEBUG, __WHENCE__, (X), (const unsigned char *)(A), (size_t)(N))

View File

@ -705,8 +705,9 @@ static void overlay_interface_poll(struct sched_ent *alarm)
interface_read_file(interface);
break;
}
if (alarm->alarm!=-1)
if (alarm->alarm!=-1) {
schedule(alarm);
}
}
if (alarm->poll.revents & POLLOUT){

View File

@ -254,10 +254,16 @@ int overlay_send_probe(struct subscriber *peer, struct sockaddr_in addr, overlay
if (interface->state!=INTERFACE_STATE_UP)
return WHY("I can't send a probe if the interface is down.");
if (addr.sin_addr.s_addr==0)
return WHY("I can't send a probe to address 0.0.0.0");
if (addr.sin_port==0)
return WHY("I can't send a probe to port 0");
if (addr.sin_addr.s_addr==0) {
if (config.debug.overlayinterfaces)
WHY("I can't send a probe to address 0.0.0.0");
return -1;
}
if (addr.sin_port==0) {
if (config.debug.overlayinterfaces)
WHY("I can't send a probe to port 0");
return -1;
}
// never send unicast probes over a stream interface
if (interface->socket_type==SOCK_STREAM)

View File

@ -17,6 +17,9 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "crypto_sign_edwards25519sha512batch.h"
#include "nacl/src/crypto_sign_edwards25519sha512batch_ref/ge.h"
#include "serval.h"
#include "conf.h"
#include "str.h"
@ -351,9 +354,6 @@ int rhizome_verify_bundle_privatekey(rhizome_manifest *m,
{
IN();
#include "crypto_sign_edwards25519sha512batch.h"
#include "nacl/src/crypto_sign_edwards25519sha512batch_ref/ge.h"
unsigned char h[64];
unsigned char pk[32];
ge_p3 A;
@ -664,4 +664,4 @@ int rhizome_derive_key(rhizome_manifest *m, rhizome_bk_t *bsk)
bcopy(hash, m->payloadNonce, sizeof(m->payloadNonce));
return 0;
}
}