+ do
+ {
+ rv = vppcom_session_attr (out_sid, VPPCOM_ATTR_GET_NWRITE, 0, 0);
+ if (rv < 0)
+ {
+ clib_warning ("[%d] ERROR: vppcom_session_attr (out_sid (%u), "
+ "VPPCOM_ATTR_GET_NWRITE, 0, 0) returned %d (%s)!",
+ getpid (), out_sid, rv, vppcom_retval_str (rv));
+ vec_reset_length (vsm->io_buffer);
+ return rv;
+ }
+
+ bytes_to_read = (size_t) rv;
+ if (VCOM_DEBUG > 2)
+ clib_warning ("[%d] results %ld, n_bytes_left %lu, "
+ "bytes_to_read %lu", getpid (), results,
+ n_bytes_left, bytes_to_read);
+ if (bytes_to_read == 0)
+ {
+ u32 flags, flags_len = sizeof (flags);
+ rv = vppcom_session_attr (out_sid, VPPCOM_ATTR_GET_FLAGS, &flags,
+ &flags_len);
+ ASSERT (rv == VPPCOM_OK);
+
+ if (flags & O_NONBLOCK)
+ {
+ if (!results)
+ {
+ if (VCOM_DEBUG > 2)
+ clib_warning ("[%d] EAGAIN", getpid ());
+ eagain = 1;
+ }
+ goto update_offset;
+ }
+ else
+ continue;
+ }
+ bytes_to_read = clib_min (n_bytes_left, bytes_to_read);
+ vec_validate (vsm->io_buffer, bytes_to_read);
+ nbytes = libc_read (__in_fd, vsm->io_buffer, bytes_to_read);
+ if (nbytes < 0)
+ {
+ errno_val = errno;
+ perror ("read()");
+ clib_warning ("[%d] ERROR: libc_read (__in_fd (%d), "
+ "io_buffer %p, bytes_to_read %lu) returned "
+ "errno %d",
+ getpid (), __in_fd, vsm->io_buffer,
+ bytes_to_read, errno_val);
+ if (results == 0)
+ {
+ vec_reset_length (vsm->io_buffer);
+ return -errno_val;
+ }
+ goto update_offset;
+ }
+ rv = vppcom_session_write (out_sid, vsm->io_buffer, nbytes);
+ if (rv < 0)
+ {
+ clib_warning ("[%d] ERROR: vppcom_session_write ("
+ "out_sid %u, io_buffer %p, nbytes %d) "
+ "returned %d (%s)",
+ getpid (), out_sid, vsm->io_buffer, nbytes,
+ rv, vppcom_retval_str (rv));
+ if (results == 0)
+ {
+ vec_reset_length (vsm->io_buffer);
+ return rv;