Esempio n. 1
0
def removeProcess(pid):
    """\internal
    \brief Called if a process leaves the system to ensure that no references that the process had remain in the system.

    If a process exits normally then all this should be unnessicary, however we can't trust user processes.
    """
    # check it actually is a process and not another node
    if utils.isThreadId(pid):
        tid = pid
        pid = utils.getProcessIdFromThreadId(pid)
        del threads[tid]
        pthreads[pid].remove(tid)
        if len(pthreads[pid]) > 0:
            for ts in local_ts:
                if local_ts[ts].isDeadLocked():
                    local_ts[ts].unblockRandom()
            return
    if not utils.isProcessId(pid):
        return

    # check that it wasn't blocked when the connection was lost
    for tid in blocked_threads.keys():
        if utils.getProcessIdFromThreadId(tid) == pid:
            del blocked_threads[tid]

    del pthreads[pid]

    if _linda_server.use_types and _linda_server.register_types:
        unregisterTypesFromProcess(pid)

    # remove any references the process may have had to our tuplespaces
    for ts in local_ts:
        local_ts.deleteAllReferences(ts, pid)
Esempio n. 2
0
def removeProcess(pid):
    """\internal
    \brief Called if a process leaves the system to ensure that no references that the process had remain in the system.

    If a process exits normally then all this should be unnessicary, however we can't trust user processes.
    """
    # check it actually is a process and not another node
    if utils.isThreadId(pid):
        tid = pid
        pid = utils.getProcessIdFromThreadId(pid)
        del threads[tid]
        pthreads[pid].remove(tid)
        if len(pthreads[pid]) > 0:
            for ts in local_ts:
                if local_ts[ts].isDeadLocked():
                    local_ts[ts].unblockRandom()
            return
    if not utils.isProcessId(pid):
        return

    # check that it wasn't blocked when the connection was lost
    for tid in blocked_threads.keys():
        if utils.getProcessIdFromThreadId(tid) == pid:
            del blocked_threads[tid]

    del pthreads[pid]

    if _linda_server.use_types and _linda_server.register_types:
        unregisterTypesFromProcess(pid)

    # remove any references the process may have had to our tuplespaces
    for ts in local_ts:
        local_ts.deleteAllReferences(ts, pid)
Esempio n. 3
0
    def add_reference(self, req, msgid, message, data):
        ts, ref = str(data[0]), str(data[1])

        if utils.isThreadId(ref):
            ref = utils.getProcessIdFromThreadId(ref)

        if not local_ts.has_key(ts):
            local_ts.newTupleSpace(ts)
        local_ts.addReference(ts, ref)

        req.send(msgid, (done, ))
Esempio n. 4
0
    def add_reference(self, req, msgid, message, data):
        ts, ref = str(data[0]), str(data[1])

        if utils.isThreadId(ref):
            ref = utils.getProcessIdFromThreadId(ref)

        if not local_ts.has_key(ts):
            local_ts.newTupleSpace(ts)
        local_ts.addReference(ts, ref)

        req.send(msgid, (done, ))
Esempio n. 5
0
    def delete_reference(self, req, msgid, message, data):
        ts, ref = str(data[0]), str(data[1])

        if ts == "UTS":
            req.send(msgid, (done, ))
            return

        if utils.isThreadId(ref):
            ref = utils.getProcessIdFromThreadId(ref)

        # see the note in the TupleSpace.removeallreference for an explanation of the killlock
        try:
            local_ts[ts].killlock.acquire()
        except KeyError:
            pass
        else:
            threading.Thread(target=local_ts.deleteReference, args=(ts, ref)).start()

        req.send(msgid, (done, ))
Esempio n. 6
0
    def delete_reference(self, req, msgid, message, data):
        ts, ref = str(data[0]), str(data[1])

        if ts == "UTS":
            req.send(msgid, (done, ))
            return

        if utils.isThreadId(ref):
            ref = utils.getProcessIdFromThreadId(ref)

        # see the note in the TupleSpace.removeallreference for an explanation of the killlock
        try:
            local_ts[ts].killlock.acquire()
        except KeyError:
            pass
        else:
            threading.Thread(target=local_ts.deleteReference,
                             args=(ts, ref)).start()

        req.send(msgid, (done, ))