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
6816fa0e
Commit
6816fa0e
authored
Oct 23, 2008
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
if we have EAGAIN when sending the buffer, also add the padding to the list of buffers to be sent
parent
8da3ad9c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
socket/tcp-turn.c
socket/tcp-turn.c
+13
-9
No files found.
socket/tcp-turn.c
View file @
6816fa0e
...
@@ -222,6 +222,9 @@ add_to_be_sent (NiceSocket *sock, const gchar *buf, guint len, gboolean head)
...
@@ -222,6 +222,9 @@ add_to_be_sent (NiceSocket *sock, const gchar *buf, guint len, gboolean head)
TurnTcpPriv
*
priv
=
sock
->
priv
;
TurnTcpPriv
*
priv
=
sock
->
priv
;
struct
to_be_sent
*
tbs
=
g_slice_new
(
struct
to_be_sent
);
struct
to_be_sent
*
tbs
=
g_slice_new
(
struct
to_be_sent
);
if
(
len
<=
0
)
return
;
tbs
->
buf
=
g_memdup
(
buf
,
len
);
tbs
->
buf
=
g_memdup
(
buf
,
len
);
tbs
->
length
=
len
;
tbs
->
length
=
len
;
if
(
head
)
if
(
head
)
...
@@ -248,7 +251,14 @@ socket_send (
...
@@ -248,7 +251,14 @@ socket_send (
{
{
int
ret
;
int
ret
;
TurnTcpPriv
*
priv
=
sock
->
priv
;
TurnTcpPriv
*
priv
=
sock
->
priv
;
gchar
padbuf
[
3
]
=
{
0
,
0
,
0
};
int
padlen
=
(
len
%
4
)
?
4
-
(
len
%
4
)
:
0
;
if
(
priv
->
compatibility
!=
NICE_UDP_TURN_SOCKET_COMPATIBILITY_DRAFT9
)
padlen
=
0
;
/* First try to send the data, don't send it later if it can be sent now
this way we avoid allocating memory on every send */
if
(
g_queue_is_empty
(
&
priv
->
send_queue
))
{
if
(
g_queue_is_empty
(
&
priv
->
send_queue
))
{
if
(
priv
->
compatibility
==
NICE_UDP_TURN_SOCKET_COMPATIBILITY_GOOGLE
)
{
if
(
priv
->
compatibility
==
NICE_UDP_TURN_SOCKET_COMPATIBILITY_GOOGLE
)
{
guint16
tmpbuf
=
htons
(
len
);
guint16
tmpbuf
=
htons
(
len
);
...
@@ -275,19 +285,19 @@ socket_send (
...
@@ -275,19 +285,19 @@ socket_send (
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
if
(
errno
==
EAGAIN
)
{
if
(
errno
==
EAGAIN
)
{
add_to_be_sent
(
sock
,
buf
,
len
,
FALSE
);
add_to_be_sent
(
sock
,
buf
,
len
,
FALSE
);
add_to_be_sent
(
sock
,
padbuf
,
padlen
,
FALSE
);
return
TRUE
;
return
TRUE
;
}
else
{
}
else
{
return
FALSE
;
return
FALSE
;
}
}
}
else
if
((
guint
)
ret
<
len
)
{
}
else
if
((
guint
)
ret
<
len
)
{
add_to_be_sent
(
sock
,
buf
+
ret
,
len
-
ret
,
FALSE
);
add_to_be_sent
(
sock
,
buf
+
ret
,
len
-
ret
,
FALSE
);
add_to_be_sent
(
sock
,
padbuf
,
padlen
,
FALSE
);
return
TRUE
;
return
TRUE
;
}
}
if
(
priv
->
compatibility
==
NICE_UDP_TURN_SOCKET_COMPATIBILITY_DRAFT9
&&
if
(
priv
->
compatibility
==
NICE_UDP_TURN_SOCKET_COMPATIBILITY_DRAFT9
&&
len
%
4
)
{
len
%
4
)
{
gchar
padbuf
[
3
]
=
{
0
,
0
,
0
};
int
padlen
=
(
len
%
4
)
?
4
-
(
len
%
4
)
:
0
;
ret
=
write
(
sock
->
fileno
,
padbuf
,
padlen
);
ret
=
write
(
sock
->
fileno
,
padbuf
,
padlen
);
...
@@ -309,14 +319,8 @@ socket_send (
...
@@ -309,14 +319,8 @@ socket_send (
add_to_be_sent
(
sock
,
(
gchar
*
)
&
tmpbuf
,
sizeof
(
guint16
),
FALSE
);
add_to_be_sent
(
sock
,
(
gchar
*
)
&
tmpbuf
,
sizeof
(
guint16
),
FALSE
);
}
}
add_to_be_sent
(
sock
,
buf
,
len
,
FALSE
);
add_to_be_sent
(
sock
,
buf
,
len
,
FALSE
);
if
(
priv
->
compatibility
==
NICE_UDP_TURN_SOCKET_COMPATIBILITY_DRAFT9
&&
len
%
4
)
{
gchar
padbuf
[
3
]
=
{
0
,
0
,
0
};
int
padlen
=
(
len
%
4
)
?
4
-
(
len
%
4
)
:
0
;
add_to_be_sent
(
sock
,
padbuf
,
padlen
,
FALSE
);
add_to_be_sent
(
sock
,
padbuf
,
padlen
,
FALSE
);
}
}
}
return
TRUE
;
return
TRUE
;
}
}
...
...
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