Save (and print) errno on socket error
This commit is contained in:
parent
2b8f39b52f
commit
9dd094daeb
|
@ -4,6 +4,7 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
|
@ -166,12 +167,14 @@ static void output_isr(struct bufferevent *bufev, IOHandle *h) {
|
|||
|
||||
static void error_isr(struct bufferevent *bufev, short what, IOHandle *h) {
|
||||
unsigned short kind = what & ~(EVBUFFER_READ | EVBUFFER_WRITE);
|
||||
int saved_errno = errno;
|
||||
info("error_isr 0x%04X fd %d\n", what, h->fd);
|
||||
h->error_direction = what & (EVBUFFER_READ | EVBUFFER_WRITE);
|
||||
if (kind == EVBUFFER_EOF) {
|
||||
h->eof = 1;
|
||||
} else {
|
||||
h->error_kind = kind;
|
||||
h->error_errno = saved_errno;
|
||||
}
|
||||
awaken_waiters(h, EV_READ | EV_WRITE);
|
||||
}
|
||||
|
@ -205,6 +208,7 @@ void delete_iohandle(IOHandle *h) {
|
|||
void iohandle_clear_error(IOHandle *h) {
|
||||
h->error_direction = 0;
|
||||
h->error_kind = 0;
|
||||
h->error_errno = 0;
|
||||
}
|
||||
|
||||
static void block_on_io(IOHandle *h, short event) {
|
||||
|
|
|
@ -24,6 +24,7 @@ typedef struct IOHandle {
|
|||
int eof;
|
||||
unsigned short error_direction;
|
||||
unsigned short error_kind;
|
||||
int error_errno;
|
||||
} IOHandle;
|
||||
|
||||
extern IOHandle *stdin_h;
|
||||
|
|
Loading…
Reference in New Issue