[MAJOR] make stream sockets aware of the stream interface
As of now, a stream socket does not directly wake up the task
but it does contact the stream interface which itself knows the
task. This allows us to perform a few cleanups upon errors and
shutdowns, which reduces the number of calls to data_update()
from 8 per session to 2 per session, and make all the functions
called in the process_session() loop completely swappable.
Some improvements are required. We need to provide a shutw()
function on stream interfaces so that one side which closes
its read part on an empty buffer can propagate the close to
the remote side.
diff --git a/include/proto/stream_sock.h b/include/proto/stream_sock.h
index fe89d98..e104054 100644
--- a/include/proto/stream_sock.h
+++ b/include/proto/stream_sock.h
@@ -33,7 +33,7 @@
/* main event functions used to move data between sockets and buffers */
int stream_sock_read(int fd);
int stream_sock_write(int fd);
-int stream_sock_data_check_errors(int fd);
+int stream_sock_data_check_timeouts(int fd);
int stream_sock_data_update(int fd);
int stream_sock_data_finish(int fd);
diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h
index edfb758..2525f12 100644
--- a/include/types/stream_interface.h
+++ b/include/types/stream_interface.h
@@ -42,24 +42,26 @@
/* error types reported on the streams interface for more accurate reporting */
enum {
- SI_ET_NONE = 0, /* no error yet, leave it to zero */
- SI_ET_QUEUE_TO, /* queue timeout */
- SI_ET_QUEUE_ERR, /* queue error (eg: full) */
- SI_ET_QUEUE_ABRT, /* aborted in queue by external cause */
- SI_ET_CONN_TO, /* connection timeout */
- SI_ET_CONN_ERR, /* connection error (eg: no server available) */
- SI_ET_CONN_ABRT, /* connection aborted by external cause (eg: abort) */
- SI_ET_CONN_OTHER, /* connection aborted for other reason (eg: 500) */
- SI_ET_DATA_TO, /* timeout during data phase */
- SI_ET_DATA_ERR, /* error during data phase */
- SI_ET_DATA_ABRT, /* data phase aborted by external cause */
+ SI_ET_NONE = 0x0000, /* no error yet, leave it to zero */
+ SI_ET_QUEUE_TO = 0x0001, /* queue timeout */
+ SI_ET_QUEUE_ERR = 0x0002, /* queue error (eg: full) */
+ SI_ET_QUEUE_ABRT = 0x0004, /* aborted in queue by external cause */
+ SI_ET_CONN_TO = 0x0008, /* connection timeout */
+ SI_ET_CONN_ERR = 0x0010, /* connection error (eg: no server available) */
+ SI_ET_CONN_ABRT = 0x0020, /* connection aborted by external cause (eg: abort) */
+ SI_ET_CONN_OTHER = 0x0040, /* connection aborted for other reason (eg: 500) */
+ SI_ET_DATA_TO = 0x0080, /* timeout during data phase */
+ SI_ET_DATA_ERR = 0x0100, /* error during data phase */
+ SI_ET_DATA_ABRT = 0x0200, /* data phase aborted by external cause */
};
struct stream_interface {
unsigned int state; /* SI_ST* */
- int err_type; /* first error detected, one of SI_ET_* */
- void *err_loc; /* commonly the server, NULL when SI_ET_NONE */
+ unsigned int prev_state;/* SI_ST*, copy of previous state */
+ void *owner; /* generally a (struct task*) */
int fd; /* file descriptor for a stream driver when known */
+ unsigned int err_type; /* first error detected, one of SI_ET_* */
+ void *err_loc; /* commonly the server, NULL when SI_ET_NONE */
};