Return the correct error values from gnutls.c
* src/gnutls.c (emacs_gnutls_read): Set errno to the value expected by process.c. (gnutls_try_handshake): Set gnutls_p to true earlier to avoid possible race condition with the process.c socket polling functions.
This commit is contained in:
parent
b829c9e15b
commit
d5f270f296
1 changed files with 7 additions and 4 deletions
11
src/gnutls.c
11
src/gnutls.c
|
@ -403,6 +403,9 @@ gnutls_try_handshake (struct Lisp_Process *proc)
|
|||
gnutls_session_t state = proc->gnutls_state;
|
||||
int ret;
|
||||
|
||||
if (proc->is_non_blocking_client)
|
||||
proc->gnutls_p = true;
|
||||
|
||||
do
|
||||
{
|
||||
ret = gnutls_handshake (state);
|
||||
|
@ -414,9 +417,6 @@ gnutls_try_handshake (struct Lisp_Process *proc)
|
|||
|
||||
proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
|
||||
|
||||
if (proc->is_non_blocking_client)
|
||||
proc->gnutls_p = true;
|
||||
|
||||
if (ret == GNUTLS_E_SUCCESS)
|
||||
{
|
||||
/* Here we're finally done. */
|
||||
|
@ -541,7 +541,10 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte)
|
|||
gnutls_session_t state = proc->gnutls_state;
|
||||
|
||||
if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
|
||||
return -1;
|
||||
{
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
|
||||
rtnval = gnutls_record_recv (state, buf, nbyte);
|
||||
if (rtnval >= 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue