mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-02-02 15:07:36 -05:00
removed redundant function, add total files requested to stats
svn path=/icecast/trunk/icecast/; revision=9247
This commit is contained in:
parent
99a9e4e3a9
commit
a922caa7f4
29
src/fserve.c
29
src/fserve.c
@ -85,7 +85,7 @@ typedef struct {
|
||||
char *type;
|
||||
} mime_type;
|
||||
|
||||
static int _free_client(void *key);
|
||||
static void fserve_client_destroy(fserve_t *fclient);
|
||||
static int _delete_mapping(void *mapping);
|
||||
static void *fserv_thread_function(void *arg);
|
||||
static void create_mime_mappings(const char *fn);
|
||||
@ -105,6 +105,7 @@ void fserve_initialize(void)
|
||||
thread_mutex_create (&pending_lock);
|
||||
|
||||
run_fserv = 1;
|
||||
stats_event (NULL, "file_connections", "0");
|
||||
|
||||
fserv_thread = thread_create("File Serving Thread",
|
||||
fserv_thread_function, NULL, THREAD_ATTACHED);
|
||||
@ -143,7 +144,7 @@ int fserve_client_waiting (void)
|
||||
}
|
||||
}
|
||||
if (!ufds)
|
||||
thread_sleep(200000);
|
||||
thread_sleep(200000);
|
||||
else if (poll(ufds, fserve_clients, 200) > 0)
|
||||
{
|
||||
/* mark any clients that are ready */
|
||||
@ -230,7 +231,7 @@ static void wait_for_fds() {
|
||||
}
|
||||
/* drop out of here is someone is ready */
|
||||
if (fserve_client_waiting())
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,7 +261,7 @@ static void *fserv_thread_function(void *arg)
|
||||
fserve_t *to_go = fclient;
|
||||
fclient = fclient->next;
|
||||
*trail = fclient;
|
||||
_free_client (to_go);
|
||||
fserve_client_destroy (to_go);
|
||||
fserve_clients--;
|
||||
client_tree_changed = 1;
|
||||
continue;
|
||||
@ -285,7 +286,7 @@ static void *fserv_thread_function(void *arg)
|
||||
fclient = fclient->next;
|
||||
*trail = fclient;
|
||||
fserve_clients--;
|
||||
_free_client (to_go);
|
||||
fserve_client_destroy (to_go);
|
||||
client_tree_changed = 1;
|
||||
continue;
|
||||
}
|
||||
@ -302,7 +303,7 @@ static void *fserv_thread_function(void *arg)
|
||||
fserve_t *to_go = (fserve_t *)pending_list;
|
||||
pending_list = to_go->next;
|
||||
|
||||
_free_client (to_go);
|
||||
fserve_client_destroy (to_go);
|
||||
}
|
||||
thread_mutex_unlock (&pending_lock);
|
||||
|
||||
@ -310,13 +311,13 @@ static void *fserv_thread_function(void *arg)
|
||||
{
|
||||
fserve_t *to_go = active_list;
|
||||
active_list = to_go->next;
|
||||
_free_client (to_go);
|
||||
fserve_client_destroy (to_go);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *fserve_content_type(char *path)
|
||||
static const char *fserve_content_type(const char *path)
|
||||
{
|
||||
char *ext = util_get_extension(path);
|
||||
mime_type exttype = {ext, NULL};
|
||||
@ -358,7 +359,8 @@ static void fserve_client_destroy(fserve_t *client)
|
||||
}
|
||||
}
|
||||
|
||||
int fserve_client_create(client_t *httpclient, char *path)
|
||||
|
||||
int fserve_client_create(client_t *httpclient, const char *path)
|
||||
{
|
||||
fserve_t *client = calloc(1, sizeof(fserve_t));
|
||||
int bytes;
|
||||
@ -474,6 +476,7 @@ int fserve_client_create(client_t *httpclient, char *path)
|
||||
if(bytes > 0) httpclient->con->sent_bytes = bytes;
|
||||
}
|
||||
|
||||
stats_event_inc (NULL, "file_connections");
|
||||
sock_set_blocking(client->client->con->sock, SOCK_NONBLOCK);
|
||||
sock_set_nodelay(client->client->con->sock);
|
||||
|
||||
@ -485,14 +488,6 @@ int fserve_client_create(client_t *httpclient, char *path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _free_client(void *key)
|
||||
{
|
||||
fserve_t *client = (fserve_t *)key;
|
||||
|
||||
fserve_client_destroy(client);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _delete_mapping(void *mapping) {
|
||||
mime_type *map = mapping;
|
||||
|
@ -31,7 +31,7 @@ typedef struct _fserve_t
|
||||
|
||||
void fserve_initialize(void);
|
||||
void fserve_shutdown(void);
|
||||
int fserve_client_create(client_t *httpclient, char *path);
|
||||
int fserve_client_create(client_t *httpclient, const char *path);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -131,7 +131,7 @@ int util_read_header(int sock, char *buff, unsigned long len, int entire)
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *util_get_extension(char *path) {
|
||||
char *util_get_extension(const char *path) {
|
||||
char *ext = strrchr(path, '.');
|
||||
|
||||
if(ext == NULL)
|
||||
@ -225,7 +225,7 @@ char *util_get_path_from_uri(char *uri) {
|
||||
}
|
||||
}
|
||||
|
||||
char *util_get_path_from_normalised_uri(char *uri) {
|
||||
char *util_get_path_from_normalised_uri(const char *uri) {
|
||||
char *fullpath;
|
||||
char *webroot;
|
||||
ice_config_t *config = config_get_config();
|
||||
|
@ -22,9 +22,9 @@
|
||||
int util_timed_wait_for_fd(int fd, int timeout);
|
||||
int util_read_header(int sock, char *buff, unsigned long len, int entire);
|
||||
int util_check_valid_extension(char *uri);
|
||||
char *util_get_extension(char *path);
|
||||
char *util_get_extension(const char *path);
|
||||
char *util_get_path_from_uri(char *uri);
|
||||
char *util_get_path_from_normalised_uri(char *uri);
|
||||
char *util_get_path_from_normalised_uri(const char *uri);
|
||||
char *util_normalise_uri(char *uri);
|
||||
char *util_base64_encode(char *data);
|
||||
char *util_base64_decode(unsigned char *input);
|
||||
|
Loading…
x
Reference in New Issue
Block a user