Problem with select/5 on AF_INET sockets with Windows 7

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with select/5 on AF_INET sockets with Windows 7

fx.nion
Dear Daniel,

I am working on a specific http server for gnu prolog (1.4.4), and i discovered
a strange comportment under windows 7 (32) with the select/5 predicate.

The simple test below works fine on a OSX (maybe all unix) system but will
return a system error under Windos 7 (32) , "Bad File Descriptor":

ERROR : Failed to start server : error(system_error(Bad file
descriptor),select/5)

To test, launch one of the two test cases and open an internet browser to
http://127.0.0.1:8080/ for example, or change the 127.0.0.1 by your IP.

%- Program Test with Select -----------------------------------

worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
...'), nl.

server_test_with_select:-
        socket('AF_INET', Socket),
        socket_bind(Socket, 'AF_INET'(Host, 8080)),
        socket_listen(Socket,10),
        catch( server_loop_with_select(Socket),E,
                 ( socket_close(Socket),
                        format( "ERROR : Failed to start server : ~w~n", [E] )
        )).

server_loop_with_select(Socket):-
        repeat,
                select([Socket],ReadyReads,[Socket],[],0),
                worker_run(Socket, Client, StreamIn, StreamOut),
        fail.

%- End of Program Test with Select -----------------------------------

When not using usefull select/5 and directly use the socket_accept/4 predicate
the server works well.


%- Program Test without Select -----------------------------------

worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
...'), nl.

server_test_without_select:-
        socket('AF_INET', Socket),
        socket_bind(Socket, 'AF_INET'(Host, 8080)),
        socket_listen(Socket,10),
        catch( server_loop_without_select(Socket),E,
                 ( socket_close(Socket),
                        format( "ERROR : Failed to start server : ~w~n", [E] )
        )).

server_loop_without_select(Socket):-
        repeat,
                socket_accept(Socket, Client, StreamIn, StreamOut),
                worker_run(Socket, Client, StreamIn, StreamOut),
        fail.

%- End of Program Test without Select -----------------------------------


Is it a known bug and did you plan to fix it in a future version ?


Best Regards,

Fx NION.


_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog
Reply | Threaded
Open this post in threaded view
|

Re: Problem with select/5 on AF_INET sockets with Windows 7

Daniel Diaz-3
Hi,

sorry for the late reply. Thank you for this bug report.

The bug is fixed in the last git version. Will be fixed in next 1.4.5

Daniel



Le 27/01/2015 12:44, [hidden email] a écrit :

> Dear Daniel,
>
> I am working on a specific http server for gnu prolog (1.4.4), and i discovered
> a strange comportment under windows 7 (32) with the select/5 predicate.
>
> The simple test below works fine on a OSX (maybe all unix) system but will
> return a system error under Windos 7 (32) , "Bad File Descriptor":
>
> ERROR : Failed to start server : error(system_error(Bad file
> descriptor),select/5)
>
> To test, launch one of the two test cases and open an internet browser to
> http://127.0.0.1:8080/ for example, or change the 127.0.0.1 by your IP.
>
> %- Program Test with Select -----------------------------------
>
> worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
> ...'), nl.
>
> server_test_with_select:-
> socket('AF_INET', Socket),
> socket_bind(Socket, 'AF_INET'(Host, 8080)),
> socket_listen(Socket,10),
> catch( server_loop_with_select(Socket),E,
> ( socket_close(Socket),
> format( "ERROR : Failed to start server : ~w~n", [E] )
> )).
>
> server_loop_with_select(Socket):-
> repeat,
> select([Socket],ReadyReads,[Socket],[],0),
> worker_run(Socket, Client, StreamIn, StreamOut),
> fail.
>
> %- End of Program Test with Select -----------------------------------
>
> When not using usefull select/5 and directly use the socket_accept/4 predicate
> the server works well.
>
>
> %- Program Test without Select -----------------------------------
>
> worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
> ...'), nl.
>
> server_test_without_select:-
> socket('AF_INET', Socket),
> socket_bind(Socket, 'AF_INET'(Host, 8080)),
> socket_listen(Socket,10),
> catch( server_loop_without_select(Socket),E,
> ( socket_close(Socket),
> format( "ERROR : Failed to start server : ~w~n", [E] )
> )).
>
> server_loop_without_select(Socket):-
> repeat,
> socket_accept(Socket, Client, StreamIn, StreamOut),
> worker_run(Socket, Client, StreamIn, StreamOut),
> fail.
>
> %- End of Program Test without Select -----------------------------------
>
>
> Is it a known bug and did you plan to fix it in a future version ?
>
>
> Best Regards,
>
> Fx NION.
>
>
> _______________________________________________
> Bug-prolog mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/bug-prolog
>


--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.


_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog
Reply | Threaded
Open this post in threaded view
|

Re: Problem with select/5 on AF_INET sockets with Windows 7

fx.nion
Daniel,

Thank you very much for your answer, and this is a great news for 1.4.5 !!!

I’ll be patient and wait for the official distribution.


Regards,

François-Xavier.


Le 17 févr. 2015 à 13:32, Daniel Diaz <[hidden email]> a écrit :

> Hi,
>
> sorry for the late reply. Thank you for this bug report.
>
> The bug is fixed in the last git version. Will be fixed in next 1.4.5
>
> Daniel
>
>
>
> Le 27/01/2015 12:44, [hidden email] a écrit :
>> Dear Daniel,
>>
>> I am working on a specific http server for gnu prolog (1.4.4), and i discovered
>> a strange comportment under windows 7 (32) with the select/5 predicate.
>>
>> The simple test below works fine on a OSX (maybe all unix) system but will
>> return a system error under Windos 7 (32) , "Bad File Descriptor":
>>
>> ERROR : Failed to start server : error(system_error(Bad file
>> descriptor),select/5)
>>
>> To test, launch one of the two test cases and open an internet browser to
>> http://127.0.0.1:8080/ for example, or change the 127.0.0.1 by your IP.
>>
>> %- Program Test with Select -----------------------------------
>>
>> worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
>> ...'), nl.
>>
>> server_test_with_select:-
>> socket('AF_INET', Socket),
>> socket_bind(Socket, 'AF_INET'(Host, 8080)),
>> socket_listen(Socket,10),
>> catch( server_loop_with_select(Socket),E,
>> ( socket_close(Socket),
>> format( "ERROR : Failed to start server : ~w~n", [E] )
>> )).
>>
>> server_loop_with_select(Socket):-
>> repeat,
>> select([Socket],ReadyReads,[Socket],[],0),
>> worker_run(Socket, Client, StreamIn, StreamOut),
>> fail.
>>
>> %- End of Program Test with Select -----------------------------------
>>
>> When not using usefull select/5 and directly use the socket_accept/4 predicate
>> the server works well.
>>
>>
>> %- Program Test without Select -----------------------------------
>>
>> worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
>> ...'), nl.
>>
>> server_test_without_select:-
>> socket('AF_INET', Socket),
>> socket_bind(Socket, 'AF_INET'(Host, 8080)),
>> socket_listen(Socket,10),
>> catch( server_loop_without_select(Socket),E,
>> ( socket_close(Socket),
>> format( "ERROR : Failed to start server : ~w~n", [E] )
>> )).
>>
>> server_loop_without_select(Socket):-
>> repeat,
>> socket_accept(Socket, Client, StreamIn, StreamOut),
>> worker_run(Socket, Client, StreamIn, StreamOut),
>> fail.
>>
>> %- End of Program Test without Select -----------------------------------
>>
>>
>> Is it a known bug and did you plan to fix it in a future version ?
>>
>>
>> Best Regards,
>>
>> Fx NION.
>>
>>
>> _______________________________________________
>> Bug-prolog mailing list
>> [hidden email]
>> https://lists.gnu.org/mailman/listinfo/bug-prolog
>>
>
>
> --
> Ce message a ete verifie par MailScanner
> pour des virus ou des polluriels et rien de
> suspect n'a ete trouve.
>


_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog
Reply | Threaded
Open this post in threaded view
|

Re: Problem with select/5 on AF_INET sockets with Windows 7

Paulo Moura-2

> On 19/02/2015, at 18:58, Fx <[hidden email]> wrote:
>
> Daniel,
>
> Thank you very much for your answer, and this is a great news for 1.4.5 !!!
>
> I’ll be patient and wait for the official distribution.

Don't be patient. Help instead beta-testing 1.4.5.

Cheers,

Paulo


> Le 17 févr. 2015 à 13:32, Daniel Diaz <[hidden email]> a écrit :
>
>> Hi,
>>
>> sorry for the late reply. Thank you for this bug report.
>>
>> The bug is fixed in the last git version. Will be fixed in next 1.4.5
>>
>> Daniel
>>
>>
>>
>> Le 27/01/2015 12:44, [hidden email] a écrit :
>>> Dear Daniel,
>>>
>>> I am working on a specific http server for gnu prolog (1.4.4), and i discovered
>>> a strange comportment under windows 7 (32) with the select/5 predicate.
>>>
>>> The simple test below works fine on a OSX (maybe all unix) system but will
>>> return a system error under Windos 7 (32) , "Bad File Descriptor":
>>>
>>> ERROR : Failed to start server : error(system_error(Bad file
>>> descriptor),select/5)
>>>
>>> To test, launch one of the two test cases and open an internet browser to
>>> http://127.0.0.1:8080/ for example, or change the 127.0.0.1 by your IP.
>>>
>>> %- Program Test with Select -----------------------------------
>>>
>>> worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
>>> ...'), nl.
>>>
>>> server_test_with_select:-
>>> socket('AF_INET', Socket),
>>> socket_bind(Socket, 'AF_INET'(Host, 8080)),
>>> socket_listen(Socket,10),
>>> catch( server_loop_with_select(Socket),E,
>>> ( socket_close(Socket),
>>> format( "ERROR : Failed to start server : ~w~n", [E] )
>>> )).
>>>
>>> server_loop_with_select(Socket):-
>>> repeat,
>>> select([Socket],ReadyReads,[Socket],[],0),
>>> worker_run(Socket, Client, StreamIn, StreamOut),
>>> fail.
>>>
>>> %- End of Program Test with Select -----------------------------------
>>>
>>> When not using usefull select/5 and directly use the socket_accept/4 predicate
>>> the server works well.
>>>
>>>
>>> %- Program Test without Select -----------------------------------
>>>
>>> worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
>>> ...'), nl.
>>>
>>> server_test_without_select:-
>>> socket('AF_INET', Socket),
>>> socket_bind(Socket, 'AF_INET'(Host, 8080)),
>>> socket_listen(Socket,10),
>>> catch( server_loop_without_select(Socket),E,
>>> ( socket_close(Socket),
>>> format( "ERROR : Failed to start server : ~w~n", [E] )
>>> )).
>>>
>>> server_loop_without_select(Socket):-
>>> repeat,
>>> socket_accept(Socket, Client, StreamIn, StreamOut),
>>> worker_run(Socket, Client, StreamIn, StreamOut),
>>> fail.
>>>
>>> %- End of Program Test without Select -----------------------------------
>>>
>>>
>>> Is it a known bug and did you plan to fix it in a future version ?
>>>
>>>
>>> Best Regards,
>>>
>>> Fx NION.
>>>
>>>
>>> _______________________________________________
>>> Bug-prolog mailing list
>>> [hidden email]
>>> https://lists.gnu.org/mailman/listinfo/bug-prolog
>>>
>>
>>
>> --
>> Ce message a ete verifie par MailScanner
>> pour des virus ou des polluriels et rien de
>> suspect n'a ete trouve.
>>
>
>
> _______________________________________________
> Bug-prolog mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/bug-prolog

-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <mailto:[hidden email]>
Web:   <http://logtalk.org/>
-----------------------------------------------------------------





_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog
Reply | Threaded
Open this post in threaded view
|

Re: Problem with select/5 on AF_INET sockets with Windows 7

fx.nion
:)) Paulo, you are right, if it can help. I won’t promise anything, but i can at least take a look, sure.

Can you help, and tell me where cans i found some infos:
- What are actually the tools (or info link )to compile under Windows (7,32b my office copmuter)
- What are actually the tools (or info link )to compile under Os X (this one is really rather a computer, my personnal(s) one(s)).

Dont’ they exists some kinda unit tests ? Prolog coded scenario ?  Or a Jenkins like for massive testing ?

Fx (shorter).


Le 19 févr. 2015 à 20:00, Paulo Moura <[hidden email]> a écrit :

>
>> On 19/02/2015, at 18:58, Fx <[hidden email]> wrote:
>>
>> Daniel,
>>
>> Thank you very much for your answer, and this is a great news for 1.4.5 !!!
>>
>> I’ll be patient and wait for the official distribution.
>
> Don't be patient. Help instead beta-testing 1.4.5.
>
> Cheers,
>
> Paulo
>
>
>> Le 17 févr. 2015 à 13:32, Daniel Diaz <[hidden email]> a écrit :
>>
>>> Hi,
>>>
>>> sorry for the late reply. Thank you for this bug report.
>>>
>>> The bug is fixed in the last git version. Will be fixed in next 1.4.5
>>>
>>> Daniel
>>>
>>>
>>>
>>> Le 27/01/2015 12:44, [hidden email] a écrit :
>>>> Dear Daniel,
>>>>
>>>> I am working on a specific http server for gnu prolog (1.4.4), and i discovered
>>>> a strange comportment under windows 7 (32) with the select/5 predicate.
>>>>
>>>> The simple test below works fine on a OSX (maybe all unix) system but will
>>>> return a system error under Windos 7 (32) , "Bad File Descriptor":
>>>>
>>>> ERROR : Failed to start server : error(system_error(Bad file
>>>> descriptor),select/5)
>>>>
>>>> To test, launch one of the two test cases and open an internet browser to
>>>> http://127.0.0.1:8080/ for example, or change the 127.0.0.1 by your IP.
>>>>
>>>> %- Program Test with Select -----------------------------------
>>>>
>>>> worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
>>>> ...'), nl.
>>>>
>>>> server_test_with_select:-
>>>> socket('AF_INET', Socket),
>>>> socket_bind(Socket, 'AF_INET'(Host, 8080)),
>>>> socket_listen(Socket,10),
>>>> catch( server_loop_with_select(Socket),E,
>>>> ( socket_close(Socket),
>>>> format( "ERROR : Failed to start server : ~w~n", [E] )
>>>> )).
>>>>
>>>> server_loop_with_select(Socket):-
>>>> repeat,
>>>> select([Socket],ReadyReads,[Socket],[],0),
>>>> worker_run(Socket, Client, StreamIn, StreamOut),
>>>> fail.
>>>>
>>>> %- End of Program Test with Select -----------------------------------
>>>>
>>>> When not using usefull select/5 and directly use the socket_accept/4 predicate
>>>> the server works well.
>>>>
>>>>
>>>> %- Program Test without Select -----------------------------------
>>>>
>>>> worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
>>>> ...'), nl.
>>>>
>>>> server_test_without_select:-
>>>> socket('AF_INET', Socket),
>>>> socket_bind(Socket, 'AF_INET'(Host, 8080)),
>>>> socket_listen(Socket,10),
>>>> catch( server_loop_without_select(Socket),E,
>>>> ( socket_close(Socket),
>>>> format( "ERROR : Failed to start server : ~w~n", [E] )
>>>> )).
>>>>
>>>> server_loop_without_select(Socket):-
>>>> repeat,
>>>> socket_accept(Socket, Client, StreamIn, StreamOut),
>>>> worker_run(Socket, Client, StreamIn, StreamOut),
>>>> fail.
>>>>
>>>> %- End of Program Test without Select -----------------------------------
>>>>
>>>>
>>>> Is it a known bug and did you plan to fix it in a future version ?
>>>>
>>>>
>>>> Best Regards,
>>>>
>>>> Fx NION.
>>>>
>>>>
>>>> _______________________________________________
>>>> Bug-prolog mailing list
>>>> [hidden email]
>>>> https://lists.gnu.org/mailman/listinfo/bug-prolog
>>>>
>>>
>>>
>>> --
>>> Ce message a ete verifie par MailScanner
>>> pour des virus ou des polluriels et rien de
>>> suspect n'a ete trouve.
>>>
>>
>>
>> _______________________________________________
>> Bug-prolog mailing list
>> [hidden email]
>> https://lists.gnu.org/mailman/listinfo/bug-prolog
>
> -----------------------------------------------------------------
> Paulo Moura
> Logtalk developer
>
> Email: <mailto:[hidden email]>
> Web:   <http://logtalk.org/>
> -----------------------------------------------------------------
>
>
>
>


_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog
Reply | Threaded
Open this post in threaded view
|

Re: Problem with select/5 on AF_INET sockets with Windows 7

Paulo Moura-2

> On 19/02/2015, at 19:11, Fx <[hidden email]> wrote:
>
> :)) Paulo, you are right, if it can help. I won’t promise anything, but i can at least take a look, sure.
>
> Can you help, and tell me where cans i found some infos:
> - What are actually the tools (or info link )to compile under Windows (7,32b my office copmuter)
> - What are actually the tools (or info link )to compile under Os X (this one is really rather a computer, my personnal(s) one(s)).

I cannot help you with building GNU Prolog on Windows but, on Mac OS X, just follow the steps in the INTALL file.

> Dont’ they exists some kinda unit tests ? Prolog coded scenario ?  Or a Jenkins like for massive testing ?

Logtalk includes a Prolog conformance test suite but it only tests, as it names indicates, standards related stuff. The small number of conformance issues are known (and some of them are really limitations in the standard). I cannot speak for Daniel, of course, but testing of other (non-standard) features would like be more useful. Specially stuff this might behave differently across different operating-systems (like sockets :-).

Cheers,

Paulo

> Le 19 févr. 2015 à 20:00, Paulo Moura <[hidden email]> a écrit :
>
>>
>>> On 19/02/2015, at 18:58, Fx <[hidden email]> wrote:
>>>
>>> Daniel,
>>>
>>> Thank you very much for your answer, and this is a great news for 1.4.5 !!!
>>>
>>> I’ll be patient and wait for the official distribution.
>>
>> Don't be patient. Help instead beta-testing 1.4.5.
>>
>> Cheers,
>>
>> Paulo
>>
>>
>>> Le 17 févr. 2015 à 13:32, Daniel Diaz <[hidden email]> a écrit :
>>>
>>>> Hi,
>>>>
>>>> sorry for the late reply. Thank you for this bug report.
>>>>
>>>> The bug is fixed in the last git version. Will be fixed in next 1.4.5
>>>>
>>>> Daniel
>>>>
>>>>
>>>>
>>>> Le 27/01/2015 12:44, [hidden email] a écrit :
>>>>> Dear Daniel,
>>>>>
>>>>> I am working on a specific http server for gnu prolog (1.4.4), and i discovered
>>>>> a strange comportment under windows 7 (32) with the select/5 predicate.
>>>>>
>>>>> The simple test below works fine on a OSX (maybe all unix) system but will
>>>>> return a system error under Windos 7 (32) , "Bad File Descriptor":
>>>>>
>>>>> ERROR : Failed to start server : error(system_error(Bad file
>>>>> descriptor),select/5)
>>>>>
>>>>> To test, launch one of the two test cases and open an internet browser to
>>>>> http://127.0.0.1:8080/ for example, or change the 127.0.0.1 by your IP.
>>>>>
>>>>> %- Program Test with Select -----------------------------------
>>>>>
>>>>> worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
>>>>> ...'), nl.
>>>>>
>>>>> server_test_with_select:-
>>>>> socket('AF_INET', Socket),
>>>>> socket_bind(Socket, 'AF_INET'(Host, 8080)),
>>>>> socket_listen(Socket,10),
>>>>> catch( server_loop_with_select(Socket),E,
>>>>> ( socket_close(Socket),
>>>>> format( "ERROR : Failed to start server : ~w~n", [E] )
>>>>> )).
>>>>>
>>>>> server_loop_with_select(Socket):-
>>>>> repeat,
>>>>> select([Socket],ReadyReads,[Socket],[],0),
>>>>> worker_run(Socket, Client, StreamIn, StreamOut),
>>>>> fail.
>>>>>
>>>>> %- End of Program Test with Select -----------------------------------
>>>>>
>>>>> When not using usefull select/5 and directly use the socket_accept/4 predicate
>>>>> the server works well.
>>>>>
>>>>>
>>>>> %- Program Test without Select -----------------------------------
>>>>>
>>>>> worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
>>>>> ...'), nl.
>>>>>
>>>>> server_test_without_select:-
>>>>> socket('AF_INET', Socket),
>>>>> socket_bind(Socket, 'AF_INET'(Host, 8080)),
>>>>> socket_listen(Socket,10),
>>>>> catch( server_loop_without_select(Socket),E,
>>>>> ( socket_close(Socket),
>>>>> format( "ERROR : Failed to start server : ~w~n", [E] )
>>>>> )).
>>>>>
>>>>> server_loop_without_select(Socket):-
>>>>> repeat,
>>>>> socket_accept(Socket, Client, StreamIn, StreamOut),
>>>>> worker_run(Socket, Client, StreamIn, StreamOut),
>>>>> fail.
>>>>>
>>>>> %- End of Program Test without Select -----------------------------------
>>>>>
>>>>>
>>>>> Is it a known bug and did you plan to fix it in a future version ?
>>>>>
>>>>>
>>>>> Best Regards,
>>>>>
>>>>> Fx NION.
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Bug-prolog mailing list
>>>>> [hidden email]
>>>>> https://lists.gnu.org/mailman/listinfo/bug-prolog
>>>>>
>>>>
>>>>
>>>> --
>>>> Ce message a ete verifie par MailScanner
>>>> pour des virus ou des polluriels et rien de
>>>> suspect n'a ete trouve.
>>>>
>>>
>>>
>>> _______________________________________________
>>> Bug-prolog mailing list
>>> [hidden email]
>>> https://lists.gnu.org/mailman/listinfo/bug-prolog
>>
>> -----------------------------------------------------------------
>> Paulo Moura
>> Logtalk developer
>>
>> Email: <mailto:[hidden email]>
>> Web:   <http://logtalk.org/>
>> -----------------------------------------------------------------
>>
>>
>>
>>
>

-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <mailto:[hidden email]>
Web:   <http://logtalk.org/>
-----------------------------------------------------------------





_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog
Reply | Threaded
Open this post in threaded view
|

Re: Problem with select/5 on AF_INET sockets with Windows 7

fx.nion
Ok, this is a very little step, but after some adventures with installation i have some news:

Getting source from git reveal two bugs (and something curious maybe):
- impossible to use anonymous git clone , so i fall back with getting the snapshot.
- the source didn’t  contain the ‘configure’ script (i picked it up from the 1.4.4 tar to go on)
- the version is still 1.4.4 (ok it’s not the end of the world).

I installed the MinGW on Windows 7 32 bit, in th standard manner. Fortunately my antivirus didn’t says nothing with the default a.out a.exe.
As si said previously, i took the « configure" file from prolog 1.4.4 source tarball

And last, but not least, the select/5 bug seems to belong to the past on windows (MinGW). I run again the tests wrote in this mailing list, and the
previous error didn’t appear anymore. 

It’s weak for a beta test, but it’s quite a good news. It would be nice if i had time to write some client/server tests, things like that.

Fx


Le 19 févr. 2015 à 20:40, Paulo Moura <[hidden email]> a écrit :


On 19/02/2015, at 19:11, Fx <[hidden email]> wrote:

:)) Paulo, you are right, if it can help. I won’t promise anything, but i can at least take a look, sure.

Can you help, and tell me where cans i found some infos:
- What are actually the tools (or info link )to compile under Windows (7,32b my office copmuter)
- What are actually the tools (or info link )to compile under Os X (this one is really rather a computer, my personnal(s) one(s)).

I cannot help you with building GNU Prolog on Windows but, on Mac OS X, just follow the steps in the INTALL file.

Dont’ they exists some kinda unit tests ? Prolog coded scenario ?  Or a Jenkins like for massive testing ?

Logtalk includes a Prolog conformance test suite but it only tests, as it names indicates, standards related stuff. The small number of conformance issues are known (and some of them are really limitations in the standard). I cannot speak for Daniel, of course, but testing of other (non-standard) features would like be more useful. Specially stuff this might behave differently across different operating-systems (like sockets :-).

Cheers,

Paulo

Le 19 févr. 2015 à 20:00, Paulo Moura <[hidden email]> a écrit :


On 19/02/2015, at 18:58, Fx <[hidden email]> wrote:

Daniel,

Thank you very much for your answer, and this is a great news for 1.4.5 !!!

I’ll be patient and wait for the official distribution.

Don't be patient. Help instead beta-testing 1.4.5.

Cheers,

Paulo


Le 17 févr. 2015 à 13:32, Daniel Diaz <[hidden email]> a écrit :

Hi,

sorry for the late reply. Thank you for this bug report.

The bug is fixed in the last git version. Will be fixed in next 1.4.5

Daniel



Le 27/01/2015 12:44, [hidden email] a écrit :
Dear Daniel,

I am working on a specific http server for gnu prolog (1.4.4), and i discovered
a strange comportment under windows 7 (32) with the select/5 predicate.

The simple test below works fine on a OSX (maybe all unix) system but will
return a system error under Windos 7 (32) , "Bad File Descriptor":

ERROR : Failed to start server : error(system_error(Bad file
descriptor),select/5)

To test, launch one of the two test cases and open an internet browser to
http://127.0.0.1:8080/ for example, or change the 127.0.0.1 by your IP.

%- Program Test with Select -----------------------------------

worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
...'), nl.

server_test_with_select:-
socket('AF_INET', Socket),
socket_bind(Socket, 'AF_INET'(Host, 8080)),
socket_listen(Socket,10),
catch(  server_loop_with_select(Socket),E,
 (  socket_close(Socket),
format( "ERROR : Failed to start server : ~w~n", [E] )
)).

server_loop_with_select(Socket):-
repeat,
select([Socket],ReadyReads,[Socket],[],0),
worker_run(Socket, Client, StreamIn, StreamOut),
fail.

%- End of Program Test with Select -----------------------------------

When not using usefull select/5 and directly use the socket_accept/4 predicate
the server works well.


%- Program Test without Select -----------------------------------

worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
...'), nl.

server_test_without_select:-
socket('AF_INET', Socket),
socket_bind(Socket, 'AF_INET'(Host, 8080)),
socket_listen(Socket,10),
catch(  server_loop_without_select(Socket),E,
 (  socket_close(Socket),
format( "ERROR : Failed to start server : ~w~n", [E] )
)).

server_loop_without_select(Socket):-
repeat,
socket_accept(Socket, Client, StreamIn, StreamOut),
worker_run(Socket, Client, StreamIn, StreamOut),
fail.

%- End of Program Test without Select -----------------------------------


Is it a known bug and did you plan to fix it in a future version ?


Best Regards,

Fx NION.


_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog



-- 
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.



_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog

-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <[hidden email]>
Web:   <http://logtalk.org/>
-----------------------------------------------------------------






-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <[hidden email]>
Web:   <http://logtalk.org/>
-----------------------------------------------------------------


_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog
Reply | Threaded
Open this post in threaded view
|

Re: Problem with select/5 on AF_INET sockets with Windows 7

fx.nion
Hi,

I went ahead in the test, and discovered a new bug: when calling select/5 on a list filled with socket Id AND input streams:
- on Windows i get a system_error(No error).Ok, clear.
- on Os X, no error but finally the program crash with an overflow while reading another file stream during the server_process_request. 
     - It seems like something like a stream scramble due to select, but i wouldn’t bet my shirt on it.

To illustrate, let say we have the following predicate:

server_handle_connections(Socket):-
connection_list_read(Reads),
select([Socket|Reads],ReadyReads,[],[],0),
server_accept_incomming(Socket,ReadyReads,StreamIn,StreamOut),
server_process_request(StreamIn, StreamOut),!.

connection_list_read(Reads) succeeds and return a list of opened input streams (filled in server_accept_incomming predicate)

server_accept_incomming(Socket,ReadyReads,StreamIn,StreamOut) succeeds when ReadyReads contain Socket. 
- It « accepts » the socket, unifying StreamIn and StreamOut, appends StreamIn to a list of active connections

server_process_request(StreamIn, StreamOut) reads the request, serve the requested file, and depending the test, close or not the streams.

At the first time, 
 - only the Socket is observed by the select.( Works nice on Windows with the correction made by Daniel.)
 - the accept return a new input stream.
 - the end of server_process_request can be viewed in to manner : it close the stream, or it doesn’t close the streams.
- if it closes the stream, the next accept call will probably « reuse » the last stream indices (as if there was no use of select, just accept): not sure this is the case.
- if it doesn’t close the streams, the current StreamIn could be observed in the next select/5 call no ? It crashes on windows, sure.

input streams are set with no buffering, according the advice in the manual.

So:

Do i use the select/5 correctly, mixing sockets and opened input streams ?

Do select/5 have a side effets on the internal stream pool (settings properties for example ) ?

Did someone already use successfully select/5 on streams, to make some kinda multiplexing server ?
 -  i see a lot of examples using accept, but no one using select. we can do better.

If i am not wrong in my tests, there is maybe a problem with streams and select/5 on all os targets.

Fx

Le 20 févr. 2015 à 19:59, Fx <[hidden email]> a écrit :

Ok, this is a very little step, but after some adventures with installation i have some news:

Getting source from git reveal two bugs (and something curious maybe):
- impossible to use anonymous git clone , so i fall back with getting the snapshot.
- the source didn’t  contain the ‘configure’ script (i picked it up from the 1.4.4 tar to go on)
- the version is still 1.4.4 (ok it’s not the end of the world).

I installed the MinGW on Windows 7 32 bit, in th standard manner. Fortunately my antivirus didn’t says nothing with the default a.out a.exe.
As si said previously, i took the « configure" file from prolog 1.4.4 source tarball

And last, but not least, the select/5 bug seems to belong to the past on windows (MinGW). I run again the tests wrote in this mailing list, and the
previous error didn’t appear anymore. 

It’s weak for a beta test, but it’s quite a good news. It would be nice if i had time to write some client/server tests, things like that.

Fx


Le 19 févr. 2015 à 20:40, Paulo Moura <[hidden email]> a écrit :


On 19/02/2015, at 19:11, Fx <[hidden email]> wrote:

:)) Paulo, you are right, if it can help. I won’t promise anything, but i can at least take a look, sure.

Can you help, and tell me where cans i found some infos:
- What are actually the tools (or info link )to compile under Windows (7,32b my office copmuter)
- What are actually the tools (or info link )to compile under Os X (this one is really rather a computer, my personnal(s) one(s)).

I cannot help you with building GNU Prolog on Windows but, on Mac OS X, just follow the steps in the INTALL file.

Dont’ they exists some kinda unit tests ? Prolog coded scenario ?  Or a Jenkins like for massive testing ?

Logtalk includes a Prolog conformance test suite but it only tests, as it names indicates, standards related stuff. The small number of conformance issues are known (and some of them are really limitations in the standard). I cannot speak for Daniel, of course, but testing of other (non-standard) features would like be more useful. Specially stuff this might behave differently across different operating-systems (like sockets :-).

Cheers,

Paulo

Le 19 févr. 2015 à 20:00, Paulo Moura <[hidden email]> a écrit :


On 19/02/2015, at 18:58, Fx <[hidden email]> wrote:

Daniel,

Thank you very much for your answer, and this is a great news for 1.4.5 !!!

I’ll be patient and wait for the official distribution.

Don't be patient. Help instead beta-testing 1.4.5.

Cheers,

Paulo


Le 17 févr. 2015 à 13:32, Daniel Diaz <[hidden email]> a écrit :

Hi,

sorry for the late reply. Thank you for this bug report.

The bug is fixed in the last git version. Will be fixed in next 1.4.5

Daniel



Le 27/01/2015 12:44, [hidden email] a écrit :
Dear Daniel,

I am working on a specific http server for gnu prolog (1.4.4), and i discovered
a strange comportment under windows 7 (32) with the select/5 predicate.

The simple test below works fine on a OSX (maybe all unix) system but will
return a system error under Windos 7 (32) , "Bad File Descriptor":

ERROR : Failed to start server : error(system_error(Bad file
descriptor),select/5)

To test, launch one of the two test cases and open an internet browser to
http://127.0.0.1:8080/ for example, or change the 127.0.0.1 by your IP.

%- Program Test with Select -----------------------------------

worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
...'), nl.

server_test_with_select:-
socket('AF_INET', Socket),
socket_bind(Socket, 'AF_INET'(Host, 8080)),
socket_listen(Socket,10),
catch(  server_loop_with_select(Socket),E,
 (  socket_close(Socket),
format( "ERROR : Failed to start server : ~w~n", [E] )
)).

server_loop_with_select(Socket):-
repeat,
select([Socket],ReadyReads,[Socket],[],0),
worker_run(Socket, Client, StreamIn, StreamOut),
fail.

%- End of Program Test with Select -----------------------------------

When not using usefull select/5 and directly use the socket_accept/4 predicate
the server works well.


%- Program Test without Select -----------------------------------

worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
...'), nl.

server_test_without_select:-
socket('AF_INET', Socket),
socket_bind(Socket, 'AF_INET'(Host, 8080)),
socket_listen(Socket,10),
catch(  server_loop_without_select(Socket),E,
 (  socket_close(Socket),
format( "ERROR : Failed to start server : ~w~n", [E] )
)).

server_loop_without_select(Socket):-
repeat,
socket_accept(Socket, Client, StreamIn, StreamOut),
worker_run(Socket, Client, StreamIn, StreamOut),
fail.

%- End of Program Test without Select -----------------------------------


Is it a known bug and did you plan to fix it in a future version ?


Best Regards,

Fx NION.


_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog



-- 
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.



_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog

-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <[hidden email]>
Web:   <http://logtalk.org/>
-----------------------------------------------------------------






-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <[hidden email]>
Web:   <http://logtalk.org/>
-----------------------------------------------------------------



_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog
Reply | Threaded
Open this post in threaded view
|

Re: Problem with select/5 on AF_INET sockets with Windows 7

fx.nion
Hi,

After several days of intensive tests around socket (git 1.4.5) on Windows, sockets seams stables.

I have maybe an explanation for the "system_error(No error) » on Windows:
     -I read somewhere that Windows didn’t support select on streams, only on sockets.

So i do not use select on streams. Sad but running.

Fx

Le 25 févr. 2015 à 07:30, Fx <[hidden email]> a écrit :

Hi,

I went ahead in the test, and discovered a new bug: when calling select/5 on a list filled with socket Id AND input streams:
- on Windows i get a system_error(No error).Ok, clear.
- on Os X, no error but finally the program crash with an overflow while reading another file stream during the server_process_request. 
     - It seems like something like a stream scramble due to select, but i wouldn’t bet my shirt on it.

To illustrate, let say we have the following predicate:

server_handle_connections(Socket):-
connection_list_read(Reads),
select([Socket|Reads],ReadyReads,[],[],0),
server_accept_incomming(Socket,ReadyReads,StreamIn,StreamOut),
server_process_request(StreamIn, StreamOut),!.

connection_list_read(Reads) succeeds and return a list of opened input streams (filled in server_accept_incomming predicate)

server_accept_incomming(Socket,ReadyReads,StreamIn,StreamOut) succeeds when ReadyReads contain Socket. 
- It « accepts » the socket, unifying StreamIn and StreamOut, appends StreamIn to a list of active connections

server_process_request(StreamIn, StreamOut) reads the request, serve the requested file, and depending the test, close or not the streams.

At the first time, 
 - only the Socket is observed by the select.( Works nice on Windows with the correction made by Daniel.)
 - the accept return a new input stream.
 - the end of server_process_request can be viewed in to manner : it close the stream, or it doesn’t close the streams.
- if it closes the stream, the next accept call will probably « reuse » the last stream indices (as if there was no use of select, just accept): not sure this is the case.
- if it doesn’t close the streams, the current StreamIn could be observed in the next select/5 call no ? It crashes on windows, sure.

input streams are set with no buffering, according the advice in the manual.

So:

Do i use the select/5 correctly, mixing sockets and opened input streams ?

Do select/5 have a side effets on the internal stream pool (settings properties for example ) ?

Did someone already use successfully select/5 on streams, to make some kinda multiplexing server ?
 -  i see a lot of examples using accept, but no one using select. we can do better.

If i am not wrong in my tests, there is maybe a problem with streams and select/5 on all os targets.

Fx

Le 20 févr. 2015 à 19:59, Fx <[hidden email]> a écrit :

Ok, this is a very little step, but after some adventures with installation i have some news:

Getting source from git reveal two bugs (and something curious maybe):
- impossible to use anonymous git clone , so i fall back with getting the snapshot.
- the source didn’t  contain the ‘configure’ script (i picked it up from the 1.4.4 tar to go on)
- the version is still 1.4.4 (ok it’s not the end of the world).

I installed the MinGW on Windows 7 32 bit, in th standard manner. Fortunately my antivirus didn’t says nothing with the default a.out a.exe.
As si said previously, i took the « configure" file from prolog 1.4.4 source tarball

And last, but not least, the select/5 bug seems to belong to the past on windows (MinGW). I run again the tests wrote in this mailing list, and the
previous error didn’t appear anymore. 

It’s weak for a beta test, but it’s quite a good news. It would be nice if i had time to write some client/server tests, things like that.

Fx


Le 19 févr. 2015 à 20:40, Paulo Moura <[hidden email]> a écrit :


On 19/02/2015, at 19:11, Fx <[hidden email]> wrote:

:)) Paulo, you are right, if it can help. I won’t promise anything, but i can at least take a look, sure.

Can you help, and tell me where cans i found some infos:
- What are actually the tools (or info link )to compile under Windows (7,32b my office copmuter)
- What are actually the tools (or info link )to compile under Os X (this one is really rather a computer, my personnal(s) one(s)).

I cannot help you with building GNU Prolog on Windows but, on Mac OS X, just follow the steps in the INTALL file.

Dont’ they exists some kinda unit tests ? Prolog coded scenario ?  Or a Jenkins like for massive testing ?

Logtalk includes a Prolog conformance test suite but it only tests, as it names indicates, standards related stuff. The small number of conformance issues are known (and some of them are really limitations in the standard). I cannot speak for Daniel, of course, but testing of other (non-standard) features would like be more useful. Specially stuff this might behave differently across different operating-systems (like sockets :-).

Cheers,

Paulo

Le 19 févr. 2015 à 20:00, Paulo Moura <[hidden email]> a écrit :


On 19/02/2015, at 18:58, Fx <[hidden email]> wrote:

Daniel,

Thank you very much for your answer, and this is a great news for 1.4.5 !!!

I’ll be patient and wait for the official distribution.

Don't be patient. Help instead beta-testing 1.4.5.

Cheers,

Paulo


Le 17 févr. 2015 à 13:32, Daniel Diaz <[hidden email]> a écrit :

Hi,

sorry for the late reply. Thank you for this bug report.

The bug is fixed in the last git version. Will be fixed in next 1.4.5

Daniel



Le 27/01/2015 12:44, [hidden email] a écrit :
Dear Daniel,

I am working on a specific http server for gnu prolog (1.4.4), and i discovered
a strange comportment under windows 7 (32) with the select/5 predicate.

The simple test below works fine on a OSX (maybe all unix) system but will
return a system error under Windos 7 (32) , "Bad File Descriptor":

ERROR : Failed to start server : error(system_error(Bad file
descriptor),select/5)

To test, launch one of the two test cases and open an internet browser to
http://127.0.0.1:8080/ for example, or change the 127.0.0.1 by your IP.

%- Program Test with Select -----------------------------------

worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
...'), nl.

server_test_with_select:-
socket('AF_INET', Socket),
socket_bind(Socket, 'AF_INET'(Host, 8080)),
socket_listen(Socket,10),
catch(  server_loop_with_select(Socket),E,
 (  socket_close(Socket),
format( "ERROR : Failed to start server : ~w~n", [E] )
)).

server_loop_with_select(Socket):-
repeat,
select([Socket],ReadyReads,[Socket],[],0),
worker_run(Socket, Client, StreamIn, StreamOut),
fail.

%- End of Program Test with Select -----------------------------------

When not using usefull select/5 and directly use the socket_accept/4 predicate
the server works well.


%- Program Test without Select -----------------------------------

worker_run(Socket, Client, StreamIn, StreamOut):- write('i am a working worker
...'), nl.

server_test_without_select:-
socket('AF_INET', Socket),
socket_bind(Socket, 'AF_INET'(Host, 8080)),
socket_listen(Socket,10),
catch(  server_loop_without_select(Socket),E,
 (  socket_close(Socket),
format( "ERROR : Failed to start server : ~w~n", [E] )
)).

server_loop_without_select(Socket):-
repeat,
socket_accept(Socket, Client, StreamIn, StreamOut),
worker_run(Socket, Client, StreamIn, StreamOut),
fail.

%- End of Program Test without Select -----------------------------------


Is it a known bug and did you plan to fix it in a future version ?


Best Regards,

Fx NION.


_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog



-- 
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.



_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog

-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <[hidden email]>
Web:   <http://logtalk.org/>
-----------------------------------------------------------------






-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <[hidden email]>
Web:   <http://logtalk.org/>
-----------------------------------------------------------------




_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog