Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 211752 | Differences between
and this patch

Collapse All | Expand All

(-)bind-9.4.1_p1/work/bind-9.4.1-P1/contrib/dlz/drivers/dlz_postgres_driver.c (-8 / +34 lines)
Lines 51-56 Link Here
51
 */
51
 */
52
52
53
#ifdef DLZ_POSTGRES
53
#ifdef DLZ_POSTGRES
54
#define CUT_TEMP_MSGS
54
55
55
#include <config.h>
56
#include <config.h>
56
#include <stdio.h>
57
#include <stdio.h>
Lines 297-306 Link Here
297
298
298
	REQUIRE(*rs == NULL);
299
	REQUIRE(*rs == NULL);
299
300
301
#ifndef CUT_TEMP_MSGS
300
	/* temporary logging message */
302
	/* temporary logging message */
301
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
303
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
302
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
304
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
303
		      "%d Getting DBI", dlz_thread_num);
305
		      "%d Getting DBI", dlz_thread_num);
306
#endif
304
307
305
	/* get db instance / connection */
308
	/* get db instance / connection */
306
#ifdef ISC_PLATFORM_USETHREADS
309
#ifdef ISC_PLATFORM_USETHREADS
Lines 318-327 Link Here
318
321
319
#endif /* ISC_PLATFORM_USETHREADS */
322
#endif /* ISC_PLATFORM_USETHREADS */
320
323
324
#ifndef CUT_TEMP_MSGS
321
	/* temporary logging message */
325
	/* temporary logging message */
322
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
326
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
323
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
327
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
324
		      "%d Got DBI - checking query", dlz_thread_num);
328
		      "%d Got DBI - checking query", dlz_thread_num);
329
#endif
325
330
326
	/* if DBI is null, can't do anything else */
331
	/* if DBI is null, can't do anything else */
327
	if (dbi == NULL) {
332
	if (dbi == NULL) {
Lines 391-400 Link Here
391
		goto cleanup;
396
		goto cleanup;
392
	}
397
	}
393
398
399
#ifndef CUT_TEMP_MSGS
394
	/* temporary logging message */
400
	/* temporary logging message */
395
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
401
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
396
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
402
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
397
		      "%d checked query", dlz_thread_num);
403
		      "%d checked query", dlz_thread_num);
404
#endif
398
405
399
	/*
406
	/*
400
	 * was a zone string passed?  If so, make it safe for use in
407
	 * was a zone string passed?  If so, make it safe for use in
Lines 410-420 Link Here
410
		dbi->zone = NULL;
417
		dbi->zone = NULL;
411
	}
418
	}
412
419
420
#ifndef CUT_TEMP_MSGS    
413
	/* temporary logging message */
421
	/* temporary logging message */
414
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
422
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
415
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
423
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
416
		      "%d did zone", dlz_thread_num);
424
		      "%d did zone", dlz_thread_num);
417
425
		      
426
#endif
418
	/*
427
	/*
419
	 * was a record string passed?  If so, make it safe for use in
428
	 * was a record string passed?  If so, make it safe for use in
420
	 * queries.
429
	 * queries.
Lines 429-440 Link Here
429
		dbi->record = NULL;
438
		dbi->record = NULL;
430
	}
439
	}
431
440
432
441
#ifndef CUT_TEMP_MSGS    
433
	/* temporary logging message */
442
	/* temporary logging message */
434
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
443
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
435
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
444
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
436
		      "%d did record", dlz_thread_num);
445
		      "%d did record", dlz_thread_num);
437
446
#endif
438
	/*
447
	/*
439
	 * was a client string passed?  If so, make it safe for use in
448
	 * was a client string passed?  If so, make it safe for use in
440
	 * queries.
449
	 * queries.
Lines 449-459 Link Here
449
		dbi->client = NULL;
458
		dbi->client = NULL;
450
	}
459
	}
451
460
461
#ifndef CUT_TEMP_MSGS
452
	/* temporary logging message */
462
	/* temporary logging message */
453
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
463
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
454
	DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
464
	DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
455
		      "%d did client", dlz_thread_num);
465
		      "%d did client", dlz_thread_num);
456
466
#endif
457
	/*
467
	/*
458
	 * what type of query are we going to run?
468
	 * what type of query are we going to run?
459
	 * this time we build the actual query to run.
469
	 * this time we build the actual query to run.
Lines 486-495 Link Here
486
		goto cleanup;
496
		goto cleanup;
487
	}
497
	}
488
498
499
#ifndef CUT_TEMP_MSGS
489
	/* temporary logging message */
500
	/* temporary logging message */
490
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
501
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
491
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
502
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
492
		      "%d built query", dlz_thread_num);
503
		      "%d built query", dlz_thread_num);
504
#endif
493
505
494
	/* if the querystring is null, Bummer, outta RAM.  UPGRADE TIME!!!   */
506
	/* if the querystring is null, Bummer, outta RAM.  UPGRADE TIME!!!   */
495
	if (querystring  == NULL) {
507
	if (querystring  == NULL) {
Lines 497-507 Link Here
497
		goto cleanup;
509
		goto cleanup;
498
	}
510
	}
499
511
512
#ifndef CUT_TEMP_MSGS
500
	/* temporary logging message */
513
	/* temporary logging message */
501
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
514
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
502
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
515
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
503
		      "%d query is '%s'", dlz_thread_num, querystring);
516
		      "%d query is '%s'", dlz_thread_num, querystring);
504
517
518
#endif
505
	/*
519
	/*
506
	 * output the full query string during debug so we can see
520
	 * output the full query string during debug so we can see
507
	 * what lame error the query has.
521
	 * what lame error the query has.
Lines 512-522 Link Here
512
526
513
	/* attempt query up to 3 times. */
527
	/* attempt query up to 3 times. */
514
	for (j=0; j < 3; j++) {
528
	for (j=0; j < 3; j++) {
529
#ifndef CUT_TEMP_MSGS
515
		/* temporary logging message */
530
		/* temporary logging message */
516
		isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
531
		isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
517
			      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
532
			      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
518
			      "%d executing query for %d time",
533
			      "%d executing query for %d time",
519
			      dlz_thread_num, j);
534
			      dlz_thread_num, j);
535
#endif
520
		/* try to get result set */
536
		/* try to get result set */
521
		*rs = PQexec((PGconn *)dbi->dbconn, querystring );
537
		*rs = PQexec((PGconn *)dbi->dbconn, querystring );
522
		result = ISC_R_SUCCESS;
538
		result = ISC_R_SUCCESS;
Lines 525-535 Link Here
525
		 * attempts.
541
		 * attempts.
526
		 */
542
		 */
527
		for (i=0; *rs == NULL && i < 3; i++) {
543
		for (i=0; *rs == NULL && i < 3; i++) {
544
#ifndef CUT_TEMP_MSGS
528
			/* temporary logging message */
545
			/* temporary logging message */
529
			isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
546
			isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
530
				      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
547
				      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
531
				      "%d resetting connection",
548
				      "%d resetting connection",
532
				      dlz_thread_num);
549
				      dlz_thread_num);
550
#endif
533
			result = ISC_R_FAILURE;
551
			result = ISC_R_FAILURE;
534
			PQreset((PGconn *) dbi->dbconn);
552
			PQreset((PGconn *) dbi->dbconn);
535
			/* connection ok, break inner loop */
553
			/* connection ok, break inner loop */
Lines 538-555 Link Here
538
		}
556
		}
539
		/* result set ok, break outter loop */
557
		/* result set ok, break outter loop */
540
		if (PQresultStatus(*rs) == PGRES_TUPLES_OK) {
558
		if (PQresultStatus(*rs) == PGRES_TUPLES_OK) {
559
#ifndef CUT_TEMP_MSGS
541
			/* temporary logging message */
560
			/* temporary logging message */
542
			isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
561
			isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
543
				      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
562
				      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
544
				      "%d rs ok", dlz_thread_num);
563
				      "%d rs ok", dlz_thread_num);
564
#endif
545
			break;
565
			break;
546
		} else {
566
		} else {
547
			/* we got a result set object, but it's not right. */
567
			/* we got a result set object, but it's not right. */
568
#ifndef CUT_TEMP_MSGS
548
			/* temporary logging message */
569
			/* temporary logging message */
549
			isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
570
			isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
550
				      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
571
				      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
551
				      "%d clearing rs", dlz_thread_num);
572
				      "%d clearing rs", dlz_thread_num);
573
#endif
552
			PQclear(*rs);	/* get rid of it */
574
			PQclear(*rs);	/* get rid of it */
575
            *rs = NULL;
553
			/* in case this was the last attempt */
576
			/* in case this was the last attempt */
554
			result = ISC_R_FAILURE;
577
			result = ISC_R_FAILURE;
555
		}
578
		}
Lines 558-568 Link Here
558
 cleanup:
581
 cleanup:
559
	/* it's always good to cleanup after yourself */
582
	/* it's always good to cleanup after yourself */
560
583
584
#ifndef CUT_TEMP_MSGS
561
	/* temporary logging message */
585
	/* temporary logging message */
562
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
586
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
563
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
587
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
564
		      "%d cleaning up", dlz_thread_num);
588
		      "%d cleaning up", dlz_thread_num);
565
589
#endif
566
	/* if we couldn't even allocate DBI, just return NULL */
590
	/* if we couldn't even allocate DBI, just return NULL */
567
	if (dbi == NULL)
591
	if (dbi == NULL)
568
		return ISC_R_FAILURE;
592
		return ISC_R_FAILURE;
Lines 581-591 Link Here
581
605
582
#ifdef ISC_PLATFORM_USETHREADS
606
#ifdef ISC_PLATFORM_USETHREADS
583
607
608
#ifndef CUT_TEMP_MSGS
584
	/* temporary logging message */
609
	/* temporary logging message */
585
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
610
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
586
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
611
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
587
		      "%d unlocking mutex", dlz_thread_num);
612
		      "%d unlocking mutex", dlz_thread_num);
588
613
#endif
589
	/* release the lock so another thread can use this dbi */
614
	/* release the lock so another thread can use this dbi */
590
	isc_mutex_unlock(&dbi->instance_lock);
615
	isc_mutex_unlock(&dbi->instance_lock);
591
616
Lines 595-605 Link Here
595
	if (querystring  != NULL)
620
	if (querystring  != NULL)
596
		isc_mem_free(ns_g_mctx, querystring );
621
		isc_mem_free(ns_g_mctx, querystring );
597
622
623
#ifndef CUT_TEMP_MSGS
598
	/* temporary logging message */
624
	/* temporary logging message */
599
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
625
	isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
600
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
626
		      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
601
		      "%d returning", dlz_thread_num);
627
		      "%d returning", dlz_thread_num);
602
628
#endif
603
	/* return result */
629
	/* return result */
604
	return result;
630
	return result;
605
}
631
}
Lines 752-758 Link Here
752
					FINDZONE, dbdata, &rs);
778
					FINDZONE, dbdata, &rs);
753
	/* if we didn't get a result set, log an err msg. */
779
	/* if we didn't get a result set, log an err msg. */
754
	if (result != ISC_R_SUCCESS) {
780
	if (result != ISC_R_SUCCESS) {
755
		if (rs != NULL)
781
		if (rs != NULL) 
756
			PQclear(rs);
782
			PQclear(rs);
757
		isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
783
		isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
758
			      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
784
			      DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,

Return to bug 211752