errno

Nikos Mavroyanopoulos nmav@hellug.gr
Mon Jun 18 10:12:02 2001


While testing gnutls against other TLS implementations I got the following problem:
  While in the handshake procedure, the client might send a warning (if he's polite enough) 
and terminate immediately, if he thinks that he cannot communicate with us. 
However we may be in a step where we are transmiting 2 messages (eg. server hello and 
certificate), thus we will get a SIGPIPE and terminate. 
 Of course this is unnacceptable for a library. I though of some solutions:
   1. Document it and request to install SIG_IGN for the SIGPIPE signal before calling
      gnutls_handshake/gnutls_rehandshake.
      (that way we detect the error and behave as expected)   
   2. Check for pending alerts between reading two messages.
	This solution gives one more problem. We must
	check for pending alerts in a way that we'll not block.
	Thus we'll have to use MSG_DONTWAIT and then check errno
	(but what happens when multithreaded?)
      [this will not work if the peer closes the connection without an alert]
   3. Install the signal handler while doing handshake(), and restore
      it when leaving (I don't really like it)

Which one do you like? Any other options?

-- 
Nikos Mavroyanopoulos
mailto:nmav@hellug.gr