root/plugin/ipc/socket/kernelbufferdrainer.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /****************************************************************************
   2  *   Copyright (C) 2006-2008 by Jason Ansel, Kapil Arya, and Gene Cooperman *
   3  *   jansel@csail.mit.edu, kapil@ccs.neu.edu, gene@ccs.neu.edu              *
   4  *                                                                          *
   5  *   This file is part of the dmtcp/src module of DMTCP (DMTCP:dmtcp/src).  *
   6  *                                                                          *
   7  *  DMTCP:dmtcp/src is free software: you can redistribute it and/or        *
   8  *  modify it under the terms of the GNU Lesser General Public License as   *
   9  *  published by the Free Software Foundation, either version 3 of the      *
  10  *  License, or (at your option) any later version.                         *
  11  *                                                                          *
  12  *  DMTCP:dmtcp/src is distributed in the hope that it will be useful,      *
  13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of          *
  14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
  15  *  GNU Lesser General Public License for more details.                     *
  16  *                                                                          *
  17  *  You should have received a copy of the GNU Lesser General Public        *
  18  *  License along with DMTCP:dmtcp/src.  If not, see                        *
  19  *  <http://www.gnu.org/licenses/>.                                         *
  20  ****************************************************************************/
  21 
  22 #pragma once
  23 #ifndef KERNELBUFFERDRAINER_H
  24 #define KERNELBUFFERDRAINER_H
  25 
  26 #include <map>
  27 #include <vector>
  28 
  29 #include "dmtcpalloc.h"
  30 #include "connectionidentifier.h"
  31 #include "../jalib/jsocket.h"
  32 
  33 namespace dmtcp
  34 {
  35 
  36   class KernelBufferDrainer : public jalib::JMultiSocketProgram
  37   {
  38     public:
  39       KernelBufferDrainer() : _timeoutCount(0) {}
  40       static KernelBufferDrainer& instance();
  41 
  42 //     void drainAllSockets();
  43       void beginDrainOf(int fd , const ConnectionIdentifier& id);
  44       void refillAllSockets();
  45       virtual void onData(jalib::JReaderInterface* sock);
  46       virtual void onConnect(const jalib::JSocket& sock, const struct sockaddr* remoteAddr,socklen_t remoteLen);
  47       virtual void onTimeoutInterval();
  48       virtual void onDisconnect(jalib::JReaderInterface* sock);
  49 
  50       const map<ConnectionIdentifier, vector<char> >&
  51         getDisconnectedSockets() const { return _disconnectedSockets; }
  52 
  53       const vector<char>& getDrainedData(ConnectionIdentifier id);
  54 
  55     private:
  56       map<int , vector<char> >    _drainedData;
  57       map<int , ConnectionIdentifier > _reverseLookup;
  58       map<ConnectionIdentifier, vector<char> > _disconnectedSockets;
  59       int _timeoutCount;
  60   };
  61 
  62 }
  63 
  64 #endif

/* [<][>][^][v][top][bottom][index][help] */