From bea433683776a0f2896172527f8fcb28965a6a28 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Mon, 26 Jul 2010 11:28:11 +0000 Subject: [PATCH] Add LOG_LEVEL_RECEIVED to log the not-yet-parsed data received. This should make debugging various parsing issues a lot easier. --- errlog.c | 5 ++++- errlog.h | 3 ++- jbsockets.c | 17 +++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/errlog.c b/errlog.c index f352f9f0..34167099 100644 --- a/errlog.c +++ b/errlog.c @@ -1,4 +1,4 @@ -const char errlog_rcs[] = "$Id: errlog.c,v 1.106 2010/07/26 11:21:47 fabiankeil Exp $"; +const char errlog_rcs[] = "$Id: errlog.c,v 1.107 2010/07/26 11:24:34 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $ @@ -575,6 +575,9 @@ static inline const char *get_log_level_string(int loglevel) case LOG_LEVEL_LOG: log_level_string = "Writing"; break; + case LOG_LEVEL_RECEIVED: + log_level_string = "Received"; + break; case LOG_LEVEL_HEADER: log_level_string = "Header"; break; diff --git a/errlog.h b/errlog.h index 75ae4c2e..7c282fac 100644 --- a/errlog.h +++ b/errlog.h @@ -1,6 +1,6 @@ #ifndef ERRLOG_H_INCLUDED #define ERRLOG_H_INCLUDED -#define ERRLOG_H_VERSION "$Id: errlog.h,v 1.23 2009/05/16 13:27:20 fabiankeil Exp $" +#define ERRLOG_H_VERSION "$Id: errlog.h,v 1.24 2010/07/21 14:43:03 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.h,v $ @@ -57,6 +57,7 @@ extern "C" { #define LOG_LEVEL_CLF 0x0200 /* Common Log File format */ #define LOG_LEVEL_CRUNCH 0x0400 #define LOG_LEVEL_CGI 0x0800 /* CGI / templates */ +#define LOG_LEVEL_RECEIVED 0x8000 /* Following are always on: */ #define LOG_LEVEL_INFO 0x1000 diff --git a/jbsockets.c b/jbsockets.c index d060a062..349a14c2 100644 --- a/jbsockets.c +++ b/jbsockets.c @@ -1,4 +1,4 @@ -const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.76 2010/06/13 12:30:10 fabiankeil Exp $"; +const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.77 2010/07/26 11:26:26 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $ @@ -559,18 +559,27 @@ int write_socket(jb_socket fd, const char *buf, size_t len) *********************************************************************/ int read_socket(jb_socket fd, char *buf, int len) { + int ret; + if (len <= 0) { return(0); } #if defined(_WIN32) - return(recv(fd, buf, len, 0)); + ret = recv(fd, buf, len, 0); #elif defined(__BEOS__) || defined(AMIGA) || defined(__OS2__) - return(recv(fd, buf, (size_t)len, 0)); + ret = recv(fd, buf, (size_t)len, 0); #else - return((int)read(fd, buf, (size_t)len)); + ret = (int)read(fd, buf, (size_t)len); #endif + + if (ret > 0) + { + log_error(LOG_LEVEL_RECEIVED, "from socket %d: %N", fd, ret, buf); + } + + return ret; } -- 2.39.2