~ubuntu-branches/ubuntu/oneiric/procserv/oneiric

« back to all changes in this revision

Viewing changes to connectionItem.cc

  • Committer: Bazaar Package Importer
  • Author(s): Ralph Lange
  • Date: 2010-01-04 16:19:35 UTC
  • Revision ID: james.westby@ubuntu.com-20100104161935-uaosvjyry3zc5l5l
Tags: upstream-2.5.0
ImportĀ upstreamĀ versionĀ 2.5.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Process server for soft ioc
 
2
// David H. Thompson 8/29/2003
 
3
// Ralph Lange 04/22/2008
 
4
// GNU Public License (GPLv3) applies - see www.gnu.org
 
5
 
 
6
#include "procServ.h"
 
7
#include <unistd.h>
 
8
#include <stdio.h>
 
9
#include <errno.h>
 
10
// This does I/O to stdio stdin and stdout
 
11
 
 
12
connectionItem::connectionItem(int fd, bool readonly)
 
13
{
 
14
    _ioHandle = fd;
 
15
    _readonly = readonly;
 
16
    _markedForDeletion = false;
 
17
    _events = POLLIN|POLLPRI;
 
18
}
 
19
 
 
20
connectionItem::~connectionItem()
 
21
{
 
22
    PRINTF("~connectionItem()\n");
 
23
 
 
24
    if (_ioHandle>=0) close(_ioHandle);
 
25
}
 
26
 
 
27
bool connectionItem::SetPoll(struct pollfd * pfd)
 
28
{
 
29
    // Do we need to be polled
 
30
    if (_markedForDeletion || _ioHandle<1 )
 
31
    {
 
32
        _pfd=NULL; // This prevents OnPoll from processing
 
33
        return false; // This prevents this item from being counted
 
34
    }
 
35
    // else copy the data into the poll descriptor
 
36
    _pfd=pfd;
 
37
    pfd->fd=_ioHandle;
 
38
    pfd->events=_events;
 
39
    return true;    // and count this in npoll
 
40
}
 
41
 
 
42
void connectionItem::OnWait(int pid) {}