[sr-dev] git:andrei/tcp_tls_changes: tcp: don' t reset read_flags on RD_CONN_REPEAT_READ
Andrei Pelinescu-Onciul
andrei at iptel.org
Mon Jun 21 16:02:10 CEST 2010
Module: sip-router
Branch: andrei/tcp_tls_changes
Commit: 21b8cf904aa6abe20d930385bf912ccf66666341
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=21b8cf904aa6abe20d930385bf912ccf66666341
Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date: Sun Jun 20 19:20:12 2010 +0200
tcp: don't reset read_flags on RD_CONN_REPEAT_READ
Allow flags value propagation between tcp_read*() that asked to be
repeated (RD_CONN_REPEAT_READ). This allows an optimization in the
tls read code: when repeating a tls_read, don't try a tcp read
syscall if the previous attempt did get the whole socket receive
buffer (RD_CONN_SHORT_READ) or detected EOF (use only the buffered
data if any).
---
tcp_read.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/tcp_read.c b/tcp_read.c
index 441521f..4881844 100644
--- a/tcp_read.c
+++ b/tcp_read.c
@@ -137,8 +137,8 @@ static ticks_t tcp_reader_prev_ticks;
* RD_CONN_FORCE_EOF.
* RD_CONN_REPEAT_READ - the read should be repeated immediately
* (used only by the tls code for now).
- * Note: RD_CONN_SHORT_READ & RD_CONN_EOF must be cleared
- * before calling this function.
+ * Note: RD_CONN_SHORT_READ & RD_CONN_EOF _are_ not cleared internally,
+ * so one should clear them before calling this function.
* @return number of bytes read, 0 on EOF or -1 on error,
* on EOF it also sets c->state to S_CONN_EOF.
* (to distinguish from reads that would block which could return 0)
@@ -955,14 +955,14 @@ again:
con, con->id, atomic_get(&con->refcnt));
goto con_error;
}
-#ifdef USE_TLS
-repeat_1st_read:
-#endif /* USE_TLS */
/* if we received the fd there is most likely data waiting to
* be read => process it first to avoid extra sys calls */
read_flags=((con->flags & (F_CONN_EOF_SEEN|F_CONN_FORCE_EOF)) &&
!(con->flags & F_CONN_OOB_DATA))? RD_CONN_FORCE_EOF
:0;
+#ifdef USE_TLS
+repeat_1st_read:
+#endif /* USE_TLS */
resp=tcp_read_req(con, &n, &read_flags);
if (unlikely(resp<0)){
/* some error occured, but on the new fd, not on the tcp
@@ -1011,9 +1011,6 @@ repeat_1st_read:
con, con->id, atomic_get(&con->refcnt));
goto read_error;
}
-#ifdef USE_TLS
-repeat_read:
-#endif /* USE_TLS */
#ifdef POLLRDHUP
read_flags=(((events & POLLRDHUP) |
(con->flags & (F_CONN_EOF_SEEN|F_CONN_FORCE_EOF)))
@@ -1021,6 +1018,9 @@ repeat_read:
#else /* POLLRDHUP */
read_flags=0;
#endif /* POLLRDHUP */
+#ifdef USE_TLS
+repeat_read:
+#endif /* USE_TLS */
resp=tcp_read_req(con, &ret, &read_flags);
if (unlikely(resp<0)){
read_error:
More information about the sr-dev
mailing list