Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
cpp-libs
libnice
Commits
ff5d688c
Commit
ff5d688c
authored
Oct 06, 2010
by
Marcus Lundblad
Committed by
Youness Alaoui
Dec 14, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store permissions in a GList instead of a GHashTable
parent
1252f780
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
socket/turn.c
socket/turn.c
+14
-10
No files found.
socket/turn.c
View file @
ff5d688c
...
@@ -89,7 +89,8 @@ typedef struct {
...
@@ -89,7 +89,8 @@ typedef struct {
uint8_t
ms_connection_id
[
20
];
uint8_t
ms_connection_id
[
20
];
uint32_t
ms_sequence_num
;
uint32_t
ms_sequence_num
;
bool
ms_connection_id_valid
;
bool
ms_connection_id_valid
;
GHashTable
*
permissions
;
/* stores installed permissions */
GList
*
permissions
;
/* the peers (NiceAddress) for which
there is an installed permission */
GHashTable
*
sent_permissions
;
/* ongoing permission installed */
GHashTable
*
sent_permissions
;
/* ongoing permission installed */
GHashTable
*
send_data_queues
;
/* stores a send data queue for per peer */
GHashTable
*
send_data_queues
;
/* stores a send data queue for per peer */
guint
permission_timeout_source
;
/* timer used to invalidate permissions */
guint
permission_timeout_source
;
/* timer used to invalidate permissions */
...
@@ -218,10 +219,6 @@ nice_turn_socket_new (NiceAgent *agent, NiceAddress *addr,
...
@@ -218,10 +219,6 @@ nice_turn_socket_new (NiceAgent *agent, NiceAddress *addr,
priv
->
server_addr
=
*
server_addr
;
priv
->
server_addr
=
*
server_addr
;
priv
->
compatibility
=
compatibility
;
priv
->
compatibility
=
compatibility
;
priv
->
send_requests
=
g_queue_new
();
priv
->
send_requests
=
g_queue_new
();
priv
->
permissions
=
g_hash_table_new_full
(
priv_nice_address_hash
,
(
GEqualFunc
)
nice_address_equal
,
(
GDestroyNotify
)
nice_address_free
,
NULL
);
priv
->
sent_permissions
=
priv
->
sent_permissions
=
g_hash_table_new_full
(
priv_nice_address_hash
,
g_hash_table_new_full
(
priv_nice_address_hash
,
(
GEqualFunc
)
nice_address_equal
,
(
GEqualFunc
)
nice_address_equal
,
...
@@ -278,7 +275,8 @@ socket_close (NiceSocket *sock)
...
@@ -278,7 +275,8 @@ socket_close (NiceSocket *sock)
}
}
g_queue_free
(
priv
->
send_requests
);
g_queue_free
(
priv
->
send_requests
);
g_hash_table_destroy
(
priv
->
permissions
);
g_list_foreach
(
priv
->
permissions
,
(
GFunc
)
nice_address_free
,
NULL
);
g_list_free
(
priv
->
permissions
);
g_hash_table_destroy
(
priv
->
send_data_queues
);
g_hash_table_destroy
(
priv
->
send_data_queues
);
g_source_remove
(
priv
->
permission_timeout_source
);
g_source_remove
(
priv
->
permission_timeout_source
);
...
@@ -341,7 +339,10 @@ stun_message_ensure_ms_realm(StunMessage *msg, uint8_t *realm)
...
@@ -341,7 +339,10 @@ stun_message_ensure_ms_realm(StunMessage *msg, uint8_t *realm)
static
gboolean
static
gboolean
priv_has_permission_for_peer
(
TurnPriv
*
priv
,
const
NiceAddress
*
to
)
priv_has_permission_for_peer
(
TurnPriv
*
priv
,
const
NiceAddress
*
to
)
{
{
return
g_hash_table_lookup
(
priv
->
permissions
,
to
)
!=
NULL
;
GList
*
found
=
g_list_find_custom
(
priv
->
permissions
,
to
,
(
GCompareFunc
)
nice_address_equal
);
return
found
!=
NULL
;
}
}
static
gboolean
static
gboolean
...
@@ -567,7 +568,9 @@ priv_permission_timeout (gpointer data)
...
@@ -567,7 +568,9 @@ priv_permission_timeout (gpointer data)
agent_lock
();
agent_lock
();
/* remove all permissions for this agent (the permission for the peer
/* remove all permissions for this agent (the permission for the peer
we are sending to will be renewed) */
we are sending to will be renewed) */
g_hash_table_remove_all
(
priv
->
permissions
);
g_list_foreach
(
priv
->
permissions
,
(
GFunc
)
nice_address_free
,
NULL
);
g_list_free
(
priv
->
permissions
);
priv
->
permissions
=
NULL
;
agent_unlock
();
agent_unlock
();
return
TRUE
;
return
TRUE
;
...
@@ -817,7 +820,8 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
...
@@ -817,7 +820,8 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
nice_address_free
(
to
);
nice_address_free
(
to
);
}
else
{
}
else
{
/* we now have a permission installed for this peer */
/* we now have a permission installed for this peer */
g_hash_table_insert
(
priv
->
permissions
,
to
,
to
);
priv
->
permissions
=
g_list_append
(
priv
->
permissions
,
to
);
g_hash_table_remove
(
priv
->
sent_permissions
,
to
);
g_hash_table_remove
(
priv
->
sent_permissions
,
to
);
/* install timer to schedule refresh of the permission */
/* install timer to schedule refresh of the permission */
...
@@ -1001,7 +1005,7 @@ priv_retransmissions_create_permission_tick_unlocked (TurnPriv *priv)
...
@@ -1001,7 +1005,7 @@ priv_retransmissions_create_permission_tick_unlocked (TurnPriv *priv)
message, assume we can just send the data, the server
message, assume we can just send the data, the server
might not support RFC TURN, or connectivity check will
might not support RFC TURN, or connectivity check will
fail eventually anyway */
fail eventually anyway */
g_hash_table_insert
(
priv
->
permissions
,
to
,
to
);
priv
->
permissions
=
g_list_append
(
priv
->
permissions
,
to
);
g_hash_table_remove
(
priv
->
sent_permissions
,
to
);
g_hash_table_remove
(
priv
->
sent_permissions
,
to
);
socket_dequeue_all_data
(
priv
,
to
);
socket_dequeue_all_data
(
priv
,
to
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment