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

Return to bug 211752