mini_receive() clean up
- for better readability xpp is substitued by sender - makes sure that the dequeued sender has p_q_link == NULL and that this condition holds when enqueuing the sender again. This is a sanity check to make sure that the new sender is not enqueued already - Before this change the dequeued sender's p_q_link may not be NULL and it was only set to NULL when enqueued again
This commit is contained in:
		
							parent
							
								
									921bacd244
								
							
						
					
					
						commit
						76708e9bf4
					
				@ -588,10 +588,10 @@ PUBLIC int mini_send(
 | 
				
			|||||||
	caller_ptr->p_sendto_e = dst_e;
 | 
						caller_ptr->p_sendto_e = dst_e;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Process is now blocked.  Put in on the destination's queue. */
 | 
						/* Process is now blocked.  Put in on the destination's queue. */
 | 
				
			||||||
 | 
						assert(caller_ptr->p_q_link == NULL);
 | 
				
			||||||
	xpp = &dst_ptr->p_caller_q;		/* find end of list */
 | 
						xpp = &dst_ptr->p_caller_q;		/* find end of list */
 | 
				
			||||||
	while (*xpp) xpp = &(*xpp)->p_q_link;	
 | 
						while (*xpp) xpp = &(*xpp)->p_q_link;	
 | 
				
			||||||
	*xpp = caller_ptr;			/* add caller to end */
 | 
						*xpp = caller_ptr;			/* add caller to end */
 | 
				
			||||||
	caller_ptr->p_q_link = NULL;	/* mark new end of list */
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return(OK);
 | 
					  return(OK);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -689,37 +689,40 @@ PRIVATE int mini_receive(struct proc * caller_ptr,
 | 
				
			|||||||
    /* Check caller queue. Use pointer pointers to keep code simple. */
 | 
					    /* Check caller queue. Use pointer pointers to keep code simple. */
 | 
				
			||||||
    xpp = &caller_ptr->p_caller_q;
 | 
					    xpp = &caller_ptr->p_caller_q;
 | 
				
			||||||
    while (*xpp) {
 | 
					    while (*xpp) {
 | 
				
			||||||
        if (src_e == ANY || src_p == proc_nr(*xpp)) {
 | 
						struct proc * sender = *xpp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (src_e == ANY || src_p == proc_nr(sender)) {
 | 
				
			||||||
            int call;
 | 
					            int call;
 | 
				
			||||||
	    assert(!RTS_ISSET(*xpp, RTS_SLOT_FREE));
 | 
						    assert(!RTS_ISSET(sender, RTS_SLOT_FREE));
 | 
				
			||||||
	    assert(!RTS_ISSET(*xpp, RTS_NO_ENDPOINT));
 | 
						    assert(!RTS_ISSET(sender, RTS_NO_ENDPOINT));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    /* Found acceptable message. Copy it and update status. */
 | 
						    /* Found acceptable message. Copy it and update status. */
 | 
				
			||||||
  	    assert(!(caller_ptr->p_misc_flags & MF_DELIVERMSG));
 | 
					  	    assert(!(caller_ptr->p_misc_flags & MF_DELIVERMSG));
 | 
				
			||||||
	    caller_ptr->p_delivermsg = (*xpp)->p_sendmsg;
 | 
						    caller_ptr->p_delivermsg = sender->p_sendmsg;
 | 
				
			||||||
	    caller_ptr->p_delivermsg.m_source = (*xpp)->p_endpoint;
 | 
						    caller_ptr->p_delivermsg.m_source = sender->p_endpoint;
 | 
				
			||||||
	    caller_ptr->p_misc_flags |= MF_DELIVERMSG;
 | 
						    caller_ptr->p_misc_flags |= MF_DELIVERMSG;
 | 
				
			||||||
	    RTS_UNSET(*xpp, RTS_SENDING);
 | 
						    RTS_UNSET(sender, RTS_SENDING);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    call = ((*xpp)->p_misc_flags & MF_REPLY_PEND ? SENDREC : SEND);
 | 
						    call = (sender->p_misc_flags & MF_REPLY_PEND ? SENDREC : SEND);
 | 
				
			||||||
	    IPC_STATUS_ADD_CALL(caller_ptr, call);
 | 
						    IPC_STATUS_ADD_CALL(caller_ptr, call);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    /*
 | 
						    /*
 | 
				
			||||||
	     * if the message is originaly from the kernel on behalf of this
 | 
						     * if the message is originaly from the kernel on behalf of this
 | 
				
			||||||
	     * process, we must send the status flags accordingly
 | 
						     * process, we must send the status flags accordingly
 | 
				
			||||||
	     */
 | 
						     */
 | 
				
			||||||
	    if ((*xpp)->p_misc_flags & MF_SENDING_FROM_KERNEL) {
 | 
						    if (sender->p_misc_flags & MF_SENDING_FROM_KERNEL) {
 | 
				
			||||||
		IPC_STATUS_ADD_FLAGS(caller_ptr, IPC_FLG_MSG_FROM_KERNEL);
 | 
							IPC_STATUS_ADD_FLAGS(caller_ptr, IPC_FLG_MSG_FROM_KERNEL);
 | 
				
			||||||
		/* we can clean the flag now, not need anymore */
 | 
							/* we can clean the flag now, not need anymore */
 | 
				
			||||||
		(*xpp)->p_misc_flags &= ~MF_SENDING_FROM_KERNEL;
 | 
							sender->p_misc_flags &= ~MF_SENDING_FROM_KERNEL;
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
	    if ((*xpp)->p_misc_flags & MF_SIG_DELAY)
 | 
						    if (sender->p_misc_flags & MF_SIG_DELAY)
 | 
				
			||||||
		sig_delay_done(*xpp);
 | 
							sig_delay_done(sender);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            *xpp = (*xpp)->p_q_link;		/* remove from queue */
 | 
					            *xpp = sender->p_q_link;		/* remove from queue */
 | 
				
			||||||
 | 
						    sender->p_q_link = NULL;
 | 
				
			||||||
            return(OK);				/* report success */
 | 
					            return(OK);				/* report success */
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	xpp = &(*xpp)->p_q_link;		/* proceed to next */
 | 
						xpp = &sender->p_q_link;		/* proceed to next */
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user