Re: ORB problem, was Re: Problem moving applets between panels



Elliot Lee <sopwith@redhat.com> writes:
> On 19 Jul 1998, Raja R Harinath wrote:
> > Anyway, I've seen this happen when the ORBit client abruptly disconnects
> > from the ORBit server (the applet being the client, and panel being the
> > server in this case).  The real problem is probably in the applet part
> > of the code.  For me, the applet usually crashes saying something like
> > Assertion "sum == res" failed.  A bit of sleuthing shows that a writev
> > call EINVALs.
> 
> Could you 'strace -e writev' the applet and send me the writev line?
> Backtrace and code to reproduce it, too.

I found that Solaris `writev' can handle only 16 iovecs.  If more iovecs
are given (as is sometimes the case: I saw 18-23 iovecs), it EINVALs.
To get around it, I added the following code to
`giop_send_buffer_write'.  (There seems to also be a problem with having
a `write' soon after an EINVALed `writev').

  if (res == (gulong)-1 && errno == EINVAL) {
#define IOVS 16
    int todo = nvecs;
    int sum = 0;
    struct iovec *data = GIOP_MESSAGE_BUFFER(send_buffer)->iovecs->data;
    int fd = GIOP_CONNECTION_GET_FD(GIOP_MESSAGE_BUFFER(send_buffer)->connection);

    while (todo) {
      int iovecs = todo > IOVS ? IOVS : todo;
      res = writev(fd, data, iovecs);
      if (res == -1)
	break;
      sum += res;
      data += iovecs;
      todo -= iovecs;
    }
    if (res != -1)
      res = sum;
  }

and I changed `giop_recv_message_buffer_use' to use `readn' instead of
`read'. 

static ssize_t readn(int fd, void *data, size_t len)
{
  char *buf = data;
  size_t todo = len;
  ssize_t rdb;

  while (todo) {
    if ((rdb = read(fd, buf, todo)) == (ssize_t)-1)
      return -1;
    if (rdb == 0) break;
    buf += rdb;
    todo -= rdb;
  }
  return len - todo;
}

In addition, `giop_recv_message_buffer_use' doesn't check for the return
value of `read' -- this can cause it to infloop if a read fails.

I don't want to commit either fix since it doesn't feel right.

- Hari
-- 
Raja R Harinath ------------------------------ harinath@cs.umn.edu
"When all else fails, read the instructions."      -- Cahn's Axiom
"Our policy is, when in doubt, do the right thing."   -- Roy L Ash



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]