bug-gnunet
[Top][All Lists]
Advanced

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

Re: [bug-GNUnet] Problem in server/tcpserver.c


From: Peter F Bradshaw
Subject: Re: [bug-GNUnet] Problem in server/tcpserver.c
Date: Sat, 27 Apr 2002 22:10:50 +0800 (WST)

Hi;

This fix polutes TCPLISTENER_sockDescriptors_[]. It is necessary to
update this array to reflect the fact the the descriptor is now closed.
Looks like I should have looked through the function a little more :-)

I now think it should be more like:

   while (pos < sizeof(GPROXY_Message)) {
      n = read(sockDescriptor,
               &((char*)&buff)[pos],
               sizeof(GPROXY_Message)-pos);
      if (n < 0)
              break;
      else if (n == 0)
      {
        mutex_lock(&TCPLISTENER_sockDescriptorGuard_);
        for (n=0;n<CONCOUNT;n++)
          if (TCPLISTENER_sockDescriptors_[n] == sockDescriptor) {
            TCPLISTENER_sockDescriptors_[n] = -1;
          break;
        }
        mutex_unlock(&TCPLISTENER_sockDescriptorGuard_);

              return;
      }
      pos += n;
    }

On Fri, 26 Apr 2002, Peter F Bradshaw wrote:

> Hi;
>
> I'm running the CVS source of this date. There is an endless loop
> in processData(). This seems to occur as the result of some searchs
> (i.e. gnunet-search).
>
> Lines from 105 read:
>
>    while (pos < sizeof(GPROXY_Message)) {
>     n = read(sockDescriptor,
>       &((char*)&buff)[pos],
>       sizeof(GPROXY_Message)-pos);
>     if (n < 0)
>       break;
>     pos += n;
>     }
>
> In some instances the read() is returning 0 which sets up an endless
> loop. In the normal blocking case a return of 0 from read() indicates
> EOF. Therefore, I think the code should be:
>
>     while (pos < sizeof(GPROXY_Message)) {
>       n = read(sockDescriptor,
>              &((char*)&buff)[pos],
>              sizeof(GPROXY_Message)-pos);
>       if (n < 0)
>             break;
>       else if (n == 0)
>         return;
>       pos += n;
>     }
>
> Cheers
>

Cheers

-- 
Peter F Bradshaw, address@hidden, ICQ 75431157 (exadios).
http://www.exadios.com
PGP public key at http://www.exadios.com/public_key.html
"Needs more salt" - Archimedes





reply via email to

[Prev in Thread] Current Thread [Next in Thread]