~ubuntu-branches/ubuntu/precise/sitecopy/precise

« back to all changes in this revision

Viewing changes to lib/neon/ne_locks.c

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2008-07-22 07:31:05 UTC
  • mfrom: (1.1.4 upstream) (4.1.7 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080722073105-cbqs1hnc2wvqejfd
Tags: 1:0.16.6-1
* New upstream release
  - fix a crash with progress bar enabled; Closes: #486378
* debian/control
  - set myself as maintainer, Kartik as uploader
  - set Vcs-{Browser,Git} fields
  - bump Standards-Version to 3.8.0
    + debian/README.source added
  - added DM-Upload-Allowed flag
* debian/patches/05_libneon27_transition.dpatch
  - removed since merged upstream
* debian/copyrightdebian/copyright
  - updated upstream email and copyright years
* debian/patches/10_bts410703_preserve_storage_files_sigint.dpatch
  - added to preserve storage files if SIGINT (Ctrl+C) is sent to sitecopy;
    thanks to Andreas Henriksson for the patch; Closes: #410703

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
struct lock_ctx {
78
78
    struct ne_lock active; /* activelock */
79
79
    ne_request *req; /* the request in question */
 
80
    ne_xml_parser *parser;
80
81
    char *token; /* the token we're after. */
81
82
    int found;
82
83
    ne_buffer *cdata;
140
141
                             item->lock->token, ">)", NULL);
141
142
            ne_free(uri);
142
143
        }
143
 
        ne_buffer_czappend(req, "\n");
 
144
        ne_buffer_czappend(req, "\r\n");
144
145
    }
145
146
}
146
147
 
579
580
        /* at the root element; retrieve the Lock-Token header,
580
581
         * and bail if it wasn't given. */
581
582
        if (token == NULL) {
582
 
            ne_set_error(ne_get_session(ctx->req), "%s",
583
 
                         _("LOCK response missing Lock-Token header"));
 
583
            ne_xml_set_error(ctx->parser, 
 
584
                             _("LOCK response missing Lock-Token header"));
584
585
            return NE_XML_ABORT;
585
586
        }
586
587
 
688
689
    ne_request *req = ne_request_create(sess, "LOCK", lock->uri.path);
689
690
    ne_buffer *body = ne_buffer_create();
690
691
    ne_xml_parser *parser = ne_xml_create();
691
 
    int ret, parse_failed;
 
692
    int ret;
692
693
    struct lock_ctx ctx;
693
694
 
694
695
    memset(&ctx, 0, sizeof ctx);
695
696
    ctx.cdata = ne_buffer_create();    
696
697
    ctx.req = req;
 
698
    ctx.parser = parser;
697
699
 
698
700
    /* LOCK is not idempotent. */
699
701
    ne_set_request_flag(req, NE_REQFLAG_IDEMPOTENT, 0);
731
733
 
732
734
    ne_buffer_destroy(body);
733
735
    ne_buffer_destroy(ctx.cdata);
734
 
    parse_failed = ne_xml_failed(parser);
735
736
    
736
737
    if (ret == NE_OK && ne_get_status(req)->klass == 2) {
737
 
        if (ctx.token == NULL) {
738
 
            ret = NE_ERROR;
739
 
            ne_set_error(sess, _("No Lock-Token header given"));
740
 
        }
741
 
        else if (parse_failed) {
742
 
            ret = NE_ERROR;
743
 
            ne_set_error(sess, "%s", ne_xml_get_error(parser));
744
 
        }
745
 
        else if (ne_get_status(req)->code == 207) {
746
 
            ret = NE_ERROR;
747
 
            /* TODO: set the error string appropriately */
748
 
        }
749
 
        else if (ctx.found) {
 
738
        if (ne_get_status(req)->code == 207) {
 
739
            ret = NE_ERROR;
 
740
            /* TODO: set the error string appropriately */
 
741
        } else if (ctx.found) {
750
742
            /* it worked: copy over real lock details if given. */
751
743
            if (lock->token) ne_free(lock->token);
752
744
            lock->token = ctx.token;
790
782
    ctx.cdata = ne_buffer_create();
791
783
    ctx.req = req;
792
784
    ctx.token = lock->token;
 
785
    ctx.parser = parser;
793
786
 
794
787
    /* Handle the response and update *lock appropriately. */
795
788
    ne_xml_push_handler(parser, lk_startelm, lk_cdata, lk_endelm, &ctx);
804
797
    if (ret == NE_OK) {
805
798
        if (ne_get_status(req)->klass != 2) {
806
799
            ret = NE_ERROR; /* and use default session error */
807
 
        } else if (ne_xml_failed(parser)) {
808
 
            ret = NE_ERROR;
809
 
            ne_set_error(sess, "%s", ne_xml_get_error(parser));
810
800
        } else if (!ctx.found) {
811
801
            ne_set_error(sess, _("No activelock for <%s> returned in "
812
802
                                 "LOCK refresh response"), lock->token);