From: Eli Zaretskii <eliz@gnu.org>
To: Teodor Zlatanov <tzz@lifelogs.com>
Cc: emacs-devel@gnu.org
Subject: Calling 'select' from emacs_gnutls_pull
Date: Sat, 16 Feb 2013 13:38:43 +0200 [thread overview]
Message-ID: <83wqu8qyik.fsf@gnu.org> (raw)
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
next reply other threads:[~2013-02-16 11:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-16 11:38 Eli Zaretskii [this message]
2013-02-16 15:55 ` Calling 'select' from emacs_gnutls_pull 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83wqu8qyik.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=tzz@lifelogs.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.