def process_message_buffer(curr_message_buffer):
    """
    Description
    ===========
    
    Helper function to process the communication between the master 
    _hole_finder_multi_process and _hole_finder_worker processes.
    
    Since communication over a socket is only guaranteed to be in order, we have 
    to process an arbitrary number of bytes depending on the message format.  
    The message format is as such:  the first byte gives the number of 8-byte 
    fields in the message.  So a first byte of 3 means the message on the head 
    of the buffer should be 1 + 3*8 = 25 bytes long.
    
    Right now there are 3 types of message: 
    
    type 0 - "status" messages from the workers, where field 0's value should be 
    2 for 2 fields, field 1 is the number of results the worker has written, and 
    field 2 (currently unused) was the number of new holes the worker has found
    
    type 1 - "worker finished" message
    
    type 2 - "sync acknowledge" message
    
    
    Parameters
    ==========
    
    curr_message_buffer : bytes
        the current string of bytes to process
        
        
    Returns
    =======
    
    messages : list
        list of parsed messages
        
    curr_message_buffer : bytes
        any remaining data in the current message buffer which was not yet able
        to be parsed, likely due to a socket read ending not perfectly on a 
        message border
    """
    
    messages = []
    
    
    if len(curr_message_buffer) > 0:
                
        messages_remaining_in_buffer = True
        
    else:
        
        messages_remaining_in_buffer = False
        
        
    while messages_remaining_in_buffer:
    
        #https://stackoverflow.com/questions/28249597/why-do-i-get-an-int-when-i-index-bytes
        #implicitly converts the 0th byte to an integer
        msg_fields = curr_message_buffer[0]
        
        msg_len = 1 + 8*msg_fields
        
        if len(curr_message_buffer) >= msg_len:
        
            curr_msg = curr_message_buffer[1:msg_len]
            
            messages.append(curr_msg)
            
            curr_message_buffer = curr_message_buffer[msg_len:]
            
            if len(curr_message_buffer) > 0:
                
                messages_remaining_in_buffer = True
                
            else:
                
                messages_remaining_in_buffer = False
                
        else:
            messages_remaining_in_buffer = False
    
    return messages, curr_message_buffer