Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
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
videolan
vlc-2-2
Commits
8c906d60
Commit
8c906d60
authored
Dec 22, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use poll() directly when you want to listen to multiple sockets.
parent
6db8acaa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
22 deletions
+39
-22
modules/services_discovery/sap.c
modules/services_discovery/sap.c
+39
-22
No files found.
modules/services_discovery/sap.c
View file @
8c906d60
...
@@ -44,6 +44,9 @@
...
@@ -44,6 +44,9 @@
#ifdef HAVE_SYS_TIME_H
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# include <sys/time.h>
#endif
#endif
#ifdef HAVE_POLL
# include <poll.h>
#endif
#ifdef HAVE_ZLIB_H
#ifdef HAVE_ZLIB_H
# include <zlib.h>
# include <zlib.h>
...
@@ -536,20 +539,49 @@ static void Run( services_discovery_t *p_sd )
...
@@ -536,20 +539,49 @@ static void Run( services_discovery_t *p_sd )
/* read SAP packets */
/* read SAP packets */
while
(
!
p_sd
->
b_die
)
while
(
!
p_sd
->
b_die
)
{
{
int
i_rea
d
;
unsigned
n
=
p_sd
->
p_sys
->
i_f
d
;
uint8_t
p_buffer
[
MAX_SAP_BUFFER
+
1
];
struct
pollfd
ufd
[
n
];
i_read
=
net_Select
(
p_sd
,
p_sd
->
p_sys
->
pi_fd
,
for
(
unsigned
i
=
0
;
i
<
n
;
i
++
)
p_sd
->
p_sys
->
i_fd
,
p_buffer
,
{
MAX_SAP_BUFFER
,
500
);
ufd
[
i
].
fd
=
p_sd
->
p_sys
->
pi_fd
[
i
];
ufd
[
i
].
events
=
POLLIN
;
ufd
[
i
].
revents
=
0
;
}
/* FIXME FIXME FIXME: short arbitrary timer */
if
(
poll
(
ufd
,
n
,
500
)
>
0
)
{
for
(
unsigned
i
=
0
;
i
<
n
;
i
++
)
{
if
(
ufd
[
i
].
revents
)
{
uint8_t
p_buffer
[
MAX_SAP_BUFFER
+
1
];
ssize_t
i_read
;
i_read
=
net_Read
(
p_sd
,
ufd
[
i
].
fd
,
NULL
,
p_buffer
,
MAX_SAP_BUFFER
,
VLC_FALSE
);
if
(
i_read
<
0
)
msg_Warn
(
p_sd
,
"receive error: %m"
);
if
(
i_read
>
6
)
{
/* Parse the packet */
p_buffer
[
i_read
]
=
'\0'
;
ParseSAP
(
p_sd
,
p_buffer
,
i_read
);
}
}
}
}
mtime_t
now
=
mdate
();
/* Check for items that need deletion */
/* Check for items that need deletion */
for
(
i
=
0
;
i
<
p_sd
->
p_sys
->
i_announces
;
i
++
)
for
(
i
=
0
;
i
<
p_sd
->
p_sys
->
i_announces
;
i
++
)
{
{
mtime_t
i_timeout
=
(
mtime_t
)
1000000
*
p_sd
->
p_sys
->
i_timeout
;
mtime_t
i_timeout
=
(
mtime_t
)
1000000
*
p_sd
->
p_sys
->
i_timeout
;
sap_announce_t
*
p_announce
=
p_sd
->
p_sys
->
pp_announces
[
i
];
sap_announce_t
*
p_announce
=
p_sd
->
p_sys
->
pp_announces
[
i
];
mtime_t
i_last_period
=
mdate
()
-
p_announce
->
i_last
;
mtime_t
i_last_period
=
now
-
p_announce
->
i_last
;
/* Remove the annoucement, if the last announcement was 1 hour ago
/* Remove the annoucement, if the last announcement was 1 hour ago
* or if the last packet emitted was 3 times the average time
* or if the last packet emitted was 3 times the average time
* between two packets */
* between two packets */
...
@@ -559,21 +591,6 @@ static void Run( services_discovery_t *p_sd )
...
@@ -559,21 +591,6 @@ static void Run( services_discovery_t *p_sd )
RemoveAnnounce
(
p_sd
,
p_announce
);
RemoveAnnounce
(
p_sd
,
p_announce
);
}
}
}
}
/* Minimum length is > 6 */
if
(
i_read
<=
6
)
{
if
(
i_read
<
0
)
{
msg_Warn
(
p_sd
,
"socket read error"
);
}
continue
;
}
p_buffer
[
i_read
]
=
'\0'
;
/* Parse the packet */
ParseSAP
(
p_sd
,
p_buffer
,
i_read
);
}
}
}
}
...
...
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