Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2016-03-15 15:19:49 -0400
committerEugene Tarassov2016-03-15 15:19:49 -0400
commit5a70e9aaf8f2fa5d0ea4cc62caa8fcb49b5ac9fe (patch)
tree260ec0c9ba5b1e11f5785f5eb98e686116a54370
parent9026d10808b086625b03c8d61232812004c5a154 (diff)
downloadorg.eclipse.tcf.agent-5a70e9aaf8f2fa5d0ea4cc62caa8fcb49b5ac9fe.tar.gz
org.eclipse.tcf.agent-5a70e9aaf8f2fa5d0ea4cc62caa8fcb49b5ac9fe.tar.xz
org.eclipse.tcf.agent-5a70e9aaf8f2fa5d0ea4cc62caa8fcb49b5ac9fe.zip
TCF Agent: Streams Service: new API functions: virtual_stream_drop_data() and virtual_stream_data_size()
-rw-r--r--agent/tcf/services/streamsservice.c15
-rw-r--r--agent/tcf/services/streamsservice.h3
2 files changed, 14 insertions, 4 deletions
diff --git a/agent/tcf/services/streamsservice.c b/agent/tcf/services/streamsservice.c
index 3e2a1ed7..68eb6741 100644
--- a/agent/tcf/services/streamsservice.c
+++ b/agent/tcf/services/streamsservice.c
@@ -272,10 +272,6 @@ static void advance_stream_buffer(VirtualStream * stream) {
assert(min_pos - buf_pos <= len);
stream->buf_out = (stream->buf_out + (unsigned)(min_pos - buf_pos)) % stream->buf_len;
}
- else if (stream->pos - min_pos >= stream->buf_len) {
- /* TODO: drop stream data */
- assert(0);
- }
if (len != (stream->buf_inp + stream->buf_len - stream->buf_out) % stream->buf_len &&
!stream->space_available_posted) {
post_event(notify_space_available, stream);
@@ -563,6 +559,17 @@ int virtual_stream_is_empty(VirtualStream * stream) {
return stream->buf_out == stream->buf_inp;
}
+void virtual_stream_drop_data(VirtualStream * stream, size_t size) {
+ size_t len = virtual_stream_data_size(stream);
+ if (size < len) len = size;
+ stream->buf_out = (stream->buf_out + len) % stream->buf_len;
+}
+
+size_t virtual_stream_data_size(VirtualStream * stream) {
+ assert(stream->magic == STREAM_MAGIC);
+ return (stream->buf_inp + stream->buf_len - stream->buf_out) % stream->buf_len;
+}
+
void virtual_stream_delete(VirtualStream * stream) {
assert(stream->magic == STREAM_MAGIC);
assert(!stream->deleted);
diff --git a/agent/tcf/services/streamsservice.h b/agent/tcf/services/streamsservice.h
index 213b133c..66f9dabe 100644
--- a/agent/tcf/services/streamsservice.h
+++ b/agent/tcf/services/streamsservice.h
@@ -43,6 +43,9 @@ extern int virtual_stream_add_data(VirtualStream * stream, char * buf, size_t bu
extern int virtual_stream_get_data(VirtualStream * stream, char * buf, size_t buf_size, size_t * data_size, int * eos);
extern int virtual_stream_is_empty(VirtualStream * stream);
+extern void virtual_stream_drop_data(VirtualStream * stream, size_t size);
+extern size_t virtual_stream_data_size(VirtualStream * stream);
+
extern int virtual_stream_eos(Channel * c, char * token, char * id);
extern int virtual_stream_write(Channel * c, char * token, char * id, size_t size, InputStream * inp);
extern int virtual_stream_read(Channel * c, char * token, char * id, size_t size);

Back to the top