Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To answer shortly: If you allways check for one type of event first and then have an <code>else if</code> for the other you risk starvation. In general I would check for both, unless the specified protocol made it impossible for both to be activated at the same time.</p> <p>Here is a more iffy answer: The link in your question does not contain a code structure such as your question. The client <a href="https://github.com/coolaj86/libev-examples/blob/master/src/unix-echo-client.c" rel="nofollow">https://github.com/coolaj86/libev-examples/blob/master/src/unix-echo-client.c</a> does have a similar callback. You will notice it disables write events, when it has written once.</p> <pre><code>// once the data is sent, stop notifications that // data can be sent until there is actually more // data to send ev_io_stop(EV_A_ &amp;send_w); ev_io_set(&amp;send_w, remote_fd, EV_READ); ev_io_start(EV_A_ &amp;send_w); </code></pre> <p>That looks like an attempt to avoid starvation of the pipe READ event branch. Even though Im not very familiar with libev, the github examples you linked to do not seem very robust. E.g <code>static void stdin_cb (EV_P_ ev_io *w, int revents)</code>does not use the return value of <code>getline()</code> to detect EOF. Also the <code>send()</code> and <code>recv()</code> socket operation return values are not inspected for how much was read or written (though on local named pipe streams the amounts will most likely match the amounts that were requested). If this was later changed to a TCP based connection, checking the amounts would be vital.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload