all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Calling 'select' from emacs_gnutls_pull
@ 2013-02-16 11:38 Eli Zaretskii
  2013-02-16 15:55 ` Ted Zlatanov
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2013-02-16 11:38 UTC (permalink / raw)
  To: Teodor Zlatanov; +Cc: emacs-devel

Ted,

I need your help in understanding the implementation of
emacs_gnutls_pull.  Specifically, why does it need to call 'select'
when 'sys_read' returns EWOULDBLOCK?  The file descriptor should
already be watched by the call to 'select' in
'wait_reading_process_output', so it seems like a call to 'sys_read'
is all that's needed here.  Am I missing something?

The reason I ask is that someone reported seeing these messages when
running Emacs on Windows under a debugger:

  warning: sys_read called when read is in progress

This comes from 'sys_read', and it means that the reader thread (used
by Emacs to read from a socket) is already blocked inside a call to
'recv' on behalf of this file descriptor, when 'sys_read' is called.

I think that the sequence of events which leads to this is as follows:

  . emacs_gnutls_pull calls sys_read, which returns EWOULDBLOCK,
    because there's no data ready to be read

  . emacs_gnutls_pull then calls select, which wakes up the reader
    thread and tells it to try reading from the socket

  . the reader thread blocks inside the call to recv (since no data is
    ready)

  . the call to select times out and returns EWOULDBLOCK, which causes
    emacs_gnutls_pull to break from the loop and return EAGAIN

  . after some time, emacs_gnutls_pull is called again, and calls
    sys_read while the reader thread is still blocked in recv, so we
    get the above message

Is this a plausible description of what might happen?  If so, would it
make sense to avoid calling 'select' in emacs_gnutls_pull, and instead
let 'wait_reading_process_output' call 'select', as it does for all
the other sockets open in Emacs?  Or am I missing something?

TIA



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-02-22 16:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-16 11:38 Calling 'select' from emacs_gnutls_pull Eli Zaretskii
2013-02-16 15:55 ` Ted Zlatanov
2013-02-16 16:52   ` Eli Zaretskii
2013-02-16 18:00     ` Ted Zlatanov
2013-02-16 19:30       ` Eli Zaretskii
2013-02-17 13:20         ` Ted Zlatanov
2013-02-22 11:15     ` Claudio Bley
2013-02-22 12:36       ` Eli Zaretskii
2013-02-22 15:17         ` Claudio Bley
2013-02-22 16:02           ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.