Commit a0783549 authored by Clément Stenac's avatar Clément Stenac

Add support for several message queues - please test

Initial support for registering and handling some shared stats 
parent d68a17b3
......@@ -455,6 +455,7 @@ SOURCES_libvlc_common = \
src/misc/block.c \
src/misc/modules.c \
src/misc/threads.c \
src/misc/stats.c \
src/misc/unicode.c \
src/misc/cpu.c \
src/misc/configuration.c \
......
......@@ -205,6 +205,7 @@ typedef struct date_t date_t;
/* Messages */
typedef struct msg_bank_t msg_bank_t;
typedef struct msg_queue_t msg_queue_t;
typedef struct msg_subscription_t msg_subscription_t;
/* Playlist */
......@@ -415,6 +416,10 @@ typedef struct vlm_schedule_t vlm_schedule_t;
/* divers */
typedef struct vlc_meta_t vlc_meta_t;
typedef struct counter_t counter_t;
typedef struct counter_sample_t counter_sample_t;
typedef struct stats_handler_t stats_handler_t;
/*****************************************************************************
* Variable callbacks
......
......@@ -45,12 +45,7 @@ typedef struct
char * psz_module;
char * psz_msg; /**< the message itself */
#if 0
mtime_t date; /* date of the message */
char * psz_file; /* file in which the function was called */
char * psz_function; /* function from which the function was called */
int i_line; /* line at which the function was called */
#endif
mtime_t date; /**< Message date */
} msg_item_t;
/* Message types */
......@@ -63,14 +58,25 @@ typedef struct
/** debug messages */
#define VLC_MSG_DBG 3
#define MSG_QUEUE_NORMAL 0
#define MSG_QUEUE_HTTPD_ACCESS 1
/**
* Store all data requiered by messages interfaces.
*/
struct msg_bank_t
{
vlc_mutex_t lock;
int i_queues;
msg_queue_t **pp_queues;
};
struct msg_queue_t
{
int i_id;
/** Message queue lock */
vlc_mutex_t lock;
vlc_bool_t b_configured;
vlc_bool_t b_overflow;
/* Message queue */
......@@ -103,9 +109,9 @@ struct msg_subscription_t
/*****************************************************************************
* Prototypes
*****************************************************************************/
VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 4, 5 ) );
VLC_EXPORT( void, __msg_GenericVa, ( vlc_object_t *, int, const char *, const char *, va_list args ) );
#define msg_GenericVa(a, b, c, d, e) __msg_GenericVa(VLC_OBJECT(a), b, c, d, e)
VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 5, 6 ) );
VLC_EXPORT( void, __msg_GenericVa, ( vlc_object_t *, int, int, const char *, const char *, va_list args ) );
#define msg_GenericVa(a, b, c, d, e),f __msg_GenericVa(VLC_OBJECT(a), b, c, d, e,f)
VLC_EXPORT( void, __msg_Info, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
VLC_EXPORT( void, __msg_Err, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
VLC_EXPORT( void, __msg_Warn, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
......@@ -114,19 +120,19 @@ VLC_EXPORT( void, __msg_Dbg, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_
#ifdef HAVE_VARIADIC_MACROS
# define msg_Info( p_this, psz_format, args... ) \
__msg_Generic( VLC_OBJECT(p_this), VLC_MSG_INFO, MODULE_STRING, \
__msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL,VLC_MSG_INFO, MODULE_STRING, \
psz_format, ## args )
# define msg_Err( p_this, psz_format, args... ) \
__msg_Generic( VLC_OBJECT(p_this), VLC_MSG_ERR, MODULE_STRING, \
__msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL, VLC_MSG_ERR, MODULE_STRING, \
psz_format, ## args )
# define msg_Warn( p_this, psz_format, args... ) \
__msg_Generic( VLC_OBJECT(p_this), VLC_MSG_WARN, MODULE_STRING, \
__msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL, VLC_MSG_WARN, MODULE_STRING, \
psz_format, ## args )
# define msg_Dbg( p_this, psz_format, args... ) \
__msg_Generic( VLC_OBJECT(p_this), VLC_MSG_DBG, MODULE_STRING, \
__msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL, VLC_MSG_DBG, MODULE_STRING, \
psz_format, ## args )
#elif defined(_MSC_VER) /* To avoid warnings and even errors with c++ files */
......@@ -135,7 +141,7 @@ inline void msg_Info( void *p_this, const char *psz_format, ... )
{
va_list ap;
va_start( ap, psz_format );
__msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_INFO, MODULE_STRING,
__msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL,VLC_MSG_INFO, MODULE_STRING,
psz_format, ap );
va_end(ap);
}
......@@ -143,7 +149,7 @@ inline void msg_Err( void *p_this, const char *psz_format, ... )
{
va_list ap;
va_start( ap, psz_format );
__msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_ERR, MODULE_STRING,
__msg_GenericVa( ( vlc_object_t *)p_this,MSG_QUEUE_NORMAL, VLC_MSG_ERR, MODULE_STRING,
psz_format, ap );
va_end(ap);
}
......@@ -151,7 +157,7 @@ inline void msg_Warn( void *p_this, const char *psz_format, ... )
{
va_list ap;
va_start( ap, psz_format );
__msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_WARN, MODULE_STRING,
__msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL, VLC_MSG_WARN, MODULE_STRING,
psz_format, ap );
va_end(ap);
}
......@@ -159,7 +165,7 @@ inline void msg_Dbg( void *p_this, const char *psz_format, ... )
{
va_list ap;
va_start( ap, psz_format );
__msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_DBG, MODULE_STRING,
__msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL, VLC_MSG_DBG, MODULE_STRING,
psz_format, ap );
va_end(ap);
}
......@@ -180,12 +186,64 @@ void __msg_Create ( vlc_object_t * );
void __msg_Flush ( vlc_object_t * );
void __msg_Destroy ( vlc_object_t * );
#define msg_Subscribe(a) __msg_Subscribe(VLC_OBJECT(a))
#define msg_Subscribe(a,b) __msg_Subscribe(VLC_OBJECT(a),b)
#define msg_Unsubscribe(a,b) __msg_Unsubscribe(VLC_OBJECT(a),b)
VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t * ) );
VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t *, int ) );
VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) );
/**
* @}
*/
/**
* \defgroup statistics Statistics
*
* @{
*/
enum
{
STATS_LAST,
STATS_COUNTER,
STATS_MAX,
STATS_MIN,
};
struct counter_sample_t
{
vlc_value_t value;
mtime_t date;
};
struct counter_t
{
char * psz_name;
int i_source_object;
int i_compute_type;
int i_type;
int i_samples;
counter_sample_t ** pp_samples;
};
struct stats_handler_t
{
VLC_COMMON_MEMBERS
int i_counters;
counter_t **pp_counters;
};
#define stats_Update( a,b,c) __stats_Update( VLC_OBJECT( a ), b, c )
VLC_EXPORT( int, __stats_Update, (vlc_object_t*, char *, vlc_value_t) );
#define stats_Create( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d )
VLC_EXPORT( int, __stats_Create, (vlc_object_t*, char *, int, int) );
static inline int __stats_UpdateInteger( vlc_object_t *p_obj, char *psz_name,
int i )
{
vlc_value_t val;
val.i_int = i;
return __stats_Update( p_obj, psz_name, val );
}
#define stats_UpdateInteger( a,b,c ) __stats_UpdateInteger( VLC_OBJECT(a),b,c )
......@@ -60,6 +60,7 @@
#define VLC_OBJECT_SD (-26)
#define VLC_OBJECT_XML (-27)
#define VLC_OBJECT_OSDMENU (-28)
#define VLC_OBJECT_STATS (-29)
#define VLC_OBJECT_GENERIC (-666)
......
......@@ -62,6 +62,7 @@ int playlist_ItemSetName (playlist_item_t *, char *);
void __osd_MenuShow (vlc_object_t *);
httpd_url_t * httpd_UrlNewUnique (httpd_host_t *, const char *psz_url, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl);
void httpd_ClientModeStream (httpd_client_t *cl);
int __stats_Create (vlc_object_t*, char *, int, int);
void httpd_RedirectDelete (httpd_redirect_t *);
void __sout_CfgParse (vlc_object_t *, char *psz_prefix, const char **ppsz_options, sout_cfg_t *);
vlm_media_t * vlm_MediaNew (vlm_t *, const char *, int);
......@@ -118,6 +119,7 @@ void vlm_MessageDelete (vlm_message_t *);
void vout_SynchroDecode (vout_synchro_t *);
int playlist_Delete (playlist_t *, int);
void aout_FiltersPlay (aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters, aout_buffer_t ** pp_input_buffer);
int __stats_Update (vlc_object_t*, char *, vlc_value_t);
char* httpd_ClientIP (httpd_client_t *cl, char *psz_ip);
int __intf_UserProgress (vlc_object_t*, const char*, const char*, float);
void httpd_FileDelete (httpd_file_t *);
......@@ -204,7 +206,7 @@ struct dirent * vlc_readdir_wrapper (void *);
void config_UnsetCallbacks (module_config_t *);
void vout_SynchroRelease (vout_synchro_t *);
void __intf_UserProgressUpdate (vlc_object_t*, int, const char*, float);
void __msg_Generic (vlc_object_t *, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 4, 5);
void __msg_Generic (vlc_object_t *, int, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 5, 6);
int vlc_closedir_wrapper (void *);
int playlist_ServicesDiscoveryAdd (playlist_t *, const char *);
char * vlc_strndup (const char *s, size_t n);
......@@ -339,7 +341,7 @@ int intf_RunThread (intf_thread_t *);
int httpd_StreamSend (httpd_stream_t *, uint8_t *p_data, int i_data);
decoder_t * input_DecoderNew (input_thread_t *, es_format_t *, vlc_bool_t b_force_decoder);
xml_t * __xml_Create (vlc_object_t *);
msg_subscription_t* __msg_Subscribe (vlc_object_t *);
msg_subscription_t* __msg_Subscribe (vlc_object_t *, int);
const char * VLC_Version (void);
session_descriptor_t* sout_AnnounceRegisterSDP (sout_instance_t *,const char *, const char *, announce_method_t*);
char * stream_ReadLine (stream_t *);
......@@ -380,7 +382,7 @@ char * ToLocale (const char *);
int vlm_Load (vlm_t *, const char *);
int aout_FiltersCreatePipeline (aout_instance_t * p_aout, aout_filter_t ** pp_filters, int * pi_nb_filters, const audio_sample_format_t * p_input_format, const audio_sample_format_t * p_output_format);
playlist_item_t * playlist_ChildSearchName (playlist_item_t*, const char*);
void __msg_GenericVa (vlc_object_t *, int, const char *, const char *, va_list args);
void __msg_GenericVa (vlc_object_t *, int, int, const char *, const char *, va_list args);
int aout_ChannelsRestart (vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void *);
char const * vlc_error (int);
int playlist_NodeGroup (playlist_t *, int,playlist_item_t *,playlist_item_t **,int, int, int);
......@@ -669,13 +671,13 @@ struct module_symbols_t
int (*intf_RunThread_inner) (intf_thread_t *);
void (*intf_StopThread_inner) (intf_thread_t *);
void (*intf_Destroy_inner) (intf_thread_t *);
void (*__msg_Generic_inner) (vlc_object_t *, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 4, 5);
void (*__msg_GenericVa_inner) (vlc_object_t *, int, const char *, const char *, va_list args);
void (*__msg_Generic_inner) (vlc_object_t *, int, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 5, 6);
void (*__msg_GenericVa_inner) (vlc_object_t *, int, int, const char *, const char *, va_list args);
void (*__msg_Info_inner) (vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3);
void (*__msg_Err_inner) (vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3);
void (*__msg_Warn_inner) (vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3);
void (*__msg_Dbg_inner) (vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3);
msg_subscription_t* (*__msg_Subscribe_inner) (vlc_object_t *);
msg_subscription_t* (*__msg_Subscribe_inner) (vlc_object_t *, int);
void (*__msg_Unsubscribe_inner) (vlc_object_t *, msg_subscription_t *);
void * (*__vlc_object_create_inner) (vlc_object_t *, int);
void (*__vlc_object_destroy_inner) (vlc_object_t *);
......@@ -869,6 +871,8 @@ struct module_symbols_t
int (*__intf_UserProgress_inner) (vlc_object_t*, const char*, const char*, float);
void (*__intf_UserProgressUpdate_inner) (vlc_object_t*, int, const char*, float);
void (*__intf_UserHide_inner) (vlc_object_t *, int);
int (*__stats_Create_inner) (vlc_object_t*, char *, int, int);
int (*__stats_Update_inner) (vlc_object_t*, char *, vlc_value_t);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
......@@ -1289,6 +1293,8 @@ struct module_symbols_t
# define __intf_UserProgress (p_symbols)->__intf_UserProgress_inner
# define __intf_UserProgressUpdate (p_symbols)->__intf_UserProgressUpdate_inner
# define __intf_UserHide (p_symbols)->__intf_UserHide_inner
# define __stats_Create (p_symbols)->__stats_Create_inner
# define __stats_Update (p_symbols)->__stats_Update_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
......@@ -1712,6 +1718,8 @@ struct module_symbols_t
((p_symbols)->__intf_UserProgress_inner) = __intf_UserProgress; \
((p_symbols)->__intf_UserProgressUpdate_inner) = __intf_UserProgressUpdate; \
((p_symbols)->__intf_UserHide_inner) = __intf_UserHide; \
((p_symbols)->__stats_Create_inner) = __stats_Create; \
((p_symbols)->__stats_Update_inner) = __stats_Update; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
# endif /* __PLUGIN__ */
......
......@@ -135,7 +135,7 @@ MessagesWindow::MessagesWindow( intf_thread_t * _p_intf,
{
SetSizeLimits( 400, 2000, 200, 2000 );
p_sub = msg_Subscribe( p_intf );
p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
BRect rect, textRect;
......
......@@ -75,7 +75,7 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
[NSThread detachNewThreadSelector:@selector(self) toTarget:[NSString string] withObject:nil];
p_intf->p_sys->o_sendport = [[NSPort port] retain];
p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
p_intf->b_play = VLC_TRUE;
p_intf->pf_run = Run;
......
......@@ -200,7 +200,7 @@ static int Open( vlc_object_t *p_this )
p_sys->i_box_plidx = 0;
p_sys->p_plnode = NULL;
p_sys->i_box_bidx = 0;
p_sys->p_sub = msg_Subscribe( p_intf );
p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
/* Initialize the curses library */
p_sys->w = initscr();
......
......@@ -77,7 +77,7 @@ static int Open( vlc_object_t *p_this )
p_intf->pf_run = Run;
// Suscribe to messages bank
p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
p_intf->p_sys->p_input = NULL;
p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf,
......
......@@ -112,7 +112,7 @@ static int Open( vlc_object_t *p_this )
}
// Suscribe to messages bank
p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
// Misc init
p_intf->p_sys->p_audio_menu = NULL;
......
......@@ -173,7 +173,7 @@ static int Open( vlc_object_t *p_this )
p_intf->pf_run = Run;
p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
/* Initialize wxWidgets thread */
p_intf->p_sys->b_playing = 0;
......
......@@ -262,7 +262,7 @@ static int Open( vlc_object_t *p_this )
#endif
}
p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
p_intf->p_sys->p_sub = msg_Subscribe( p_intf , MSG_QUEUE_NORMAL );
p_intf->pf_run = Run;
return 0;
......
This diff is collapsed.
......@@ -212,6 +212,10 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
i_size = sizeof( osd_menu_t );
psz_type = "osd menu";
break;
case VLC_OBJECT_STATS:
i_size = sizeof( stats_handler_t );
psz_type = "statistics";
break;
default:
i_size = i_type > 0
? i_type > (int)sizeof(vlc_object_t)
......
/*****************************************************************************
* stats.c: Statistics handling
*****************************************************************************
* Copyright (C) 1998-2005 the VideoLAN team
* $Id: messages.c 12729 2005-10-02 08:00:06Z courmisch $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdio.h> /* required */
#include <vlc/vlc.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static counter_t *stats_GetCounter( stats_handler_t *p_handler, int i_object_id,
char *psz_name );
static int stats_CounterUpdate( stats_handler_t *p_handler,
counter_t *p_counter,
vlc_value_t val );
static stats_handler_t* stats_HandlerCreate( vlc_object_t *p_this );
static stats_handler_t *stats_HandlerGet( vlc_object_t *p_this );
/*****************************************************************************
* Exported functions
*****************************************************************************/
int __stats_Create( vlc_object_t *p_this, char *psz_name, int i_type,
int i_compute_type )
{
counter_t *p_counter;
stats_handler_t *p_handler = stats_HandlerGet( p_this );
p_counter = (counter_t*) malloc( sizeof( counter_t ) ) ;
p_counter->psz_name = strdup( psz_name );
p_counter->i_source_object = p_this->i_object_id;
p_counter->i_compute_type = i_compute_type;
p_counter->i_type = i_type;
p_counter->i_samples = 0;
p_counter->pp_samples = NULL;
INSERT_ELEM( p_handler->pp_counters,
p_handler->i_counters,
p_handler->i_counters,
p_counter );
fprintf (stderr, "Counter created\n");
return VLC_SUCCESS;
}
int __stats_Update( vlc_object_t *p_this, char *psz_name, vlc_value_t val )
{
counter_t *p_counter;
fprintf( stderr, "Updating\n");
/* Get stats handler singleton */
stats_handler_t *p_handler = stats_HandlerGet( p_this );
if( !p_handler ) return VLC_ENOMEM;
fprintf( stderr, "Got handler\n");
/* Look for existing element */
p_counter = stats_GetCounter( p_handler, p_this->i_object_id,
psz_name );
if( !p_counter )
{
vlc_object_release( p_handler );
return VLC_ENOOBJ;
}
fprintf (stderr, "Got counter, updating it\n");
return stats_CounterUpdate( p_handler, p_counter, val );
}
static int stats_CounterUpdate( stats_handler_t *p_handler,
counter_t *p_counter,
vlc_value_t val )
{
switch( p_counter->i_compute_type )
{
case STATS_LAST:
if( p_counter->i_samples > 1)
{
msg_Err( p_handler, "LAST counter has several samples !" );
return VLC_EGENERIC;
}
if( p_counter->i_samples == 0 )
{
counter_sample_t *p_new = (counter_sample_t*)malloc(
sizeof( counter_sample_t ) );
p_new->value.psz_string = NULL;
INSERT_ELEM( p_counter->pp_samples, p_counter->i_samples,
p_counter->i_samples, p_new );
}
if( p_counter->i_samples == 1 )
{
if( p_counter->i_type == VLC_VAR_STRING &&
p_counter->pp_samples[0]->value.psz_string )
{
free( p_counter->pp_samples[0]->value.psz_string );
}
p_counter->pp_samples[0]->value = val;
}
break;
case STATS_COUNTER:
if( p_counter->i_samples > 1)
{
msg_Err( p_handler, "LAST counter has several samples !" );
return VLC_EGENERIC;
}
if( p_counter->i_samples == 0 )
{
counter_sample_t *p_new = (counter_sample_t*)malloc(
sizeof( counter_sample_t ) );
p_new->value.psz_string = NULL;
INSERT_ELEM( p_counter->pp_samples, p_counter->i_samples,
p_counter->i_samples, p_new );
}
if( p_counter->i_samples == 1 )
{
switch( p_counter->i_type )
{
case VLC_VAR_INTEGER:
case VLC_VAR_FLOAT:
p_counter->pp_samples[0]->value.i_int += val.i_int;
break;
default:
msg_Err( p_handler, "Trying to increment invalid variable %s",
p_counter->psz_name );
return VLC_EGENERIC;
}
}
break;
}
fprintf (stderr, "Counter value is %i\n", p_counter->pp_samples[0]->value.i_int );
return VLC_SUCCESS;
}
static counter_t *stats_GetCounter( stats_handler_t *p_handler, int i_object_id,
char *psz_name )
{
int i;
fprintf( stderr, "Looking through %i counters\n", p_handler->i_counters );
for( i = 0; i< p_handler->i_counters; i++ )
{
counter_t *p_counter = p_handler->pp_counters[i];
fprintf( stderr, "%i - %s\n", p_counter->i_source_object, p_counter->psz_name );
if( p_counter->i_source_object == i_object_id &&
!strcmp( p_counter->psz_name, psz_name ) )
{
return p_counter;
}
}
return NULL;
}
static stats_handler_t *stats_HandlerGet( vlc_object_t *p_this )
{
fprintf (stderr, "Getting handler\n");
stats_handler_t *p_handler = (stats_handler_t*)
vlc_object_find( p_this->p_vlc, VLC_OBJECT_STATS,
FIND_ANYWHERE );
fprintf( stderr, "Got it %p\n", p_handler );
if( !p_handler )
{
p_handler = stats_HandlerCreate( p_this );
if( !p_handler )
{
return NULL;
}
vlc_object_yield( p_handler );
}
return p_handler;
}
/**
* Initialize statistics handler
*
* This function initializes the global statistics handler singleton,
* \param p_this the parent VLC object
*/
static stats_handler_t* stats_HandlerCreate( vlc_object_t *p_this )
{
stats_handler_t *p_handler;
msg_Dbg( p_this, "creating statistics handler" );
p_handler = (stats_handler_t*) vlc_object_create( p_this,
VLC_OBJECT_STATS );
if( !p_handler )
{
msg_Err( p_this, "out of memory" );
return NULL;
}
p_handler->i_counters = 0;
p_handler->pp_counters = NULL;
/// \bug is it p_vlc or p_libvlc ?
vlc_object_attach( p_handler, p_this->p_vlc );
return p_handler;
}
......@@ -2058,6 +2058,8 @@ static void httpd_HostThread( httpd_host_t *host )
{
tls_session_t *p_tls = NULL;
stats_Create( host, "client_connections", VLC_VAR_INTEGER, STATS_COUNTER );
while( !host->b_die )
{
struct timeval timeout;
......@@ -2520,6 +2522,7 @@ static void httpd_HostThread( httpd_host_t *host )
struct sockaddr_storage sock;
fd = accept( fd, (struct sockaddr *)&sock, &i_sock_size );
fprintf ( stderr, "Accepting\n");
if( fd >= 0 )
{
int i_state = 0;
......@@ -2558,7 +2561,8 @@ static void httpd_HostThread( httpd_host_t *host )
if( fd >= 0 )
{
httpd_client_t *cl;
stats_UpdateInteger( host, "client_connections",
1 );
cl = httpd_ClientNew( fd, &sock, i_sock_size, p_tls );
p_tls = NULL;
vlc_mutex_lock( &host->lock );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment