Beispiel #1
0
void
cleanup(void)
{
	if(P == nil)
		return;

	remproc(P);
	decref(&nproc);
	freesegs();
	fddecref(P->fd);
	if(P->path != nil && decref(P->path) == 0)
		free(P->path);
	free(P);
}
Beispiel #2
0
//---------------------------------
char* Seg::maskseq(const char *fastaseq)
{
    Segment *segs;
    Sequen *seq = openseq(fastaseq);

    segs = (Segment *) NULL;
    segseq(seq, &segs, 0);
    mergesegs(seq, segs);
    char *masked = singreport(seq, segs);

    freesegs(segs);
    closeseq(seq);

    return masked;
}
Beispiel #3
0
void nyx_cleanup()
{
   // Garbage-collect nyx_result
   xlpop();

#if defined(NYX_FULL_COPY) && NYX_FULL_COPY

   // Restore the original symbol values
   nyx_restore_obarray();

#else

   // Restore obarray to original state...but not the values
   setvalue(obarray, nyx_obarray);

#endif

   // Make sure the sound nodes can be garbage-collected.  Sounds are EXTERN
   // nodes whose value does not get copied during a full copy of the obarray.
   setvalue(xlenter("S"), NIL);

   // Free excess memory segments - does a gc()
   freesegs();

   // Free unused memory pools
   falloc_gc();

   // No longer need the callbacks
   nyx_output_cb = NULL;
   nyx_os_cb = NULL;

#if defined(NYX_MEMORY_STATS) && NYX_MEMORY_STATS
   printf("\nnyx_cleanup\n");
   xmem();
#endif
}
Beispiel #4
0
/*
 * bounce_msgs()
 *	Take the messages off a port, and bounce each of them
 *
 * We need to do this as sysmsg's can have segments within them,
 * and we need to clean those segments up.  This routine is called
 * with the port locked, and returns with it released.
 */
static void
bounce_msgs(struct port *port)
{
	struct sysmsg *msgs, *sm, *smn;
	struct portref *pr;

	/*
	 * Pull whatever messages are on the port out of the queue.
	 * We'll walk the list once we've released our lock.  We can't
	 * hold the port lock and go for the portrefs, as we lock in
	 * the other order, and would deadlock.
	 */
	p_lock_void(&port->p_lock, SPL0);
	msgs = port->p_hd;
	port->p_hd = 0;
	v_lock(&port->p_lock, SPL0);

	/*
	 * Step through the linked list.  As our clients will be waking
	 * up and discarding messages, we record the next pointer field
	 * into a local variable.
	 */
	for (sm = msgs; sm; sm = smn) {
		/*
		 * Get pointers, apply sanity check
		 */
		pr = sm->sm_sender;
		smn = sm->sm_next;
#ifdef DEBUG
		sm->sm_next = 0;
#endif

		/*
		 * ISR messages are somewhat special.  They don't have
		 * a portref, and there's no connection to break.
		 * We have already de-registered, so it can't come
		 * back.
		 */
		if (pr == 0) {
			ASSERT_DEBUG(sm->sm_op == M_ISR,
				"bounce_msgs: !pr !M_ISR");
			continue;
		}

		ASSERT_DEBUG(pr->p_port == port,
			"bounce_msgs: msg in queue not for port");

		/*
		 * Lock portref, then port
		 */
		p_lock_void(&pr->p_lock, SPL0_SAME);
		p_lock_void(&port->p_lock, SPLHI);

		/*
		 * If any segments in the message, discard them
		 */
		if (sm->sm_nseg > 0) {
			freesegs(sm);
		}

		/*
		 * If the client has tried to abort the operation,
		 * ignore anything but the abort message itself.
		 */
		if ((pr->p_state == PS_ABWAIT) &&
				(sm->sm_op != M_ABORT)) {
			/* nothing */ ;
		} else {

			/*
			 * Fill in sysmsg as an I/O error, clear
			 * p_port to preclude further I/O, and
			 * kick client awake.
			 */
			sm->sm_arg1 = sm->sm_arg = -1;
			strcpy(sm->sm_err, EIO);
			pr->p_port = 0;
			v_sema(&pr->p_iowait);
		}

		/*
		 * Release locks, and remove the portref from our list
		 */
		v_lock(&port->p_lock, SPL0);
		v_lock(&pr->p_lock, SPL0_SAME);
	}
}