-const char jcc_rcs[] = "$Id: jcc.c,v 1.322 2010/07/21 14:30:40 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.323 2010/07/21 14:32:00 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
const char project_h_rcs[] = PROJECT_H_VERSION;
int daemon_mode = 1;
-struct client_state clients[1];
+struct client_states clients[1];
struct file_list files[1];
#ifdef FEATURE_STATISTICS
*********************************************************************/
static void listen_loop(void)
{
+ struct client_states *csp_list = NULL;
struct client_state *csp = NULL;
jb_socket bfd;
struct configuration_spec *config;
}
#endif
- if ( NULL == (csp = (struct client_state *) zalloc(sizeof(*csp))) )
+ csp_list = (struct client_states *)zalloc(sizeof(*csp_list));
+ if (NULL == csp_list)
{
- log_error(LOG_LEVEL_FATAL, "malloc(%d) for csp failed: %E", sizeof(*csp));
+ log_error(LOG_LEVEL_FATAL,
+ "malloc(%d) for csp_list failed: %E", sizeof(*csp_list));
continue;
}
+ csp = &csp_list->csp;
csp->flags |= CSP_FLAG_ACTIVE;
csp->server_connection.sfd = JB_INVALID_SOCKET;
}
/* add it to the list of clients */
- csp->next = clients->next;
- clients->next = csp;
+ csp_list->next = clients->next;
+ clients->next = csp_list;
if (config->multi_threaded)
{
#ifndef JCC_H_INCLUDED
#define JCC_H_INCLUDED
-#define JCC_H_VERSION "$Id: jcc.h,v 1.27 2009/09/10 14:42:01 fabiankeil Exp $"
+#define JCC_H_VERSION "$Id: jcc.h,v 1.28 2010/01/03 12:37:14 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.h,v $
extern int urls_rejected;
#endif /*def FEATURE_STATISTICS*/
-extern struct client_state clients[1];
+extern struct client_states clients[1];
extern struct file_list files[1];
#ifdef unix
-const char loaders_rcs[] = "$Id: loaders.c,v 1.74 2009/09/26 13:29:57 fabiankeil Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.75 2010/05/26 23:01:47 ler762 Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loaders.c,v $
unsigned int sweep(void)
{
struct file_list *fl, *nfl;
- struct client_state *csp, *last_active;
+ struct client_state *csp;
+ struct client_states *last_active, *client_list;
int i;
unsigned int active_threads = 0;
}
last_active = clients;
- csp = clients->next;
+ client_list = clients->next;
- while (NULL != csp)
+ while (NULL != client_list)
{
+ csp = &client_list->csp;
if (csp->flags & CSP_FLAG_ACTIVE)
{
/* Mark this client's files as active */
active_threads++;
- last_active = csp;
- csp = csp->next;
+ last_active = client_list;
+ client_list = client_list->next;
}
else
/*
* This client is not active. Free its resources.
*/
{
- last_active->next = csp->next;
+ last_active->next = client_list->next;
freez(csp->ip_addr_str);
freez(csp->iob->buf);
}
#endif /* def FEATURE_STATISTICS */
- freez(csp);
+ freez(client_list);
- csp = last_active->next;
+ client_list = last_active->next;
}
}
#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
/** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.156 2010/05/24 11:38:22 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.157 2010/05/24 11:39:36 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
* or NULL. Currently only used for socks errors.
*/
char *error_message;
-
- /** Next thread in linked list. Only read or modify from the main thread! */
- struct client_state *next;
};
+/**
+ * List of client states so the main thread can keep
+ * track of them and garbage collect their resources.
+ */
+struct client_states
+{
+ struct client_states *next;
+ struct client_state csp;
+};
/**
* A function to add a header