[vlc-devel] commit: SAP: use thread cancellation, get rid of the waitpipe hack ( Rémi Denis-Courmont )
git version control
git at videolan.org
Thu Aug 28 21:39:20 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Thu Aug 28 22:41:15 2008 +0300| [64d0d7acc0cdea0885d06c95c74eedbdc7ec19d0] | committer: Rémi Denis-Courmont
SAP: use thread cancellation, get rid of the waitpipe hack
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=64d0d7acc0cdea0885d06c95c74eedbdc7ec19d0
---
modules/services_discovery/sap.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/modules/services_discovery/sap.c b/modules/services_discovery/sap.c
index ec84aa9..eb1bc53 100644
--- a/modules/services_discovery/sap.c
+++ b/modules/services_discovery/sap.c
@@ -481,6 +481,7 @@ static void Run( services_discovery_t *p_sd )
char *psz_addr;
int i;
int timeout = -1;
+ int canc = vlc_savecancel ();
/* Braindead Winsock DNS resolver will get stuck over 2 seconds per failed
* DNS queries, even if the DNS server returns an error with milliseconds.
@@ -557,10 +558,11 @@ static void Run( services_discovery_t *p_sd )
}
/* read SAP packets */
- while( vlc_object_alive( p_sd ) )
+ for (;;)
{
+ vlc_restorecancel (canc);
unsigned n = p_sd->p_sys->i_fd;
- struct pollfd ufd[n+1];
+ struct pollfd ufd[n];
for (unsigned i = 0; i < n; i++)
{
@@ -569,12 +571,9 @@ static void Run( services_discovery_t *p_sd )
ufd[i].revents = 0;
}
- /* Make sure we track vlc_object_signal() */
- ufd[n].fd = vlc_object_waitpipe( p_sd );
- ufd[n].events = POLLIN;
- ufd[n].revents = 0;
-
- if (poll (ufd, n+1, timeout) > 0)
+ int val = poll (ufd, n, timeout);
+ canc = vlc_savecancel ();
+ if (val > 0)
{
for (unsigned i = 0; i < n; i++)
{
More information about the vlc-devel
mailing list