RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  [EMAIL PROTECTED]
  Module: rpm                              Date:   09-Jul-2008 21:48:49
  Branch: HEAD                             Handle: 2008070919484900

  Modified files:
    rpm/rpmio               rpmdav.c

  Log:
    - rpmio: mark "server awol" disconnected state for graceful error
    handling.

  Summary:
    Revision    Changes     Path
    2.81        +32 -29     rpm/rpmio/rpmdav.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmdav.c
  ============================================================================
  $ cvs diff -u -r2.80 -r2.81 rpmdav.c
  --- rpm/rpmio/rpmdav.c        7 Jul 2008 20:02:31 -0000       2.80
  +++ rpm/rpmio/rpmdav.c        9 Jul 2008 19:48:49 -0000       2.81
  @@ -317,6 +317,7 @@
   /* =============================================================== */
   int davDisconnect(void * _u)
   {
  +#ifdef       NOTYET  /* XXX not quite right yet. */
       urlinfo u = (urlinfo)_u;
       int rc;
   
  @@ -340,6 +341,7 @@
   if (_dav_debug < 0)
   fprintf(stderr, "*** davDisconnect(%p) active %d\n", u, rc);
       /* XXX return active state? */
  +#endif       /* NOTYET */
       return 0;
   }
   
  @@ -1257,6 +1259,7 @@
   /[EMAIL PROTECTED]@*/        /* XXX annotate ctx->st correctly */
           rc = davHEAD(u, ctx->st);    /* use HEAD to get contentLength */
   /[EMAIL PROTECTED]@*/
  +
       }
   
       switch (rc) {
  @@ -1305,22 +1308,6 @@
       return ret;
   }
   
  -#ifdef       DYING
  -static void hexdump(const unsigned char * buf, ssize_t len)
  -     /[EMAIL PROTECTED]/
  -{
  -    int i;
  -    if (len <= 0)
  -     return;
  -    for (i = 0; i < len; i++) {
  -     if (i != 0 && (i%16) == 0)
  -         fprintf(stderr, "\n");
  -     fprintf(stderr, " %02X", buf[i]);
  -    }
  -    fprintf(stderr, "\n");
  -}
  -#endif
  -
   /[EMAIL PROTECTED]@*/
   static void davAcceptRanges(void * userdata, /[EMAIL PROTECTED]@*/ const 
char * value)
        /[EMAIL PROTECTED] userdata @*/
  @@ -1459,6 +1446,9 @@
       ctrl = fdLink(ctrl, "open ctrl (davReq)");
   
   assert(u->sess != NULL);
  +    /* XXX reset disconnected handle to NULL. should never happen ... */
  +    if (ctrl->req == (void *)-1)
  +     ctrl->req = NULL;
   /[EMAIL PROTECTED]@*/
   assert(ctrl->req == NULL);
   /[EMAIL PROTECTED]@*/
  @@ -1609,16 +1599,31 @@
       FD_t fd = cookie;
       ssize_t rc;
   
  -#if 0
  -assert(count >= 128);        /* HACK: see ne_request.h comment */
  -#endif
  +#if WITH_NEON_MIN_VERSION >= 0x002700
  +  { urlinfo u = NULL;
  +    u = urlLink(fd->url, "url (davRead)");
  +    if (u->info.status == ne_status_recving)
  +     rc = ne_read_response_block(fd->req, buf, count);
  +    else {
  +     /* If server has disconnected, then tear down the neon request. */
  +     if (u->info.status == ne_status_disconnected) {
  +         int xx;
  +         xx = ne_end_request(fd->req);
  +         xx = my_result("davRead: ne_end_request(req)", xx, NULL);
  +         ne_request_destroy(fd->req);
  +         fd->req = (void *)-1;
  +     }
  +     errno = EIO;       /* XXX what to do? */
  +     rc = -1;
  +    }
  +    u = urlFree(u, "url (davRead)");
  +  }
  +#else
       rc = ne_read_response_block(fd->req, buf, count);
  +#endif
   
   if (_dav_debug < 0) {
   fprintf(stderr, "*** davRead(%p,%p,0x%x) rc 0x%x\n", cookie, buf, 
(unsigned)count, (unsigned)rc);
  -#ifdef       DYING
  -hexdump(buf, rc);
  -#endif
       }
   
       return rc;
  @@ -1658,10 +1663,6 @@
   
   if (_dav_debug < 0)
   fprintf(stderr, "*** davWrite(%p,%p,0x%x) rc 0x%x\n", cookie, buf, 
(unsigned)count, (unsigned)rc);
  -#ifdef       DYING
  -if (count > 0)
  -hexdump(buf, count);
  -#endif
   
       return rc;
   }
  @@ -1682,10 +1683,12 @@
       int rc;
   
   assert(fd->req != NULL);
  -    rc = ne_end_request(fd->req);
  -    rc = my_result("ne_end_request(req)", rc, NULL);
  +    if (fd->req != (void *)-1) {
  +     rc = ne_end_request(fd->req);
  +     rc = my_result("ne_end_request(req)", rc, NULL);
   
  -    ne_request_destroy(fd->req);
  +     ne_request_destroy(fd->req);
  +    }
       fd->req = NULL;
   
   if (_dav_debug < 0)
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                [email protected]

Reply via email to