|
|
@ -50,7 +50,6 @@ class SHMProcess::Private
|
|
|
|
shm_ID = -1;
|
|
|
|
shm_ID = -1;
|
|
|
|
window = NULL;
|
|
|
|
window = NULL;
|
|
|
|
attached = false;
|
|
|
|
attached = false;
|
|
|
|
suspended = false;
|
|
|
|
|
|
|
|
identified = false;
|
|
|
|
identified = false;
|
|
|
|
useYield = false;
|
|
|
|
useYield = false;
|
|
|
|
server_lock = -1;
|
|
|
|
server_lock = -1;
|
|
|
@ -71,14 +70,14 @@ class SHMProcess::Private
|
|
|
|
int suspend_lock;
|
|
|
|
int suspend_lock;
|
|
|
|
int attachmentIdx;
|
|
|
|
int attachmentIdx;
|
|
|
|
|
|
|
|
|
|
|
|
bool locked;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool attached;
|
|
|
|
bool attached;
|
|
|
|
bool suspended;
|
|
|
|
bool locked;
|
|
|
|
bool identified;
|
|
|
|
bool identified;
|
|
|
|
bool useYield;
|
|
|
|
bool useYield;
|
|
|
|
|
|
|
|
|
|
|
|
bool validate(char* exe_file, uint32_t pid, std::vector< memory_info* >& known_versions);
|
|
|
|
bool validate(std::vector< memory_info* >& known_versions);
|
|
|
|
|
|
|
|
|
|
|
|
bool Aux_Core_Attach(bool & versionOK, pid_t & PID);
|
|
|
|
bool Aux_Core_Attach(bool & versionOK, pid_t & PID);
|
|
|
|
//bool waitWhile (uint32_t state);
|
|
|
|
//bool waitWhile (uint32_t state);
|
|
|
@ -110,13 +109,11 @@ bool SHMProcess::Private::SetAndWait (uint32_t state)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//detach the shared memory
|
|
|
|
//detach the shared memory
|
|
|
|
shmdt(shm_addr);
|
|
|
|
shmdt(shm_addr);
|
|
|
|
attached = suspended = identified = false;
|
|
|
|
FreeLocks();
|
|
|
|
|
|
|
|
attached = locked = identified = false;
|
|
|
|
// we aren't the current process anymore
|
|
|
|
// we aren't the current process anymore
|
|
|
|
g_pProcess = NULL;
|
|
|
|
g_pProcess = NULL;
|
|
|
|
FreeLocks();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw Error::SHMServerDisappeared();
|
|
|
|
throw Error::SHMServerDisappeared();
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -146,14 +143,6 @@ bool SHMProcess::SetAndWait (uint32_t state)
|
|
|
|
return d->SetAndWait(state);
|
|
|
|
return d->SetAndWait(state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
// set SHM command.
|
|
|
|
|
|
|
|
void SHMProcess::setCmd (uint32_t newstate)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(d->attached && d->suspended)
|
|
|
|
|
|
|
|
D_SHMCMD = newstate;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint32_t OS_getAffinity()
|
|
|
|
uint32_t OS_getAffinity()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
cpu_set_t mask;
|
|
|
|
cpu_set_t mask;
|
|
|
@ -163,25 +152,6 @@ uint32_t OS_getAffinity()
|
|
|
|
return affinity;
|
|
|
|
return affinity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SHMProcess::Private::Aux_Core_Attach(bool & versionOK, pid_t & PID)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(!locked) return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SHMDATA(coreattach)->cl_affinity = OS_getAffinity();
|
|
|
|
|
|
|
|
if(!SetAndWait(CORE_ATTACH)) return false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
cerr <<"CORE_VERSION" << CORE_VERSION << endl;
|
|
|
|
|
|
|
|
cerr <<"server CORE_VERSION" << SHMDATA(coreattach)->sv_version << endl;
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
versionOK =( SHMDATA(coreattach)->sv_version == CORE_VERSION );
|
|
|
|
|
|
|
|
PID = SHMDATA(coreattach)->sv_PID;
|
|
|
|
|
|
|
|
useYield = SHMDATA(coreattach)->sv_useYield;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
if(useYield) cerr << "Using Yield!" << endl;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// test if we have client and server locks and the server is present
|
|
|
|
// test if we have client and server locks and the server is present
|
|
|
|
bool SHMProcess::Private::AreLocksOk()
|
|
|
|
bool SHMProcess::Private::AreLocksOk()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -215,7 +185,6 @@ void SHMProcess::Private::FreeLocks()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
close(suspend_lock);
|
|
|
|
close(suspend_lock);
|
|
|
|
locked = false;
|
|
|
|
locked = false;
|
|
|
|
suspended = false;
|
|
|
|
|
|
|
|
suspend_lock = -1;
|
|
|
|
suspend_lock = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -229,7 +198,7 @@ bool SHMProcess::Private::GetLocks()
|
|
|
|
server_lock = open(name,O_WRONLY);
|
|
|
|
server_lock = open(name,O_WRONLY);
|
|
|
|
if(server_lock == -1)
|
|
|
|
if(server_lock == -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
cerr << "can't open sv lock" << endl;
|
|
|
|
// cerr << "can't open sv lock" << endl;
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -289,27 +258,6 @@ bool SHMProcess::Private::GetLocks()
|
|
|
|
SHMProcess::SHMProcess(uint32_t PID, vector< memory_info* >& known_versions)
|
|
|
|
SHMProcess::SHMProcess(uint32_t PID, vector< memory_info* >& known_versions)
|
|
|
|
: d(new Private())
|
|
|
|
: d(new Private())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char exe_link_name [256];
|
|
|
|
|
|
|
|
char target_name[1024];
|
|
|
|
|
|
|
|
int target_result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Locate the segment.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((d->shm_ID = shmget(SHM_KEY + PID, /*SHM_ALL_CLIENTS*/SHM_SIZE, 0666)) < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Attach the segment
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
if ((d->shm_addr = (char *) shmat(d->shm_ID, NULL, 0)) == (char *) -1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
d->process_ID = PID;
|
|
|
|
d->process_ID = PID;
|
|
|
|
if(!attach())
|
|
|
|
if(!attach())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -324,31 +272,15 @@ SHMProcess::SHMProcess(uint32_t PID, vector< memory_info* >& known_versions)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
detach();
|
|
|
|
detach();
|
|
|
|
throw Error::SHMAttachFailure();
|
|
|
|
throw Error::SHMAttachFailure();
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!bridgeOK)
|
|
|
|
if(!bridgeOK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Error::SHMVersionMismatch();
|
|
|
|
|
|
|
|
detach();
|
|
|
|
detach();
|
|
|
|
|
|
|
|
throw Error::SHMVersionMismatch();
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// find the binary
|
|
|
|
|
|
|
|
sprintf(exe_link_name,"/proc/%d/exe", d->process_ID);
|
|
|
|
|
|
|
|
target_result = readlink(exe_link_name, target_name, sizeof(target_name)-1);
|
|
|
|
|
|
|
|
if (target_result == -1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
perror("readlink");
|
|
|
|
|
|
|
|
detach();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// make sure we have a null terminated string...
|
|
|
|
|
|
|
|
// see http://www.opengroup.org/onlinepubs/000095399/functions/readlink.html
|
|
|
|
|
|
|
|
target_name[target_result] = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// try to identify the DF version (md5 the binary, compare with known versions)
|
|
|
|
// try to identify the DF version (md5 the binary, compare with known versions)
|
|
|
|
d->validate(target_name, d->process_ID, known_versions);
|
|
|
|
d->validate(known_versions);
|
|
|
|
d->window = new DFWindow(this);
|
|
|
|
d->window = new DFWindow(this);
|
|
|
|
|
|
|
|
|
|
|
|
// detach
|
|
|
|
// detach
|
|
|
@ -357,7 +289,7 @@ SHMProcess::SHMProcess(uint32_t PID, vector< memory_info* >& known_versions)
|
|
|
|
|
|
|
|
|
|
|
|
bool SHMProcess::isSuspended()
|
|
|
|
bool SHMProcess::isSuspended()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return d->suspended;
|
|
|
|
return d->locked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool SHMProcess::isAttached()
|
|
|
|
bool SHMProcess::isAttached()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -369,11 +301,26 @@ bool SHMProcess::isIdentified()
|
|
|
|
return d->identified;
|
|
|
|
return d->identified;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SHMProcess::Private::validate(char * exe_file, uint32_t pid, vector <memory_info *> & known_versions)
|
|
|
|
bool SHMProcess::Private::validate(vector <memory_info *> & known_versions)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
char exe_link_name [256];
|
|
|
|
|
|
|
|
char target_name[1024];
|
|
|
|
|
|
|
|
int target_result;
|
|
|
|
|
|
|
|
// find the binary
|
|
|
|
|
|
|
|
sprintf(exe_link_name,"/proc/%d/exe", process_ID);
|
|
|
|
|
|
|
|
target_result = readlink(exe_link_name, target_name, sizeof(target_name)-1);
|
|
|
|
|
|
|
|
if (target_result == -1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
perror("readlink");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// make sure we have a null terminated string...
|
|
|
|
|
|
|
|
// see http://www.opengroup.org/onlinepubs/000095399/functions/readlink.html
|
|
|
|
|
|
|
|
target_name[target_result] = 0;
|
|
|
|
|
|
|
|
|
|
|
|
md5wrapper md5;
|
|
|
|
md5wrapper md5;
|
|
|
|
// get hash of the running DF process
|
|
|
|
// get hash of the running DF process
|
|
|
|
string hash = md5.getHashFromFile(exe_file);
|
|
|
|
string hash = md5.getHashFromFile(target_name);
|
|
|
|
vector<memory_info *>::iterator it;
|
|
|
|
vector<memory_info *>::iterator it;
|
|
|
|
// cerr << exe_file << " " << hash << endl;
|
|
|
|
// cerr << exe_file << " " << hash << endl;
|
|
|
|
// iterate over the list of memory locations
|
|
|
|
// iterate over the list of memory locations
|
|
|
@ -384,7 +331,6 @@ bool SHMProcess::Private::validate(char * exe_file, uint32_t pid, vector <memory
|
|
|
|
{
|
|
|
|
{
|
|
|
|
memory_info * m = *it;
|
|
|
|
memory_info * m = *it;
|
|
|
|
memdescriptor = m;
|
|
|
|
memdescriptor = m;
|
|
|
|
process_ID = pid;
|
|
|
|
|
|
|
|
identified = true;
|
|
|
|
identified = true;
|
|
|
|
// cerr << "identified " << m->getVersion() << endl;
|
|
|
|
// cerr << "identified " << m->getVersion() << endl;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -427,9 +373,15 @@ int SHMProcess::getPID()
|
|
|
|
return d->process_ID;
|
|
|
|
return d->process_ID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//FIXME: implement
|
|
|
|
// there is only one we care about.
|
|
|
|
bool SHMProcess::getThreadIDs(vector<uint32_t> & threads )
|
|
|
|
bool SHMProcess::getThreadIDs(vector<uint32_t> & threads )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if(d->attached)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
threads.clear();
|
|
|
|
|
|
|
|
threads.push_back(d->process_ID);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -466,7 +418,7 @@ bool SHMProcess::suspend()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(d->suspended)
|
|
|
|
if(d->locked)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -496,7 +448,6 @@ bool SHMProcess::suspend()
|
|
|
|
// we wait for the server to give up our suspend lock (held by default)
|
|
|
|
// we wait for the server to give up our suspend lock (held by default)
|
|
|
|
if(lockf(d->suspend_lock,F_LOCK,0) == 0)
|
|
|
|
if(lockf(d->suspend_lock,F_LOCK,0) == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->suspended = true;
|
|
|
|
|
|
|
|
d->locked = true;
|
|
|
|
d->locked = true;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -510,18 +461,17 @@ bool SHMProcess::asyncSuspend()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(d->suspended)
|
|
|
|
if(d->locked)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t cmd = D_SHMCMD;
|
|
|
|
if(D_SHMCMD == CORE_SUSPENDED)
|
|
|
|
if(cmd == CORE_SUSPENDED)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// we have to hold the lock to be really suspended
|
|
|
|
// we have to hold the lock to be really suspended
|
|
|
|
if(lockf(d->suspend_lock,F_LOCK,0) == 0)
|
|
|
|
if(lockf(d->suspend_lock,F_LOCK,0) == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->locked = true;
|
|
|
|
d->locked = true;
|
|
|
|
d->suspended = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -529,7 +479,11 @@ bool SHMProcess::asyncSuspend()
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// did we just resume a moment ago?
|
|
|
|
// did we just resume a moment ago?
|
|
|
|
if(D_SHMCMD == CORE_RUN)
|
|
|
|
if(cmd == CORE_STEP)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(cmd == CORE_RUN)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
D_SHMCMD = CORE_STEP;
|
|
|
|
D_SHMCMD = CORE_STEP;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -537,14 +491,6 @@ bool SHMProcess::asyncSuspend()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
D_SHMCMD = CORE_SUSPEND;
|
|
|
|
D_SHMCMD = CORE_SUSPEND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// try locking
|
|
|
|
|
|
|
|
if(lockf(d->suspend_lock,F_TLOCK,0) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
d->locked = true;
|
|
|
|
|
|
|
|
d->suspended = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -559,12 +505,11 @@ bool SHMProcess::resume()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!d->attached)
|
|
|
|
if(!d->attached)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
if(!d->suspended)
|
|
|
|
if(!d->locked)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
// unlock the suspend lock
|
|
|
|
// unlock the suspend lock
|
|
|
|
if(lockf(d->suspend_lock,F_ULOCK,0) == 0)
|
|
|
|
if(lockf(d->suspend_lock,F_ULOCK,0) == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->suspended = false;
|
|
|
|
|
|
|
|
d->locked = false;
|
|
|
|
d->locked = false;
|
|
|
|
if(d->SetAndWait(CORE_RUN)) // we have to make sure the server responds!
|
|
|
|
if(d->SetAndWait(CORE_RUN)) // we have to make sure the server responds!
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -587,7 +532,17 @@ bool SHMProcess::attach()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!d->GetLocks())
|
|
|
|
if(!d->GetLocks())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
cerr << "server is full or not really there!" << endl;
|
|
|
|
//cerr << "server is full or not really there!" << endl;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Locate the segment.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((d->shm_ID = shmget(SHM_KEY + d->process_ID, SHM_SIZE, 0666)) < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
d->FreeLocks();
|
|
|
|
|
|
|
|
cerr << "can't find segment" << endl; // FIXME: throw
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -597,7 +552,7 @@ bool SHMProcess::attach()
|
|
|
|
if ((d->shm_addr = (char *) shmat(d->shm_ID, NULL, 0)) == (char *) -1)
|
|
|
|
if ((d->shm_addr = (char *) shmat(d->shm_ID, NULL, 0)) == (char *) -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->FreeLocks();
|
|
|
|
d->FreeLocks();
|
|
|
|
cerr << "can't attach segment" << endl;
|
|
|
|
cerr << "can't attach segment" << endl; // FIXME: throw
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d->attached = true;
|
|
|
|
d->attached = true;
|
|
|
@ -618,18 +573,18 @@ bool SHMProcess::detach()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(d->suspended)
|
|
|
|
if(d->locked)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
resume();
|
|
|
|
resume();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// detach segment
|
|
|
|
// detach segment
|
|
|
|
if(shmdt(d->shm_addr) != -1)
|
|
|
|
if(shmdt(d->shm_addr) != -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
d->FreeLocks();
|
|
|
|
|
|
|
|
d->locked = false;
|
|
|
|
d->attached = false;
|
|
|
|
d->attached = false;
|
|
|
|
d->suspended = false;
|
|
|
|
|
|
|
|
d->shm_addr = 0;
|
|
|
|
d->shm_addr = 0;
|
|
|
|
g_pProcess = 0;
|
|
|
|
g_pProcess = 0;
|
|
|
|
d->FreeLocks();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// fail if we can't detach
|
|
|
|
// fail if we can't detach
|
|
|
@ -851,7 +806,6 @@ const std::string SHMProcess::readSTLString(uint32_t offset)
|
|
|
|
D_SHMHDR->address = offset;
|
|
|
|
D_SHMHDR->address = offset;
|
|
|
|
full_barrier
|
|
|
|
full_barrier
|
|
|
|
d->SetAndWait(CORE_READ_STL_STRING);
|
|
|
|
d->SetAndWait(CORE_READ_STL_STRING);
|
|
|
|
//int length = ((shm_retval *)d->my_shm)->value;
|
|
|
|
|
|
|
|
return(string( D_SHMDATA(char) ));
|
|
|
|
return(string( D_SHMDATA(char) ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -921,3 +875,22 @@ char * SHMProcess::getSHMStart (void)
|
|
|
|
|
|
|
|
|
|
|
|
return /*d->shm_addr_with_cl_idx*/ d->shm_addr;
|
|
|
|
return /*d->shm_addr_with_cl_idx*/ d->shm_addr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool SHMProcess::Private::Aux_Core_Attach(bool & versionOK, pid_t & PID)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(!locked) throw Error::SHMAccessDenied();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SHMDATA(coreattach)->cl_affinity = OS_getAffinity();
|
|
|
|
|
|
|
|
if(!SetAndWait(CORE_ATTACH)) return false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
cerr <<"CORE_VERSION" << CORE_VERSION << endl;
|
|
|
|
|
|
|
|
cerr <<"server CORE_VERSION" << SHMDATA(coreattach)->sv_version << endl;
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
versionOK =( SHMDATA(coreattach)->sv_version == CORE_VERSION );
|
|
|
|
|
|
|
|
PID = SHMDATA(coreattach)->sv_PID;
|
|
|
|
|
|
|
|
useYield = SHMDATA(coreattach)->sv_useYield;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
if(useYield) cerr << "Using Yield!" << endl;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|