Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Steve Lhomme
VLC
Commits
b6769673
Commit
b6769673
authored
Mar 08, 2004
by
gbazin
Browse files
* src/misc/net.c: fixes a few corner cases.
parent
d504b458
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/misc/net.c
View file @
b6769673
...
...
@@ -2,7 +2,7 @@
* net.c:
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id
: net.c,v 1.10 2004/03/03 20:39:53 gbazin Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@videolan.org>
*
...
...
@@ -194,7 +194,7 @@ int __net_Read( vlc_object_t *p_this, int fd, uint8_t *p_data, int i_data,
vlc_bool_t
b_retry
)
{
struct
timeval
timeout
;
fd_set
fds
;
fd_set
fds
_r
,
fds_e
;
int
i_recv
;
int
i_total
=
0
;
int
i_ret
;
...
...
@@ -210,14 +210,17 @@ int __net_Read( vlc_object_t *p_this, int fd, uint8_t *p_data, int i_data,
}
/* Initialize file descriptor set */
FD_ZERO
(
&
fds
);
FD_SET
(
fd
,
&
fds
);
FD_ZERO
(
&
fds_r
);
FD_SET
(
fd
,
&
fds_r
);
FD_ZERO
(
&
fds_e
);
FD_SET
(
fd
,
&
fds_e
);
/* We'll wait 0.5 second if nothing happens */
timeout
.
tv_sec
=
0
;
timeout
.
tv_usec
=
500000
;
}
while
(
(
i_ret
=
select
(
fd
+
1
,
&
fds
,
NULL
,
NULL
,
&
timeout
))
==
0
||
(
i_ret
<
0
&&
errno
==
EINTR
)
);
}
while
(
(
i_ret
=
select
(
fd
+
1
,
&
fds_r
,
NULL
,
&
fds_e
,
&
timeout
))
==
0
||
(
i_ret
<
0
&&
errno
==
EINTR
)
);
if
(
i_ret
<
0
)
{
...
...
@@ -239,10 +242,17 @@ int __net_Read( vlc_object_t *p_this, int fd, uint8_t *p_data, int i_data,
i_recv
=
i_data
;
}
else
#endif
msg_Err
(
p_this
,
"recv failed (%i)"
,
WSAGetLastError
()
);
#else
msg_Err
(
p_this
,
"recv failed (%s)"
,
strerror
(
errno
)
);
#endif
return
i_total
>
0
?
i_total
:
-
1
;
}
else
if
(
i_recv
==
0
)
{
/* Connection closed */
b_retry
=
VLC_FALSE
;
}
p_data
+=
i_recv
;
i_data
-=
i_recv
;
...
...
@@ -259,7 +269,7 @@ int __net_Read( vlc_object_t *p_this, int fd, uint8_t *p_data, int i_data,
int
__net_Write
(
vlc_object_t
*
p_this
,
int
fd
,
uint8_t
*
p_data
,
int
i_data
)
{
struct
timeval
timeout
;
fd_set
fds
;
fd_set
fds
_w
,
fds_e
;
int
i_send
;
int
i_total
=
0
;
int
i_ret
;
...
...
@@ -276,14 +286,17 @@ int __net_Write( vlc_object_t *p_this, int fd, uint8_t *p_data, int i_data )
}
/* Initialize file descriptor set */
FD_ZERO
(
&
fds
);
FD_SET
(
fd
,
&
fds
);
FD_ZERO
(
&
fds_w
);
FD_SET
(
fd
,
&
fds_w
);
FD_ZERO
(
&
fds_e
);
FD_SET
(
fd
,
&
fds_e
);
/* We'll wait 0.5 second if nothing happens */
timeout
.
tv_sec
=
0
;
timeout
.
tv_usec
=
500000
;
}
while
(
(
i_ret
=
select
(
fd
+
1
,
NULL
,
&
fds
,
NULL
,
&
timeout
))
==
0
||
(
i_ret
<
0
&&
errno
==
EINTR
)
);
}
while
(
(
i_ret
=
select
(
fd
+
1
,
NULL
,
&
fds_w
,
&
fds_e
,
&
timeout
))
==
0
||
(
i_ret
<
0
&&
errno
==
EINTR
)
);
if
(
i_ret
<
0
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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