BridgeProtocolEngine.cpp 105 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/******************************************************************************
 *                      BridgeProtocolEngine.cpp
 *
 * This file is part of the Castor project.
 * See http://castor.web.cern.ch/castor
 *
 * Copyright (C) 2003  CERN
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 *
 *
 *
 * @author Nicola.Bessone@cern.ch Steven.Murray@cern.ch
 *****************************************************************************/

#include "castor/Constants.hpp"
#include "castor/dlf/Dlf.hpp"
#include "castor/exception/Internal.hpp"
#include "castor/exception/PermissionDenied.hpp"
#include "castor/exception/TimeOut.hpp"
#include "castor/tape/Constants.hpp"
32
#include "castor/tape/legacymsg/TapeBridgeMarshal.hpp"
33
34
35
36
#include "castor/tape/tapebridge/DlfMessageConstants.hpp"
#include "castor/tape/tapebridge/BridgeProtocolEngine.hpp"
#include "castor/tape/tapebridge/Constants.hpp"
#include "castor/tape/tapebridge/ClientTxRx.hpp"
37
#include "castor/tape/tapebridge/DlfMessageConstants.hpp"
38
39
#include "castor/tape/tapebridge/FailedToMigrateFileToTape.hpp"
#include "castor/tape/tapebridge/FailedToRecallFileFromTape.hpp"
40
#include "castor/tape/tapebridge/LegacyTxRx.hpp"
41
#include "castor/tape/tapebridge/RequestToMigrateFile.hpp"
42
#include "castor/tape/tapebridge/RtcpTxRx.hpp"
43
#include "castor/tape/tapebridge/TapeFlushConfigParams.hpp"
44
#include "castor/tape/net/net.hpp"
45
#include "castor/tape/tapegateway/EndNotification.hpp"
46
#include "castor/tape/tapegateway/EndNotificationErrorReport.hpp"
47
48
49
50
51
52
53
54
55
56
#include "castor/tape/tapegateway/FileMigratedNotificationStruct.hpp"
#include "castor/tape/tapegateway/FileMigrationReportList.hpp"
#include "castor/tape/tapegateway/FileRecalledNotificationStruct.hpp"
#include "castor/tape/tapegateway/FileRecallReportList.hpp"
#include "castor/tape/tapegateway/FilesToMigrateList.hpp"
#include "castor/tape/tapegateway/FilesToMigrateListRequest.hpp"
#include "castor/tape/tapegateway/FilesToRecallList.hpp"
#include "castor/tape/tapegateway/FilesToRecallListRequest.hpp"
#include "castor/tape/tapegateway/FileToMigrateStruct.hpp"
#include "castor/tape/tapegateway/FileToRecallStruct.hpp"
57
58
59
60
61
62
63
64
65
#include "castor/tape/tapegateway/NoMoreFiles.hpp"
#include "castor/tape/tapegateway/NotificationAcknowledge.hpp"
#include "castor/tape/utils/SmartFd.hpp"
#include "castor/tape/utils/SmartFdList.hpp"
#include "castor/tape/utils/utils.hpp"
#include "h/Ctape_constants.h"
#include "h/getconfent.h"
#include "h/rtcp_constants.h"
#include "h/rtcpd_constants.h"
66
67
#include "h/tapebridge_constants.h"
#include "h/tapeBridgeFlushedToTapeMsgBody.h"
68
69
70
71
72
73
74
75
76
77

#include <algorithm>
#include <list>
#include <memory>
#include <sys/time.h>


//-----------------------------------------------------------------------------
// constructor
//-----------------------------------------------------------------------------
78
castor::tape::tapebridge::BridgeProtocolEngine::BridgeProtocolEngine(
79
  const TapeFlushConfigParams         &tapeFlushConfigParams,
80
81
82
83
  const Cuuid_t                       &cuuid,
  const int                           listenSock,
  const int                           initialRtcpdSock,
  const legacymsg::RtcpJobRqstMsgBody &jobRequest,
84
  const tapegateway::Volume           &volume,
85
  const uint32_t                      nbFilesOnDestinationTape,
86
  utils::BoolFunctor                  &stoppingGracefully,
87
  Counter<uint64_t>                   &tapebridgeTransactionCounter) throw() :
88
  m_tapeFlushConfigParams(tapeFlushConfigParams),
89
90
91
  m_cuuid(cuuid),
  m_jobRequest(jobRequest),
  m_volume(volume),
92
  m_nextDestinationTapeFSeq(nbFilesOnDestinationTape + 1),
93
  m_stoppingGracefully(stoppingGracefully),
94
  m_tapebridgeTransactionCounter(tapebridgeTransactionCounter),
95
  m_nbReceivedENDOF_REQs(0),
96
97
98
  m_pendingTransferIds(MAXPENDINGTRANSFERS),
  m_pendingMigrationsStore(
    tapeFlushConfigParams.getMaxBytesBeforeFlush().value,
99
100
    tapeFlushConfigParams.getMaxFilesBeforeFlush().value),
  m_sessionWithRtcpdIsFinished(false) {
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

  // Store the listen socket and initial rtcpd connection in the socket
  // catalogue
  m_sockCatalogue.addListenSock(listenSock);
  m_sockCatalogue.addInitialRtcpdConn(initialRtcpdSock);

  // Build the map of rtcpd message body handlers
  m_rtcpdHandlers[createRtcpdHandlerKey(RTCOPY_MAGIC, RTCP_FILE_REQ   )] =
    &BridgeProtocolEngine::rtcpFileReqRtcpdCallback;
  m_rtcpdHandlers[createRtcpdHandlerKey(RTCOPY_MAGIC, RTCP_FILEERR_REQ)] =
    &BridgeProtocolEngine::rtcpFileErrReqRtcpdCallback;
  m_rtcpdHandlers[createRtcpdHandlerKey(RTCOPY_MAGIC, RTCP_TAPE_REQ   )] =
    &BridgeProtocolEngine::rtcpTapeReqRtcpdCallback;
  m_rtcpdHandlers[createRtcpdHandlerKey(RTCOPY_MAGIC, RTCP_TAPEERR_REQ)] =
    &BridgeProtocolEngine::rtcpTapeErrReqRtcpdCallback;
  m_rtcpdHandlers[createRtcpdHandlerKey(RTCOPY_MAGIC, RTCP_ENDOF_REQ  )] =
    &BridgeProtocolEngine::rtcpEndOfReqRtcpdCallback;
118
119
120
  m_rtcpdHandlers[createRtcpdHandlerKey(RTCOPY_MAGIC,
    TAPEBRIDGE_FLUSHEDTOTAPE)] =
    &BridgeProtocolEngine::tapeBridgeFlushedToTapeCallback;
121
122
123
124
  m_rtcpdHandlers[createRtcpdHandlerKey(RTCOPY_MAGIC_SHIFT, GIVE_OUTP )] =
    &BridgeProtocolEngine::giveOutpRtcpdCallback;

  // Build the map of client message handlers
125
126
127
128
  m_clientHandlers[OBJ_FilesToMigrateList] =
    &BridgeProtocolEngine::filesToMigrateListClientCallback;
  m_clientHandlers[OBJ_FilesToRecallList]  =
    &BridgeProtocolEngine::filesToRecallListClientCallback;
129
130
131
132
133
134
135
136
137
138
  m_clientHandlers[OBJ_NoMoreFiles]  =
    &BridgeProtocolEngine::noMoreFilesClientCallback;
  m_clientHandlers[OBJ_EndNotificationErrorReport]  =
    &BridgeProtocolEngine::endNotificationErrorReportClientCallback;
}


//-----------------------------------------------------------------------------
// acceptRtcpdConnection
//-----------------------------------------------------------------------------
139
int castor::tape::tapebridge::BridgeProtocolEngine::acceptRtcpdConnection()
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
  throw(castor::exception::Exception) {

  utils::SmartFd connectedSock;
  const int timeout = 5; // Seconds

  bool connectionAccepted = false;
  for(int i=0; i<timeout && !connectionAccepted; i++) {
    try {
      const time_t timeout = 1; // Timeout in seconds
      connectedSock.reset(net::acceptConnection(m_sockCatalogue.getListenSock(),
        timeout));
      connectionAccepted = true;
    } catch(castor::exception::TimeOut &ex) {
      // Do nothing
    }

    // Throw an exception if the daemon is stopping gracefully
    if(m_stoppingGracefully()) {
      castor::exception::Exception ex(ECANCELED);

      ex.getMessage() << "Stopping gracefully";
      throw(ex);
    }
  }

  // Throw an exception if the rtcpd connection could not be accepted
  if(!connectionAccepted) {
    castor::exception::TimeOut ex;

    ex.getMessage() <<
      "Failed to accept rtcpd connection after " << timeout << " seconds";
    throw ex;
  }

  try {
    unsigned short port = 0; // Client port
    unsigned long  ip   = 0; // Client IP
    char           hostName[net::HOSTNAMEBUFLEN];

    net::getPeerIpPort(connectedSock.get(), ip, port);
    net::getPeerHostName(connectedSock.get(), hostName);

    castor::dlf::Param params[] = {
183
184
185
186
      castor::dlf::Param("mountTransactionId", m_jobRequest.volReqId       ),
      castor::dlf::Param("volReqId"          , m_jobRequest.volReqId       ),
      castor::dlf::Param("TPVID"             , m_volume.vid()              ),
      castor::dlf::Param("driveUnit"         , m_jobRequest.driveUnit      ),
187
      castor::dlf::Param("dgn"               , m_jobRequest.dgn            ),
188
189
190
191
192
193
194
195
      castor::dlf::Param("clientHost"        , m_jobRequest.clientHost     ),
      castor::dlf::Param("clientPort"        , m_jobRequest.clientPort     ),
      castor::dlf::Param("clientType",
        utils::volumeClientTypeToString(m_volume.clientType())),
      castor::dlf::Param("IP"                , castor::dlf::IPAddress(ip)  ),
      castor::dlf::Param("Port"              , port                        ),
      castor::dlf::Param("HostName"          , hostName                    ),
      castor::dlf::Param("socketFd"          , connectedSock.get()         ),
196
197
      castor::dlf::Param("nbDiskTapeConns"   ,
        m_sockCatalogue.getNbDiskTapeIOControlConns())};
198
    castor::dlf::dlf_writep(m_cuuid, DLF_LVL_SYSTEM, TAPEBRIDGE_RTCPD_CALLBACK,
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
      params);
  } catch(castor::exception::Exception &ex) {
    TAPE_THROW_CODE(ECANCELED,
      ": Failed to get IP, port and host name"
      ": volReqId=" << m_jobRequest.volReqId <<
      ": nbDiskTapeConns=" << m_sockCatalogue.getNbDiskTapeIOControlConns());
  }

  return connectedSock.release();
}


//-----------------------------------------------------------------------------
// processSocks
//-----------------------------------------------------------------------------
214
void castor::tape::tapebridge::BridgeProtocolEngine::processSocks()
215
216
217
218
219
220
221
222
223
224
  throw(castor::exception::Exception) {

  int          selectRc            = 0;
  int          selectErrno         = 0;
  unsigned int nbOneSecondTimeouts = 0;
  int          maxFd               = 0;
  fd_set       readFdSet;
  timeval      timeout;

  // Select loop
225
226
  bool continueProcessingSocks = true;
  while(continueProcessingSocks) {
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
    // Throw an exception if the daemon is stopping gracefully
    if(m_stoppingGracefully()) {
      castor::exception::Exception ex(ECANCELED);

      ex.getMessage() << "Stopping gracefully";
      throw(ex);
    }

    m_sockCatalogue.buildReadFdSet(readFdSet, maxFd);

    timeout.tv_sec  = 1; // 1 second
    timeout.tv_usec = 0;

    // Wait for up to 1 second to see if any read file descriptors are ready
    selectRc = select(maxFd + 1, &readFdSet, NULL, NULL, &timeout);
    selectErrno = errno;

    switch(selectRc) {
    case 0: // Select timed out

      nbOneSecondTimeouts++;

249
250
251
252
      // Ping rtcpd if the session with rtcpd is not finished and the
      // RTCPDPINGTIMEOUT has been reached
      if(!m_sessionWithRtcpdIsFinished &&
        (nbOneSecondTimeouts % RTCPDPINGTIMEOUT == 0)) {
253
254
255
256
257
258
259
260
261
262
263
264
265
266
        RtcpTxRx::pingRtcpd(m_cuuid, m_jobRequest.volReqId,
        m_sockCatalogue.getInitialRtcpdConn(), RTCPDNETRWTIMEOUT);
      }

      // Ping the client if the ping timeout has been reached and the client is
      // readtp, writetp or dumptp
      if(
        (nbOneSecondTimeouts % CLIENTPINGTIMEOUT == 0) &&
        (m_volume.clientType() == tapegateway::READ_TP  ||
         m_volume.clientType() == tapegateway::WRITE_TP ||
         m_volume.clientType() == tapegateway::DUMP_TP)) {

        try {
          ClientTxRx::ping(m_cuuid, m_jobRequest.volReqId,
267
            m_tapebridgeTransactionCounter.next(), m_jobRequest.clientHost,
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
            m_jobRequest.clientPort);
        } catch(castor::exception::Exception &ex) {
          castor::exception::Exception ex2(ex.code());

          ex2.getMessage() <<
            "Failed to ping client"
            ": clientType=" <<
            utils::volumeClientTypeToString(m_volume.clientType()) <<
            ": " << ex.getMessage().str();

          throw(ex2);
        }
      }

      break;

    case -1: // Select encountered an error

      // If select was interrupted
      if(selectErrno == EINTR) {

        // Write a log message
        castor::dlf::Param params[] = {
291
292
293
294
295
296
297
          castor::dlf::Param("mountTransactionId", m_jobRequest.volReqId  ),
          castor::dlf::Param("volReqId"          , m_jobRequest.volReqId  ),
          castor::dlf::Param("TPVID"             , m_volume.vid()         ),
          castor::dlf::Param("driveUnit"         , m_jobRequest.driveUnit ),
          castor::dlf::Param("dgn"               , m_jobRequest.dgn       ),
          castor::dlf::Param("clientHost"        , m_jobRequest.clientHost),
          castor::dlf::Param("clientPort"        , m_jobRequest.clientPort),
298
299
300
          castor::dlf::Param("clientType",
        utils::volumeClientTypeToString(m_volume.clientType()))};
        castor::dlf::dlf_writep(m_cuuid, DLF_LVL_DEBUG,
301
          TAPEBRIDGE_SELECT_INTR, params);
302
303
304
305
306
307
308
309
310
311
312
313
314

      // Else select encountered an error other than an interruption
      } else {

        // Convert the error into an exception
        TAPE_THROW_CODE(selectErrno,
          ": Select encountered an error other than an interruption"
          ": " << sstrerror(selectErrno));
      }
      break;

    default: // One or more select file descriptors require attention

315
      processAPendingSocket(readFdSet);
316
317
318
319
320
321

    } // switch(selectRc)

    // Throw an exception if a timeout has occured
    m_sockCatalogue.checkForTimeout();

322
323
324
325
326
327
328
    // Determine whether or not continue processing sockets
    continueProcessingSocks = !(
      m_sessionWithRtcpdIsFinished &&
      m_flushedBatches.empty() &&
      !m_sockCatalogue.clientMigrationReportSockIsSet());

  } // while(continueProcessingSocks)
329
330
331
332
333
334
}


//------------------------------------------------------------------------------
// processAPendingSocket
//------------------------------------------------------------------------------
335
void castor::tape::tapebridge::BridgeProtocolEngine::processAPendingSocket(
336
337
338
339
340
341
342
343
344
345
346
  fd_set &readFdSet) throw(castor::exception::Exception) {

  BridgeSocketCatalogue::SocketType sockType = BridgeSocketCatalogue::LISTEN;
  const int pendingSock = m_sockCatalogue.getAPendingSock(readFdSet, sockType);
  if(pendingSock == -1) {
    TAPE_THROW_EX(exception::Internal,
      ": Lost pending file descriptor");
  }

  switch(sockType) {
  case BridgeSocketCatalogue::LISTEN:
347
348
    processPendingListenSocket();
    break;
349
  case BridgeSocketCatalogue::INITIAL_RTCPD:
350
351
    processPendingInitialRtcpdSocket(pendingSock);
    break;
352
  case BridgeSocketCatalogue::RTCPD_DISK_TAPE_IO_CONTROL:
353
354
    processPendingRtcpdDiskTapeIOControlSocket(pendingSock);
    break;
355
  case BridgeSocketCatalogue::CLIENT:
356
357
358
359
360
    processPendingClientSocket(pendingSock);
    break;
  case BridgeSocketCatalogue::CLIENT_MIGRATION_REPORT:
    processPendingClientMigrationReportSocket(pendingSock);
    break;
361
362
363
364
365
366
367
368
369
370
371
  default:
    TAPE_THROW_EX(exception::Internal,
      "Unknown socket type"
      ": socketType = " << sockType);
  }
}


//------------------------------------------------------------------------------
// processPendingListenSocket
//------------------------------------------------------------------------------
372
void castor::tape::tapebridge::BridgeProtocolEngine::
373
  processPendingListenSocket() throw(castor::exception::Exception) {
374
  const int acceptedConnection = acceptRtcpdConnection();
375
376

  // Accept the connection
377
  m_sockCatalogue.addRtcpdDiskTapeIOControlConn(acceptedConnection);
378
379
380
381
382
383
384
385
386

  // Throw an exception if connection is not from localhost
  checkPeerIsLocalhost(acceptedConnection);
}


//------------------------------------------------------------------------------
// processPendingInitialRtcpdSocket
//------------------------------------------------------------------------------
387
void castor::tape::tapebridge::BridgeProtocolEngine::
388
389
390
391
392
393
394
395
396
397
398
  processPendingInitialRtcpdSocket(const int pendingSock)
  throw(castor::exception::Exception) {

  // Check function arguments
  if(pendingSock < 0) {
    TAPE_THROW_EX(castor::exception::InvalidArgument,
      ": Invalid method argument"
      ": pendingSock is an invalid socket descriptor"
      ": value=" << pendingSock);
  }

399
400
401
402
403
404
405
406
407
408
409
  // Determine whether rtcpd closed the connection or whether it sent some data
  bool rtcpdClosedConnection = false;
  try {
    char dummyBuf[1];
    net::readBytesFromCloseable(rtcpdClosedConnection, pendingSock,
      RTCPDNETRWTIMEOUT, sizeof(dummyBuf), dummyBuf);
  } catch(castor::exception::Exception &ex) {
    TAPE_THROW_EX(castor::exception::Internal,
      ": Failed to determine why the socket of the initial rtcpd connection"
      " has become pending"
      ": " << ex.getMessage().str());
410
411
  }

412
413
414
415
416
417
418
  if(rtcpdClosedConnection) {
    TAPE_THROW_CODE(ECANCELED,
      ": Initial rtcpd connection un-expectedly closed");
  } else {
    TAPE_THROW_CODE(ECANCELED,
      ": Received un-expected data from the initial rtcpd connection");
  }
419
420
421
422
423
424
}


//------------------------------------------------------------------------------
// processPendingRtcpdDiskTapeIOControlSocket
//------------------------------------------------------------------------------
425
void castor::tape::tapebridge::BridgeProtocolEngine::
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
  processPendingRtcpdDiskTapeIOControlSocket(const int pendingSock)
  throw(castor::exception::Exception) {

  // Check function arguments
  if(pendingSock < 0) {
    TAPE_THROW_EX(castor::exception::InvalidArgument,
      ": Invalid method argument"
      ": pendingSock is an invalid socket descriptor"
      ": value=" << pendingSock);
  }

  legacymsg::MessageHeader header;
  utils::setBytes(header, '\0');

  // Try to receive the message header which may not be possible; The file
  // descriptor may be ready because rtcpd has closed the connection
  {
    bool peerClosed = false;
    LegacyTxRx::receiveMsgHeaderFromCloseable(m_cuuid, peerClosed,
      m_jobRequest.volReqId, pendingSock, RTCPDNETRWTIMEOUT, header);

    // If the peer closed its side of the connection, then close this side
448
    // of the connection and return in order to continue the RTCOPY session
449
450
    if(peerClosed) {
      close(m_sockCatalogue.releaseRtcpdDiskTapeIOControlConn(pendingSock));
451

452
      castor::dlf::Param params[] = {
453
454
455
456
457
458
459
460
461
462
463
464
465
        castor::dlf::Param("mountTransactionId", m_jobRequest.volReqId  ),
        castor::dlf::Param("volReqId"          , m_jobRequest.volReqId  ),
        castor::dlf::Param("TPVID"             , m_volume.vid()         ),
        castor::dlf::Param("driveUnit"         , m_jobRequest.driveUnit ),
        castor::dlf::Param("dgn"               , m_jobRequest.dgn       ),
        castor::dlf::Param("clientHost"        , m_jobRequest.clientHost),
        castor::dlf::Param("clientPort"        , m_jobRequest.clientPort),
        castor::dlf::Param("clientType",
          utils::volumeClientTypeToString(m_volume.clientType())),
        castor::dlf::Param("socketFd"          , pendingSock            )};
      castor::dlf::dlf_writep(m_cuuid, DLF_LVL_SYSTEM,
        TAPEBRIDGE_CLOSED_RTCPD_DISK_TAPE_CONNECTION_DUE_TO_PEER, params);

466
      return; // Continue the RTCOPY session
467
    }
468
  }
469

470
471
472
473
  // Process the rtcpd request
  {
    bool receivedENDOF_REQ = false;
    processRtcpdRequest(header, pendingSock, receivedENDOF_REQ);
474

475
476
    // If the message processed was not an ENDOF_REQ, then return in order to
    // continue the RTCOPY session
477
    if(!receivedENDOF_REQ) {
478
      return; // Continue the RTCOPY session
479
480
    }
  }
481

482
483
484
  // If this line has been reached, then the processed rtcpd message was
  // an ENDOF_REQ
  m_nbReceivedENDOF_REQs++;
485

486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
  {
    castor::dlf::Param params[] = {
      castor::dlf::Param("mountTransactionId"  , m_jobRequest.volReqId  ),
      castor::dlf::Param("volReqId"            , m_jobRequest.volReqId  ),
      castor::dlf::Param("TPVID"               , m_volume.vid()         ),
      castor::dlf::Param("driveUnit"           , m_jobRequest.driveUnit ),
      castor::dlf::Param("dgn"                 , m_jobRequest.dgn       ),
      castor::dlf::Param("clientHost"          , m_jobRequest.clientHost),
      castor::dlf::Param("clientPort"          , m_jobRequest.clientPort),
      castor::dlf::Param("clientType",
        utils::volumeClientTypeToString(m_volume.clientType())),
      castor::dlf::Param("socketFd"            , pendingSock           ),
      castor::dlf::Param("nbReceivedENDOF_REQs", m_nbReceivedENDOF_REQs)};
    castor::dlf::dlf_writep(m_cuuid, DLF_LVL_SYSTEM,
      TAPEBRIDGE_RECEIVED_RTCP_ENDOF_REQ, params);
  }
502

503
  close(m_sockCatalogue.releaseRtcpdDiskTapeIOControlConn(pendingSock));
504

505
506
507
508
509
  // If only the initial callback connection is open, then record the fact that
  // the session with the rtcpd daemon is over and the rtcpd daemon is awaiting
  // the final RTCP_ENDOF_REQ message from the tapebridged daemon
  if(0 == m_sockCatalogue.getNbDiskTapeIOControlConns()) {
    m_sessionWithRtcpdIsFinished = true;
510
511
512
513
514
515
516
  }
}


//------------------------------------------------------------------------------
// processPendingClientSocket
//------------------------------------------------------------------------------
517
void castor::tape::tapebridge::BridgeProtocolEngine::
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
  processPendingClientSocket(const int pendingSock)
  throw(castor::exception::Exception) {

  // Check function arguments
  if(pendingSock < 0) {
    TAPE_THROW_EX(castor::exception::InvalidArgument,
      ": Invalid method argument"
      ": pendingSock is an invalid socket descriptor"
      ": value=" << pendingSock);
  }

  // Get information about the rtcpd disk/tape IO control-connection that
  // is waiting for the reply from the pending client-connection
  int            rtcpdSock          = 0;
  uint32_t       rtcpdReqMagic      = 0;
  uint32_t       rtcpdReqType       = 0;
534
  const char     *rtcpdReqTapePath  = NULL;
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
  uint64_t       tapebridgeTransId  = 0;
  struct timeval clientReqTimeStamp = {0, 0};
  m_sockCatalogue.getRtcpdConn(pendingSock, rtcpdSock, rtcpdReqMagic,
    rtcpdReqType, rtcpdReqTapePath, tapebridgeTransId, clientReqTimeStamp);

  // Release the client-connection from the catalogue
  m_sockCatalogue.releaseClientConn(rtcpdSock, pendingSock);

  // Get the current time
  struct timeval now = {0, 0};
  gettimeofday(&now, NULL);

  // Calculate the number of remaining seconds before timing out the
  // client-connection
  int remainingClientTimeout = CLIENTNETRWTIMEOUT -
    (now.tv_sec - clientReqTimeStamp.tv_sec);
  if(remainingClientTimeout <= 0) {
    remainingClientTimeout = 1;
  }

  std::auto_ptr<IObject> obj(ClientTxRx::receiveReplyAndClose(pendingSock,
    remainingClientTimeout));

  // Find the message type's corresponding handler
  ClientCallbackMap::iterator itor = m_clientHandlers.find(obj->type());
  if(itor == m_clientHandlers.end()) {
    TAPE_THROW_CODE(EBADMSG,
      ": Unknown client message object type"
      ": object type=0x"   << std::hex << obj->type() << std::dec);
564
  }
565
566
567
568
569
570
571
572
573
574
575
576
577
  const ClientMsgCallback handler = itor->second;

  // Invoke the handler
  try {
    (this->*handler)(pendingSock, obj.get(), rtcpdSock, rtcpdReqMagic,
      rtcpdReqType, rtcpdReqTapePath, tapebridgeTransId,
      clientReqTimeStamp);
  } catch(castor::exception::Exception &ex) {
    TAPE_THROW_CODE(ECANCELED,
      ": Client message handler failed"
      ": message type=" << utils::objectTypeToString(obj->type()) <<
      ": " << ex.getMessage().str());
  }
578
}
579

580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636

//------------------------------------------------------------------------------
// processPendingClientMigrationReportSocket
//------------------------------------------------------------------------------
void castor::tape::tapebridge::BridgeProtocolEngine::
  processPendingClientMigrationReportSocket(const int pendingSock)
  throw(castor::exception::Exception) {

  // Check function arguments
  if(pendingSock < 0) {
    TAPE_THROW_EX(castor::exception::InvalidArgument,
      ": Invalid method argument"
      ": pendingSock is an invalid socket descriptor"
      ": value=" << pendingSock);
  }

  // Release the socket-descriptor from the catalogue
  uint64_t tapebridgeTransId = 0;
  utils::SmartFd catalogueSock(
    m_sockCatalogue.releaseClientMigrationReportSock(tapebridgeTransId));

  // Check for a mismatch between the pending and catalogue socket-decriptors
  if(pendingSock != catalogueSock.get()) {
      TAPE_THROW_EX(castor::exception::Internal,
        ": Client migration-report socket-descriptor mismatch"
        ": pendingSock=" << pendingSock <<
        ": catalogueSock=" << catalogueSock.get());
  }

  // Receive reply from client and close the connection
  const int closedClientSock = catalogueSock.release();
  ClientTxRx::receiveNotificationReplyAndClose(m_jobRequest.volReqId,
    tapebridgeTransId, closedClientSock);
  {
    castor::dlf::Param params[] = {
      castor::dlf::Param("tapebridgeTransId" , tapebridgeTransId      ),
      castor::dlf::Param("mountTransActionId", m_jobRequest.volReqId  ),
      castor::dlf::Param("volReqId"          , m_jobRequest.volReqId  ),
      castor::dlf::Param("TPVID"             , m_volume.vid()         ),
      castor::dlf::Param("driveUnit"         , m_jobRequest.driveUnit ),
      castor::dlf::Param("dgn"               , m_jobRequest.dgn       ),
      castor::dlf::Param("clientHost"        , m_jobRequest.clientHost),
      castor::dlf::Param("clientPort"        , m_jobRequest.clientPort),
      castor::dlf::Param("clientType",
        utils::volumeClientTypeToString(m_volume.clientType())),
      castor::dlf::Param("clientSock"        , closedClientSock       )};
    castor::dlf::dlf_writep(m_cuuid, DLF_LVL_SYSTEM,
      TAPEBRIDGE_RECEIVED_ACK_OF_NOTIFICATION, params);
  }

  // If there is a pending batch of flushed files to be reported to the client,
  // then send the batch to the client
  if(!m_flushedBatches.empty()) {
    const FileWrittenNotificationList migrations = m_flushedBatches.front();
    m_flushedBatches.pop_front();
    sendFlushedMigrationsToClient(migrations);
  }
637
638
639
640
641
642
}


//-----------------------------------------------------------------------------
// run
//-----------------------------------------------------------------------------
643
void castor::tape::tapebridge::BridgeProtocolEngine::run()
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
  throw(castor::exception::Exception) {

  switch(m_volume.mode()) {
  case tapegateway::READ:
    runRecallSession();
    break;
  case tapegateway::WRITE:
    runMigrationSession();
    break;
  case tapegateway::DUMP:
    runDumpSession();
    break;
  default:
    TAPE_THROW_EX(castor::exception::Internal,
      ": Unknown VolumeMode"
      ": Actual=" << m_volume.mode());
  }
}


//-----------------------------------------------------------------------------
// runMigrationSession
//-----------------------------------------------------------------------------
667
void castor::tape::tapebridge::BridgeProtocolEngine::runMigrationSession()
668
669
670
671
  throw(castor::exception::Exception) {

  // Send the request for the first file to migrate to the client
  time_t connectDuration = 0;
672
  const uint64_t tapebridgeTransId =
673
    m_tapebridgeTransactionCounter.next();
674
675
676
  const uint64_t maxFiles = 1;
  const uint64_t maxBytes = 1;
  utils::SmartFd clientSock(ClientTxRx::sendFilesToMigrateListRequest(
677
    m_jobRequest.volReqId, tapebridgeTransId, m_jobRequest.clientHost,
678
    m_jobRequest.clientPort, maxFiles, maxBytes, connectDuration));
679
680
  {
    castor::dlf::Param params[] = {
681
      castor::dlf::Param("tapebridgeTransId" , tapebridgeTransId      ),
682
      castor::dlf::Param("mountTransactionId", m_jobRequest.volReqId  ),
683
      castor::dlf::Param("volReqId"          , m_jobRequest.volReqId  ),
684
      castor::dlf::Param("TPVID"             , m_volume.vid()         ),
685
      castor::dlf::Param("driveUnit"         , m_jobRequest.driveUnit ),
686
      castor::dlf::Param("dgn"               , m_jobRequest.dgn       ),
687
688
      castor::dlf::Param("clientHost"        , m_jobRequest.clientHost),
      castor::dlf::Param("clientPort"        , m_jobRequest.clientPort),
689
690
      castor::dlf::Param("maxFiles"          , maxFiles               ),
      castor::dlf::Param("maxBytes"          , maxBytes               ),
691
692
693
      castor::dlf::Param("clientType"        ,
        utils::volumeClientTypeToString(m_volume.clientType())),
      castor::dlf::Param("clientSock"        , clientSock.get()       ),
694
695
      castor::dlf::Param("connectDuration"   , connectDuration        )};
    castor::dlf::dlf_writep(m_cuuid, DLF_LVL_SYSTEM,
696
      TAPEBRIDGE_SENT_FILESTOMIGRATELISTREQUEST, params);
697
698
699
  }

  // Receive the reply
700
701
702
703
  const int closedClientSock = clientSock.release();
  std::auto_ptr<tapegateway::FilesToMigrateList> filesFromClient(
    ClientTxRx::receiveFilesToMigrateListRequestReplyAndClose(
      m_jobRequest.volReqId, tapebridgeTransId, closedClientSock));
704

705
  if(filesFromClient.get() != NULL) {
706
    castor::dlf::Param params[] = {
707
      castor::dlf::Param("tapebridgeTransId", 
708
        filesFromClient->aggregatorTransactionId()),
709
      castor::dlf::Param("mountTransactionId",
710
        filesFromClient->mountTransactionId()),
711
      castor::dlf::Param("volReqId"  , m_jobRequest.volReqId  ),
712
      castor::dlf::Param("TPVID"     , m_volume.vid()         ),
713
      castor::dlf::Param("driveUnit" , m_jobRequest.driveUnit ),
714
      castor::dlf::Param("dgn"       , m_jobRequest.dgn       ),
715
716
      castor::dlf::Param("clientHost", m_jobRequest.clientHost),
      castor::dlf::Param("clientPort", m_jobRequest.clientPort),
717
718
719
      castor::dlf::Param("clientType",
        utils::volumeClientTypeToString(m_volume.clientType())),
      castor::dlf::Param("clientSock", closedClientSock       ),
720
721
      castor::dlf::Param("nbFiles"   ,
        filesFromClient->filesToMigrate().size())};
722
    castor::dlf::dlf_writep(m_cuuid, DLF_LVL_SYSTEM,
723
      TAPEBRIDGE_RECEIVED_FILESTOMIGRATELIST, params);
724
725
726
  } else {
    castor::dlf::Param params[] = {
      castor::dlf::Param("mountTransactionId", m_jobRequest.volReqId  ),
727
      castor::dlf::Param("volReqId"          , m_jobRequest.volReqId  ),
728
      castor::dlf::Param("TPVID"             , m_volume.vid()         ),
729
      castor::dlf::Param("driveUnit"         , m_jobRequest.driveUnit ),
730
      castor::dlf::Param("dgn"               , m_jobRequest.dgn       ),
731
      castor::dlf::Param("clientHost"        , m_jobRequest.clientHost),
732
733
734
735
      castor::dlf::Param("clientPort"        , m_jobRequest.clientPort),
      castor::dlf::Param("clientType",
        utils::volumeClientTypeToString(m_volume.clientType())),
      castor::dlf::Param("clientSock"        , closedClientSock       )};
736
    castor::dlf::dlf_writep(m_cuuid, DLF_LVL_DEBUG,
737
      TAPEBRIDGE_RECEIVED_NOMOREFILES, params);
738
739
  }

740
741
742
743
  // If there is no file to migrate, then notify the client of the end of
  // session and return
  if(filesFromClient.get() == NULL) {
    notifyClientEndOfSession();
744
745
746
    return;
  }

747
748
749
750
751
752
753
754
755
756
757
758
759
  // For the very first file to migrate the FilesToMigrateList message
  // should only contain one file
  if(1 != filesFromClient->filesToMigrate().size()) {
    TAPE_THROW_CODE(ENOTSUP,
      ": The FilesToMigrateList message for the first file to migrate should"
      " only contain one file"
      ": nbFiles=" << filesFromClient->filesToMigrate().size());
  }
  const tapegateway::FileToMigrateStruct *const firstFileToMigrate =
    filesFromClient->filesToMigrate()[0];

  // If the client is the tape-gateway then cross-check and update the next
  // expected tape-file sequence-number
760
  if(tapegateway::TAPE_GATEWAY == m_volume.clientType()) {
761

762
    if(firstFileToMigrate->fseq() != m_nextDestinationTapeFSeq) {
763
764
765
766
      castor::exception::Exception ex(ECANCELED);

      ex.getMessage() <<
        "Invalid tape file sequence number from client"
767
768
        ": expected=" << (m_nextDestinationTapeFSeq) <<
        ": actual=" << firstFileToMigrate->fseq();
769
770
771
772

      throw(ex);
    }

773
    m_nextDestinationTapeFSeq++;
774
775
776
777
  }

  // Remember the file transaction ID and get its unique index to be passed
  // to rtcpd through the "rtcpFileRequest.disk_fseq" message field
778
779
  const uint32_t diskFSeq = m_pendingTransferIds.insert(
    firstFileToMigrate->fileTransactionId());
780
781
782
783
784
785
786
787
788
789
790
791

  // Give volume to rtcpd
  legacymsg::RtcpTapeRqstErrMsgBody rtcpVolume;
  utils::setBytes(rtcpVolume, '\0');
  utils::copyString(rtcpVolume.vid    , m_volume.vid().c_str()    );
  utils::copyString(rtcpVolume.vsn    , EMPTYVSN                  );
  utils::copyString(rtcpVolume.label  , m_volume.label().c_str()  );
  utils::copyString(rtcpVolume.density, m_volume.density().c_str());
  utils::copyString(rtcpVolume.unit   , m_jobRequest.driveUnit    );
  rtcpVolume.volReqId       = m_jobRequest.volReqId;
  rtcpVolume.mode           = WRITE_ENABLE;
  rtcpVolume.tStartRequest  = time(NULL);
792
793
794
  rtcpVolume.err.severity   = 1;
  rtcpVolume.err.maxTpRetry = 1; // Only try once - no retries
  rtcpVolume.err.maxCpRetry = 1; // Only try once - no retries
795
796
797
  RtcpTxRx::giveVolumeToRtcpd(m_cuuid, m_jobRequest.volReqId,
    m_sockCatalogue.getInitialRtcpdConn(), RTCPDNETRWTIMEOUT, rtcpVolume);

798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
  // Add the first file to migrate to the pending migrations store
  {
    RequestToMigrateFile request;

    request.fileTransactionId = firstFileToMigrate->fileTransactionId();
    request.nsHost = firstFileToMigrate->nshost();
    request.nsFileId = firstFileToMigrate->fileid();
    request.positionCommandCode =
      firstFileToMigrate->positionCommandCode();
    request.tapeFSeq = firstFileToMigrate->fseq();
    request.fileSize = firstFileToMigrate->fileSize();
    request.lastKnownFilename = firstFileToMigrate->lastKnownFilename();
    request.lastModificationTime =
      firstFileToMigrate->lastModificationTime();
    request.path = firstFileToMigrate->path();
    request.umask = firstFileToMigrate->umask();

    m_pendingMigrationsStore.receivedRequestToMigrateFile(request);
  }
817
818
  {
    castor::dlf::Param params[] = {
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
      castor::dlf::Param("tapebridgeTransId" ,
        filesFromClient->aggregatorTransactionId()),
      castor::dlf::Param("mountTransactionId",
        filesFromClient->mountTransactionId()),
      castor::dlf::Param("volReqId", m_jobRequest.volReqId),
      castor::dlf::Param("TPVID", m_volume.vid()),
      castor::dlf::Param("driveUnit", m_jobRequest.driveUnit),
      castor::dlf::Param("dgn", m_jobRequest.dgn),
      castor::dlf::Param("clientHost", m_jobRequest.clientHost),
      castor::dlf::Param("clientPort", m_jobRequest.clientPort),
      castor::dlf::Param("clientType",
        utils::volumeClientTypeToString(m_volume.clientType())),
      castor::dlf::Param("clientSock", closedClientSock),
      castor::dlf::Param("fileTransactionId",
        firstFileToMigrate->fileTransactionId()),
      castor::dlf::Param("NSHOSTNAME", firstFileToMigrate->nshost()),
      castor::dlf::Param("NSFILEID", firstFileToMigrate->fileid()),
      castor::dlf::Param("tapeFSeq", firstFileToMigrate->fseq())};
837
838
839
840
    castor::dlf::dlf_writep(m_cuuid, DLF_LVL_SYSTEM,
      TAPEBRIDGE_ADDED_PENDING_MIGRATION_TO_STORE, params);
  }

841
  // Give first file to migrate to rtcpd
842
843
  {
    char migrationTapeFileId[CA_MAXPATHLEN+1];
844
845
    utils::toHex((uint64_t)firstFileToMigrate->fileid(),
      migrationTapeFileId);
846
847
848
    unsigned char blockId[4];
    utils::setBytes(blockId, '\0');
    char nshost[CA_MAXHOSTNAMELEN+1];
849
    utils::copyString(nshost, firstFileToMigrate->nshost().c_str());
850
851
852
853
854
855
856

    RtcpTxRx::giveFileToRtcpd(
      m_cuuid,
      m_jobRequest.volReqId,
      m_sockCatalogue.getInitialRtcpdConn(),
      RTCPDNETRWTIMEOUT,
      rtcpVolume.mode,
857
858
      firstFileToMigrate->path().c_str(),
      firstFileToMigrate->fileSize(),
859
860
861
862
      "",
      RECORDFORMAT,
      migrationTapeFileId,
      RTCOPYCONSERVATIVEUMASK,
863
864
865
      (int32_t)firstFileToMigrate->positionCommandCode(),
      (int32_t)firstFileToMigrate->fseq(),
      diskFSeq,
866
      nshost,
867
      (uint64_t)firstFileToMigrate->fileid(),
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
      blockId);
  }

  char tapePath[CA_MAXPATHLEN+1];
  utils::setBytes(tapePath, '\0');

  // Ask rtcpd to request more work
  RtcpTxRx::askRtcpdToRequestMoreWork(m_cuuid, m_jobRequest.volReqId,
    tapePath, m_sockCatalogue.getInitialRtcpdConn(), RTCPDNETRWTIMEOUT,
    WRITE_ENABLE);

  // Tell rtcpd end of file list
  RtcpTxRx::tellRtcpdEndOfFileList(m_cuuid, m_jobRequest.volReqId,
    m_sockCatalogue.getInitialRtcpdConn(), RTCPDNETRWTIMEOUT);

883
  // Process the rtcpd and client sockets in a loop until the end of the rtcpd
884
885
  // session has been reached and all file-transfer report messages have been
  // sent to the client
886
887
  processSocks();

888
889
  notifyRtcpdEndOfSessionAndCloseInitialConnection();
  notifyClientEndOfSession();
890
891
892
893
894
895
}


//-----------------------------------------------------------------------------
// runRecallSession
//-----------------------------------------------------------------------------
896
void castor::tape::tapebridge::BridgeProtocolEngine::runRecallSession()
897
898
  throw(castor::exception::Exception) {

899
900
  char tapePath[CA_MAXPATHLEN+1];
  utils::setBytes(tapePath, '\0');
901

902
903
904
905
906
907
908
909
910
911
912
  // Give volume to rtcpd
  legacymsg::RtcpTapeRqstErrMsgBody rtcpVolume;
  utils::setBytes(rtcpVolume, '\0');
  utils::copyString(rtcpVolume.vid    , m_volume.vid().c_str()    );
  utils::copyString(rtcpVolume.vsn    , EMPTYVSN                  );
  utils::copyString(rtcpVolume.label  , m_volume.label().c_str()  );
  utils::copyString(rtcpVolume.density, m_volume.density().c_str());
  utils::copyString(rtcpVolume.unit   , m_jobRequest.driveUnit    );
  rtcpVolume.volReqId       = m_jobRequest.volReqId;
  rtcpVolume.mode           = WRITE_DISABLE;
  rtcpVolume.tStartRequest  = time(NULL);
913
914
915
  rtcpVolume.err.severity   = 1;
  rtcpVolume.err.maxTpRetry = 1; // Only try once - no retries
  rtcpVolume.err.maxCpRetry = 1; // Only try once - no retries
916
917
  RtcpTxRx::giveVolumeToRtcpd(m_cuuid, m_jobRequest.volReqId,
    m_sockCatalogue.getInitialRtcpdConn(), RTCPDNETRWTIMEOUT, rtcpVolume);
918

919
920
921
922
  // Ask rtcpd to request more work
  RtcpTxRx::askRtcpdToRequestMoreWork(m_cuuid, m_jobRequest.volReqId,
    tapePath, m_sockCatalogue.getInitialRtcpdConn(), RTCPDNETRWTIMEOUT,
    WRITE_DISABLE);
923

924
925
926
  // Tell rtcpd end of file list
  RtcpTxRx::tellRtcpdEndOfFileList(m_cuuid, m_jobRequest.volReqId,
    m_sockCatalogue.getInitialRtcpdConn(), RTCPDNETRWTIMEOUT);
927

928
929
  // Process the rtcpd and client sockets in a loop until the end of the rtcpd
  // session has been reached
930
  processSocks();
931

932
  notifyClientEndOfSession();
933
934
935
936
937
938
}


//-----------------------------------------------------------------------------
// runDumpSession
//-----------------------------------------------------------------------------
939
void castor::tape::tapebridge::BridgeProtocolEngine::runDumpSession()
940
941
942
943
944
945
946
947
948
949
950
951
952
953
  throw(castor::exception::Exception) {

  try {
    // Give volume to rtcpd
    legacymsg::RtcpTapeRqstErrMsgBody rtcpVolume;
    utils::setBytes(rtcpVolume, '\0');
    utils::copyString(rtcpVolume.vid    , m_volume.vid().c_str()    );
    utils::copyString(rtcpVolume.vsn    , EMPTYVSN                  );
    utils::copyString(rtcpVolume.label  , m_volume.label().c_str()  );
    utils::copyString(rtcpVolume.density, m_volume.density().c_str());
    utils::copyString(rtcpVolume.unit   , m_jobRequest.driveUnit    );
    rtcpVolume.volReqId       = m_jobRequest.volReqId;
    rtcpVolume.mode           = WRITE_DISABLE;
    rtcpVolume.tStartRequest  = time(NULL);
954
955
956
    rtcpVolume.err.severity   = 1;
    rtcpVolume.err.maxTpRetry = 1; // Only try once - no retries
    rtcpVolume.err.maxCpRetry = 1; // Only try once - no retries
957
958
959
960
961
962
    RtcpTxRx::giveVolumeToRtcpd(m_cuuid, m_jobRequest.volReqId,
      m_sockCatalogue.getInitialRtcpdConn(), RTCPDNETRWTIMEOUT, rtcpVolume);

    // Get dump parameters message
    std::auto_ptr<tapegateway::DumpParameters> dumpParameters(
      ClientTxRx::getDumpParameters(m_cuuid, m_jobRequest.volReqId,
963
      m_tapebridgeTransactionCounter.next(), m_jobRequest.clientHost,
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
      m_jobRequest.clientPort));

    // Tell rtcpd to dump the tape
    legacymsg::RtcpDumpTapeRqstMsgBody request;
    request.maxBytes      = dumpParameters->maxBytes();
    request.blockSize     = dumpParameters->blockSize();
    request.convert       = dumpParameters->converter();
    request.tapeErrAction = dumpParameters->errAction();
    request.startFile     = dumpParameters->startFile();
    request.maxFiles      = dumpParameters->maxFile();
    request.fromBlock     = dumpParameters->fromBlock();
    request.toBlock       = dumpParameters->toBlock();
    RtcpTxRx::tellRtcpdDumpTape(m_cuuid, m_jobRequest.volReqId,
      m_sockCatalogue.getInitialRtcpdConn(), RTCPDNETRWTIMEOUT, request);

    // Tell rtcpd end of file list
    RtcpTxRx::tellRtcpdEndOfFileList(m_cuuid, m_jobRequest.volReqId,
      m_sockCatalogue.getInitialRtcpdConn(), RTCPDNETRWTIMEOUT);

983
984
    // Process the rtcpd and client sockets in a loop until the end of the
    // rtcpd session has been reached
985
986
    processSocks();

987
    notifyClientEndOfSession();
988
989
990
991
992
993
994
995
996
997
998
999
1000
  } catch(castor::exception::Exception &ex) {
    castor::exception::Exception ex2(ex.code());

    ex2.getMessage() <<
      "Failed to process rtcpd sockets"
      ": " << ex.getMessage().str();

    throw(ex2);
  }
}


//-----------------------------------------------------------------------------
For faster browsing, not all history is shown. View entire blame