src/sock_test.c
changeset 46 0c13bca53ae1
parent 43 42f5dc680930
child 118 05b8d5150313
--- a/src/sock_test.c	Thu Mar 12 22:50:08 2009 +0200
+++ b/src/sock_test.c	Thu Mar 12 23:05:54 2009 +0200
@@ -206,6 +206,18 @@
         sock->eof = true;
 }
 
+void sock_test_notify_events (struct sock_test *sock)
+{
+    // notify if events are enabled
+    if (sock->ev_mask) {
+        // zero mask
+        int mask = sock->ev_mask;
+        sock->ev_mask = 0;
+
+        sock_stream_invoke_callbacks(SOCK_TEST_BASE(sock), mask);
+    }
+}
+
 void sock_test_add_recv_vec (struct sock_test *sock, struct io_vec new_vec)
 {
     struct io_buf *buf = &sock->recv_buf;
@@ -215,14 +227,9 @@
     
     // copy    
     *(buf->write_vec++) = new_vec;
-
-    // notify events?
-    if (sock->ev_mask) {
-        int mask = sock->ev_mask;
-        sock->ev_mask = 0;
-
-        sock_stream_invoke_callbacks(SOCK_TEST_BASE(sock), mask);
-    }
+    
+    // notify
+    sock_test_notify_events(sock);
 }
 
 void sock_test_add_recv_str (struct sock_test *sock, const char *str)
@@ -234,6 +241,13 @@
     sock_test_add_recv_vec(sock, vec);
 }
 
+void sock_test_set_recv_eof (struct sock_test *sock)
+{
+    sock->eof = true;
+
+    sock_test_notify_events(sock);
+}
+
 void sock_test_get_send_data (struct sock_test *sock, char **buf_ptr, size_t *len_ptr)
 {
     struct io_buf *buf = &sock->send_buf;