diff options
-rw-r--r-- | src/buffer.c | 14 | ||||
-rw-r--r-- | src/reqs.c | 22 | ||||
-rw-r--r-- | src/sock.c | 14 | ||||
-rw-r--r-- | src/thread.c | 8 | ||||
-rw-r--r-- | src/utils.c | 16 |
5 files changed, 35 insertions, 39 deletions
diff --git a/src/buffer.c b/src/buffer.c index 30603a5..c34d645 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1,4 +1,4 @@ -/* $Id: buffer.c,v 1.12 2001-10-18 21:45:54 rjkaes Exp $ +/* $Id: buffer.c,v 1.13 2001-10-24 00:37:23 rjkaes Exp $ * * The buffer used in each connection is a linked list of lines. As the lines * are read in and written out the buffer expands and contracts. Basically, @@ -208,6 +208,7 @@ ssize_t readbuff(int fd, struct buffer_s *buffptr) } if (add_to_buffer(buffptr, newbuffer, bytesin) < 0) { + log_message(LOG_ERR, "readbuff: add_to_buffer() error."); return -1; } @@ -229,8 +230,7 @@ ssize_t readbuff(int fd, struct buffer_s *buffptr) safefree(buffer); return 0; default: - log_message(LOG_ERR, "recv error (fd %d: %s:%d) in 'readbuff'.", - fd, strerror(errno), errno); + log_message(LOG_ERR, "readbuff: recv() error \"%s\" on file descriptor %d", strerror(errno), fd); safefree(buffer); return -1; } @@ -275,14 +275,10 @@ ssize_t writebuff(int fd, struct buffer_s *buffptr) return 0; case ENOBUFS: case ENOMEM: - log_message(LOG_ERR, - "write error [NOBUFS/NOMEM] (%s) in 'writebuff'.", - strerror(errno)); + log_message(LOG_ERR, "writebuff: write() error [NOBUFS/NOMEM] \"%s\" on file descriptor %d", strerror(errno), fd); return 0; default: - log_message(LOG_ERR, - "write error (fd %d: %s:%d) in 'writebuff'.", - fd, strerror(errno), errno); + log_message(LOG_ERR, "writebuff: write() error \"%s\" on file descriptor %d", strerror(errno), fd); return -1; } } @@ -1,4 +1,4 @@ -/* $Id: reqs.c,v 1.31 2001-10-22 16:08:29 rjkaes Exp $ +/* $Id: reqs.c,v 1.32 2001-10-24 00:37:23 rjkaes Exp $ * * This is where all the work in tinyproxy is actually done. Incoming * connections have a new thread created for them. The thread then @@ -81,7 +81,7 @@ static char *read_request_line(struct conn_s *connptr) len = readline(connptr->client_fd, request_buffer, LINE_LENGTH); if (len <= 0) { - log_message(LOG_ERR, "Client (file descriptor: %d) closed socket before read.", connptr->client_fd); + log_message(LOG_ERR, "read_request_line: Client (file descriptor: %d) closed socket before read.", connptr->client_fd); safefree(request_buffer); return NULL; } @@ -148,7 +148,7 @@ static int extract_http_url(const char *url, struct request_s *request) request->port = 80; strcpy(request->path, "/"); } else { - log_message(LOG_ERR, "Can't parse URL."); + log_message(LOG_ERR, "extract_http_url: Can't parse URL."); safefree(request->host); safefree(request->path); @@ -173,7 +173,7 @@ static int extract_ssl_url(const char *url, struct request_s *request) else if (sscanf(url, "%s", request->host) == 1) request->port = 443; else { - log_message(LOG_ERR, "Can't parse URL."); + log_message(LOG_ERR, "extract_ssl_url: Can't parse URL."); safefree(request->host); return -1; @@ -281,7 +281,7 @@ static struct request_s *process_request(struct conn_s *connptr, ret = sscanf(request_line, "%[^ ] %[^ ] %[^ ]", request->method, url, request->protocol); if (ret < 2) { - log_message(LOG_ERR, "Bad Request on file descriptor %d", connptr->client_fd); + log_message(LOG_ERR, "process_request: Bad Request on file descriptor %d", connptr->client_fd); httperr(connptr, 400, "Bad Request. No request found."); safefree(url); @@ -293,7 +293,7 @@ static struct request_s *process_request(struct conn_s *connptr, } if (!url) { - log_message(LOG_ERR, "Null URL on file descriptor %d", connptr->client_fd); + log_message(LOG_ERR, "process_request: Null URL on file descriptor %d", connptr->client_fd); httperr(connptr, 400, "Bad Request. Null URL."); safefree(url); @@ -326,7 +326,7 @@ static struct request_s *process_request(struct conn_s *connptr, } connptr->ssl = TRUE; } else { - log_message(LOG_ERR, "Unknown URL type on file descriptor %d", connptr->client_fd); + log_message(LOG_ERR, "process_request: Unknown URL type on file descriptor %d", connptr->client_fd); httperr(connptr, 400, "Bad Request. Unknown URL type."); safefree(url); @@ -345,7 +345,7 @@ static struct request_s *process_request(struct conn_s *connptr, if (filter_url(request->host)) { update_stats(STAT_DENIED); - log_message(LOG_ERR, "Proxying refused on filtered domain \"%s\"", request->host); + log_message(LOG_NOTICE, "Proxying refused on filtered domain \"%s\"", request->host); httperr(connptr, 404, "Connection to filtered domain is now allowed."); free_request_struct(request); @@ -359,7 +359,7 @@ static struct request_s *process_request(struct conn_s *connptr, * Check to see if they're requesting the stat host */ if (config.stathost && strcmp(config.stathost, request->host) == 0) { - log_message(LOG_NOTICE, "tinyproxy stathost request."); + log_message(LOG_NOTICE, "Request for the stathost."); free_request_struct(request); @@ -638,7 +638,7 @@ static void relay_connection(struct conn_s *connptr) continue; } } else if (ret < 0) { - log_message(LOG_ERR, "Received an error in select() [\"%s\", %d], so closing connection (client_fd:%d, server_fd:%d)", strerror(errno), errno, connptr->client_fd, connptr->server_fd); + log_message(LOG_ERR, "relay_connection: select() error \"%s\". Closing connection (client_fd:%d, server_fd:%d)", strerror(errno), connptr->client_fd, connptr->server_fd); return; } else { /* @@ -893,7 +893,7 @@ send_error: } } else { if (send_ssl_response(connptr) < 0) { - log_message(LOG_ERR, "Could not send SSL greeting to client."); + log_message(LOG_ERR, "handle_connection: Could not send SSL greeting to client."); update_stats(STAT_BADCONN); destroy_conn(connptr); return; @@ -1,4 +1,4 @@ -/* $Id: sock.c,v 1.12 2001-10-23 16:43:08 rjkaes Exp $ +/* $Id: sock.c,v 1.13 2001-10-24 00:37:23 rjkaes Exp $ * * Sockets are created and destroyed here. When a new connection comes in from * a client, we need to copy the socket and the create a second socket to the @@ -66,19 +66,19 @@ int opensock(char *ip_addr, uint16_t port) ret = dnscache(&port_info.sin_addr, ip_addr); if (ret < 0) { - log_message(LOG_ERR, "Could not lookup address [%s].", ip_addr); + log_message(LOG_ERR, "opensock: Could not lookup address \"%s\".", ip_addr); return -1; } port_info.sin_port = htons(port); if ((sock_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { - log_message(LOG_ERR, "Could not create socket because of '%s'.", strerror(errno)); + log_message(LOG_ERR, "opensock: socket() error \"%s\".", strerror(errno)); return -1; } if (connect(sock_fd, (struct sockaddr*)&port_info, sizeof(port_info)) < 0) { - log_message(LOG_ERR, "Could not connect socket because of '%s'", strerror(errno)); + log_message(LOG_ERR, "opensock: connect() error \"%s\".", strerror(errno)); return -1; } @@ -166,7 +166,7 @@ char *getpeer_ip(int fd, char *ipaddr) *ipaddr = '\0'; if (getpeername(fd, (struct sockaddr*)&name, &namelen) != 0) { - log_message(LOG_ERR, "getpeer_ip: 'could not get peer's IP address' (\"%s\": %d)", strerror(errno), errno); + log_message(LOG_ERR, "getpeer_ip: getpeername() error \"%s\".", strerror(errno)); } else { strlcpy(ipaddr, inet_ntoa(*(struct in_addr*)&name.sin_addr.s_addr), @@ -195,7 +195,7 @@ char *getpeer_string(int fd, char *string) *string = '\0'; if (getpeername(fd, (struct sockaddr *)&name, &namelen) != 0) { - log_message(LOG_ERR, "getpeer_string: 'could not get peer name' (\"%s\": %d)", strerror(errno), errno); + log_message(LOG_ERR, "getpeer_string: getpeername() error \"%s\".", strerror(errno)); } else { LOCK(); peername = gethostbyaddr((char *)&name.sin_addr.s_addr, @@ -204,7 +204,7 @@ char *getpeer_string(int fd, char *string) if (peername) strlcpy(string, peername->h_name, PEER_STRING_LENGTH); else - log_message(LOG_ERR, "getpeer_string: 'gethostbyaddr()' returned an error (\"%s\": %d).", hstrerror(h_errno), h_errno); + log_message(LOG_ERR, "getpeer_string: gethostbyaddr() error \"%s\".", hstrerror(h_errno)); UNLOCK(); } diff --git a/src/thread.c b/src/thread.c index 9d0423c..db1036b 100644 --- a/src/thread.c +++ b/src/thread.c @@ -1,4 +1,4 @@ -/* $Id: thread.c,v 1.16 2001-09-15 21:28:25 rjkaes Exp $ +/* $Id: thread.c,v 1.17 2001-10-24 00:37:23 rjkaes Exp $ * * Handles the creation/destruction of the various threads required for * processing incoming connections. @@ -196,11 +196,11 @@ short int thread_pool_create(void) pthread_attr_setstacksize(&thread_attr, THREAD_STACK_SIZE); if (thread_config.maxclients == 0) { - log_message(LOG_ERR, "'MaxClients' must be greater than zero."); + log_message(LOG_ERR, "thread_pool_create: \"MaxClients\" must be greater than zero."); return -1; } if (thread_config.startservers == 0) { - log_message(LOG_ERR, "'StartServers' must be greater than zero."); + log_message(LOG_ERR, "thread_pool_create: \"StartServers\" must be greater than zero."); return -1; } @@ -209,7 +209,7 @@ short int thread_pool_create(void) return -1; if (thread_config.startservers > thread_config.maxclients) { - log_message(LOG_WARNING, "Can not start more than 'MaxClients' servers. Starting %u servers instead.", thread_config.maxclients); + log_message(LOG_WARNING, "Can not start more than \"MaxClients\" servers. Starting %u servers instead.", thread_config.maxclients); thread_config.startservers = thread_config.maxclients; } diff --git a/src/utils.c b/src/utils.c index 9e3214c..2feed99 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,4 +1,4 @@ -/* $Id: utils.c,v 1.13 2001-09-16 20:13:52 rjkaes Exp $ +/* $Id: utils.c,v 1.14 2001-10-24 00:37:23 rjkaes Exp $ * * Misc. routines which are used by the various functions to handle strings * and memory allocation and pretty much anything else we can think of. Also, @@ -173,7 +173,7 @@ int create_file_safely(const char *filename) * existing", exit. */ if (errno != ENOENT) { - log_message(LOG_ERR, "Error checking PID file %s: %s.", + log_message(LOG_ERR, "create_file_safely: Error checking PID file %s: %s.", filename, strerror(errno)); return -1; } @@ -184,7 +184,7 @@ int create_file_safely(const char *filename) * and open() */ if ((fildes = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) { - log_message(LOG_ERR, "Could not create PID file %s: %s.", + log_message(LOG_ERR, "create_file_safely: Could not create PID file %s: %s.", filename, strerror(errno)); return -1; } @@ -195,7 +195,7 @@ int create_file_safely(const char *filename) * Open an existing file. */ if ((fildes = open(filename, O_RDWR)) < 0) { - log_message(LOG_ERR, "Could not open PID file %s: %s.", + log_message(LOG_ERR, "create_file_safely: Could not open PID file %s: %s.", filename, strerror(errno)); return -1; } @@ -208,7 +208,7 @@ int create_file_safely(const char *filename) || lstatinfo.st_mode != fstatinfo.st_mode || lstatinfo.st_ino != fstatinfo.st_ino || lstatinfo.st_dev != fstatinfo.st_dev) { - log_message(LOG_ERR, "The PID file %s has been changed before it could be opened.", + log_message(LOG_ERR, "create_file_safely: The PID file %s has been changed before it could be opened.", filename); close(fildes); return -1; @@ -222,7 +222,7 @@ int create_file_safely(const char *filename) * st_mode check would also find this) */ if (fstatinfo.st_nlink > 1 || !S_ISREG(lstatinfo.st_mode)) { - log_message(LOG_ERR, "The PID file %s has too many links, or is not a regular file: %s.", + log_message(LOG_ERR, "create_file_safely: The PID file %s has too many links, or is not a regular file: %s.", filename, strerror(errno)); close(fildes); return -1; @@ -241,7 +241,7 @@ int create_file_safely(const char *filename) #else close(fildes); if ((fildes = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) { - log_message(LOG_ERR, "Could not open PID file %s: %s.", + log_message(LOG_ERR, "create_file_safely: Could not open PID file %s: %s.", filename, strerror(errno)); return -1; } @@ -269,7 +269,7 @@ void pidfile_create(const char *filename) * Open a stdio file over the low-level one. */ if ((fd = fdopen(fildes, "w")) == NULL) { - log_message(LOG_ERR, "fdopen() error on PID file %s: %s.", + log_message(LOG_ERR, "pidfile_create: fdopen() error on PID file %s: %s.", filename, strerror(errno)); close(fildes); unlink(filename); |