~ubuntu-branches/ubuntu/utopic/nordugrid-arc/utopic

« back to all changes in this revision

Viewing changes to src/hed/dmc/gridftp/Lister.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2014-05-01 20:51:02 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140501205102-icy9t3348uxobyx7
Tags: 4.1.0-1
* 4.1.0 Release
* Call dh_autoreconf to support ppc64le (Closes: #744639)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include "Lister.h"
27
27
 
28
28
 
29
 
static char default_ftp_user[] = "ftp";
 
29
static char default_ftp_user[] = "anonymous";
30
30
static char default_gsiftp_user[] = ":globus-mapping:";
31
 
static char default_ftp_pass[] = "user@";
 
31
static char default_ftp_pass[] = "dummy";
32
32
static char default_gsiftp_pass[] = "user@";
33
33
 
34
34
static void dos_to_unix(char *s) {
109
109
    } else {
110
110
      globus_abstime_t timeout;
111
111
      GlobusTimeAbstimeSet(timeout,to,0);
112
 
      globus_cond_timedwait(&cond, &mutex, &timeout);
 
112
      if (globus_cond_timedwait(&cond, &mutex, &timeout) == ETIMEDOUT) {
 
113
        // on timeout the mutex is unlocked
 
114
        callback_status = CALLBACK_NOTREADY;
 
115
        return CALLBACK_TIMEDOUT;
 
116
      }
113
117
    }
114
118
    res = callback_status;
115
119
    callback_status = CALLBACK_NOTREADY;
520
524
    bool res = true;
521
525
    close_callback_status = CALLBACK_NOTREADY;
522
526
    logger.msg(VERBOSE, "Closing connection");
523
 
    if (globus_ftp_control_data_force_close(handle, simple_callback, this) != GLOBUS_SUCCESS) {
524
 
    } else if (wait_for_callback() != CALLBACK_DONE) {
525
 
      res = false;
 
527
    if (globus_ftp_control_data_force_close(handle, simple_callback, this) == GLOBUS_SUCCESS) {
 
528
      // Timeouts are used while waiting for callbacks just in case they never
 
529
      // come. If a timeout happens then the response object is not freed just
 
530
      // in case the callback eventually arrives.
 
531
      callback_status_t cbs = wait_for_callback(60);
 
532
      if (cbs == CALLBACK_TIMEDOUT) {
 
533
        logger.msg(VERBOSE, "Timeout waiting for Globus callback - leaking connection");
 
534
        return;
 
535
      }
 
536
      if (cbs != CALLBACK_DONE) res = false;
526
537
    }
527
538
    //if (globus_ftp_control_abort(handle, resp_callback, this) != GLOBUS_SUCCESS) {
528
539
    //} else if (wait_for_callback() != CALLBACK_DONE) {
531
542
    if(send_command("ABOR", NULL, true, NULL) == GLOBUS_FTP_UNKNOWN_REPLY) {
532
543
      res = false;
533
544
    }
534
 
    if (globus_ftp_control_quit(handle, resp_callback, this) != GLOBUS_SUCCESS) {
535
 
    } else if (wait_for_callback() != CALLBACK_DONE) {
536
 
      res = false;
537
 
    }
538
 
    if (globus_ftp_control_force_close(handle, close_callback, this) != GLOBUS_SUCCESS) {
539
 
    } else if (wait_for_close_callback() != CALLBACK_DONE) {
540
 
      res = false;
541
 
    }
542
 
    if(res) {
 
545
    if (globus_ftp_control_quit(handle, resp_callback, this) == GLOBUS_SUCCESS) {
 
546
      callback_status_t cbs = wait_for_callback(60);
 
547
      if (cbs == CALLBACK_TIMEDOUT) {
 
548
        logger.msg(VERBOSE, "Timeout waiting for Globus callback - leaking connection");
 
549
        return;
 
550
      }
 
551
      if (cbs != CALLBACK_DONE) res = false;
 
552
    }
 
553
    if (globus_ftp_control_force_close(handle, close_callback, this) == GLOBUS_SUCCESS) {
 
554
      callback_status_t cbs = wait_for_close_callback();
 
555
      if (cbs != CALLBACK_DONE) res = false;
 
556
    }
 
557
    if (res) {
543
558
      logger.msg(VERBOSE, "Closed successfully");
544
559
    } else {
545
560
      logger.msg(VERBOSE, "Closing may have failed");