fukamachi / woo

A fast non-blocking HTTP server on top of libev
http://ultra.wikia.com/wiki/Woo_(kaiju)
MIT License
1.27k stars 96 forks source link

Incorrect error codes lead to Unexpected error (Code: 104) #103

Open svetlyak40wt opened 1 year ago

svetlyak40wt commented 1 year ago

I'm working on improvement of a Woo benchmark at and discovered, that sometimes Woo logs errors like this:

woo:  <ERROR> [08:11:41] woo.ev.tcp - Unexpected error (Code: 104)

I've dig into the source code and found the place where it logs an error:

Also, I've discovered that Woo defines error codes like this, but on Ubuntu 22.04 they are different. Here in comments I've added results of the grep in header files on my linux virtual machine:

;; /usr/include/asm-generic/errno.h:#define        EWOULDBLOCK     EAGAIN  /* Operation would block */
(defconstant EWOULDBLOCK 35.)
;; correct
(defconstant EPIPE 32.)
;; correct
(defconstant EINTR 4.)
;; /usr/include/asm-generic/errno.h:#define        EPROTO          71      /* Protocol error */
(defconstant EPROTO 100.)
;; /usr/include/asm-generic/errno.h:#define        ECONNABORTED    103     /* Software caused connection abort */
(defconstant ECONNABORTED 53.)
;; /usr/include/asm-generic/errno.h:#define        ECONNREFUSED    111     /* Connection refused */
(defconstant ECONNREFUSED 61.)
;; /usr/include/asm-generic/errno.h:#define        ECONNRESET      104     /* Connection reset by peer */
(defconstant ECONNRESET 54.)
;; /usr/include/asm-generic/errno.h:#define        ENOTCONN        107     /* Transport endpoint is not connected */
(defconstant ENOTCONN 57.)
;; correct
(defconstant EAGAIN 11.)

Should these constants be fixed in Woo sources?

fukamachi commented 1 year ago

Thanks for the patch! Since the error codes are possibly different in other environments like Darwin, so need to look into it. It may be better to use Grovel to retrieve them.

svetlyak40wt commented 1 year ago

If you wish, I could try to redo this patch for using groveler.

fukamachi commented 1 year ago

Oh, it'd be great if you don't mind. Thanks!