Fix reread of buffer data, better, also for TCP.
@@ -1353,17 +1353,6 @@ ssl_handle_write(struct comm_point* c)
static int
ssl_handle_it(struct comm_point* c)
{
- if(c->tcp_req_info) {
- do {
- int r;
- c->tcp_req_info->read_again = 0;
- if(c->tcp_is_reading)
- r = ssl_handle_read(c);
- else r = ssl_handle_write(c);
- if(!r) return r;
- } while (c->tcp_req_info->read_again);
- return 1;
- }
if(c->tcp_is_reading)
return ssl_handle_read(c);
return ssl_handle_write(c);
@@ -1698,6 +1687,29 @@ comm_point_tcp_handle_write(int fd, struct comm_point* c)
return 1;
}
+/** read again to drain buffers when there could be more to read */
+static void
+tcp_req_info_read_again(int fd, struct comm_point* c)
+{
+ while(c->tcp_req_info->read_again) {
+ int r;
+ c->tcp_req_info->read_again = 0;
+ if(c->tcp_is_reading)
+ r = comm_point_tcp_handle_read(fd, c, 0);
+ else r = comm_point_tcp_handle_write(fd, c);
+ if(!r) {
+ reclaim_tcp_handler(c);
+ if(!c->tcp_do_close) {
+ fptr_ok(fptr_whitelist_comm_point(
+ c->callback));
+ (void)(*c->callback)(c, c->cb_arg,
+ NETEVENT_CLOSED, NULL);
+ }
+ return;
+ }
+ }
+}
+
void
comm_point_tcp_handle_callback(int fd, short event, void* arg)
{
@@ -1736,6 +1748,8 @@ comm_point_tcp_handle_callback(int fd, short event, void* arg)
NETEVENT_CLOSED, NULL);
}
}
+ if(c->tcp_req_info && c->tcp_req_info->read_again)
+ tcp_req_info_read_again(fd, c);
return;
}
if(event&UB_EV_WRITE) {
@@ -1748,6 +1762,8 @@ comm_point_tcp_handle_callback(int fd, short event, void* arg)
NETEVENT_CLOSED, NULL);
}
}
+ if(c->tcp_req_info && c->tcp_req_info->read_again)
+ tcp_req_info_read_again(fd, c);
return;
}
if(event&UB_EV_TIMEOUT) {
