GithubHelp home page GithubHelp logo

Comments (20)

repeatedly avatar repeatedly commented on June 23, 2024

I want to know the problem is Cool.io or libev.
Could you try following code with libev 4.15?

http://codefundas.blogspot.jp/2010/09/create-tcp-echo-server-using-libev.html

from cool.io.

repeatedly avatar repeatedly commented on June 23, 2024

And it happens only on Widows Server 2012?
What about other Windows versions?

from cool.io.

okahashi117 avatar okahashi117 commented on June 23, 2024

What about other Windows versions?

CPU Usage value is different, but think it is the same problem. I will check more.

from cool.io.

okahashi117 avatar okahashi117 commented on June 23, 2024

I want to know the problem is Cool.io or libev.
Could you try following code with libev 4.15?

http://codefundas.blogspot.jp/2010/09/create-tcp-echo-server-using-libev.html

Anybody has a help to use libev on Windows ?

from cool.io.

repeatedly avatar repeatedly commented on June 23, 2024

Building libev with make failed?

from cool.io.

okahashi117 avatar okahashi117 commented on June 23, 2024

I've done it now, forget it, thank you.
but process will terminate in ev_io_start().

http://codefundas.blogspot.jp/2010/09/create-tcp-echo-server-using-libev.html

I will continue to check on ev.c.

from cool.io.

repeatedly avatar repeatedly commented on June 23, 2024

@okahashi117 It means above code doesn't work on Windows corretly with libev 4.15, right?

On my Mac, the result is below(I fixed some #include for Mac manner).
Server side:

$ gcc -L. -lev test_code.c
% ./a.out
Successfully connected with client.
1 client(s) connected.
message:hoge
message:foo
message:hoge
peer might closing: Undefined error: 0
0 client(s) connected.

Client side:

% gcc -o client test_code_client.c
% ./client
warning: this program uses gets(), which is unsafe.
hoge
message: hoge
foo
message: foo
hoge
message: hoge

from cool.io.

okahashi117 avatar okahashi117 commented on June 23, 2024

Hi,

It means above code doesn't work on Windows corretly with libev 4.15, right?

I'm not sure because I might me making a mistaken. I'm not familiar with gcc so much, you know, and some changes to were required to build the sample code you suggeseted, especially to use WinSock.
I want to check a little more.

from cool.io.

okahashi117 avatar okahashi117 commented on June 23, 2024

Ah?
I'm using mingw to compile on Windows. Is it correct? Should use cygwin ?

from cool.io.

repeatedly avatar repeatedly commented on June 23, 2024

some changes to were required to build the sample code you suggeseted, especially to use WinSock.

Ah, I see.

Should use cygwin ?

No, MinGW is correct. I also compile Cool.io with MinGW for windows binary.

from cool.io.

okahashi117 avatar okahashi117 commented on June 23, 2024

@repeatedly Do I need some option to compile libev correctly ?
I did just 'configure --prefix=/xxxx' and 'make'.
ev_default_loop(0) always returns Null and it makes a process crash, because ev_io_start() needs a valid loop pointer to realloc memory and shows segmentation fault.

from cool.io.

repeatedly avatar repeatedly commented on June 23, 2024

@okahashi117 Hmm... how about use ev_loop_new(0) instead of ev_default_loop(0)?

from cool.io.

okahashi117 avatar okahashi117 commented on June 23, 2024

@repeatedly
Same result I got.
I found that all backend flags were off (PORT, KQUEUE, EPOLL, POLL and SELECT) so that a loop pointer is always NULL.
I may be mistaken. Could you give me any help, please.

from cool.io.

repeatedly avatar repeatedly commented on June 23, 2024

@okahashi117 Hmm. On Windows, libev should use select.
How about define EV_USE_SELECT like -DEV_USE_SELECT?

from cool.io.

okahashi117 avatar okahashi117 commented on June 23, 2024

OK, HAVE_SELECT and HAVE_SYS_SELECT_H has been required.
But a process still terminates. I check more.

from cool.io.

okahashi117 avatar okahashi117 commented on June 23, 2024

@repeatedly Hi.
I built the program and tested.
'CPU100%' does not occur (0%-15%, Win2012R2, Win8, Win7).
So it seems it is a problem of Coolio or Ruby.

from cool.io.

repeatedly avatar repeatedly commented on June 23, 2024

@okahashi117 Okay.
And could you try following combination?

  • Using Cool.io 1.2.2 and set timeout to run method. 0.5 or similar timeout.
  • Another Ruby version, e.g. 2.0, 2.1.

I'm not familiar with Windows debug tools.
Do you find the code block which consumes CPU 100%?

from cool.io.

okahashi117 avatar okahashi117 commented on June 23, 2024

Same problem occurs with Cool.io 1.2.2

from cool.io.

repeatedly avatar repeatedly commented on June 23, 2024

From @okahashi117 , select seems to receive bad file descriptor and retry causes busy loop.
We investigate the problem deeply.

from cool.io.

repeatedly avatar repeatedly commented on June 23, 2024

My investigation is here:

The problem is fd to handle conversion (Use _get_osfhandle).

https://github.com/tarcieri/cool.io/blob/64657d653cafe2ed1c02f4ba38c347e6b9faf2b9/ext/libev/ev_select.c#L80

For example, if fd is 3, then handle is 352 or similar value.
In this result, FD_SET and FD_ISSET are broken.
Set handle using FD_SET(handle, vec_ri) but FD_ISSET(handle, vec_ri) failed.
I am not familiar with Windows these utilities implementation (Increase FD_SETSIZE doesn't help).

Second, I tried to use fd instead of handle directly.
It works on first access but select returns an error on next access.
I'm not sure why first select call succeeded.
TCPSocket creates fd using socket function in Ruby. Using this fd for select is invalid?

Other status.
Disabling EV_SELECT_USE_FD_SET doesn't help.
ev related values are same on between Windows and Mac, e.g. vec_ri, fd_count and etc.

There are several approaches to resolve this issue:

  • Research windows deeply for resolving first and second case. Maybe, need Windows expert.
  • Use Ruby's select for Windows. I'm not sure how effect other stat and timer watchers.
  • Implement JRuby extension

from cool.io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.