[vlc-devel] [PATCH 1/4] os2: thread: set POLLNVAL instead of returning -1 if not a socket
KO Myung-Hun
komh78 at gmail.com
Sat Oct 10 07:09:23 CEST 2015
Ping ?
KO Myung-Hun wrote:
>
>
> Rémi Denis-Courmont wrote:
>> Le 2015-09-15 18:17, KO Myung-Hun a écrit :
>>> Rémi Denis-Courmont wrote:
>>>> Le 2015-09-13 10:54, KO Myung-Hun a écrit :
>>>>> KO Myung-Hun wrote:
>>>>>> From: KO Myung-Hun <komh78 at gmail.com>
>>>>>>
>>>>>> ---
>>>>>> src/os2/thread.c | 32 +++++++++++++++++++++++++-------
>>>>>> 1 file changed, 25 insertions(+), 7 deletions(-)
>>>>>>
>>>>>
>>>>> Updated.
>>>>
>>>> FWIW, I think the patch gives incorrect results if there are more than
>>>> one non-socket or bad file descriptors in the set. Bad file descriptors
>>>> should never happen, but regular files and pipes definitely do.
>>>>
>>>
>>> Fixed.
>>
>> It looks to me that this gives incorrect results on poll(whatever, 0,
>> timeout);
>>
>>
>
> I did simple tests on OS/2 and Linux. And I could get the same results
> from both OSes.
>
> Here is the test code. Any problems ?
>
> -----
> #include <stdio.h>
> #include <sys/socket.h>
> #include <unistd.h>
>
> #include "poll.h"
>
> #define FD_SIZE 2
>
> void poll_test( const char *msg, struct pollfd *fds, int n, int timeout )
> {
> int i;
> int rc;
>
> printf("%s\n", msg );
>
> rc = poll( fds, n, timeout );
>
> printf("rc = %d\n", rc );
>
> for( i = 0; i < n; i++ )
> {
> printf("fd = %d, events = %x, revents = %x\n",
> fds[ i ].fd, fds[ i ].events, fds[ i ].revents );
> }
>
> printf("\n");
> }
>
> int main( void )
> {
> struct pollfd fds[ 2 ];
> int sv[ 2 ];
>
> fds[ 0 ].fd = 100; /* invalid handle */
> fds[ 0 ].events = POLLIN;
>
> socketpair( AF_LOCAL, SOCK_STREAM, 0, sv );
>
> fds[ 1 ].fd = sv[ 0 ];
> fds[ 1 ].events = POLLIN;
>
> poll_test("An invalid handle only, 0 timeout.",
> fds, 1, 0 );
>
> poll_test("An invalid handle only, 1000 timeout.",
> fds, 1, 1000 );
>
> poll_test("An invalid handle only, -1 timeout.",
> fds, 1, -1 );
>
> poll_test("A not-read-ready-socket only, 0 timeout.",
> fds + 1, 1, 0 );
>
> poll_test("A not-read-ready-socket only, 1000 timeout.",
> fds + 1, 1, 1000 );
>
> #if 0
> poll_test("A not-read-ready-socket only, -1 timeout.",
> fds + 1, 1, -1 );
> #endif
>
> poll_test("An invalid handle and a not-read-ready-socket, 0 timeout.",
> fds, 2, 0 );
>
> poll_test("An invalid handle and a not-read-ready-socket, 1000
> timeout.",
> fds, 2, 1000 );
>
> poll_test("An invalid handle and a not-read-ready-socket, -1 timeout.",
> fds, 2, -1 );
>
> write( sv[ 1 ], "\0", 1 );
>
> poll_test("A read-ready-socket only, 0 timeout.",
> fds + 1, 1, 0 );
>
> poll_test("A read-ready-socket only, 1000 timeout.",
> fds + 1, 1, 1000 );
>
> poll_test("A read-ready-socket only, -1 timeout.",
> fds + 1, 1, -1 );
>
> poll_test("An invalid handle and a read-ready-socket, 0 timeout.",
> fds, 2, 0 );
>
> poll_test("An invalid handle and a read-ready-socket, 1000 timeout.",
> fds, 2, 1000 );
>
> poll_test("An invalid handle and a read-ready-socket, -1 timeout.",
> fds, 2, -1 );
>
> close( sv[ 0 ]);
> close( sv[ 1 ]);
>
> return 0;
> }
> -----
>
--
KO Myung-Hun
Using Mozilla SeaMonkey 2.7.2
Under OS/2 Warp 4 for Korean with FixPak #15
In VirtualBox v4.1.32 on Intel Core i7-3615QM 2.30GHz with 8GB RAM
Korean OS/2 User Community : http://www.ecomstation.co.kr
More information about the vlc-devel
mailing list