mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
minor cleanups, and only have one thread responding to TERM
svn path=/trunk/avl/; revision=5787
This commit is contained in:
parent
1665a4f7d9
commit
6c6a22bf45
@ -22,7 +22,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* $Id: avl.c,v 1.10 2003/12/04 16:27:30 oddsock Exp $ */
|
||||
/* $Id: avl.c,v 1.11 2004/01/27 02:16:25 karl Exp $ */
|
||||
|
||||
/*
|
||||
* This is a fairly straightfoward translation of a prototype
|
||||
@ -89,6 +89,7 @@ avl_tree_free_helper (avl_node * node, avl_free_key_fun_type free_key_fun)
|
||||
if (node->left) {
|
||||
avl_tree_free_helper (node->left, free_key_fun);
|
||||
}
|
||||
if (free_key_fun)
|
||||
free_key_fun (node->key);
|
||||
if (node->right) {
|
||||
avl_tree_free_helper (node->right, free_key_fun);
|
||||
@ -446,6 +447,7 @@ int avl_delete(avl_tree *tree, void *key, avl_free_key_fun_type free_key_fun)
|
||||
p = x->parent;
|
||||
|
||||
/* return the key and node to storage */
|
||||
if (free_key_fun)
|
||||
free_key_fun (x->key);
|
||||
thread_rwlock_destroy (&x->rwlock);
|
||||
free (x);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "os.h"
|
||||
#include "cfgfile.h"
|
||||
#include "logging.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define snprintf _snprintf
|
||||
@ -44,33 +45,43 @@ void logging_access(client_t *client)
|
||||
{
|
||||
char datebuf[128];
|
||||
char reqbuf[1024];
|
||||
struct tm *thetime;
|
||||
struct tm thetime;
|
||||
time_t now;
|
||||
time_t stayed;
|
||||
char *referrer, *user_agent;
|
||||
|
||||
now = time(NULL);
|
||||
|
||||
/* build the data */
|
||||
/* TODO: localtime is not threadsafe on all platforms
|
||||
** we should probably use localtime_r if it's available
|
||||
*/
|
||||
PROTECT_CODE(thetime = localtime(&now); strftime(datebuf, 128, LOGGING_FORMAT_CLF, thetime))
|
||||
localtime_r (&now, &thetime);
|
||||
strftime (datebuf, sizeof(datebuf), LOGGING_FORMAT_CLF, &thetime);
|
||||
|
||||
/* build the request */
|
||||
snprintf(reqbuf, 1024, "%s %s %s/%s", httpp_getvar(client->parser, HTTPP_VAR_REQ_TYPE), httpp_getvar(client->parser, HTTPP_VAR_URI),
|
||||
httpp_getvar(client->parser, HTTPP_VAR_PROTOCOL), httpp_getvar(client->parser, HTTPP_VAR_VERSION));
|
||||
snprintf (reqbuf, sizeof(reqbuf), "%s %s %s/%s",
|
||||
httpp_getvar (client->parser, HTTPP_VAR_REQ_TYPE),
|
||||
httpp_getvar (client->parser, HTTPP_VAR_URI),
|
||||
httpp_getvar (client->parser, HTTPP_VAR_PROTOCOL),
|
||||
httpp_getvar (client->parser, HTTPP_VAR_VERSION));
|
||||
|
||||
stayed = now - client->con->con_time;
|
||||
|
||||
log_write_direct(accesslog, "%s - - [%s] \"%s\" %d %lld \"%s\" \"%s\" %d",
|
||||
referrer = httpp_getvar (client->parser, "referer");
|
||||
if (referrer == NULL)
|
||||
referrer = "-";
|
||||
|
||||
user_agent = httpp_getvar (client->parser, "user-agent");
|
||||
if (user_agent == NULL)
|
||||
user_agent = "-";
|
||||
|
||||
log_write_direct (accesslog, "%s - - [%s] \"%s\" %d %lld \"%s\" \"%s\" %u",
|
||||
client->con->ip,
|
||||
datebuf,
|
||||
reqbuf,
|
||||
client->respcode,
|
||||
client->con->sent_bytes,
|
||||
(httpp_getvar(client->parser, "referer") != NULL) ? httpp_getvar(client->parser, "referer") : "-",
|
||||
(httpp_getvar(client->parser, "user-agent") != NULL) ? httpp_getvar(client->parser, "user-agent") : "-",
|
||||
(int)stayed);
|
||||
referrer,
|
||||
user_agent,
|
||||
stayed);
|
||||
}
|
||||
|
||||
|
||||
|
2
src/os.h
2
src/os.h
@ -15,4 +15,4 @@
|
||||
#define PATH_SEPARATOR "/"
|
||||
#endif
|
||||
|
||||
#endif /* __GLOBALS_H__ */
|
||||
#endif /* __OS_H__ */
|
||||
|
@ -455,8 +455,6 @@ static void *_stats_thread(void *arg)
|
||||
/* wake the other threads so they can shut down cleanly */
|
||||
thread_cond_broadcast(&_event_signal_cond);
|
||||
|
||||
thread_exit(0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -652,8 +650,6 @@ void *stats_connection(void *arg)
|
||||
_stats_threads--;
|
||||
thread_mutex_unlock(&_stats_mutex);
|
||||
|
||||
thread_exit(0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,6 @@ static void _block_signals(void)
|
||||
/* These ones we want */
|
||||
sigdelset(&ss, SIGKILL);
|
||||
sigdelset(&ss, SIGSTOP);
|
||||
sigdelset(&ss, SIGTERM);
|
||||
sigdelset(&ss, SIGSEGV);
|
||||
sigdelset(&ss, SIGBUS);
|
||||
if (pthread_sigmask(SIG_BLOCK, &ss, NULL) != 0) {
|
||||
@ -250,6 +249,7 @@ static void _catch_signals(void)
|
||||
sigaddset(&ss, SIGCHLD);
|
||||
sigaddset(&ss, SIGINT);
|
||||
sigaddset(&ss, SIGPIPE);
|
||||
sigaddset(&ss, SIGTERM);
|
||||
|
||||
if (pthread_sigmask(SIG_UNBLOCK, &ss, NULL) != 0) {
|
||||
#ifdef THREAD_DEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user