void bbcp_LogFile::Monitor(int fdnum, char *fdname) { bbcp_LogFiler *lrP = new bbcp_LogFiler(this, fdname, fdnum); int retc; // Start a log file thread (we loose storage upon failure) // if ((retc = bbcp_Thread_Run(bbcp_FileLog, (void *)lrP, &(lrP->LogT)))) {bbcp_Emsg("LogFile", errno, "start logging thread to", Logfn); return; } // Chain this logger into out list of loggers // Flog.Lock(); lrP->Next = Loggers; Loggers = lrP; Flog.UnLock(); DEBUG("Thread " <<lrP->LogT <<" assigned to logging " <<fdname); }
void bbcp_ProgMon::Start(bbcp_File *fs_obj, bbcp_ZCX *cx_obj, int pint, long long xfrbytes) { int retc; // If we are already monitoring, issue a stop // if (mytid) Stop(); // Preset all values // alldone = 0; FSp = fs_obj; CXp = cx_obj; wtime = pint; Tbytes = xfrbytes; // Run a thread to start the monitor // if (retc = bbcp_Thread_Run(bbcp_MonProg, (void *)this, &mytid)) {DEBUG("Error " <<retc <<" starting progress monitor thread.");} else {DEBUG("Thread " <<mytid <<" monitoring progress.");} return; }
int bbcp_RTCopy::Start(bbcp_FileSystem *fsp, const char *iofn, int iofd) { bbcp_Semaphore xSem(0); int rc; // Initialize the common variables // ioFD = iofd; Grow = 1; Left = 0; Blok = (bbcp_Config.Options & bbcp_RTCBLOK ? bbcp_Config.Streams : 0); FSp = fsp; // Initialize variable dependent on how we will do locking // if (bbcp_Config.rtLockf) {lkFN = bbcp_Config.rtLockf; lkFD = bbcp_Config.rtLockd; } else { lkFN = iofn; lkFD = dup(iofd); } // Now start a thread that will try to obtain a shared lock // if ((rc = bbcp_Thread_Run(bbcp_RTCopyLK, (void *)&xSem, &Tid)) < 0) {bbcp_Emsg("RTCopy", rc, "starting file r/t lock thread."); Grow = -rc; return 0; } // Wait for the thread to set up // xSem.Wait(); return (Grow >= 0); }