/* ******************************************************************************* * Copyright (c) 1996 Martin Poole * ******************************************************************************* ** ** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! ** ** Any changes to be made to this file should first be checked with ** mplib1 source control for library integrity. ** ** mplib1 source control can be reached at mplib1@quatermass.co.uk ** * * $Source: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/bpo_val_q.c,v $ * $Author: mpoole $ * $Date: 2002/10/07 09:37:37 $ * $Revision: 1.2 $ * ******************************************************************************* * * Change History * * $Log: bpo_val_q.c,v $ * Revision 1.2 2002/10/07 09:37:37 mpoole * Initial checkin of mplib1-3.1.0 * * Revision 1.1 2002/10/07 09:36:54 mpoole * Initial checkin of mplib1-3.1.0 * * ******************************************************************************* */ #ident "$Header: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/bpo_val_q.c,v 1.2 2002/10/07 09:37:37 mpoole Exp $" /* ------------------------------------------------------------------ Include files ------------------------------------------------------------------ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "include/bpo_q_internal.h" #include #include /* ------------------------------------------------------------------ defines ------------------------------------------------------------------ */ struct qwalk { int which_queues; int (*isp_disp)( struct bpo_private_q *pqp, void *param1 ); struct Q_Head *qh; void *f_param1; }; static dl_List_t del_list; static int n_del; /* ------------------------------------------------------------------ Code starts here ------------------------------------------------------------------ */ static int do_del_queues( bpo_List_t *blp, dl_List_t *lp ) { struct bpo_private_q *pqp; while( (pqp=dl_Remove_Head_Item( lp )) ) { /* Now, since we have the real queueu list locked we can check whether this queue is still in the list. If it is, we remove, and free the queue. If not, we assume that the queue has been freed by someone else and all we need to do is to free up our local details */ if (bpo_Find_Node_By_Item( blp, pqp->qp )!=NULL) { bpo_Remove_Node( &pqp->qp->Q_Node ); /* We now have a dissociated qp, all we have to do is loose all the associated items */ free_q_stuff( pqp->qp ); } free_this_private_q( pqp ); } return(0); } static void q_check_proc( struct bpo_private_q *pqp, struct qwalk *pw ) { int rv = Q_LEAVE_QUEUE; switch(pw->which_queues) { case Q_CHECK_ALL_QUEUES : rv = (* pw->isp_disp)( pqp, pw->f_param1 ); break; case Q_CHECK_DEAD_QUEUES : if ( (pqp->Q_flags & Q_SOLE_READER) && (pqp->Q_flags & Q_PERSISTENT)==0 && is_pid_dead( pqp->Q_sole_pid ) != 0) { rv = (* pw->isp_disp)( pqp, pw->f_param1 ); } break; default : /* huh? */ break; } if (rv == Q_DELETE_QUEUE) { dl_Remove_Node( &pqp->q_Node ); dl_Add_Tail( &del_list, &pqp->q_Node ); n_del++; } return; } int Validate_Queues( const void * hint, int p_which_queues, Validate_Queues_t disp, void *param1 ) { /* OK, so walk the process list and call the routine for each process that is dead */ struct Q_Head *qh; struct qwalk myqwalk; struct cache_queue_list *qpl; qh = get_Q_resource( hint ); if (qh==NULL) { errno = ENOSYS; return(-1); } dl_Init_List( &del_list, 0 ); n_del=0; myqwalk.which_queues = p_which_queues; myqwalk.qh = qh; myqwalk.isp_disp = disp; myqwalk.f_param1 = param1; qpl = cache_queues( qh, NULL ); dl_Walk_List( &qpl->q_list, (dl_Walk_List_t)q_check_proc, &myqwalk ); if (n_del) bpo_Work_List( &qh->Qh_List, (bpo_Work_List_t)do_del_queues, &del_list ); return(0); } /* -- End of File -- */