Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Bug? rsrcdb_destroy() of already destroyed resource succeeds: (1 Item)
   
Bug? rsrcdb_destroy() of already destroyed resource succeeds  
Create a resource, destroy it and then destroy it again. All three actions succeed. 

Here's the test program output:

# rsrcdb_bug_test
io/tester resource created.
io/tester resource destroyed.
Already destroyed io/tester resource destroyed again!!

# uname -a
QNX localhost 6.5.0 2010/07/09-14:43:25EDT x86pc x86

Here's the test program:

/*
 *  rsrcdb_bug_test - Demonstrates that if you create a resource and
 *  then destroy it then all seems to work fine. But if you try to
 *  destroy it a 2nd time without creating it again, it also returns
 *  success. The program session output is:
 *
 */

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/rsrcdbmgr.h>
#include <sys/rsrcdbmsg.h>

#define MY_RSRC_NAME	"io/tester"

int main(int argc, char **argv)
{
	rsrc_alloc_t alloc;

	memset(&alloc, 0, sizeof(alloc));
	alloc.start = 0;
	alloc.end = 1024;
	alloc.flags = RSRCDBMGR_FLAG_NAME | RSRCDBMGR_FLAG_NOREMOVE;
	alloc.name = MY_RSRC_NAME;

	if (rsrcdbmgr_create(&alloc, 1) == -1) {
		fprintf(stderr, "rsrcdbmgr_create failed: %s\n", strerror(errno));
		exit(EXIT_FAILURE);
	}
	printf("%s resource created.\n", MY_RSRC_NAME);

	if (rsrcdbmgr_destroy(&alloc, 1) == -1) {
		fprintf(stderr, "2nd rsrcdbmgr_destroy failed: %s\n", strerror(errno));
		exit(EXIT_FAILURE);
	}
	printf("%s resource destroyed.\n", MY_RSRC_NAME);

	if (rsrcdbmgr_destroy(&alloc, 1) == -1) {
		fprintf(stderr, "3rd rsrcdbmgr_destroy failed: %s\n", strerror(errno));
		exit(EXIT_FAILURE);
	}
	printf("Already destroyed %s resource destroyed again!!\n", MY_RSRC_NAME);

	return (EXIT_SUCCESS);
}

-Steve(n D.)