Back to index

nordugrid-arc-nox  1.1.0~rc6
Functions
commfifo.cpp File Reference
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "commfifo.h"

Go to the source code of this file.

Functions

static int OpenFIFO (const JobUser &user)
bool SignalFIFO (const JobUser &user)
bool PingFIFO (const JobUser &user)

Function Documentation

static int OpenFIFO ( const JobUser user) [static]

Definition at line 116 of file commfifo.cpp.

                                         {
  // Here O_NONBLOCK ensures open() will fail if nothing listens
  std::string path = user.ControlDir() + "/gm." + user.UnixName() + ".fifo";
  int fd = open(path.c_str(),O_WRONLY | O_NONBLOCK);
  if(fd == -1) {
    // If there is no fifo for this user, try to use common one
    path=user.ControlDir() + "/gm..fifo";
    fd=open(path.c_str(),O_WRONLY | O_NONBLOCK);
  };
  // If fd == -1 here there is no FIFO or nothing is listening on another end
  return fd;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool PingFIFO ( const JobUser user)

Definition at line 138 of file commfifo.cpp.

                                   {
  int fd = OpenFIFO(user);
  // If nothing is listening open() will fail
  // so there is no need to send anything.
  if(fd == -1) return false;
  close(fd);
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool SignalFIFO ( const JobUser user)

Definition at line 129 of file commfifo.cpp.

                                     {
  int fd = OpenFIFO(user);
  if(fd == -1) return false;
  char c = 0;
  if(write(fd,&c,1) != 1) { close(fd); return false; };
  close(fd);
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function: