Some code clean up due to the creation of the conns.{c,h} files which now

store the creation/destruction and definition of the connection structure.
This commit is contained in:
Robert James Kaes 2001-10-25 16:58:50 +00:00
parent f8ad0dced3
commit d3b099140f
6 changed files with 13 additions and 47 deletions

View File

@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.5 2001-10-01 04:01:10 rjkaes Exp $
# $Id: Makefile.am,v 1.6 2001-10-25 16:58:50 rjkaes Exp $
#
#
#
@ -21,6 +21,7 @@ LDFLAGS = @LDFLAGS@
bin_PROGRAMS = tinyproxy
tinyproxy_SOURCES = \
conns.c conns.h \
buffer.c buffer.h \
dnscache.c dnscache.h \
log.c log.h \

View File

@ -1,4 +1,4 @@
/* $Id: reqs.c,v 1.34 2001-10-25 05:12:46 rjkaes Exp $
/* $Id: reqs.c,v 1.35 2001-10-25 16:58:50 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
@ -28,6 +28,7 @@
#include "acl.h"
#include "anonymous.h"
#include "buffer.h"
#include "conns.h"
#include "filter.h"
#include "log.h"
#include "regexp.h"
@ -688,38 +689,6 @@ static void relay_connection(struct conn_s *connptr)
return;
}
static void initialize_conn(struct conn_s *connptr)
{
connptr->client_fd = connptr->server_fd = -1;
connptr->cbuffer = new_buffer();
connptr->sbuffer = new_buffer();
connptr->send_message = FALSE;
connptr->simple_req = FALSE;
connptr->ssl = FALSE;
connptr->upstream = FALSE;
update_stats(STAT_OPEN);
}
static void destroy_conn(struct conn_s *connptr)
{
if (connptr->client_fd != -1)
close(connptr->client_fd);
if (connptr->server_fd != -1)
close(connptr->server_fd);
if (connptr->cbuffer)
delete_buffer(connptr->cbuffer);
if (connptr->sbuffer)
delete_buffer(connptr->sbuffer);
safefree(connptr);
update_stats(STAT_CLOSE);
}
#ifdef UPSTREAM_SUPPORT
/*
* Establish a connection to the upstream proxy server.

View File

@ -1,4 +1,4 @@
/* $Id: stats.h,v 1.2 2001-09-16 20:11:24 rjkaes Exp $
/* $Id: stats.h,v 1.3 2001-10-25 16:58:50 rjkaes Exp $
*
* See 'stats.h' for a detailed description.
*
@ -18,6 +18,8 @@
#ifndef _TINYPROXY_STATS_H_
#define _TINYPROXY_STATS_H_
#include "conns.h"
/*
* Various logable statistics
*/

View File

@ -1,4 +1,4 @@
/* $Id: tinyproxy.h,v 1.17 2001-10-25 05:10:57 rjkaes Exp $
/* $Id: tinyproxy.h,v 1.18 2001-10-25 16:58:50 rjkaes Exp $
*
* See 'tinyproxy.c' for a detailed description.
*
@ -113,15 +113,6 @@ struct config_s {
};
struct conn_s {
int client_fd, server_fd;
struct buffer_s *cbuffer, *sbuffer;
bool_t simple_req;
bool_t ssl;
bool_t upstream;
bool_t send_message;
};
/* Global Structures used in the program */
extern struct config_s config;

View File

@ -1,4 +1,4 @@
/* $Id: utils.c,v 1.14 2001-10-24 00:37:23 rjkaes Exp $
/* $Id: utils.c,v 1.15 2001-10-25 16:58:50 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,
@ -26,6 +26,7 @@
#include <sysexits.h>
#include "buffer.h"
#include "conns.h"
#include "log.h"
#include "sock.h"
#include "utils.h"

View File

@ -1,4 +1,4 @@
/* $Id: utils.h,v 1.9 2001-09-15 21:29:59 rjkaes Exp $
/* $Id: utils.h,v 1.10 2001-10-25 16:58:50 rjkaes Exp $
*
* See 'utils.h' for a detailed description.
*
@ -21,6 +21,8 @@
#include "tinyproxy.h"
#include "conns.h"
extern int send_http_message(struct conn_s* connptr, int http_code,
const char *error_title, const char *message);
extern int httperr(struct conn_s *connptr, int err, const char *msg);