21#include "RConfigure.h"
37#if (defined(__FreeBSD__) && (__FreeBSD__ < 4)) || \
38 (defined(__APPLE__) && (!defined(MAC_OS_X_VERSION_10_3) || \
39 (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3)))
41#define lockf(fd, op, sz) flock((fd), (op))
43#define F_LOCK (LOCK_EX | LOCK_NB)
46#define F_ULOCK LOCK_UN
65#include "compiledata.h"
152 Error(
"TASLogHandler",
"executing command in pipe");
155 Error(
"TASLogHandler",
156 "undefined command (%p) or socket (%p)", (
int *)cmd, s);
173 Error(
"TASLogHandler",
"undefined file (%p) or socket (%p)",
f, s);
198 if ((plf = strchr(
line,
'\n')))
238 Error(
"TASLogHandlerGuard",
"invalid handler");
242 Error(
"TASLogHandlerGuard",
"undefined command");
258 Error(
"TASLogHandlerGuard",
"invalid handler");
262 Error(
"TASLogHandlerGuard",
"undefined file");
284 FILE *flog,
const char *logfile)
321 Error(
"TApplicationServer",
"failed to setup - quitting");
371 Error(
"Setup",
"failed to send startup message");
377 Error(
"Setup",
"failed to send local protocol");
397 SysError(
"Setup",
"can not change to directory %s",
405 SysError(
"Setup",
"can not change to directory %s",
415 SysWarning(
"Setup",
"failed to enable SIGURG generation on incoming OOB");
452 Fatal(
"GetOptions",
"must be started with 4 arguments");
481 Error(
"Run",
"invalid instance: cannot Run()");
498 Error(
"HandleSocketInput",
"retrieving message from input socket");
505 Info(
"HandleSocketInput",
"got message of type %d",
what);
513 Info(
"HandleSocketInput:kMESS_CINT",
"processing: %s...", str);
546 {
char name[2048], i1[20], i2[40];
547 sscanf(str,
"%2047s %19s %39s",
name, i1, i2);
548 Int_t bin = atoi(i1);
568 Warning(
"HandleSocketInput",
"message type unknown (%d)",
what);
584 const Int_t kBufSize = 1024;
585 char waste[kBufSize];
590 Info(
"HandleUrgentData",
"handling oob...");
611 if (nch > kBufSize) nch = kBufSize;
614 Error(
"HandleUrgentData",
"error receiving waste");
619 Error(
"HandleUrgentData",
"error receiving OOB (n = %d)",
n);
624 Info(
"HandleUrgentData",
"got OOB byte: %d\n", oob_byte);
629 Info(
"HandleUrgentData",
"*** Hard Interrupt");
642 Error(
"HandleUrgentData",
"error sending OOB");
653 if (nch > kBufSize) nch = kBufSize;
656 Error(
"HandleUrgentData",
"error receiving waste (2)");
666 Info(
"HandleUrgentData",
"Soft Interrupt");
669 Error(
"HandleUrgentData",
"soft interrupt flushed stream");
680 Info(
"HandleUrgentData",
"Shutdown Interrupt");
687 Error(
"HandleUrgentData",
"unexpected OOB byte");
701 Info(
"HandleSigPipe",
"client died");
731 if (
size <= 0)
return 0;
734 Int_t fd = open(
file, O_CREAT | O_TRUNC | O_WRONLY, 0600);
740 const Int_t kMAXBUF = 16384;
741 char buf[kMAXBUF], cpy[kMAXBUF];
746 while (filesize <
size) {
759 Int_t k = 0, i = 0, j = 0;
776 SysError(
"ReceiveFile",
"error writing to file %s",
file);
784 Error(
"ReceiveFile",
"error during receiving file %s",
file);
807 off_t ltot=0, lnow=0;
812 ltot = lseek(fileno(stdout), (off_t) 0, SEEK_END);
815 SysError(
"SendLogFile",
"lseek failed");
821 if (end <= start || end > ltot)
823 left = (
Int_t)(end - start);
828 left = (
Int_t)(ltot - lnow);
839 const Int_t kMAXBUF = 32768;
841 Int_t wanted = (left > kMAXBUF) ? kMAXBUF : left;
849 SysError(
"SendLogFile",
"error reading log file");
853 if (end == ltot &&
len == wanted)
857 SysError(
"SendLogFile",
"error sending log file");
863 wanted = (left > kMAXBUF) ? kMAXBUF : left;
865 }
while (
len > 0 && left > 0);
889 while ((o = next())) {
904 Info(
"SendCanvases",
"new canvas found: %p", o);
957 if (!fname || !*fname) {
962 while ((fh = (
TNamed *)next())) {
979 TList *keylist = (
TList *)
gROOT->ProcessLine(
Form(
"((TFile *)0x%zx)->GetListOfKeys();", (
size_t)fh));
980 TIter nextk(keylist);
983 while ((key = (
TNamed *)nextk())) {
985 const char *classname = (
const char *)
gROOT->ProcessLine(
Form(
"((TKey *)0x%zx)->GetClassName();", (
size_t)key));
1045 while ((fh = next())) {
1065 (*mess) >> filenam >> md5;
1069 if (md5local && md5 == (*md5local)) {
1074 Info(
"HandleCheckFile",
"up-to-date version of %s available", filenam.
Data());
1079 Info(
"HandleCheckFile",
"file %s needs to be uploaded", filenam.
Data());
1117 if (syslogService.
IsNull()) {
1118 syslogService =
"server";
1122 const char *
type = 0;
1129 if (level >=
kInfo) {
1143 type =
"*** Break ***";
1157 if (!location || !location[0] ||
1160 fprintf(stderr,
"%s on %s: %s\n",
type, node.
Data(), msg);
1163 fprintf(stderr,
"%s in <%s> on %s: %s\n",
type, location, node.
Data(), msg);
1164 buf.
Form(
"%s:%s:<%s>:%s", node.
Data(),
type, location, msg);
1171 fprintf(stderr,
"aborting\n");
1190 if (!strncmp(
line,
".L", 2) || !strncmp(
line,
".U", 2) ||
1191 !strncmp(
line,
".X", 2) || !strncmp(
line,
".x", 2)) {
1207 Info(
"ProcessLine",
"macro %s not found in path %s: asking the client",
1217 while (filefollows) {
1222 Error(
"ProcessLine",
"ask-file: received empty message from client");
1226 Error(
"ProcessLine",
"ask-file: wrong message received (what: %d)", rm->
What());
1231 Error(
"ProcessLine",
"ask-file: wrong sub-type received (type: %d)",
type);
1234 (*rm) >> filefollows;
1238 Error(
"ProcessLine",
"file: received empty message from client");
1242 Error(
"ProcessLine",
"file: wrong message received (what: %d)", rm->
What());
1247 Error(
"ProcessLine",
"file: wrong sub-type received (type: %d)",
type);
1253 char name[2048], i1[20], i2[40];
1254 sscanf(str,
"%2047s %19s %39s",
name, i1, i2);
1255 Int_t bin = atoi(i1);
1301 const char *logon =
gEnv->
GetValue(
"Rint.Logon", (
char*)0);
const Int_t kRRemote_Protocol
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
R__EXTERN TBenchmark * gBenchmark
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Int_t gErrorIgnoreLevel
Error handling routines.
constexpr Int_t kSysError
ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler)
Set an errorhandler function. Returns the old handler.
R__EXTERN void Throw(int code)
If an exception context has been set (using the TRY and RETRY macros) jump back to where it was set.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TSystem * gSystem
TApplicationServer * fServ
Bool_t Notify() override
Handle this interrupt.
TASInterruptHandler(TApplicationServer *s)
TASLogHandlerGuard(const char *cmd, TSocket *s, const char *pfx="", Bool_t on=kTRUE)
Init a guard for executing a command in a pipe.
virtual ~TASLogHandlerGuard()
Close a guard for executing a command in a pipe.
TASLogHandler * fExecHandler
virtual ~TASLogHandler()
Handle available message in the open file.
Bool_t Notify() override
Handle available message in the open file.
TASLogHandler(const char *cmd, TSocket *s, const char *pfx="")
Execute 'cmd' in a pipe and handle output messages from the related file.
static void SetDefaultPrefix(const char *pfx)
Static method to set the default prefix.
Bool_t Notify() override
Handle this signal.
TApplicationServer * fServ
TASSigPipeHandler(TApplicationServer *s)
void Run(Bool_t retrn=kFALSE) override
Main server eventloop.
void ExecLogon()
Execute logon macro's.
Int_t SendCanvases()
Send any created canvas to client.
Longptr_t ProcessLine(const char *line, Bool_t=kFALSE, Int_t *err=nullptr) override
Parse a command line received from the client, making sure that the files needed for the execution,...
TApplicationServer(Int_t *argc, char **argv, FILE *flog, const char *logfile)
Main constructor.
void HandleUrgentData()
Handle Out-Of-Band data sent by the master or client.
void HandleSocketInput()
Handle input coming from the client or from the master server.
Int_t ReceiveFile(const char *file, Bool_t bin, Long64_t size)
Receive a file, either sent by a client or a master server.
const char * GetHost() const
void Reset(const char *dir)
Reset environment to be ready for execution of next command.
void GetOptions(Int_t *argc, char **argv) override
Get and handle command line options.
void HandleSigPipe()
Called when the client is not alive anymore (i.e.
TRemoteObject * fWorkingDir
static void ErrorHandler(Int_t level, Bool_t abort, const char *location, const char *msg)
The error handler function.
Int_t BrowseKey(const char *keyname)
Read key object and send it back to client.
Int_t Setup()
Print the Remote Server logo on standard output.
Int_t BrowseDirectory(const char *dirname)
Browse directory and send back its content to client.
void HandleCheckFile(TMessage *mess)
Handle file checking request.
virtual ~TApplicationServer()
Cleanup.
void Terminate(Int_t status) override
Terminate the proof server.
Int_t BrowseFile(const char *fname)
Browse root file and send back its content; if fname is null, send the full list of files.
void SendLogFile(Int_t status=0, Int_t start=-1, Int_t end=-1)
Send log file to master.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
virtual Longptr_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=nullptr)
Process a single command line, either a C++ statement or an interpreter command starting with a "....
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
virtual Longptr_t ProcessFile(const char *file, Int_t *error=nullptr, Bool_t keep=kFALSE)
Process a file containing a C++ macro.
This class is a ROOT utility to help benchmarking applications.
TObject * ReadObject(const TClass *cl) override
Read object from I/O buffer.
char * ReadString(char *s, Int_t max) override
Read string from I/O buffer.
void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Describe directory structure in memory.
TObject * FindObject(const char *name) const override
Find object by name in the list of memory objects.
virtual Bool_t cd()
Change current directory to "this" directory.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
void Add(TObject *obj) override
virtual TObjLink * FirstLink() const
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
This code implements the MD5 message-digest algorithm.
static TMD5 * FileChecksum(const char *file)
Returns checksum of specified file.
void Reset() override
Reset the message buffer so we can use (i.e. fill) it again.
TClass * GetClass() const
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Wrapper around a TObject so it can be stored in a TList.
TObject * GetObject() const
Mother of all ROOT objects.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
static const char * GetMacroPath()
Get macro search path. Static utility function.
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session.
void SetKeyClassName(const char *name)
void Browse(TBrowser *b) override
Browse remote object.
void SetRemoteAddress(Longptr_t addr)
void SetFolder(Bool_t isFolder)
ESignals GetSignal() const
virtual Int_t SetOption(ESockOptions opt, Int_t val)
Set socket options.
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
virtual Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
virtual Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Send a raw buffer of specified length.
Option_t * GetOption() const override
virtual Int_t GetDescriptor() const
virtual Int_t Send(const TMessage &mess)
Send a TMessage object.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Int_t Atoi() const
Return integer value of string.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
virtual void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
virtual void Syslog(ELogLevel level, const char *mess)
Send mess to syslog daemon.
static void ResetErrno()
Static function resetting system error number.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual void Openlog(const char *name, Int_t options, ELogFacility facility)
Open connection to system log daemon.
static Int_t GetErrno()
Static function returning system error number.
virtual int GetPid()
Get process id.
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
virtual TFileHandler * RemoveFileHandler(TFileHandler *fh)
Remove a file handler from the list of file handlers.
virtual TSeqCollection * GetListOfFileHandlers() const
virtual FILE * OpenPipe(const char *command, const char *mode)
Open a pipe.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
virtual int ClosePipe(FILE *pipe)
Close the pipe.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual void AddSignalHandler(TSignalHandler *sh)
Add a signal handler to list of system signal handlers.
virtual void Exit(int code, Bool_t mode=kTRUE)
Exit the application.
virtual const char * HostName()
Return the system's host name.
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual const char * WorkingDirectory()
Return working directory.
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
virtual void Abort(int code=0)
Abort the application.
virtual int Unlink(const char *name)
Unlink, i.e.
virtual void StackTrace()
Print a stack trace.
const char * GetFile() const
void SetUrl(const char *url, Bool_t defaultIsFile=kFALSE)
Parse url character string and split in its different subcomponents.
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.