mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
Merge pull request #1678 from defnax/fix-retroshare-ipc
Fix retroshare ipc
This commit is contained in:
commit
66d31d7629
@ -241,6 +241,11 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, const QString &dir)
|
|||||||
localServer= new QLocalServer();
|
localServer= new QLocalServer();
|
||||||
QObject::connect(localServer, SIGNAL(newConnection()), this, SLOT(slotConnectionEstablished()));
|
QObject::connect(localServer, SIGNAL(newConnection()), this, SLOT(slotConnectionEstablished()));
|
||||||
updateLocalServer();
|
updateLocalServer();
|
||||||
|
// clear out any old arguments (race condition?)
|
||||||
|
QSharedMemory newArgs;
|
||||||
|
newArgs.setKey(QString(TARGET) + "_newArgs");
|
||||||
|
if(newArgs.attach(QSharedMemory::ReadWrite))
|
||||||
|
newArgs.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,20 +330,27 @@ Rshare::~Rshare()
|
|||||||
*/
|
*/
|
||||||
void Rshare::slotConnectionEstablished()
|
void Rshare::slotConnectionEstablished()
|
||||||
{
|
{
|
||||||
QLocalSocket *socket = localServer->nextPendingConnection();
|
|
||||||
socket->close();
|
|
||||||
delete socket;
|
|
||||||
|
|
||||||
QSharedMemory newArgs;
|
QSharedMemory newArgs;
|
||||||
newArgs.setKey(QString(TARGET) + "_newArgs");
|
newArgs.setKey(QString(TARGET) + "_newArgs");
|
||||||
|
|
||||||
|
QLocalSocket *socket = localServer->nextPendingConnection();
|
||||||
|
|
||||||
if (!newArgs.attach())
|
if (!newArgs.attach())
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) Rshare::slotConnectionEstablished() Unable to attach to shared memory segment."
|
/* this is not an error. It just means we were notified to check
|
||||||
<< newArgs.errorString().toStdString() << std::endl;
|
newArgs, but none had been set yet.
|
||||||
|
TODO: implement separate ping/take messages
|
||||||
|
std::cerr << "(EE) Rshare::slotConnectionEstablished() Unable to attach to shared memory segment."
|
||||||
|
<< newArgs.errorString().toStdString() << std::endl;
|
||||||
|
*/
|
||||||
|
socket->close();
|
||||||
|
delete socket;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
socket->close();
|
||||||
|
delete socket;
|
||||||
|
|
||||||
QBuffer buffer;
|
QBuffer buffer;
|
||||||
QDataStream in(&buffer);
|
QDataStream in(&buffer);
|
||||||
QStringList args;
|
QStringList args;
|
||||||
|
Loading…
Reference in New Issue
Block a user