Common subdirectories: thttpd-2.16/cgi-bin and thttpd-2.16.spread/cgi-bin Common subdirectories: thttpd-2.16/cgi-src and thttpd-2.16.spread/cgi-src diff -u thttpd-2.16/config.h thttpd-2.16.spread/config.h --- thttpd-2.16/config.h Tue Feb 29 17:42:04 2000 +++ thttpd-2.16.spread/config.h Sat May 6 23:12:51 2000 @@ -298,6 +298,15 @@ */ #define THROTTLE_TIME 300 + +/* CONFIGURE: The maximun length of a single log entry line. +*/ +#define MAX_LOG_ENTRY_SIZE 256 + +/* CONFIGURE: The default spread daemon name. +*/ +#define DEFAULT_SPREADDAEMON "4308" + /* CONFIGURE: The listen() backlog queue length. The 1024 doesn't actually ** get used, the kernel uses its maximum allowed value. This is a config ** parameter only in case there's some OS where asking for too high a queue Common subdirectories: thttpd-2.16/contrib and thttpd-2.16.spread/contrib Only in thttpd-2.16.spread: core Common subdirectories: thttpd-2.16/extras and thttpd-2.16.spread/extras diff -u thttpd-2.16/libhttpd.c thttpd-2.16.spread/libhttpd.c --- thttpd-2.16/libhttpd.c Wed Mar 1 00:26:40 2000 +++ thttpd-2.16.spread/libhttpd.c Sun May 21 19:27:59 2000 @@ -25,6 +25,9 @@ ** SUCH DAMAGE. */ +/* Facilities for logging to Spread groups added by George Schlossnagle. +** george@lethargy.org +*/ #include "config.h" #include "version.h" @@ -34,6 +37,7 @@ #include #include #include +#include "sp.h" #include #include @@ -154,8 +158,9 @@ static int really_check_referer( httpd_conn* hc ); static size_t sockaddr_len( httpd_sockaddr* saP ); static int my_snprintf( char* str, size_t size, const char* format, ... ); - - +/*for spread*/ +static char log_private_group[MAX_GROUP_NAME]; +static char logmessage[MAX_LOG_ENTRY_SIZE]; static int reap_time; static void @@ -239,7 +244,8 @@ httpd_initialize( char* hostname, httpd_sockaddr* saP, int port, char* cgi_pattern, char* cwd, FILE* logfp, int no_symlinks, int vhost, char* url_pattern, - char* local_pattern, int no_empty_referers ) + char* local_pattern, int no_empty_referers, char* spreaddaemon, + char* spreadgroup ) { httpd_server* hs; static char ghnbuf[256]; @@ -339,7 +345,10 @@ } } hs->logfp = (FILE*) 0; + hs->spreaddaemon = spreaddaemon; + hs->spreadgroup = spreadgroup; httpd_set_logfp( hs, logfp ); + httpd_init_spread( hs, &(hs->spread_fd)); hs->no_symlinks = no_symlinks; hs->vhost = vhost; hs->no_empty_referers = no_empty_referers; @@ -417,6 +426,22 @@ hs->logfp = logfp; } +void +httpd_init_spread ( httpd_server* hs, mailbox *spread_fd) + { + char private_name[MAX_GROUP_NAME]; + if ( hs->spreadgroup != (char*) 0 ) + { + /* Open spread connection here */ + snprintf(private_name, MAX_SPREAD_NAME,"thtp-%05d",getpid()); + if (SP_connect(hs->spreaddaemon, private_name, 0, 0, spread_fd, + log_private_group) !=0) + { + syslog(LOG_CRIT, "Could not connect to spread"); + } + } +} + void httpd_terminate( httpd_server* hs ) @@ -3353,6 +3378,7 @@ ** syslogd puts it in. The included syslogtocern script turns the ** results into true CERN format. */ +/*Main logging routine, need SP_multicast spread statements here.*/ /* Format remote user. */ if ( hc->remoteuser[0] != '\0' ) @@ -3379,6 +3405,7 @@ (void) strcpy( bytes, "-" ); /* Logfile or syslog? */ + if ( hc->hs->logfp != (FILE*) 0 ) { time_t now; @@ -3419,6 +3446,62 @@ hc->status, bytes, hc->referer, hc->useragent ); (void) fflush( hc->hs->logfp ); /* don't need to flush every time */ } + + + if (hc->hs->spreadgroup != NULL) + { + time_t now; + struct tm* t; + const char* cernfmt_nozone = "%d/%b/%Y:%H:%M:%S"; + char date_nozone[100]; + int zone; + char sign; + char date[100]; + int spret; + + /* Format the time, forcing a numeric timezone (some log analyzers + ** are stoooopid about this). + */ + now = time( (time_t*) 0 ); + t = localtime( &now ); + (void) strftime( date_nozone, sizeof(date_nozone), cernfmt_nozone, t ); +#ifdef HAVE_TM_GMTOFF + zone = t->tm_gmtoff / 60L; +#else + zone = -timezone / 60L; + /* Probably have to add something about daylight time here. */ +#endif + if ( zone >= 0 ) + sign = '+'; + else + { + sign = '-'; + zone = -zone; + } + zone = ( zone / 60 ) * 100 + zone % 60; + (void) my_snprintf( date, sizeof(date), + "%s %c%04d", date_nozone, sign, zone ); + /* And write the log entry. */ + + + snprintf(logmessage, MAX_LOG_ENTRY_SIZE,"%.80s - %.80s [%s] \"%.80s %.300s %.80s\" %d %s\n", + httpd_ntoa( &hc->client_addr ), ru, date, + httpd_method_str( hc->method ), url, hc->protocol, + hc->status, bytes ); + + if ((spret =SP_multicast( hc->hs->spread_fd, RELIABLE_MESS, + hc->hs->spreadgroup, 1, strlen(logmessage), logmessage)) < 0 ) + { + syslog(LOG_ERR, "Error multicasting log entry."); + SP_disconnect (hc->hs->spread_fd); + httpd_init_spread ( hc->hs, &(hc->hs->spread_fd)); + } + + } + + + + else syslog( LOG_INFO, "%.80s - %.80s \"%.80s %.200s %.80s\" %d %s \"%.200s\" \"%.80s\"", Only in thttpd-2.16.spread: libhttpd.c~ diff -u thttpd-2.16/libhttpd.h thttpd-2.16.spread/libhttpd.h --- thttpd-2.16/libhttpd.h Mon Jan 31 13:42:11 2000 +++ thttpd-2.16.spread/libhttpd.h Sun May 21 19:28:12 2000 @@ -25,6 +25,11 @@ ** SUCH DAMAGE. */ +/* Facilities for logging to Spread groups added by George Schlossnagle. +** george@lethargy.org +*/ + + #ifndef _LIBHTTPD_H_ #define _LIBHTTPD_H_ @@ -35,7 +40,12 @@ #include #include #include +#include "sp.h" +/*Spread parameters*/ +#define MAX_SPREAD_GROUP 20 +#define MAX_SPREAD_NAME 10 +#define MAX_SPREAD_DAEMON_NAME 20 /* A few convenient defines. */ @@ -78,6 +88,9 @@ char* url_pattern; char* local_pattern; int no_empty_referers; + char* spreadgroup; + char* spreaddaemon; + mailbox spread_fd; } httpd_server; /* A connection. */ @@ -161,11 +174,12 @@ extern httpd_server* httpd_initialize( char* hostname, httpd_sockaddr* saP, int port, char* cgi_pattern, char* cwd, FILE* logfp, int no_symlinks, int vhost, char* url_pattern, - char* local_pattern, int no_empty_referers ); + char* local_pattern, int no_empty_referers, char* spreaddaemon, + char* spreadgroup ); /* Change the log file. */ extern void httpd_set_logfp( httpd_server* hs, FILE* logfp ); - +extern void httpd_init_spread( httpd_server* hs, mailbox* spread_fd ); /* Call to shut down. */ extern void httpd_terminate( httpd_server* hs ); Common subdirectories: thttpd-2.16/scripts and thttpd-2.16.spread/scripts diff -u thttpd-2.16/thttpd.8 thttpd-2.16.spread/thttpd.8 --- thttpd-2.16/thttpd.8 Tue Feb 29 20:14:24 2000 +++ thttpd-2.16.spread/thttpd.8 Sun May 21 19:32:44 2000 @@ -24,6 +24,10 @@ .IR logfile ] .RB [ -i .IR pidfile ] +.RB [ -spd +.lR spreaddaemon ] +.RB [ -spg +.lR spreadgroup ] .SH DESCRIPTION .PP .I thttpd @@ -107,6 +111,14 @@ Specifies a file for logging. If no file is specified, thttpd logs via syslog(). The config-file option name for this flag is "logfile". +.TP +.B -spd +Specifies spread daemon to connect to for logging. +The config-file option is "spreaddaemon". +.TP +.B -spg +Specifies a spread group to log requests to. +The config-file option is "spreadgroup". .TP .B -i Specifies a file to write the process-id to. diff -u thttpd-2.16/thttpd.c thttpd-2.16.spread/thttpd.c --- thttpd-2.16/thttpd.c Sun Feb 6 20:35:38 2000 +++ thttpd-2.16.spread/thttpd.c Sun May 21 19:29:20 2000 @@ -25,6 +25,9 @@ ** SUCH DAMAGE. */ +/* Facilities for logging to Spread groups added by George Schlossnagle. +** george@lethargy.org +*/ #include "config.h" #include "version.h" @@ -34,6 +37,7 @@ #include #include #include +#include "sp.h" #include #ifdef HAVE_FCNTL_H @@ -70,6 +74,9 @@ static int no_empty_referers; static char* local_pattern; static char* logfile; +static char* spreaddaemon; +static char* spreadgroup; +static mailbox spread_fd; static char* throttlefile; static char* hostname; static char* pidfile; @@ -168,7 +175,7 @@ handle_hup( int sig ) { FILE* logfp; - +/* spread add hup-shit here*/ /* Re-open the log file. */ if ( logfile != (char*) 0 ) { @@ -212,7 +219,7 @@ httpd_conn* hc; httpd_sockaddr sa; struct timeval tv; - + static mailbox spread_fd; argv0 = argv[0]; cp = strrchr( argv0, '/' ); @@ -246,7 +253,11 @@ read_throttlefile( throttlefile ); /* Log file. */ - if ( logfile != (char*) 0 ) + if ( logfile == (char*) 0 ) + { + logfp = (FILE*) 0; + } + else { logfp = fopen( logfile, "a" ); if ( logfp == (FILE*) 0 ) @@ -257,8 +268,6 @@ } (void) fcntl( fileno( logfp ), F_SETFD, 1 ); } - else - logfp = (FILE*) 0; /* Figure out uid/gid from user. */ pwd = getpwnam( user ); @@ -321,6 +330,7 @@ #else /* HAVE_DAEMON */ switch ( fork() ) { + sleep 10; case 0: break; case -1: @@ -388,7 +398,8 @@ */ hs = httpd_initialize( hostname, &sa, port, cgi_pattern, cwd, logfp, no_symlinks, do_vhost, - url_pattern, local_pattern, no_empty_referers ); + url_pattern, local_pattern, no_empty_referers, spreaddaemon, + spreadgroup ); if ( hs == (httpd_server*) 0 ) exit( 1 ); @@ -562,6 +573,7 @@ debug = 0; port = DEFAULT_PORT; + spreaddaemon = DEFAULT_SPREADDAEMON; dir = (char*) 0; #ifdef ALWAYS_CHROOT do_chroot = 1; @@ -585,6 +597,8 @@ throttlefile = (char*) 0; hostname = (char*) 0; logfile = (char*) 0; + spreaddaemon = (char*) 0; + spread_fd = (mailbox) 0; pidfile = (char*) 0; user = DEFAULT_USER; argn = 1; @@ -646,6 +660,16 @@ ++argn; logfile = argv[argn]; } + else if (strcmp( argv[argn], "-spd" ) == 0 && argn +1 < argc ) + { + ++argn; + spreaddaemon = argv[argn]; + } + else if (strcmp( argv[argn], "-spg" ) == 0 && argn +1 < argc ) + { + ++argn; + spreadgroup = argv[argn]; + } else if ( strcmp( argv[argn], "-v" ) == 0 ) do_vhost = 1; else if ( strcmp( argv[argn], "-nov" ) == 0 ) @@ -790,6 +814,16 @@ value_required( name, value ); logfile = e_strdup( value ); } + else if ( strcasecmp( name, "spreaddaemon" ) == 0 ) + { + value_required( name, value ); + spreaddaemon = e_strdup( value ); + } + else if ( strcasecmp( name, "spreadgroup" ) == 0 ) + { + value_required( name, value ); + spreadgroup = e_strdup( value ); + } else if ( strcasecmp( name, "vhost" ) == 0 ) { no_value_required( name, value );