~ubuntu-branches/debian/sid/nordugrid-arc/sid

« back to all changes in this revision

Viewing changes to src/libs/data-staging/DataStagingDelivery.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2012-12-13 16:41:31 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20121213164131-0fumka0jar8mxm07
Tags: 2.0.1-1
* 2.0.1 Release
* Drop patches accepted upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
#include <arc/OptionParser.h>
11
11
#include <arc/StringConv.h>
12
12
#include <arc/UserConfig.h>
 
13
#include <arc/Utils.h>
13
14
#include <arc/data/DataHandle.h>
14
15
#include <arc/data/DataBuffer.h>
15
16
 
227
228
  dest->SetSecure(false);
228
229
  dest->Passive(true);
229
230
 
 
231
  // set X509* for 3rd party tools which need it (eg GFAL)
 
232
  SetEnv("X509_USER_PROXY", source_cfg.ProxyPath());
 
233
  if (!source_cfg.CACertificatesDirectory().empty()) SetEnv("X509_CERT_DIR", source_cfg.CACertificatesDirectory());
 
234
  // those tools also use hostcert by default if the user is root...
 
235
  if (getuid() == 0) {
 
236
    SetEnv("X509_USER_CERT", source_cfg.ProxyPath());
 
237
    SetEnv("X509_USER_KEY", source_cfg.ProxyPath());
 
238
  }
 
239
 
230
240
  // set signal handlers
231
241
  signal(SIGTERM, sig_shutdown);
232
242
  signal(SIGINT, sig_shutdown);
273
283
                  DataStaging::DTRErrorStatus::LOCAL_FILE_ERROR,
274
284
                 DataStaging::DTRErrorStatus::ERROR_SOURCE,
275
285
                 std::string("Failed reading from source: ")+source->CurrentLocation().str()+
276
 
                  " : "+source->GetFailureReason().GetDesc()+": "+source_st.GetDesc(),
 
286
                  " : "+std::string(source_st),
277
287
                 0,0);
278
288
    _exit(-1);
279
289
    //return -1;
287
297
                  DataStaging::DTRErrorStatus::LOCAL_FILE_ERROR,
288
298
                 DataStaging::DTRErrorStatus::ERROR_DESTINATION,
289
299
                 std::string("Failed writing to destination: ")+dest->CurrentLocation().str()+
290
 
                  " : "+dest->GetFailureReason().GetDesc()+": "+dest_st.GetDesc(),
 
300
                  " : "+std::string(dest_st),
291
301
                 0,0);
292
302
    _exit(-1);
293
303
    //return -1;
333
343
 
334
344
  // Error at source or destination
335
345
  if(source_failed || !source_st) {
 
346
    std::string err("Failed reading from source: "+source->CurrentLocation().str());
 
347
    // If error reported in read callback, use that instead
 
348
    if (source->GetFailureReason() != DataStatus::UnknownError) source_st = source->GetFailureReason();
 
349
    if (!source_st) err += " : " + std::string(source_st);
336
350
    ReportStatus(DataStaging::DTRStatus::TRANSFERRED,
337
351
                 (source_url.Protocol() != "file") ?
338
 
                  (!source_st && source_st.Retryable() ?
 
352
                  (((!source_st && source_st.Retryable()) || buffer.speed.transferred_size() > 0) ?
339
353
                      DataStaging::DTRErrorStatus::TEMPORARY_REMOTE_ERROR :
340
354
                      DataStaging::DTRErrorStatus::PERMANENT_REMOTE_ERROR) :
341
355
                  DataStaging::DTRErrorStatus::LOCAL_FILE_ERROR,
342
356
                 DataStaging::DTRErrorStatus::ERROR_SOURCE,
343
 
                 std::string("Failed reading from source: ")+source->CurrentLocation().str()+
344
 
                  " : "+source->GetFailureReason().GetDesc()+": "+source_st.GetDesc(),
 
357
                 err,
345
358
                 buffer.speed.transferred_size(),
346
359
                 GetFileSize(*source,*dest));
347
360
    reported = true;
348
361
  };
349
362
  if(dest_failed || !dest_st) {
 
363
    std::string err("Failed writing to destination: "+dest->CurrentLocation().str());
 
364
    // If error reported in write callback, use that instead
 
365
    if (dest->GetFailureReason() != DataStatus::UnknownError) dest_st = dest->GetFailureReason();
 
366
    if (!dest_st) err += " : " + std::string(dest_st);
350
367
    ReportStatus(DataStaging::DTRStatus::TRANSFERRED,
351
368
                 (dest_url.Protocol() != "file") ?
352
 
                  (!dest_st && dest_st.Retryable() ?
 
369
                  (((!dest_st && dest_st.Retryable()) || buffer.speed.transferred_size() > 0) ?
353
370
                         DataStaging::DTRErrorStatus::TEMPORARY_REMOTE_ERROR :
354
371
                         DataStaging::DTRErrorStatus::PERMANENT_REMOTE_ERROR) :
355
372
                  DataStaging::DTRErrorStatus::LOCAL_FILE_ERROR,
356
373
                 DataStaging::DTRErrorStatus::ERROR_DESTINATION,
357
 
                 std::string("Failed writing to destination: ")+dest->CurrentLocation().str()+
358
 
                  " : "+dest->GetFailureReason().GetDesc()+": "+dest_st.GetDesc(),
 
374
                 err,
359
375
                 buffer.speed.transferred_size(),
360
376
                 GetFileSize(*source,*dest));
361
377
    reported = true;
389
405
    crc_dest.print(buf,100);
390
406
    calc_csum = buf;
391
407
  }
392
 
  if (!calc_csum.empty() && crc.Type() != CheckSumAny::none) {
 
408
  if (!reported && !calc_csum.empty() && crc.Type() != CheckSumAny::none) {
393
409
 
394
410
    // compare calculated to any checksum given as an option
395
411
    if (source->CheckCheckSum()) {
404
420
                     0,0);
405
421
        reported = true;
406
422
        eof_reached = false; // TODO general error flag is better than this
 
423
        // Delete destination
 
424
        if (!dest->Remove().Passed()) {
 
425
          logger.msg(WARNING, "Failed cleaning up destination %s", dest->GetURL().str());
 
426
        }
407
427
      }
408
428
      else
409
429
        logger.msg(INFO, "Calculated transfer checksum %s matches source checksum", calc_csum);