("ipfix_double_lock_mutex failed: Exporter is NULL!\n");
DPRINTF("ipfix_double_lock_mutex failed: Exporter is NULL!\n");
int ipfix_double_lock_mutex(ipfix_exporter* exporter, enum ipfix_lock_target t1, enum ipfix_lock_target t2) {#ifdef IPFIX_THREADED	int ret = 0;	int success = FALSE;	pthread_mutex_t* my_mutex1;	pthread_mutex_t* my_mutex2;	// is our exporter possibly invalid?	if (exporter == NULL) {		("ipfix_double_lock_mutex failed: Exporter is NULL!\n");		return -1;	}	// sanity check: are both targets the same?	if (t1 == t2) {		fprintf (stderr, "ipfix_double_lock_mutex: cannot lock the same target twice.\n");		return -1;	}			/* determine our first mutex: */	switch (t1){	case DATA:		my_mutex1 = &exporter-> data_sendbuffer_mutex;		break;	case TEMPLATE:		my_mutex1 = &exporter-> template_sendbuffer_mutex;		break;	case COLLECTOR:		my_mutex1 = &exporter->  collector_array_mutex;		break;	default:		fprintf (stderr, "Ipfix_double_lock_mutex: invalid type %i!\n", t1);		fprintf (stderr, "Ipfix_double_lock_mutex: cannot be used on EXPORTER\n");					DPRINTF ("++++++++++++++++++++++++++++++++++++++++++\n");		ret = pthread_mutex_unlock( &(exporter->exporter_mutex));		if (ret !=0 ) {			fprintf (stderr, "ipfix_double_lock_mutex unlocking exporter mutex failed!\n");			DPRINTF ("pthread_mutex_unlock returned %i, Thread %i \n", ret, pthread_self());			return -1;		}		return -1;	}	/* determine our second mutex: */	switch (t2){	case DATA:		my_mutex2 = &exporter-> data_sendbuffer_mutex;		break;	case TEMPLATE:		my_mutex2 = &exporter-> template_sendbuffer_mutex;		break;	case COLLECTOR:		my_mutex2 = &exporter->  collector_array_mutex;		break;	default:		fprintf (stderr, "Ipfix_double_lock_mutex: invalid type %i!\n", t2);		fprintf (stderr, "Ipfix_double_lock_mutex: cannot be used on EXPORTER\n");					DPRINTF ("++++++++++++++++++++++++++++++++++++++++++\n");		ret = pthread_mutex_unlock( &(exporter->exporter_mutex));		if (ret !=0 ) {			fprintf (stderr, "ipfix_double_lock_mutex unlocking exporter mutex failed!\n");			DPRINTF ("pthread_mutex_unlock returned %i, Thread %i \n", ret, pthread_self());			return -1;		}		return -1;	}	while (!success) { // success loop		// try to lock the exporter (superlock)		ret = pthread_mutex_lock( &(exporter->exporter_mutex));		DPRINTF (" Thread %i Locked exporter \n", pthread_self() );		if (ret !=0 ) {			fprintf (stderr, "ipfix_double_lock_mutex on exporter mutex failed!\n");			DPRINTF (" pthread_mutex_lock returned %i, Thread %i \n", ret,  pthread_self());			return -1;		}		/* now, try to obtain our first lock */		ret = pthread_mutex_trylock (my_mutex1);		if (ret == 0 ) {			DPRINTF ("Locked 1st. mutex No. %i, Thread %i\n", t1, pthread_self() );			// try to lock the 2nd target			ret = pthread_mutex_trylock (my_mutex2);						// 2nd lock			if (ret == 0 ) {				// we are successful				success = TRUE;				DPRINTF ("Locked 2nd. mutex No. %i, Thread %i\n", t2, pthread_self());			} else {  				// check for serious error conditions:				if (errno == EINVAL) {					fprintf (stderr, "ipfix_double_lock_mutex: the mutex has not been properly initialized\n");					DPRINTF ("++++++++++++++++++++++++++++++++++++++++++\n");				}				// unlock the first lock!				ret = pthread_mutex_unlock(my_mutex1);				if (ret !=0 ) {					fprintf (stderr, "ipfix_double_lock_mutex unlocking first mutex failed!\n");					DPRINTF ("pthread_mutex_unlock returned %i, Thread %i \n", ret, pthread_self());				        // cannot exit here.				}			} // end 2nd lock					} else {			// check for serious error conditions:			if (errno == EINVAL) {				fprintf (stderr, "ipfix_lock_mutex: the mutex has not been properly initialized\n");				DPRINTF ("++++++++++++++++++++++++++++++++++++++++++\n");			}					}		// unlock the exporter again:		ret = pthread_mutex_unlock(&(exporter->exporter_mutex));		DPRINTF ("UNLocked exporter\n");		if (ret !=0 ) {			fprintf (stderr, "ipfix_double_lock_mutex unlocking exporter mutex failed!\n");			DPRINTF ("pthread_mutex_unlock returned %i, Thread %i \n", ret, pthread_self());			return -1;		}		DPRINTF ("Thread %i UNLocked exporter\n", pthread_self());	} // end loop#else	// we may just as well check, if the exporter is valid:	if (exporter == NULL) {		DPRINTF ("ipfix_lock_mutex failed: Exporter is NULL!\n");				return -1;	}#endif	return 0;}