Hi, can someone validate this function? I have made a chat server that adds a user to a linked list. This functions deletes some data related to a user when he/she quits. But if I join two users, and the latter user reconnects a couple of times, the element isn't deleted. Can you see some flaw in the code?

Thanks in advance!

Code:
#include "flp.h"

struct pending *delPenderByFD (struct pending *pFF, int match)
{


	struct pending *a = pFF;
	struct pending *b = NULL;
	
	if (a == NULL)	// no users in the list
	{
		close (match);
		FD_CLR (match, &active_fd_set);
		return (struct pending *)1;
	}
	if (a->next == NULL) // one user in the list
	{
		if ( (b = findPenderByFD (a, match)) ) //the user is in the list
		{
			ppFirst = NULL;
			ppNew = NULL;
			ppLast = NULL;
			close (match);
			FD_CLR (match, &active_fd_set);
			free (b);
			return (struct pending *)1;
		}
		
		// the user is not in the list
		close (match);
		FD_CLR (match, &active_fd_set);
		free (b);
		return (struct pending *)1;
	
	}
	b = a;
	if (b == findPenderByFD (ppFirst, match) ) // while there are users - check the first
		{
			a = b->next;
			ppFirst = a;
			close (match);
			FD_CLR (b->fd, &active_fd_set);
			free (b);
			return (struct pending *)1;
		}
	
	while (a->next) // while there is another user
	{
		b = a->next;
		if (b == findPenderByFD (ppFirst, match) ) 
		{
			a->next = b->next;
			close (match);
			FD_CLR (b->fd, &active_fd_set);
			free (b);
			return (struct pending *)1;
		}
		a = b;
		
		
	}
		// user is not in list
		close (match);
		FD_CLR (match, &active_fd_set);
		return (struct pending *)1;

}