Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Icecast-Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
spr0cketeer
Icecast-Server
Commits
f915fe76
Commit
f915fe76
authored
Nov 02, 2018
by
Philipp Schafft
🦁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update: Migrated from refobject to igloo_ro
parent
ae9a7ca0
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
274 additions
and
668 deletions
+274
-668
src/Makefile.am
src/Makefile.am
+0
-2
src/buffer.c
src/buffer.c
+14
-12
src/buffer.h
src/buffer.h
+3
-3
src/cfgfile.c
src/cfgfile.c
+4
-4
src/client.c
src/client.c
+11
-11
src/connection.c
src/connection.c
+9
-9
src/fastevent.c
src/fastevent.c
+22
-18
src/fastevent.h
src/fastevent.h
+2
-2
src/global.c
src/global.c
+3
-3
src/icecasttypes.h
src/icecasttypes.h
+11
-17
src/listensocket.c
src/listensocket.c
+31
-27
src/listensocket.h
src/listensocket.h
+3
-3
src/main.c
src/main.c
+2
-2
src/module.c
src/module.c
+36
-31
src/module.h
src/module.h
+3
-3
src/refobject.c
src/refobject.c
+0
-198
src/refobject.h
src/refobject.h
+0
-206
src/reportxml.c
src/reportxml.c
+116
-113
src/reportxml.h
src/reportxml.h
+4
-4
No files found.
src/Makefile.am
View file @
f915fe76
...
...
@@ -28,7 +28,6 @@ noinst_HEADERS = \
md5.h
\
matchfile.h
\
tls.h
\
refobject.h
\
buffer.h
\
module.h
\
reportxml.h
\
...
...
@@ -74,7 +73,6 @@ icecast_SOURCES = \
md5.c
\
matchfile.c
\
tls.c
\
refobject.c
\
buffer.c
\
module.c
\
reportxml.c
\
...
...
src/buffer.c
View file @
f915fe76
...
...
@@ -16,10 +16,10 @@
#include <stdarg.h>
#include "buffer.h"
#include
"refobject.h"
#include
<igloo/ro.h>
struct
buffer_tag
{
refobject
_base_t
__base
;
igloo_ro
_base_t
__base
;
/* Buffer itself */
void
*
buffer
;
/* Length in bytes of buffer */
...
...
@@ -30,21 +30,23 @@ struct buffer_tag {
size_t
offset
;
};
static
void
__free
(
refobject_t
self
,
void
**
userdata
)
static
void
__free
(
igloo_ro_t
self
);
igloo_RO_PUBLIC_TYPE
(
buffer_t
,
igloo_RO_TYPEDECL_FREE
(
__free
),
igloo_RO_TYPEDECL_NEW_NOOP
()
);
static
void
__free
(
igloo_ro_t
self
)
{
buffer_t
*
buffer
=
REFOBJECT_TO_TYPE
(
self
,
buffer_t
*
);
buffer_t
*
buffer
=
igloo_RO_TO_TYPE
(
self
,
buffer_t
);
free
(
buffer
->
buffer
);
}
REFOBJECT_DEFINE_TYPE
(
buffer_t
,
REFOBJECT_DEFINE_TYPE_FREE
(
__free
),
REFOBJECT_DEFINE_TYPE_NEW_NOOP
()
);
buffer_t
*
buffer_new
(
ssize_t
preallocation
,
void
*
userdata
,
const
char
*
name
,
refobject_t
associated
)
buffer_t
*
buffer_new
(
ssize_t
preallocation
,
const
char
*
name
,
igloo_ro_t
associated
)
{
buffer_t
*
buffer
=
refobject_new_ext
(
buffer_t
,
userdata
,
name
,
associated
);
buffer_t
*
buffer
=
igloo_ro_new_ext
(
buffer_t
,
name
,
associated
);
if
(
!
buffer
)
return
NULL
;
...
...
@@ -57,7 +59,7 @@ buffer_t * buffer_new(ssize_t preallocation, void *userdata, const char *name,
buffer_t
*
buffer_new_simple
(
void
)
{
return
refobject
_new
(
buffer_t
);
return
igloo_ro
_new
(
buffer_t
);
}
void
buffer_preallocate
(
buffer_t
*
buffer
,
size_t
request
)
...
...
src/buffer.h
View file @
f915fe76
...
...
@@ -22,13 +22,13 @@
#include "icecasttypes.h"
#include "compat.h"
#include
"refobject.h"
#include
<igloo/ro.h>
/* About thread safety:
* This set of functions is intentinally not thread safe.
*/
REFOBJECT
_FORWARD_TYPE
(
buffer_t
);
igloo_RO
_FORWARD_TYPE
(
buffer_t
);
/* This creates a new buffer object.
* Parameters:
...
...
@@ -37,7 +37,7 @@ REFOBJECT_FORWARD_TYPE(buffer_t);
* userdata, name, associated
* See refobject_new().
*/
buffer_t
*
buffer_new
(
ssize_t
preallocation
,
void
*
userdata
,
const
char
*
name
,
refobject
_t
associated
);
buffer_t
*
buffer_new
(
ssize_t
preallocation
,
const
char
*
name
,
igloo_ro
_t
associated
);
/* Depreciated: This creates a new buffer with defaults.
* Do NOT use this. Use refobject_new(buffer_t)
...
...
src/cfgfile.c
View file @
f915fe76
...
...
@@ -34,7 +34,7 @@
#include "util.h"
#include "auth.h"
#include "event.h"
#include
"refobject.h"
#include
<igloo/ro.h>
#include "reportxml.h"
/* for config_reread_config() */
...
...
@@ -234,7 +234,7 @@ void config_init_configuration(ice_config_t *configuration)
{
memset
(
configuration
,
0
,
sizeof
(
ice_config_t
));
_set_defaults
(
configuration
);
configuration
->
reportxml_db
=
refobject
_new
(
reportxml_database_t
);
configuration
->
reportxml_db
=
igloo_ro
_new
(
reportxml_database_t
);
}
static
inline
void
__read_int
(
xmlDocPtr
doc
,
xmlNodePtr
node
,
int
*
val
,
const
char
*
warning
)
...
...
@@ -699,7 +699,7 @@ void config_clear(ice_config_t *c)
config_clear_http_header
(
c
->
http_headers
);
refobject
_unref
(
c
->
reportxml_db
);
igloo_ro
_unref
(
c
->
reportxml_db
);
memset
(
c
,
0
,
sizeof
(
ice_config_t
));
}
...
...
@@ -2241,7 +2241,7 @@ static void _parse_paths(xmlDocPtr doc,
ICECAST_LOG_ERROR
(
"Can not parse report xml database
\"
%H
\"
"
,
temp
);
}
else
{
reportxml_database_add_report
(
configuration
->
reportxml_db
,
report
);
refobject
_unref
(
report
);
igloo_ro
_unref
(
report
);
ICECAST_LOG_INFO
(
"File
\"
%H
\"
added to report xml database"
,
temp
);
}
}
...
...
src/client.c
View file @
f915fe76
...
...
@@ -31,7 +31,7 @@
#include <igloo/httpp.h>
#include "global.h"
#include
"refobject.h"
#include
<igloo/ro.h>
#include "cfgfile.h"
#include "connection.h"
#include "tls.h"
...
...
@@ -41,7 +41,7 @@
#include "fserve.h"
#include "errors.h"
#include "reportxml.h"
#include
"refobject.h"
#include
<igloo/ro.h>
#include "xslt.h"
#include "source.h"
...
...
@@ -266,7 +266,7 @@ void client_destroy(client_t *client)
if
(
client
->
free_client_data
)
client
->
free_client_data
(
client
);
refobject
_unref
(
client
->
handler_module
);
igloo_ro
_unref
(
client
->
handler_module
);
free
(
client
->
handler_function
);
free
(
client
->
uri
);
free
(
client
->
username
);
...
...
@@ -344,7 +344,7 @@ static inline void _client_send_report(client_t *client, const char *uuid, const
client_send_reportxml
(
client
,
report
,
DOCUMENT_DOMAIN_ADMIN
,
xslt
,
admin_format
,
http_status
,
location
);
refobject
_unref
(
report
);
igloo_ro
_unref
(
report
);
}
void
client_send_error_by_error
(
client_t
*
client
,
const
icecast_error_t
*
error
)
...
...
@@ -659,7 +659,7 @@ static void client_get_reportxml__add_basic_stats(reportxml_t *report)
reportxml_node_add_child
(
rootnode
,
extension
);
refobject
_unref
(
rootnode
);
igloo_ro
_unref
(
rootnode
);
xmlroot
=
xmlNewNode
(
NULL
,
XMLSTR
(
"icestats"
));
modules
=
module_container_get_modulelist_as_xml
(
global
.
modulecontainer
);
...
...
@@ -667,7 +667,7 @@ static void client_get_reportxml__add_basic_stats(reportxml_t *report)
reportxml_node_add_xml_child
(
extension
,
xmlroot
);
refobject
_unref
(
extension
);
igloo_ro
_unref
(
extension
);
xmlFreeNode
(
xmlroot
);
}
...
...
@@ -686,7 +686,7 @@ reportxml_t *client_get_reportxml(const char *state_definition, const char *stat
if
(
!
report
)
{
reportxml_node_t
*
rootnode
,
*
incidentnode
,
*
statenode
;
report
=
refobject
_new
(
reportxml_t
);
report
=
igloo_ro
_new
(
reportxml_t
);
rootnode
=
reportxml_get_root_node
(
report
);
incidentnode
=
reportxml_node_new
(
REPORTXML_NODE_TYPE_INCIDENT
,
NULL
,
NULL
,
NULL
);
statenode
=
reportxml_node_new
(
REPORTXML_NODE_TYPE_STATE
,
NULL
,
state_definition
,
state_akindof
);
...
...
@@ -697,14 +697,14 @@ reportxml_t *client_get_reportxml(const char *state_definition, const char *stat
textnode
=
reportxml_node_new
(
REPORTXML_NODE_TYPE_TEXT
,
NULL
,
NULL
,
NULL
);
reportxml_node_set_content
(
textnode
,
state_text
);
reportxml_node_add_child
(
statenode
,
textnode
);
refobject
_unref
(
textnode
);
igloo_ro
_unref
(
textnode
);
}
reportxml_node_add_child
(
incidentnode
,
statenode
);
reportxml_node_add_child
(
rootnode
,
incidentnode
);
refobject
_unref
(
statenode
);
refobject
_unref
(
incidentnode
);
refobject
_unref
(
rootnode
);
igloo_ro
_unref
(
statenode
);
igloo_ro
_unref
(
incidentnode
);
igloo_ro
_unref
(
rootnode
);
}
client_get_reportxml__add_basic_stats
(
report
);
...
...
src/connection.c
View file @
f915fe76
...
...
@@ -43,7 +43,7 @@
#include "cfgfile.h"
#include "global.h"
#include "util.h"
#include
"refobject.h"
#include
<igloo/ro.h>
#include "refbuf.h"
#include "client.h"
#include "errors.h"
...
...
@@ -58,7 +58,7 @@
#include "matchfile.h"
#include "tls.h"
#include "acl.h"
#include
"refobject.h"
#include
<igloo/ro.h>
#include "listensocket.h"
#include "fastevent.h"
...
...
@@ -261,8 +261,8 @@ connection_t *connection_create(igloo_sock_t sock, listensocket_t *listensocket_
con
=
(
connection_t
*
)
calloc
(
1
,
sizeof
(
connection_t
));
if
(
con
)
{
refobject
_ref
(
listensocket_real
);
refobject
_ref
(
listensocket_effective
);
igloo_ro
_ref
(
listensocket_real
);
igloo_ro
_ref
(
listensocket_effective
);
con
->
sock
=
sock
;
con
->
listensocket_real
=
listensocket_real
;
...
...
@@ -1242,7 +1242,7 @@ static int _handle_resources(client_t *client, char **uri)
module_t
*
module
=
module_container_get_module
(
global
.
modulecontainer
,
resource
->
module
);
if
(
module
!=
NULL
)
{
refobject
_unref
(
client
->
handler_module
);
igloo_ro
_unref
(
client
->
handler_module
);
client
->
handler_module
=
module
;
}
else
{
ICECAST_LOG_ERROR
(
"Module used in alias not found: %s"
,
resource
->
module
);
...
...
@@ -1701,7 +1701,7 @@ static void __on_sock_count(size_t count, void *userdata)
void
connection_setup_sockets
(
ice_config_t
*
config
)
{
global_lock
();
refobject
_unref
(
global
.
listensockets
);
igloo_ro
_unref
(
global
.
listensockets
);
if
(
config
==
NULL
)
{
global_unlock
();
...
...
@@ -1721,7 +1721,7 @@ void connection_setup_sockets (ice_config_t *config)
allowed_ip
=
matchfile_new
(
config
->
allowfile
);
}
global
.
listensockets
=
refobject
_new
(
listensocket_container_t
);
global
.
listensockets
=
igloo_ro
_new
(
listensocket_container_t
);
listensocket_container_configure
(
global
.
listensockets
,
config
);
global_unlock
();
...
...
@@ -1745,8 +1745,8 @@ void connection_close(connection_t *con)
free
(
con
->
ip
);
if
(
con
->
readbuffer
)
free
(
con
->
readbuffer
);
refobject
_unref
(
con
->
listensocket_real
);
refobject
_unref
(
con
->
listensocket_effective
);
igloo_ro
_unref
(
con
->
listensocket_real
);
igloo_ro
_unref
(
con
->
listensocket_effective
);
free
(
con
);
}
...
...
src/fastevent.c
View file @
f915fe76
...
...
@@ -14,6 +14,10 @@
#include <config.h>
#endif
#include <igloo/typedef.h>
typedef
struct
fastevent_registration_tag
fastevent_registration_t
;
#define igloo_RO_PRIVATETYPES igloo_RO_TYPE(fastevent_registration_t)
#include <stdlib.h>
#include <string.h>
...
...
@@ -26,14 +30,19 @@
#ifdef FASTEVENT_ENABLED
typedef
struct
{
refobject
_base_t
__base
;
struct
fastevent_registration_tag
{
igloo_ro
_base_t
__base
;
fastevent_type_t
type
;
fastevent_cb_t
cb
;
fastevent_freecb_t
freecb
;
void
*
userdata
;
}
fastevent_registration_t
;
};
static
void
__unregister
(
igloo_ro_t
self
);
igloo_RO_PRIVATE_TYPE
(
fastevent_registration_t
,
igloo_RO_TYPEDECL_FREE
(
__unregister
)
);
struct
eventrow
{
size_t
length
;
...
...
@@ -96,13 +105,11 @@ static int __remove_from_row(struct eventrow * row, fastevent_registration_t *re
}
static
void
__unregister
(
refobject_t
self
,
void
**
userdata
)
static
void
__unregister
(
igloo_ro_t
self
)
{
fastevent_registration_t
*
registration
=
REFOBJECT_TO_TYPE
(
self
,
fastevent_registration_t
*
);
fastevent_registration_t
*
registration
=
igloo_RO_TO_TYPE
(
self
,
fastevent_registration_t
);
struct
eventrow
*
row
;
(
void
)
userdata
;
igloo_thread_rwlock_wlock
(
&
fastevent_lock
);
row
=
__get_row
(
registration
->
type
);
if
(
__remove_from_row
(
row
,
registration
)
!=
0
)
{
...
...
@@ -143,31 +150,28 @@ int fastevent_shutdown(void)
return
0
;
}
REFOBJECT_DEFINE_PRIVATE_TYPE
(
fastevent_registration_t
,
REFOBJECT_DEFINE_TYPE_FREE
(
__unregister
)
);
refobject
_t
fastevent_register
(
fastevent_type_t
type
,
fastevent_cb_t
cb
,
fastevent_freecb_t
freecb
,
void
*
userdata
)
igloo_ro
_t
fastevent_register
(
fastevent_type_t
type
,
fastevent_cb_t
cb
,
fastevent_freecb_t
freecb
,
void
*
userdata
)
{
struct
eventrow
*
row
;
fastevent_registration_t
*
registration
;
if
(
cb
==
NULL
)
return
REFOBJECT
_NULL
;
return
igloo_RO
_NULL
;
igloo_thread_rwlock_wlock
(
&
fastevent_lock
);
row
=
__get_row
(
type
);
if
(
row
==
NULL
)
{
igloo_thread_rwlock_unlock
(
&
fastevent_lock
);
return
REFOBJECT
_NULL
;
return
igloo_RO
_NULL
;
}
registration
=
refobject_new__new
(
fastevent_registration_t
,
NULL
,
NULL
,
NULL
);
registration
=
igloo_ro_new_raw
(
fastevent_registration_t
,
NULL
,
igloo_RO_
NULL
);
if
(
!
registration
)
{
igloo_thread_rwlock_unlock
(
&
fastevent_lock
);
return
REFOBJECT
_NULL
;
return
igloo_RO
_NULL
;
}
registration
->
type
=
type
;
...
...
@@ -177,12 +181,12 @@ refobject_t fastevent_register(fastevent_type_t type, fastevent_cb_t cb, fasteve
if
(
__add_to_row
(
row
,
registration
)
!=
0
)
{
igloo_thread_rwlock_unlock
(
&
fastevent_lock
);
refobject_unref
(
REFOBJECT_FROM_TYPE
(
registration
)
);
return
REFOBJECT
_NULL
;
igloo_ro_unref
(
registration
);
return
igloo_RO
_NULL
;
}
igloo_thread_rwlock_unlock
(
&
fastevent_lock
);
return
REFOBJECT_FROM_TYPE
(
registration
)
;
return
(
igloo_ro_t
)
registration
;
}
void
fastevent_emit
(
fastevent_type_t
type
,
fastevent_flag_t
flags
,
fastevent_datatype_t
datatype
,
...)
...
...
src/fastevent.h
View file @
f915fe76
...
...
@@ -15,7 +15,7 @@
#endif
#include <stdarg.h>
#include
"refobject.h"
#include
<igloo/ro.h>
typedef
enum
{
FASTEVENT_TYPE_SLOWEVENT
=
0
,
...
...
@@ -54,7 +54,7 @@ typedef void (*fastevent_freecb_t)(void **userdata);
#ifdef FASTEVENT_ENABLED
int
fastevent_initialize
(
void
);
int
fastevent_shutdown
(
void
);
refobject
_t
fastevent_register
(
fastevent_type_t
type
,
fastevent_cb_t
cb
,
fastevent_freecb_t
freecb
,
void
*
userdata
);
igloo_ro
_t
fastevent_register
(
fastevent_type_t
type
,
fastevent_cb_t
cb
,
fastevent_freecb_t
freecb
,
void
*
userdata
);
void
fastevent_emit
(
fastevent_type_t
type
,
fastevent_flag_t
flags
,
fastevent_datatype_t
datatype
,
...);
#else
#define fastevent_initialize() 0
...
...
src/global.c
View file @
f915fe76
...
...
@@ -22,7 +22,7 @@
#include <igloo/avl.h>
#include "global.h"
#include
"refobject.h"
#include
<igloo/ro.h>
#include "module.h"
#include "source.h"
...
...
@@ -39,14 +39,14 @@ void global_initialize(void)
global
.
clients
=
0
;
global
.
sources
=
0
;
global
.
source_tree
=
igloo_avl_tree_new
(
source_compare_sources
,
NULL
);
global
.
modulecontainer
=
refobject
_new
(
module_container_t
);
global
.
modulecontainer
=
igloo_ro
_new
(
module_container_t
);
igloo_thread_mutex_create
(
&
_global_mutex
);
}
void
global_shutdown
(
void
)
{
igloo_thread_mutex_destroy
(
&
_global_mutex
);
refobject
_unref
(
global
.
modulecontainer
);
igloo_ro
_unref
(
global
.
modulecontainer
);
igloo_avl_tree_free
(
global
.
source_tree
,
NULL
);
}
...
...
src/icecasttypes.h
View file @
f915fe76
...
...
@@ -15,6 +15,8 @@
#include "compat.h"
#include <igloo/typedef.h>
/* ---[ client.[ch] ]--- */
typedef
struct
_client_tag
client_t
;
...
...
@@ -116,22 +118,14 @@ typedef struct listensocket_tag listensocket_t;
/* ---[ refobject.[ch] ]--- */
typedef
struct
refobject_base_tag
refobject_base_t
;
#ifdef HAVE_TYPE_ATTRIBUTE_TRANSPARENT_UNION
typedef
union
__attribute__
((
__transparent_union__
))
{
refobject_base_t
*
refobject_base
;
buffer_t
*
buffer
;
module_t
*
module
;
module_container_t
*
module_container
;
reportxml_t
*
reportxml
;
reportxml_node_t
*
reportxml_node
;
reportxml_database_t
*
reportxml_database
;
listensocket_container_t
*
listensocket_container
;
listensocket_t
*
listensocket
;
}
refobject_t
;
#else
typedef
void
*
refobject_t
;
#endif
#define igloo_RO_APPTYPES \
igloo_RO_TYPE(buffer_t) \
igloo_RO_TYPE(module_t) \
igloo_RO_TYPE(module_container_t) \
igloo_RO_TYPE(reportxml_t) \
igloo_RO_TYPE(reportxml_node_t) \
igloo_RO_TYPE(reportxml_database_t) \
igloo_RO_TYPE(listensocket_container_t) \
igloo_RO_TYPE(listensocket_t)
#endif
src/listensocket.c
View file @
f915fe76
...
...
@@ -22,20 +22,22 @@
#include <string.h>
#include "icecasttypes.h"
#include <igloo/sock.h>
#include <igloo/thread.h>
#include "listensocket.h"
#include "global.h"
#include "connection.h"
#include
"refobject.h"
#include
<igloo/ro.h>
#include "logging.h"
#define CATMODULE "listensocket"
struct
listensocket_container_tag
{
refobject
_base_t
__base
;
igloo_ro
_base_t
__base
;
igloo_mutex_t
lock
;
listensocket_t
**
sock
;
int
*
sockref
;
...
...
@@ -44,7 +46,7 @@ struct listensocket_container_tag {
void
*
sockcount_userdata
;
};
struct
listensocket_tag
{
refobject
_base_t
__base
;
igloo_ro
_base_t
__base
;
size_t
sockrefc
;
igloo_mutex_t
lock
;
igloo_rwlock_t
listener_rwlock
;
...
...
@@ -53,6 +55,17 @@ struct listensocket_tag {
igloo_sock_t
sock
;
};
static
void
__listensocket_container_free
(
igloo_ro_t
self
);
int
__listensocket_container_new
(
igloo_ro_t
self
,
const
igloo_ro_type_t
*
type
,
va_list
ap
);
igloo_RO_PUBLIC_TYPE
(
listensocket_container_t
,
igloo_RO_TYPEDECL_FREE
(
__listensocket_container_free
),
igloo_RO_TYPEDECL_NEW
(
__listensocket_container_new
)
);
static
void
__listensocket_free
(
igloo_ro_t
self
);
igloo_RO_PUBLIC_TYPE
(
listensocket_t
,
igloo_RO_TYPEDECL_FREE
(
__listensocket_free
)
);
static
listensocket_t
*
listensocket_container_get_by_id
(
listensocket_container_t
*
self
,
const
char
*
id
);
static
int
listensocket_container_configure__unlocked
(
listensocket_container_t
*
self
,
const
ice_config_t
*
config
);
static
int
listensocket_container_setup__unlocked
(
listensocket_container_t
*
self
);
...
...
@@ -126,7 +139,7 @@ static void __listensocket_container_clear_sockets(listensocket_container_t *sel
if
(
self
->
sockref
[
i
])
{
listensocket_unrefsock
(
self
->
sock
[
i
]);
}
refobject
_unref
(
self
->
sock
[
i
]);
igloo_ro
_unref
(
self
->
sock
[
i
]);
self
->
sock
[
i
]
=
NULL
;
}
}
...
...
@@ -141,18 +154,18 @@ static void __listensocket_container_clear_sockets(listensocket_container_t *sel
}
static
void
__listensocket_container_free
(
refobject_t
self
,
void
**
userdata
)
static
void
__listensocket_container_free
(
igloo_ro_t
self
)
{
listensocket_container_t
*
container
=
REFOBJECT_TO_TYPE
(
self
,
listensocket_container_t
*
);
listensocket_container_t
*
container
=
igloo_RO_TO_TYPE
(
self
,
listensocket_container_t
);
igloo_thread_mutex_lock
(
&
container
->
lock
);
__listensocket_container_clear_sockets
(
container
);
igloo_thread_mutex_unlock
(
&
container
->
lock
);
igloo_thread_mutex_destroy
(
&
container
->
lock
);
}
int
__listensocket_container_new
(
refobject_t
self
,
const
refobject
_type_t
*
type
,
va_list
ap
)
int
__listensocket_container_new
(
igloo_ro_t
self
,
const
igloo_ro
_type_t
*
type
,
va_list
ap
)
{
listensocket_container_t
*
ret
=
REFOBJECT_TO_TYPE
(
self
,
listensocket_container_t
*
);
listensocket_container_t
*
ret
=
igloo_RO_TO_TYPE
(
self
,
listensocket_container_t
);
ret
->
sock
=
NULL
;
ret
->
sock_len
=
0
;
...
...
@@ -164,11 +177,6 @@ int __listensocket_container_new(refobject_t self, const refobject_type_t *type,
return
0
;
}
REFOBJECT_DEFINE_TYPE
(
listensocket_container_t
,
REFOBJECT_DEFINE_TYPE_FREE
(
__listensocket_container_free
),
REFOBJECT_DEFINE_TYPE_NEW
(
__listensocket_container_new
)
);
static
inline
void
__find_matching_entry
(
listensocket_container_t
*
self
,
const
listener_t
*
listener
,
listensocket_t
***
found
,
int
**
ref
)
{
const
listener_t
*
b
;
...
...
@@ -251,7 +259,7 @@ static int listensocket_container_configure__unlocked(listensocket_container_t *
}
if
(
n
[
i
]
==
NULL
)
{
for
(;
i
;
i
--
)
{
refobject
_unref
(
n
[
i
-
1
]);
igloo_ro
_unref
(
n
[
i
-
1
]);
}
return
-
1
;
}
...
...
@@ -434,11 +442,11 @@ connection_t * listensocket_container_accept(listensocket_container
igloo_thread_mutex_lock
(
&
self
->
lock
);
ls
=
listensocket_container_accept__inner
(
self
,
timeout
);
refobject
_ref
(
ls
);
igloo_ro
_ref
(
ls
);
igloo_thread_mutex_unlock
(
&
self
->
lock
);
ret
=
listensocket_accept
(
ls
,
self
);
refobject
_unref
(
ls
);
igloo_ro
_unref
(
ls
);
return
ret
;
}
...
...
@@ -495,7 +503,7 @@ static listensocket_t * listensocket_container_get_by_id(listensocket_container_
if
(
listener
)
{
if
(
listener
->
id
!=
NULL
&&
strcmp
(
listener
->
id
,
id
)
==
0
)
{
listensocket_release_listener
(
self
->
sock
[
i
]);
if
(
refobject
_ref
(
self
->
sock
[
i
])
==
0
)
{
if
(
igloo_ro
_ref
(
self
->
sock
[
i
])
==
0
)
{
return
self
->
sock
[
i
];
}
}
...
...
@@ -509,9 +517,9 @@ static listensocket_t * listensocket_container_get_by_id(listensocket_container_
/* ---------------------------------------------------------------------------- */
static
void
__listensocket_free
(
refobject_t
self
,
void
**
userdata
)
static
void
__listensocket_free
(
igloo_ro_t
self
)
{
listensocket_t
*
listensocket
=
REFOBJECT_TO_TYPE
(
self
,
listensocket_t
*
);
listensocket_t
*
listensocket
=
igloo_RO_TO_TYPE
(
self
,
listensocket_t
);
igloo_thread_mutex_lock
(
&
listensocket
->
lock
);
...
...
@@ -530,17 +538,13 @@ static void __listensocket_free(refobject_t self, void **userdata)
igloo_thread_mutex_destroy
(
&
listensocket
->
lock
);
}
REFOBJECT_DEFINE_TYPE
(
listensocket_t
,
REFOBJECT_DEFINE_TYPE_FREE
(
__listensocket_free
)
);
static
listensocket_t
*
listensocket_new
(
const
listener_t
*
listener
)
{
listensocket_t
*
self
;
if
(
listener
==
NULL
)
return
NULL
;
self
=
refobject_new__new
(
listensocket_t
,
NULL
,
NULL
,
NULL
);
self
=
igloo_ro_new_raw
(
listensocket_t
,
NULL
,
igloo_RO_
NULL
);
if
(
!
self
)
return
NULL
;
...
...
@@ -551,7 +555,7 @@ static listensocket_t * listensocket_new(const listener_t *listener) {
self
->
listener
=
config_copy_listener_one
(
listener
);
if
(
self
->
listener
==
NULL
)
{
refobject
_unref
(
self
);
igloo_ro
_unref
(
self
);
return
NULL
;
}
...
...
@@ -738,12 +742,12 @@ connection_t * listensocket_accept(listensocket_t *self, listensock
if
(
!
effective
)
{
effective
=
self
;
refobject
_ref
(
effective
);
igloo_ro
_ref
(
effective
);
}
con
=
connection_create
(
sock
,
self
,
effective
,
ip
);
refobject
_unref
(
effective
);
igloo_ro
_unref
(
effective
);
if
(
con
==
NULL
)
{
igloo_sock_close
(
sock
);
...
...
src/listensocket.h
View file @
f915fe76
...
...
@@ -10,10 +10,10 @@
#define __LISTENSOCKET_H__
#include "icecasttypes.h"
#include
"refobject.h"
#include
<igloo/ro.h>
#include "cfgfile.h"
REFOBJECT
_FORWARD_TYPE
(
listensocket_container_t
);
igloo_RO
_FORWARD_TYPE
(
listensocket_container_t
);
listensocket_container_t
*
listensocket_container_new
(
void
);
int
listensocket_container_configure
(
listensocket_container_t
*
self
,
const
ice_config_t
*
config
);
...
...
@@ -23,7 +23,7 @@ connection_t * listensocket_container_accept(listensocket_container
int
listensocket_container_set_sockcount_cb
(
listensocket_container_t
*
self
,
void
(
*
cb
)(
size_t
count
,
void
*
userdata
),
void
*
userdata
);
ssize_t
listensocket_container_sockcount
(
listensocket_container_t
*
self
);
REFOBJECT
_FORWARD_TYPE
(
listensocket_t
);
igloo_RO
_FORWARD_TYPE
(
listensocket_t
);